You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
294 lines
8.5 KiB
294 lines
8.5 KiB
3 months ago
|
using MESClassLibrary.BLL.Log;
|
||
|
using MESClassLibrary.DAL.User;
|
||
|
using MESClassLibrary.EFModel;
|
||
|
using MESClassLibrary.Model;
|
||
|
using System;
|
||
|
using System.Collections.Generic;
|
||
|
using System.Data;
|
||
|
using System.Linq;
|
||
|
using System.Reflection;
|
||
|
using System.Text;
|
||
|
|
||
|
namespace MESClassLibrary.BLL.User
|
||
|
{
|
||
|
public class UserBLL
|
||
|
{
|
||
|
UserDAL db = new UserDAL();
|
||
|
//用户登录
|
||
|
public bool Login(UserModel md)
|
||
|
{
|
||
|
|
||
|
try
|
||
|
{
|
||
|
|
||
|
#region 入参校验
|
||
|
if (string.IsNullOrWhiteSpace(md.Username) || string.IsNullOrWhiteSpace(md.Password))
|
||
|
{
|
||
|
return false;
|
||
|
}
|
||
|
#endregion
|
||
|
|
||
|
#region 登陆
|
||
|
//DataTable dt = db.Search_UserInfoByUP(md.Username, Tool.MD5encryption(md.Password));
|
||
|
DataTable dt = db.Search_UserInfoByUP(md.Username, md.Password);
|
||
|
if (dt != null && dt.Rows.Count > 0)
|
||
|
{
|
||
|
#region 记录用户登录日志-暂注销
|
||
|
md.ID = dt.Rows[0][0].ToString();
|
||
|
//md.TrueName = dt.Rows[0]["TrueName"].ToString();
|
||
|
//md.FaceURL = dt.Rows[0]["FaceURL"].ToString();
|
||
|
//md.RoleID = dt.Rows[0]["RoleID"].ToString();
|
||
|
//md.RoleName = dt.Rows[0]["RoleName"].ToString();
|
||
|
//md.RoleJurisdiction = dt.Rows[0]["RoleJurisdiction"].ToString();
|
||
|
//md.CompanyPost = dt.Rows[0]["CompanyPost"].ToString();
|
||
|
//md.ContactWay = dt.Rows[0]["ContactWay"].ToString();
|
||
|
//md.CreateUserID = dt.Rows[0]["CreateUserID"].ToString();
|
||
|
//md.IsUseing = (int)dt.Rows[0]["IsUseing"];
|
||
|
db.Add_UserLoginInfo(md.ID);
|
||
|
#endregion
|
||
|
return true;
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
return false;
|
||
|
}
|
||
|
|
||
|
#endregion
|
||
|
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
|
||
|
return false;
|
||
|
}
|
||
|
|
||
|
}
|
||
|
/// <summary>
|
||
|
/// 新增用户信息
|
||
|
/// </summary>
|
||
|
/// <param name="md"></param>
|
||
|
/// <returns></returns>
|
||
|
public bool AddUserInfo(UserModel md)
|
||
|
{
|
||
|
//try
|
||
|
//{
|
||
|
// DataTable dt = db.Search_UserInfoByUserName(md.ID, md.Username);
|
||
|
// if (dt != null && dt.Rows.Count > 0)
|
||
|
// {
|
||
|
// return false;
|
||
|
// }
|
||
|
// md.Password = Tool.MD5encryption(md.Password);
|
||
|
// return db.Add_UserInfo(md);
|
||
|
//}
|
||
|
//catch (Exception ex)
|
||
|
//{
|
||
|
// LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
|
||
|
// return false;
|
||
|
//}
|
||
|
|
||
|
return false;
|
||
|
|
||
|
}
|
||
|
/// <summary>
|
||
|
/// 修改用户信息
|
||
|
/// </summary>
|
||
|
/// <param name="md"></param>
|
||
|
/// <param name="flag"></param>
|
||
|
/// <returns></returns>
|
||
|
public bool UpdateUserInfo(UserModel md)
|
||
|
{
|
||
|
try
|
||
|
{
|
||
|
return db.Update_UserInfo(md);
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
|
||
|
return false;
|
||
|
}
|
||
|
|
||
|
}
|
||
|
/// <summary>
|
||
|
/// 修改用户密码
|
||
|
/// </summary>
|
||
|
/// <param name="oldpassword"></param>
|
||
|
/// <param name="newpassword"></param>
|
||
|
/// <param name="id"></param>
|
||
|
/// <returns></returns>
|
||
|
public bool UpdateUserPassword(string oldpassword, string newpassword, string id)
|
||
|
{
|
||
|
try
|
||
|
{
|
||
|
DataTable dt = db.Search_UserInfoByID_v2(id);
|
||
|
if (dt != null && dt.Rows.Count > 0)
|
||
|
{
|
||
|
if (dt.Rows[0]["Password"].ToString() == oldpassword)
|
||
|
{
|
||
|
return db.Update_Password(id, oldpassword, newpassword);
|
||
|
}
|
||
|
}
|
||
|
return false;
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
|
||
|
return false;
|
||
|
}
|
||
|
|
||
|
}
|
||
|
/// <summary>
|
||
|
///
|
||
|
/// </summary>
|
||
|
/// <param name="id"></param>
|
||
|
/// <param name="userid"></param>
|
||
|
/// <returns></returns>
|
||
|
public bool DelUserInfoByID(string id, string userid)
|
||
|
{
|
||
|
try
|
||
|
{
|
||
|
return db.Del_Info(db.GetTableName(), id, userid);
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
|
||
|
return false;
|
||
|
}
|
||
|
|
||
|
}
|
||
|
|
||
|
#region 查询用户信息
|
||
|
/// <summary>
|
||
|
/// 查询全部用户信息
|
||
|
/// </summary>
|
||
|
/// <returns></returns>
|
||
|
public DataTable SearchUserInfo()
|
||
|
{
|
||
|
try
|
||
|
{
|
||
|
return db.Search_UserInfo();
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
|
||
|
return null;
|
||
|
}
|
||
|
|
||
|
}
|
||
|
/// <summary>
|
||
|
/// 根据ID查询用户信息
|
||
|
/// </summary>
|
||
|
/// <param name="id"></param>
|
||
|
/// <returns></returns>
|
||
|
public DataTable SearchUserInfoByID(string id)
|
||
|
{
|
||
|
try
|
||
|
{
|
||
|
return db.Search_UserInfoByID(id);
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
|
||
|
return null;
|
||
|
}
|
||
|
|
||
|
}
|
||
|
/// <summary>
|
||
|
/// 根据登录账号查询用户信息
|
||
|
/// </summary>
|
||
|
/// <param name="username"></param>
|
||
|
/// <returns></returns>
|
||
|
public DataTable SearchUserInfoByUserName(string username)
|
||
|
{
|
||
|
try
|
||
|
{
|
||
|
DataTable dt = db.Search_UserInfoByUserName(username);
|
||
|
if (dt != null && dt.Rows.Count > 0)
|
||
|
{
|
||
|
return dt;
|
||
|
}
|
||
|
return null;
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
|
||
|
return null;
|
||
|
}
|
||
|
|
||
|
}
|
||
|
|
||
|
/// <summary>
|
||
|
/// 根据角色ID查询用户信息
|
||
|
/// </summary>
|
||
|
/// <param name="roleid">角色主键ID</param>
|
||
|
/// <returns></returns>
|
||
|
public DataTable SearchUserInfoByRoleID(string roleid)
|
||
|
{
|
||
|
try
|
||
|
{
|
||
|
DataTable dt = db.Search_UserInfoByRoleID(roleid);
|
||
|
if (dt != null && dt.Rows.Count > 0)
|
||
|
{
|
||
|
return dt;
|
||
|
}
|
||
|
return null;
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
|
||
|
return null;
|
||
|
}
|
||
|
|
||
|
}
|
||
|
/// <summary>
|
||
|
/// 查询用户登录记录
|
||
|
/// </summary>
|
||
|
/// <returns></returns>
|
||
|
public DataTable SearchUserLoginInfo()
|
||
|
{
|
||
|
try
|
||
|
{
|
||
|
return db.Search_UserLoginInfo();
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
|
||
|
return null;
|
||
|
}
|
||
|
|
||
|
}
|
||
|
|
||
|
|
||
|
public string GetComboboxData()
|
||
|
{
|
||
|
try
|
||
|
{
|
||
|
|
||
|
string jsonStr = "[]";
|
||
|
DataTable dt = db.Search_UserInfo();
|
||
|
if (dt!=null && dt.Rows.Count>0)
|
||
|
{
|
||
|
List<T_Sys_Users> list = new List<T_Sys_Users>();
|
||
|
for (int i = 0; i < dt.Rows.Count; i++)
|
||
|
{
|
||
|
T_Sys_Users md = new T_Sys_Users();
|
||
|
md.UserID = (Guid)dt.Rows[i]["UserID"];
|
||
|
md.RealName = dt.Rows[i]["RealName"].ToString();
|
||
|
list.Add(md);
|
||
|
}
|
||
|
jsonStr = JSONTools.ScriptSerialize<List<T_Sys_Users>>(list);
|
||
|
}
|
||
|
return jsonStr;
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
return "";
|
||
|
}
|
||
|
}
|
||
|
|
||
|
|
||
|
|
||
|
#endregion
|
||
|
|
||
|
}
|
||
|
}
|