コード例 #1
0
ファイル: EmployeeService.cs プロジェクト: 842549829/Pool
        /// <summary>
        /// 重置指定员工的密码。
        /// </summary>
        /// <param name="id">将被重置密码的员工的 Id</param>
        /// <param name="reason"> 重置密码原因 </param>
        /// <param name="operatorAccount">操作员账号</param>
        /// <returns>返回重置操作是否成功。</returns>
        public static bool ResetPassword(Guid id, string reason, string operatorAccount)
        {
            bool isSuccess       = false;
            var  defaultPassword = SystemManagement.SystemParamService.DefaultPassword;
            var  employee        = EmployeeService.QueryEmployee(id);

            //var employee = DataContext.Employees.Where(e => e.Id == id).Select(e => new Employee {
            //    Id = e.Id,
            //    Password = e.Password
            //}).FirstOrDefault();
            if (employee == null)
            {
                throw new InvalidOperationException("指定的账号不存在。");
            }
            if (AccountBaseService.GetMebershipUser(employee.UserName))
            {
                AccountBaseService.B3BResetLoginPassword(employee.UserName, defaultPassword);
            }
            isSuccess = DataContext.Employees.Update(e => new
            {
                Password = ChinaPay.Utility.MD5EncryptorService.MD5FilterZero(defaultPassword, "utf-8")
            }, e => e.Id == id) > 0;
            saveLog(OperationType.Update, string.Format("将账号{0}密码重置为{1}", employee.UserName, defaultPassword), OperatorRole.User, employee.UserName, operatorAccount);
            return(isSuccess);
        }
コード例 #2
0
ファイル: EmployeeService.cs プロジェクト: 842549829/Pool
        /// <summary>
        /// 根据登录账号重置员工密码
        /// </summary>
        /// <param name="login">登录账号</param>
        /// <param name="reason"> 重置密码原因 </param>
        /// <param name="operatorAccount">操作员账号</param>
        /// <returns>返回重置密码操作是否成功</returns>
        public static bool ResetPassword(string login, string reason, string operatorAccount)
        {
            bool isSuccess       = false;
            var  defaultPassword = SystemManagement.SystemParamService.DefaultPassword;

            if (AccountBaseService.GetMebershipUser(login))
            {
                AccountBaseService.B3BResetLoginPassword(login, defaultPassword);
            }
            isSuccess = DataContext.Employees.Update(e => new
            {
                Password = ChinaPay.Utility.MD5EncryptorService.MD5FilterZero(defaultPassword, "utf-8")
            }, e => e.Login == login) > 0;
            saveLog(OperationType.Update, string.Format("将账号{0}密码重置为{1}", login, defaultPassword), OperatorRole.User, login, operatorAccount);
            return(isSuccess);
        }
コード例 #3
0
ファイル: EmployeeService.cs プロジェクト: 842549829/Pool
        /// <summary>
        /// 员工修改自身密码
        /// </summary>
        /// <param name="info">密码修改信息。</param>
        /// <param name="operatorAccount">操作员账号</param>
        /// <returns>返回修改操作是否成功。</returns>
        public static bool ChangePassword(ChangePasswordInfo info, string operatorAccount)
        {
            bool isSuccess = false;

            if (info == null)
            {
                throw new ArgumentNullException("info");
            }
            if (info.NewPassword != info.ConfirmPassword)
            {
                throw new InvalidOperationException("\"密码\" 与 \"确认密码\" 不相同。");
            }
            var employee = EmployeeService.QueryEmployee(info.EmployeeId);

            //var employee = DataContext.Employees.Where(e => e.Id == info.EmployeeId).Select(e => new Employee
            //{
            //    Id = e.Id,
            //    Password = e.Password
            //}).FirstOrDefault();
            if (employee == null)
            {
                throw new InvalidOperationException("指定的账号不存在。");
            }
            if (employee.UserPassword != Utility.MD5EncryptorService.MD5FilterZero(info.OldPassword, "utf-8"))
            {
                throw new InvalidOperationException("密码不正确。");
            }
            if (AccountBaseService.GetMebershipUser(info.UserNo))
            {
                AccountBaseService.B3BResetLoginPassword(info.UserNo, info.NewPassword);
            }
            isSuccess = DataContext.Employees.Update(e => new
            {
                Password = Utility.MD5EncryptorService.MD5FilterZero(info.NewPassword, "utf-8")
            }, e => e.Id == info.EmployeeId) > 0;
            saveLog(OperationType.Update, "修改密码。", OperatorRole.User, info.EmployeeId.ToString(), operatorAccount);
            return(isSuccess);
        }