Files

82 lines
2.2 KiB
C#
Raw Permalink Normal View History

2021-05-22 16:38:37 +08:00

using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
2021-05-22 16:38:37 +08:00
using System.Web;
2021-10-28 11:14:04 +08:00
2021-05-22 16:38:37 +08:00
using Dapper;
namespace NX.ERP.U8.User
{
2021-10-28 11:14:04 +08:00
public class UserDal
2021-05-22 16:38:37 +08:00
{
2021-10-28 11:14:04 +08:00
public IEnumerable<Model.Request.User> GetList(string strWhere = "", object Param = null)
{
using (var conn = U8LoginContext.Instance.Connection)
{
2022-01-05 09:54:27 +08:00
var sql = @" select cUser_Id as Code ,cUser_Name as Name,cPassword as mdPassword from UFSystem..UA_User ";
2021-10-28 11:14:04 +08:00
if (!string.IsNullOrEmpty(strWhere))
{
sql += $" where {strWhere}";
}
return conn.Query<Model.Request.User>(sql, Param);
}
}
public Model.Request.User GetModel(string UserCode)
{
return this.GetList(" cUser_Id =@UserCode", new { UserCode }).FirstOrDefault();
}
public bool Login(string UserId, string Password)
{
byte[] byte1 = Encoding.UTF8.GetBytes(Password);
SHA1Managed sHA1Managed = new SHA1Managed();
var hashValue = sHA1Managed.ComputeHash(byte1);
var mdPassword = Convert.ToBase64String(hashValue) + (char)3;
//密码密文
var userDal = new UserDal();
var user = userDal.GetModel(UserId);
if (user == null)
{
return false;
}
if (user.MdPassword != mdPassword)
{
return false;
}
return true;
}
2021-10-28 11:14:04 +08:00
2021-05-22 16:38:37 +08:00
public string Userrole(string Opnanme, string Pasd)
{
var AccID = ConfigurationManager.AppSettings["AccId"];
var Server = ConfigurationManager.AppSettings["Server"];
var _login = new NX.ERP.U8.U8LoginContext(Server, AccID);
_login.Login(Opnanme, Pasd);
var sql = $@" SELECT 1 from UFSystem..UA_Role where cUser_Id=@Opnanme and cGroup_Id='report' ;";
2021-10-28 11:14:04 +08:00
using (var conn = _login.Connection)
2021-05-22 16:38:37 +08:00
{
2021-10-28 11:14:04 +08:00
return conn.ExecuteScalar<string>(sql, new { Opnanme }, null, 30, System.Data.CommandType.Text);
2021-05-22 16:38:37 +08:00
}
}
}
}