public void GenerateConsInvtCheckingTask(bool isScheduled = false) { var rmgInfo = ReimageInfo.Search(e => e.ProjectId.Equals(ProjectId)).AsNoTracking().FirstOrDefault(); if (rmgInfo == null) { throw new Exception("Could not find the Reimage Info, please check it!"); } var taskUrl = string.Format(@"/Reimage/Main#/ConsInvtChecking?projectId={0}", ProjectId); var task = rmgInfo.GenerateTaskWork(WorkflowCode, WorkflowCode, WorkflowCode, taskUrl); task.ActivityName = NodeCode.Start; task.ActionName = SetTaskActionName(ProjectId); if (!isScheduled) { TaskWork.Add(task); } else { var gbMemo = ReimageGBMemo.GetGBMemo(ProjectId); if (gbMemo != null && gbMemo.ConstCompletionDate.HasValue) { ScheduleLog.GenerateTaskSchedule(gbMemo.ConstCompletionDate.Value.AddDays(60), task, ClientCookie.UserCode, ProjectId, FlowCode.Reimage_ConsInvtChecking, rmgInfo.USCode); } } }
public override string Edit() { var taskUrl = string.Format("/Reimage/Main#/GBMemo?projectId={0}", ProjectId); using (var scope = new TransactionScope()) { var rmgInfo = ReimageInfo.Search(e => e.ProjectId.Equals(ProjectId)).FirstOrDefault(); if (rmgInfo == null) { throw new Exception("Could not find the Reimage Info, please check it!"); } var task = rmgInfo.GenerateTaskWork(WorkflowCode, "Reimage_GBMemo", "Reimage_GBMemo", taskUrl); task.ActivityName = NodeCode.Start; task.ActionName = SetTaskActionName(ProjectId); TaskWork.Add(task); ProjectInfo.Reset(ProjectId, WorkflowCode); if (IsInOperation) { ProjectInfo.Reset(ProjectId, FlowCode.Reimage_ReopenMemo); ProjectInfo.Reset(ProjectId, FlowCode.Reimage_TempClosureMemo); } else { CompleteNotFinishTask(); } CompleteNotifyTask(ProjectId); IsHistory = true; Update(this); Mapper.CreateMap <ReimageGBMemo, ReimageGBMemo>(); var entity = Mapper.Map <ReimageGBMemo>(this); entity.Id = Guid.Empty; entity.ProcInstID = null; entity.IsHistory = false; entity.Comments = null; entity.CreateTime = DateTime.Now; entity.Save(); CopyAppUsers(Id.ToString(), entity.Id.ToString()); scope.Complete(); } return(taskUrl); }
public override void Finish(TaskWorkStatus status, TaskWork task) { using (var scope = new TransactionScope()) { switch (status) { case TaskWorkStatus.K2ProcessApproved: var imgInfo = ReimageInfo.Search(e => e.ProjectId.Equals(ProjectId)).FirstOrDefault(); ProjectInfo.FinishNode(ProjectId, FlowCode.Reimage_GBMemo, NodeCode.Finish, ProjectStatus.Finished); if (IsInOperation) { ProjectInfo.FinishNode(ProjectId, FlowCode.Reimage_ReopenMemo, NodeCode.Finish, ProjectStatus.Finished); ProjectInfo.FinishNode(ProjectId, FlowCode.Reimage_TempClosureMemo, NodeCode.Finish, ProjectStatus.Finished); } else { var taskUrlReopen = string.Format(@"/Reimage/Main#/ReopenMemo?projectId={0}", ProjectId); var taskReopen = imgInfo.GenerateTaskWork(FlowCode.Reimage_ReopenMemo, "Reopen Memo", "Reopen Memo", taskUrlReopen); taskReopen.ActivityName = NodeCode.Start; taskReopen.ActionName = SetTaskActionName(ProjectId); //TaskWork.Add(taskReopen); if (rmgInfo.ReopenDate.HasValue) { ScheduleLog.GenerateTaskSchedule(rmgInfo.ReopenDate.Value.AddDays(-7), taskReopen, ClientCookie.UserCode, ProjectId, FlowCode.Reimage_ReopenMemo, rmgInfo.USCode); } ProjectInfo.Reset(ProjectId, FlowCode.Reimage_ReopenMemo); var taskUrlClosure = string.Format(@"/Reimage/Main#/TempClosureMemo?projectId={0}", ProjectId); var taskClosure = imgInfo.GenerateTaskWork(FlowCode.Reimage_TempClosureMemo, "TempClosure Memo", "TempClosure Memo", taskUrlClosure); taskClosure.ActivityName = NodeCode.Start; taskClosure.ActionName = SetTaskActionName(ProjectId); TaskWork.Add(taskClosure); ProjectInfo.Reset(ProjectId, FlowCode.Reimage_TempClosureMemo); } var consCheckingTask = TaskWork.FirstOrDefault(e => e.RefID == ProjectId && e.TypeCode == FlowCode.Reimage_ConsInvtChecking && e.Status == TaskWorkStatus.UnFinish); var checkingProj = ProjectInfo.FirstOrDefault(e => e.ProjectId == ProjectId && e.FlowCode == FlowCode.Reimage_ConsInvtChecking); if (consCheckingTask == null && checkingProj != null && checkingProj.Status != ProjectStatus.Finished) { var consInvtChecking = new ReimageConsInvtChecking(); consInvtChecking.ProjectId = task.RefID; consInvtChecking.GenerateConsInvtCheckingTask(true); } ProjectInfo.CompleteMainIfEnable(ProjectId); var pmTaskUrl = string.Format(@"/Reimage/Main#/GBMemo/Process/Notify?projectId={0}", ProjectId); var pmTask = imgInfo.GenerateTaskWork(WorkflowCode, "Reimage GBMemo", "Reimage GBMemo", pmTaskUrl); pmTask.ActivityName = "Notify"; pmTask.ActionName = "Notify"; TaskWork.Add(pmTask); GenerateSiteInfoTask(); break; case TaskWorkStatus.K2ProcessDeclined: ProjectInfo.UpdateProjectStatus(ProjectId, FlowCode.Reimage, ProjectStatus.Rejected); ProjectInfo.UpdateProjectStatus(ProjectId, FlowCode.Reimage_GBMemo, ProjectStatus.Rejected); break; } scope.Complete(); } }