| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108 |
- using System;
- using System.Collections.Generic;
- using System.Configuration;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using SqlSugar;
- using WMS.Util;
- using WMS.Info;
- namespace WMS.Core
- {
- public class LoginUserEditPwdBLL : IBLL
- {
- public object OutObjData { get; set; }
- public string SuccessMsg { get; set; } = "用户密码修改成功。";
- public LoginUserInfo LoginUser { get; set; }
- public string InJsonData { get; set; }
- public string BLLDesc { get; private set; } = "用户密码过期修改。";
- public void Exec()
- {
- try
- {
- void action(SqlSugarClient Ctx)
- {
- LoginUserEditPwdInfo indata = InJsonData.ToObject<LoginUserEditPwdInfo>();
- if (indata == null)
- {
- throw SysExCore.ThrowInEmpty();
- }
- if (string.IsNullOrWhiteSpace(indata.TextU))
- {
- throw SysExCore.ThrowFailException("用户名为空。");
- }
- if (string.IsNullOrWhiteSpace(indata.TextOP))
- {
- throw SysExCore.ThrowFailException("旧密码为空。");
- }
- if (string.IsNullOrWhiteSpace(indata.TextNP))
- {
- throw SysExCore.ThrowFailException("新密码为空。");
- }
- if (indata.TextOP == indata.TextNP)
- {
- throw SysExCore.ThrowFailException("旧密码与新密码相同,请重新输入。");
- }
- bool tag = ValidUtil.IsPasswordOne(indata.TextNP);
- if (!tag)
- {
- throw SysExCore.ThrowFailException("新密码格式不对,需输入6-25位包含特殊字符。");
- }
- //获取数据
- ACL_USERITEM user = Ctx.Queryable<ACL_USERITEM>().Where(it => it.F_NO.ToUpper() == indata.TextU.ToUpper()).First();
- if (user == null)
- throw SysExCore.ThrowFailException("无法找到指定用户");
- if (user.F_ISDELETE > 0)
- throw SysExCore.ThrowFailException("用户已删除!!!");
- if (user.F_ISSTOP > 0)
- throw SysExCore.ThrowFailException("用户已停用!!!");
- //用户密码已过期
- if (user.F_AUTOSTOPTIME.ToString("yyyy-MM-dd") != DateTime.MaxValue.ToString("yyyy-MM-dd"))
- {
- if (user.F_AUTOSTOPTIME < DateTime.Now)
- throw SysExCore.ThrowFailException("用户已过期!!!");
- }
- if (user.F_PWDERRQTY >= SysSetCore.GetSysSet().UserPwdErrQty)
- throw SysExCore.ThrowFailException(string.Format("用户密码错误已超过{0}次,已被锁定。", SysSetCore.GetSysSet().UserPwdErrQty));
- ////用户密码已过期
- //if (user.F_EDITPWDTIME != DateTime.MaxValue)
- //{
- // if (user.F_EDITPWDTIME.AddDays(SysSetCore.GetSysSet().UserPwdExpD) < DateTime.Now)
- // throw SysExCore.ThrowLoginTimeout();
- //}
- //用户密码错误
- if (user.F_PASSWORD != SysSecurityCore.Aes256Encrypt(indata.TextOP))
- {
- int qty = SysSetCore.GetSysSet().UserPwdErrQty - user.F_PWDERRQTY;
- if (user.F_PWDERRQTY > 0)
- throw new SysExCore(ESysExType.PwdError, string.Format("用户密码错误,您还有{0}次", qty > 0 ? qty : 0));
- else
- throw new SysExCore(ESysExType.PwdError, "用户密码错误。");
- }
- int i = Ctx.Updateable<ACL_USERITEM>().SetColumns(it => new ACL_USERITEM()
- {
- F_PASSWORD = SysSecurityCore.Aes256Encrypt(indata.TextNP),
- F_EDITTIME = DateTime.Now,
- F_EDITUSERNO = user.F_NO,
- F_EDITPWDTIME = DateTime.Now,
- F_PWDERRQTY = 0
- }).Where(it => it.F_NO == user.F_NO).ExecuteCommand();
- if (i <= 0)
- {
- throw SysExCore.ThrowFailException("修改密码失败!!!");
- }
- }
- SysDbCore.DbTranExec(action);
- }
- catch (Exception ex)
- {
- throw ex;
- }
- }
- }
- }
|