public override void Finish(TaskWorkStatus status, TaskWork task) { switch (status) { case TaskWorkStatus.K2ProcessDeclined: ProjectInfo.UpdateProjectStatus(ProjectId, FlowCode.Closure, ProjectStatus.Rejected); //删除未处理完成的任务 var oldTask = TaskWork.Search(i => i.SourceCode == FlowCode.Closure && i.RefID == this.ProjectId && i.Status == TaskWorkStatus.UnFinish).ToArray(); foreach (var taskItem in oldTask) { taskItem.Status = TaskWorkStatus.Cancel; } TaskWork.Update(oldTask); ProjectInfo.UpdateProjectStatus(ProjectId, FlowCode.Closure_ClosurePackage, ProjectStatus.Rejected); break; case TaskWorkStatus.K2ProcessApproved: //ClosurePackage的最后一步在K2中,但不属于审批 task.ActionName = ""; task.Update(); ProjectInfo.FinishNode(this.ProjectId, FlowCode.Closure_ClosurePackage, NodeCode.Closure_ClosurePackage_ResourceUpload, ProjectStatus.Finished); //Package流程走完后,在Actor处生成一条任务,供Actor上传Signed Termination Agreement与Signed Package //GenerateSignedPackageTask(ProjectId); if (!TaskWork.Any(i => i.RefID == this.ProjectId && i.SourceCode == FlowCode.Closure && i.TypeCode == FlowCode.Closure_ContractInfo && i.Status != TaskWorkStatus.Cancel)) { TaskWork taskWorkContractInfo = new TaskWork(); taskWorkContractInfo.SourceCode = FlowCode.Closure; taskWorkContractInfo.SourceNameENUS = FlowCode.Closure; taskWorkContractInfo.SourceNameZHCN = "关店流程"; taskWorkContractInfo.Status = TaskWorkStatus.UnFinish; taskWorkContractInfo.StatusNameZHCN = "任务"; taskWorkContractInfo.StatusNameENUS = "任务"; taskWorkContractInfo.RefID = ProjectId; taskWorkContractInfo.Id = Guid.NewGuid(); taskWorkContractInfo.CreateTime = DateTime.Now; //ClosureInfo closure = new ClosureInfo(); var closureInfo = ClosureInfo.GetByProjectId(ProjectId); taskWorkContractInfo.Title = TaskWork.BuildTitle(ProjectId, closureInfo.StoreNameZHCN, closureInfo.StoreNameENUS); taskWorkContractInfo.TypeCode = FlowCode.Closure_ContractInfo; taskWorkContractInfo.TypeNameENUS = "ContractInfo"; taskWorkContractInfo.TypeNameZHCN = "ContractInfo"; taskWorkContractInfo.ReceiverAccount = closureInfo.AssetActorAccount; taskWorkContractInfo.ReceiverNameENUS = closureInfo.AssetActorNameENUS; taskWorkContractInfo.ReceiverNameZHCN = closureInfo.AssetActorNameZHCN; taskWorkContractInfo.Url = SiteInfo.GetProjectHandlerPageUrl(FlowCode.Closure_ContractInfo, closureInfo.ProjectId); taskWorkContractInfo.StoreCode = closureInfo.USCode; taskWorkContractInfo.ActivityName = "Start"; taskWorkContractInfo.Add(); } //为了方便测试,暂时做成Package走完立刻生成ConsInvtChecking和ClourseMemo //var consInvtChecking = new ClosureConsInvtChecking(); //consInvtChecking.GenerateConsInvtCheckingTask(ProjectId); var memo = new ClosureMemo(); memo.GenerateClourseMemoTask(ProjectId); //如果是Complete了的流程,Edit后流程走完需要重新把主流程状态改成Complete ProjectInfo.CompleteMainIfEnable(ProjectId); break; } }
private void SendWorkTaskAndEmail(ClosureInfo entity) { var newGuid = new Guid(); var taskWorkController = new TaskWorkController(); //任务通用部分 var taskWork = new TaskWork(); taskWork.SourceCode = FlowCode.Closure; taskWork.SourceNameZHCN = "关店流程"; taskWork.SourceNameENUS = taskWork.SourceCode; taskWork.Status = 0; taskWork.StatusNameZHCN = "任务"; taskWork.StatusNameENUS = "任务"; var title = TaskWork.BuildTitle(entity.ProjectId, entity.StoreNameZHCN, entity.StoreNameENUS); taskWork.Title = title; //string.Format("{0} {1}", entity.StoreNameCN, entity.StoreNameEN); taskWork.RefID = entity.ProjectId.ToString(); taskWork.StoreCode = entity.USCode; taskWork.ActionName = NodeCode.Start; var objectCopy = new ObjectCopy(); var taskWorkEntity = objectCopy.AutoCopy(taskWork); //创建WOChecklist任务 taskWorkEntity.TypeCode = FlowCode.Closure_WOCheckList; taskWorkEntity.TypeNameENUS = "WOChecklist"; taskWorkEntity.TypeNameZHCN = "WOChecklist"; taskWorkEntity.ReceiverAccount = entity.PMAccount; taskWorkEntity.ReceiverNameENUS = entity.PMNameENUS; taskWorkEntity.ReceiverNameZHCN = entity.PMNameZHCN; taskWorkEntity.Id = newGuid; //taskWorkEntity.Url = SiteInfo.WebUrl + "/closure/Main#/closure/WOCheckList/" + entity.ProjectId; taskWorkEntity.Url = SiteInfo.GetProjectHandlerPageUrl(FlowCode.Closure_WOCheckList, entity.ProjectId); taskWorkEntity.ActivityName = "Start"; taskWorkController.Create(taskWorkEntity); var closureHandler = new ClosureHandler(); var noticerList = new List <string>(); if (entity.NoticeUserList != null && entity.NoticeUserList.Count > 0) { noticerList = entity.NoticeUserList.Select(e => e.Account).ToList(); } //noticerList.Add(entity.PMAccount); //closureHandler.SendEmail(newGuid, noticerList.ToArray(), "WOChecklist", entity.ProjectId, ClosureWOCheckList.TableName, entity.PMNameENUS); //noticerList.Remove(entity.PMAccount); taskWorkEntity = objectCopy.AutoCopy(taskWork); //创建Closure Tool任务 taskWorkEntity.TypeCode = FlowCode.Closure_ClosureTool; taskWorkEntity.TypeNameENUS = "Closure Tool(Fin)"; taskWorkEntity.TypeNameZHCN = "Closure Tool(Fin)"; taskWorkEntity.ReceiverAccount = entity.FinanceAccount; taskWorkEntity.ReceiverNameZHCN = entity.FinanceNameZHCN; taskWorkEntity.ReceiverNameENUS = entity.FinanceNameENUS; taskWorkEntity.Id = newGuid; taskWorkEntity.Url = SiteInfo.GetProjectHandlerPageUrl(FlowCode.Closure_ClosureTool, entity.ProjectId); taskWorkEntity.ActivityName = "Start"; taskWorkController.Create(taskWorkEntity); //noticerList.Add(entity.FinanceAccount); //closureHandler.SendEmail(newGuid, noticerList.ToArray(), "Closure Tool", entity.ProjectId, ClosureTool.TableName, entity.PMNameENUS); //noticerList.Remove(entity.FinanceAccount); taskWorkEntity = objectCopy.AutoCopy(taskWork); //创建LegalReview(Rep)任务 taskWorkEntity.TypeCode = FlowCode.Closure_LegalReview; taskWorkEntity.TypeNameENUS = "LegalReview(Rep)"; taskWorkEntity.TypeNameZHCN = "LegalReview(Rep)"; taskWorkEntity.ReceiverAccount = entity.AssetActorAccount; taskWorkEntity.ReceiverNameZHCN = entity.AssetActorNameZHCN; taskWorkEntity.ReceiverNameENUS = entity.AssetActorNameENUS; taskWorkEntity.Id = newGuid; taskWorkEntity.Url = SiteInfo.GetProjectHandlerPageUrl(FlowCode.Closure_LegalReview, entity.ProjectId); taskWorkEntity.ActivityName = "Start"; taskWorkController.Create(taskWorkEntity); //noticerList.Add(entity.AssetActorAccount); //closureHandler.SendEmail(newGuid, noticerList.ToArray(), "LegalReview", entity.ProjectId, ClosureLegalReview.TableName,entity.PMNameENUS); //noticerList.Remove(entity.AssetActorAccount); }