Exemplo n.º 1
0
        internal bool Truncate(User data)
        {
            bool result = false;

            try
            {
                bool         valid   = true;
                AasUserCheck checker = new AasUserCheck(param);
                valid = valid && IsNotNull(data);
                User raw = null;
                valid = valid && checker.VerifyId(data.Id, ref raw);
                valid = valid && checker.IsUnLock(raw);
                valid = valid && checker.CheckConstraint(data.Id);
                if (valid)
                {
                    result = DAOWorker.AasUserDAO.Truncate(data);
                }
            }
            catch (Exception ex)
            {
                LogSystem.Error(ex);
                param.HasException = true;
                result             = false;
            }
            return(result);
        }
Exemplo n.º 2
0
        internal bool Run(long id)
        {
            bool result = false;

            try
            {
                bool         valid   = true;
                User         raw     = null;
                AasUserCheck checker = new AasUserCheck(param);
                valid = valid && IsGreaterThanZero(id);
                valid = valid && checker.VerifyId(id, ref raw);
                valid = valid && checker.IsUnLock(raw);
                if (valid)
                {
                    Mapper.CreateMap <User, User>();
                    User beforeUpdate = Mapper.Map <User>(raw);
                    raw.Password = new DungLH.Util.Token.Password.PasswordManager().HashPassword(raw.Loginname, raw.Salt, raw.Loginname);
                    if (!this.aasUserUpdate.Update(raw, beforeUpdate))
                    {
                        throw new Exception("Reset passwod that bai");
                    }
                    result = true;
                }
            }
            catch (Exception ex)
            {
                DungLH.Util.CommonLogging.LogSystem.Error(ex);
                param.HasException = true;
                result             = false;
            }
            return(result);
        }
Exemplo n.º 3
0
        internal bool Update(User data)
        {
            bool result = false;

            try
            {
                bool         valid   = true;
                AasUserCheck checker = new AasUserCheck(param);
                valid = valid && checker.VerifyRequireField(data);
                User raw = null;
                valid = valid && checker.VerifyId(data.Id, ref raw);
                valid = valid && checker.IsUnLock(raw);
                valid = valid && checker.ExistsLoginname(data.Loginname, data.Id);
                if (valid)
                {
                    data.Password = raw.Password;
                    data.Salt     = raw.Salt;
                    if (!DAOWorker.AasUserDAO.Update(data))
                    {
                        BugUtil.SetBugCode(param, LibraryBug.Bug.Enum.AasUser_CapNhatThatBai);
                        throw new Exception("Cap nhat thong tin AasUser that bai." + LogUtil.TraceData("data", data));
                    }
                    data.Password = null;
                    data.Salt     = null;
                    this.beforeUpdateAasUsers.Add(raw);
                    result = true;
                }
            }
            catch (Exception ex)
            {
                LogSystem.Error(ex);
                param.HasException = true;
                result             = false;
            }
            return(result);
        }