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

            try
            {
                bool            valid   = true;
                PcsProjectCheck checker = new PcsProjectCheck(param);
                valid = valid && checker.VerifyRequireField(data);
                valid = valid && checker.ExistsCode(data.ProjectCode, null);
                if (valid)
                {
                    if (!DAOWorker.PcsProjectDAO.Create(data))
                    {
                        BugUtil.SetBugCode(param, LibraryBug.Bug.Enum.PcsProject_ThemMoiThatBai);
                        throw new Exception("Them moi thong tin PcsProject that bai." + LogUtil.TraceData("data", data));
                    }
                    this.recentPcsProjects.Add(data);
                    result = true;
                }
            }
            catch (Exception ex)
            {
                LogSystem.Error(ex);
                param.HasException = true;
                result             = false;
            }
            return(result);
        }
Exemplo n.º 2
0
        internal bool TruncateList(List <Project> listData)
        {
            bool result = false;

            try
            {
                bool valid = true;
                valid = IsNotNullOrEmpty(listData);
                PcsProjectCheck checker = new PcsProjectCheck(param);
                foreach (var data in listData)
                {
                    valid = valid && IsNotNull(data) && IsGreaterThanZero(data.Id);
                    valid = valid && checker.IsUnLock(data.Id);
                }
                if (valid)
                {
                    result = DAOWorker.PcsProjectDAO.TruncateList(listData);
                }
            }
            catch (Exception ex)
            {
                LogSystem.Error(ex);
                param.HasException = true;
                result             = false;
            }
            return(result);
        }
Exemplo n.º 3
0
        internal bool Truncate(Project data)
        {
            bool result = false;

            try
            {
                bool            valid   = true;
                PcsProjectCheck checker = new PcsProjectCheck(param);
                valid = valid && IsNotNull(data);
                Project raw = null;
                valid = valid && checker.VerifyId(data.Id, ref raw);
                valid = valid && checker.IsUnLock(raw);
                valid = valid && checker.IsUnFinish(raw);
                valid = valid && checker.CheckConstraint(data.Id);
                if (valid)
                {
                    result = DAOWorker.PcsProjectDAO.Truncate(data);
                }
            }
            catch (Exception ex)
            {
                LogSystem.Error(ex);
                param.HasException = true;
                result             = false;
            }
            return(result);
        }
Exemplo n.º 4
0
        internal bool Update(Project data, Project before)
        {
            bool result = false;

            try
            {
                bool            valid   = true;
                PcsProjectCheck checker = new PcsProjectCheck(param);
                valid = valid && checker.VerifyRequireField(data);
                valid = valid && checker.IsUnLock(before);
                valid = valid && checker.IsUnFinish(before);
                valid = valid && checker.ExistsCode(data.ProjectCode, data.Id);
                if (valid)
                {
                    if (!DAOWorker.PcsProjectDAO.Update(data))
                    {
                        BugUtil.SetBugCode(param, LibraryBug.Bug.Enum.PcsProject_CapNhatThatBai);
                        throw new Exception("Cap nhat thong tin PcsProject that bai." + LogUtil.TraceData("data", data));
                    }

                    this.beforeUpdatePcsProjects.Add(before);
                    result = true;
                }
            }
            catch (Exception ex)
            {
                LogSystem.Error(ex);
                param.HasException = true;
                result             = false;
            }
            return(result);
        }
Exemplo n.º 5
0
        internal bool UpdateList(List <Project> listData)
        {
            bool result = false;

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