Beispiel #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);
        }
Beispiel #2
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);
        }
Beispiel #3
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);
        }