Beispiel #1
0
        internal bool TruncateList(List <User> listData)
        {
            bool result = false;

            try
            {
                bool valid = true;
                valid = IsNotNullOrEmpty(listData);
                AasUserCheck checker = new AasUserCheck(param);
                foreach (var data in listData)
                {
                    valid = valid && IsNotNull(data) && IsGreaterThanZero(data.Id);
                    valid = valid && checker.IsUnLock(data.Id);
                }
                if (valid)
                {
                    result = DAOWorker.AasUserDAO.TruncateList(listData);
                }
            }
            catch (Exception ex)
            {
                LogSystem.Error(ex);
                param.HasException = true;
                result             = false;
            }
            return(result);
        }
Beispiel #2
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);
        }
Beispiel #3
0
        internal bool Update(User data, User before)
        {
            bool result = false;

            try
            {
                bool         valid   = true;
                AasUserCheck checker = new AasUserCheck(param);
                valid = valid && checker.VerifyRequireField(data);
                valid = valid && checker.IsUnLock(before);
                valid = valid && checker.ExistsLoginname(data.Loginname, data.Id);
                if (valid)
                {
                    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));
                    }
                    this.beforeUpdateAasUsers.Add(before);
                    result = true;
                }
            }
            catch (Exception ex)
            {
                LogSystem.Error(ex);
                param.HasException = true;
                result             = false;
            }
            return(result);
        }
        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);
        }
Beispiel #5
0
        internal bool Create(User data)
        {
            bool result = false;

            try
            {
                bool            valid           = true;
                PasswordManager passwordManager = new PasswordManager();
                AasUserCheck    checker         = new AasUserCheck(param);
                valid = valid && checker.VerifyRequireField(data);
                valid = valid && checker.ExistsLoginname(data.Loginname, null);
                if (valid)
                {
                    string password = "";
                    if (!String.IsNullOrWhiteSpace(data.Password))
                    {
                        password = data.Password;
                    }
                    else
                    {
                        password = data.Loginname;
                    }
                    data.Salt     = passwordManager.GenerateSalt();
                    data.Password = passwordManager.HashPassword(password, data.Salt, data.Loginname);

                    if (!DAOWorker.AasUserDAO.Create(data))
                    {
                        BugUtil.SetBugCode(param, LibraryBug.Bug.Enum.AasUser_ThemMoiThatBai);
                        throw new Exception("Them moi thong tin AasUser that bai." + LogUtil.TraceData("data", data));
                    }
                    data.Password = "";
                    data.Salt     = "";
                    this.recentAasUsers.Add(data);
                    result = true;
                }
            }
            catch (Exception ex)
            {
                LogSystem.Error(ex);
                param.HasException = true;
                result             = false;
            }
            return(result);
        }
Beispiel #6
0
        internal bool UpdateList(List <User> listData)
        {
            bool result = false;

            try
            {
                bool valid = true;
                valid = IsNotNullOrEmpty(listData);
                AasUserCheck checker = new AasUserCheck(param);
                List <User>  listRaw = new List <User>();
                List <long>  listId  = listData.Select(o => o.Id).ToList();
                valid = valid && checker.VerifyIds(listId, listRaw);
                valid = valid && checker.IsUnLock(listRaw);
                foreach (var data in listData)
                {
                    valid = valid && checker.VerifyRequireField(data);
                    valid = valid && checker.ExistsLoginname(data.Loginname, data.Id);
                }
                if (valid)
                {
                    if (!DAOWorker.AasUserDAO.UpdateList(listData))
                    {
                        BugUtil.SetBugCode(param, LibraryBug.Bug.Enum.AasUser_CapNhatThatBai);
                        throw new Exception("Cap nhat thong tin AasUser that bai." + LogUtil.TraceData("listData", listData));
                    }
                    this.beforeUpdateAasUsers.AddRange(listRaw);
                    result = true;
                }
            }
            catch (Exception ex)
            {
                LogSystem.Error(ex);
                param.HasException = true;
                result             = false;
            }
            return(result);
        }