示例#1
0
        internal bool TruncateList(List <Role> listData)
        {
            bool result = false;

            try
            {
                bool valid = true;
                valid = IsNotNullOrEmpty(listData);
                AasRoleCheck checker = new AasRoleCheck(param);
                foreach (var data in listData)
                {
                    valid = valid && IsNotNull(data) && IsGreaterThanZero(data.Id);
                    valid = valid && checker.IsUnLock(data.Id);
                }
                if (valid)
                {
                    result = DAOWorker.AasRoleDAO.TruncateList(listData);
                }
            }
            catch (Exception ex)
            {
                LogSystem.Error(ex);
                param.HasException = true;
                result             = false;
            }
            return(result);
        }
示例#2
0
        internal bool Truncate(Role data)
        {
            bool result = false;

            try
            {
                bool         valid   = true;
                AasRoleCheck checker = new AasRoleCheck(param);
                valid = valid && IsNotNull(data);
                Role 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.AasRoleDAO.Truncate(data);
                }
            }
            catch (Exception ex)
            {
                LogSystem.Error(ex);
                param.HasException = true;
                result             = false;
            }
            return(result);
        }
示例#3
0
        internal bool Update(Role data)
        {
            bool result = false;

            try
            {
                bool         valid   = true;
                AasRoleCheck checker = new AasRoleCheck(param);
                valid = valid && checker.VerifyRequireField(data);
                Role raw = null;
                valid = valid && checker.VerifyId(data.Id, ref raw);
                valid = valid && checker.IsUnLock(raw);
                valid = valid && checker.ExistsCode(data.RoleCode, data.Id);
                if (valid)
                {
                    if (!DAOWorker.AasRoleDAO.Update(data))
                    {
                        BugUtil.SetBugCode(param, LibraryBug.Bug.Enum.AasRole_CapNhatThatBai);
                        throw new Exception("Cap nhat thong tin AasRole that bai." + LogUtil.TraceData("data", data));
                    }

                    this.beforeUpdateAasRoles.Add(raw);
                    result = true;
                }
            }
            catch (Exception ex)
            {
                LogSystem.Error(ex);
                param.HasException = true;
                result             = false;
            }
            return(result);
        }
示例#4
0
        internal bool UpdateList(List <Role> listData)
        {
            bool result = false;

            try
            {
                bool valid = true;
                valid = IsNotNullOrEmpty(listData);
                AasRoleCheck checker = new AasRoleCheck(param);
                List <Role>  listRaw = new List <Role>();
                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.ExistsCode(data.RoleCode, data.Id);
                }
                if (valid)
                {
                    if (!DAOWorker.AasRoleDAO.UpdateList(listData))
                    {
                        BugUtil.SetBugCode(param, LibraryBug.Bug.Enum.AasRole_CapNhatThatBai);
                        throw new Exception("Cap nhat thong tin AasRole that bai." + LogUtil.TraceData("listData", listData));
                    }
                    this.beforeUpdateAasRoles.AddRange(listRaw);
                    result = true;
                }
            }
            catch (Exception ex)
            {
                LogSystem.Error(ex);
                param.HasException = true;
                result             = false;
            }
            return(result);
        }