|
|
using Estsh.Core.IRepositories;
|
|
|
using Estsh.Core.IServices;
|
|
|
using Estsh.Core.Models;
|
|
|
using Estsh.Core.Util;
|
|
|
using System.Collections;
|
|
|
|
|
|
/***************************************************************************************************
|
|
|
*
|
|
|
* 更新人:sitong.dong
|
|
|
* 描述:用户登录处理类
|
|
|
* 修改时间:2022.06.22
|
|
|
* 修改日志:系统迭代升级
|
|
|
*
|
|
|
**************************************************************************************************/
|
|
|
namespace Estsh.Core.Services
|
|
|
{
|
|
|
public enum LoginStatus { USERNAMENOEXISTED, PASSWORDERROR, LOGINSUCESS };
|
|
|
|
|
|
/// <summary>
|
|
|
/// 处理登录过程
|
|
|
/// </summary>
|
|
|
public class AccountService : BaseService<SysEmp>, IAccountService
|
|
|
{
|
|
|
//private UserDal repository = new UserDal(RemotingProxyProvider._remotingProxy);
|
|
|
private readonly IUserRepository repository;
|
|
|
|
|
|
public AccountService(IUserRepository _repository) : base(_repository)
|
|
|
{
|
|
|
repository = _repository;
|
|
|
}
|
|
|
|
|
|
#region 系统登录
|
|
|
/// <summary>
|
|
|
/// 用户登录
|
|
|
/// </summary>
|
|
|
/// <param name="user"></param>
|
|
|
/// <returns></returns>
|
|
|
public Hashtable login(SysEmp user)
|
|
|
{
|
|
|
Hashtable result = new Hashtable();
|
|
|
LoginStatus status;
|
|
|
SysEmp userInfo = null;
|
|
|
try
|
|
|
{
|
|
|
if (userInfo != null)
|
|
|
{
|
|
|
string userPassword = MD5Encrypt.NewObject.MD5(user.Passwd);
|
|
|
if (userInfo != null && userInfo.EmpId == 0)
|
|
|
{
|
|
|
if (userInfo.Passwd == userPassword)
|
|
|
{
|
|
|
status = LoginStatus.LOGINSUCESS;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
status = LoginStatus.PASSWORDERROR;
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
status = LoginStatus.USERNAMENOEXISTED;
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
userInfo = repository.getUserInfo(" and emp_no ='" + user.EmpNo.Trim() + "' ");
|
|
|
string userPassword = MD5Encrypt.NewObject.MD5(user.Passwd);
|
|
|
if (userInfo != null && userInfo.EmpId > 0)
|
|
|
{
|
|
|
if (userInfo.Passwd == userPassword)
|
|
|
{
|
|
|
status = LoginStatus.LOGINSUCESS;
|
|
|
userInfo.EmpNoMD5 = MD5Encrypt.NewObject.MD5(user.EmpNo).Trim();
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
status = LoginStatus.PASSWORDERROR;
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
status = LoginStatus.USERNAMENOEXISTED;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
}
|
|
|
catch (Exception e)
|
|
|
{
|
|
|
status = LoginStatus.USERNAMENOEXISTED;
|
|
|
System.Console.WriteLine(e.Message);
|
|
|
}
|
|
|
result.Add("status", status);
|
|
|
result.Add("userInfo", userInfo);
|
|
|
return result;
|
|
|
}
|
|
|
#endregion
|
|
|
#region 修改密码
|
|
|
public Hashtable EditUserPassword(string userId, string oldPasWord, string newPasWord,string updateEmpId)
|
|
|
{
|
|
|
Hashtable result = new Hashtable();
|
|
|
string msg = string.Empty;
|
|
|
bool status = false;
|
|
|
SysEmp userInfo = repository.getUserInfo(" and emp_id ='" + userId.Trim() + "' ");
|
|
|
if (userInfo != null)
|
|
|
{
|
|
|
|
|
|
oldPasWord = MD5Encrypt.NewObject.MD5(oldPasWord);
|
|
|
if (oldPasWord == userInfo.Passwd)
|
|
|
{
|
|
|
newPasWord = MD5Encrypt.NewObject.MD5(newPasWord);
|
|
|
status = repository.UpdatePassword(userId, newPasWord, updateEmpId);
|
|
|
if (status)
|
|
|
{
|
|
|
msg = "修改成功!";
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
msg = "修改失败!";
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
msg = "原始密码输入错误!请检查……";
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
msg = "没查询到该用户的信息!";
|
|
|
|
|
|
}
|
|
|
result.Add("status", status);
|
|
|
result.Add("msg", msg);
|
|
|
return result;
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
//获取工厂信息
|
|
|
public List<SysFactory> getSelectFactory(int factoryID)
|
|
|
{
|
|
|
return repository.getSelectFactory(factoryID);
|
|
|
}
|
|
|
|
|
|
}
|
|
|
} |