internal bool Create(Address data) { bool result = false; try { bool valid = true; Project project = null; PcsAddressCheck checker = new PcsAddressCheck(param); PcsProjectCheck projectChecker = new PcsProjectCheck(param); valid = valid && checker.VerifyRequireField(data); valid = valid && projectChecker.VerifyId(data.ProjectId, ref project); valid = valid && projectChecker.IsUnLock(project); valid = valid && projectChecker.IsUnFinish(project); if (valid) { if (!DAOWorker.PcsAddressDAO.Create(data)) { BugUtil.SetBugCode(param, LibraryBug.Bug.Enum.PcsAddress_ThemMoiThatBai); throw new Exception("Them moi thong tin PcsAddress that bai." + LogUtil.TraceData("data", data)); } this.recentPcsAddresss.Add(data); result = true; } } catch (Exception ex) { LogSystem.Error(ex); param.HasException = true; result = false; } return(result); }
internal bool Truncate(Address data) { bool result = false; try { bool valid = true; Address raw = null; Project project = null; PcsAddressCheck checker = new PcsAddressCheck(param); PcsProjectCheck projectChecker = new PcsProjectCheck(param); valid = valid && IsNotNull(data); valid = valid && checker.VerifyId(data.Id, ref raw); valid = valid && checker.IsUnLock(raw); valid = valid && projectChecker.VerifyId(data.ProjectId, ref project); valid = valid && projectChecker.IsUnLock(project); valid = valid && projectChecker.IsUnFinish(project); valid = valid && checker.CheckConstraint(data.Id); if (valid) { result = DAOWorker.PcsAddressDAO.Truncate(data); } } catch (Exception ex) { LogSystem.Error(ex); param.HasException = true; result = false; } return(result); }
internal bool Run(PcsPostSDO data, ref List <Post> resultData) { bool result = false; try { bool valid = true; Project project = null; List <Post> listRaw = null; string loginname = DungLH.Util.Token.Backend.BackendTokenManager.GetLoginname(); string username = DungLH.Util.Token.Backend.BackendTokenManager.GetUsername(); PcsPostRejectCheck checker = new PcsPostRejectCheck(param); PcsProjectCheck projectChecker = new PcsProjectCheck(param); PcsEmployeeCheck employeeChecker = new PcsEmployeeCheck(param); valid = valid && IsNotNull(data); valid = valid && IsGreaterThanZero(data.ProjectId); valid = valid && projectChecker.VerifyId(data.ProjectId, ref project); valid = valid && checker.ValidData(data, ref listRaw); valid = valid && projectChecker.IsUnFinish(project); valid = valid && checker.AllowReject(listRaw); valid = valid && checker.ValidNote(data); valid = valid && employeeChecker.CheckRoleApproveOrReject(loginname); if (valid) { Mapper.CreateMap <Post, Post>(); List <Post> befores = Mapper.Map <List <Post> >(listRaw); long approveTime = Convert.ToInt64(DateTime.Now.ToString("yyyyMMddHHmmss")); foreach (Post raw in listRaw) { Post p = data.Posts != null?data.Posts.FirstOrDefault(o => o.Id == raw.Id) : null; raw.PostSttId = PostSttConstant.POST_STT_ID__REJECT; raw.ApprovalLoginname = loginname; raw.ApprovalTime = approveTime; raw.ApprovalUsername = username; raw.ApprovalNote = (p == null || String.IsNullOrWhiteSpace(p.ApprovalNote)) ? data.Note : p.ApprovalNote; } if (!this.pcsPostUpdate.UpdateList(listRaw, befores)) { throw new Exception("pcsPostUpdate. Ket thuc nghiep vu. Rollback du lieu"); } result = true; resultData = listRaw; } } catch (Exception ex) { LogSystem.Error(ex); param.HasException = true; this.Rollback(); result = false; resultData = null; } return(result); }
internal bool Create(Post data) { bool result = false; try { bool valid = true; Project project = null; PcsPostCheck checker = new PcsPostCheck(param); PcsProjectCheck projectChecker = new PcsProjectCheck(param); valid = valid && IsNotNull(data); valid = valid && checker.VerifyRequireField(data); valid = valid && projectChecker.VerifyId(data.ProjectId, ref project); valid = valid && projectChecker.IsUnFinish(project); if (valid) { data.PostSttId = PostSttConstant.POST_STT_ID__NOT_APPROVAL; if (String.IsNullOrWhiteSpace(data.PostType)) { data.PostType = "post"; } if (String.IsNullOrWhiteSpace(data.Status)) { data.Status = "publish"; } data.ApprovalLoginname = null; data.ApprovalTime = null; data.ApprovalUsername = null; data.PostTime = null; data.ApprovalNote = null; if (!DAOWorker.PcsPostDAO.Create(data)) { BugUtil.SetBugCode(param, LibraryBug.Bug.Enum.PcsPost_ThemMoiThatBai); throw new Exception("Them moi thong tin PcsPost that bai." + LogUtil.TraceData("data", data)); } this.recentPcsPosts.Add(data); result = true; } } catch (Exception ex) { LogSystem.Error(ex); param.HasException = true; result = false; } return(result); }
internal bool Run(long id, ref Project resultData) { bool result = false; try { bool valid = true; Project raw = null; PcsProjectCheck checker = new PcsProjectCheck(param); valid = valid && IsGreaterThanZero(id); valid = valid && checker.VerifyId(id, ref raw); valid = valid && checker.IsUnLock(raw); valid = valid && checker.IsUnFinish(raw); if (valid) { Mapper.CreateMap <Project, Project>(); Project before = Mapper.Map <Project>(raw); raw.ProjectSttId = ProjectSttConstant.PROJECT_STT_ID__FINISH; raw.FinishTime = Convert.ToInt64(DateTime.Now.ToString("yyyyMMddHHmmss")); if (!this.pcsProjectUpdate.Update(raw, before)) { throw new Exception("pcsProjectUpdate. Ket thuc nghiep vu. Rollback du lieu"); } resultData = raw; result = true; } } catch (Exception ex) { LogSystem.Error(ex); param.HasException = true; this.Rollback(); result = false; } return(result); }