public override string Edit() { var info = RenewalInfo.Get(this.ProjectId); using (var tranScope = new TransactionScope()) { var legalApproval = Duplicator.AutoCopy(this); legalApproval.Id = Guid.NewGuid(); legalApproval.IsHistory = false; legalApproval.LegalComments = ""; legalApproval.CreateUserAccount = ClientCookie.UserCode; legalApproval.Add(); IsHistory = true; this.Update(); ProjectInfo.Reset(ProjectId, this.WorkflowCode); var attachments = Attachment.GetList(this.TableName, Id.ToString(), string.Empty); attachments.ForEach(att => { att.RefTableID = legalApproval.Id.ToString(); att.ID = Guid.NewGuid(); }); Attachment.Add(attachments.ToArray()); var assetActor = ProjectUsers.FirstOrDefault(pu => pu.ProjectId == ProjectId && pu.RoleCode == ProjectUserRoleCode.AssetActor); TaskWork.Cancel(t => t.RefID == ProjectId && t.Status == TaskWorkStatus.UnFinish); var task = info.GenerateSubmitTask(this.WorkflowCode); tranScope.Complete(); return(task.Url); } }
public override string Edit() { using (TransactionScope tranScope = new TransactionScope()) { var info = RenewalInfo.Get(ProjectId); this.IsHistory = true; this.Update(); var entity = Duplicator.AutoCopy(this); entity.Id = Guid.NewGuid(); entity.IsHistory = false; entity.Add(); var attachments = Attachment.GetList(this.TableName, Id.ToString(), string.Empty); attachments.ForEach(att => { att.RefTableID = entity.Id.ToString(); att.ID = Guid.NewGuid(); }); Attachment.Add(attachments.ToArray()); TaskWork.Cancel(e => e.TypeCode == this.WorkflowCode && e.RefID == ProjectId && e.Status == TaskWorkStatus.UnFinish); ProjectInfo.Reset(ProjectId, this.WorkflowCode); var task = info.GenerateSubmitTask(this.WorkflowCode); tranScope.Complete(); return(task.Url); } }
public override string Edit() { var taskUrl = string.Format("/MajorLease/Main#/LegalReview?projectId={0}", ProjectId); using (var scope = new TransactionScope()) { var majorLeaseInfo = MajorLeaseInfo.Search(e => e.ProjectId.Equals(ProjectId)).FirstOrDefault(); if (majorLeaseInfo == null) { throw new Exception("Could not find the Major Lease Info, please check it!"); } TaskWork.Cancel(t => t.RefID == ProjectId && t.Status == TaskWorkStatus.UnFinish && t.TypeCode == this.WorkflowCode);//取消老的流程实例的所有未完成任务 var task = majorLeaseInfo.GenerateTaskWork(WorkflowCode, "LegalReview", "LegalReview", taskUrl); task.ActivityName = NodeCode.Start; task.ActionName = SetTaskActionName(ProjectId); TaskWork.Add(task); var package = MajorLeaseChangePackage.GetMajorPackageInfo(ProjectId); if (package != null) { package.ProjectId = ProjectId; package.CompleteActorPackageTask(majorLeaseInfo.AssetActorAccount); } IsHistory = true; Update(this); var attachments = Attachment.Search(e => e.RefTableID == Id.ToString() && e.RefTableName == WFMajorLeaseLegalReview.TableName).ToList(); ProjectInfo.Reset(ProjectId, WorkflowCode); Mapper.CreateMap <MajorLeaseLegalReview, MajorLeaseLegalReview>(); var newMajorLeaseLR = Mapper.Map <MajorLeaseLegalReview>(this); newMajorLeaseLR.Id = Guid.Empty; newMajorLeaseLR.ProcInstID = null; newMajorLeaseLR.IsHistory = false; newMajorLeaseLR.Comments = null; newMajorLeaseLR.Save(); var newAttachmentList = new List <Attachment>(); Mapper.CreateMap <Attachment, Attachment>(); foreach (var attachment in attachments) { var newAttachment = Mapper.Map <Attachment>(attachment); newAttachment.RefTableID = newMajorLeaseLR.Id.ToString(); newAttachment.ID = Guid.NewGuid(); newAttachmentList.Add(newAttachment); } Attachment.Add(newAttachmentList.ToArray()); scope.Complete(); } return(taskUrl); }
public TaskWork GenerateSubmitTask(string flowCode) { TaskWork.Cancel(t => t.TypeCode == flowCode && t.ActivityName == "Start" && t.RefID == this.ProjectId); TaskWork taskWork = new TaskWork(); var url = TaskWork.BuildUrl(flowCode, this.ProjectId); switch (flowCode) { case FlowCode.Renewal_Letter: taskWork = GenerateTask(flowCode, url, AssetActorAccount, AssetActorNameENUS, AssetActorNameZHCN, "Start"); break; case FlowCode.Renewal_LLNegotiation: taskWork = GenerateTask(flowCode, url, AssetActorAccount, AssetActorNameENUS, AssetActorNameZHCN, "Start"); break; case FlowCode.Renewal_ConsInfo: taskWork = GenerateTask(flowCode, url, PMAccount, PMNameENUS, PMNameZHCN, "Start"); break; case FlowCode.Renewal_Tool: taskWork = GenerateTask(flowCode, url, FinanceAccount, FinanceNameENUS, FinanceNameZHCN, "Start"); break; case FlowCode.Renewal_Analysis: taskWork = GenerateTask(flowCode, url, AssetActorAccount, AssetActorNameENUS, AssetActorNameZHCN, "Start"); break; case FlowCode.Renewal_ClearanceReport: taskWork = GenerateTask(flowCode, url, AssetActorAccount, AssetActorNameENUS, AssetActorNameZHCN, "Start"); break; case FlowCode.Renewal_ConfirmLetter: taskWork = GenerateTask(flowCode, url, AssetActorAccount, AssetActorNameENUS, AssetActorNameZHCN, "Start"); break; case FlowCode.Renewal_LegalApproval: taskWork = GenerateTask(flowCode, url, AssetActorAccount, AssetActorNameENUS, AssetActorNameZHCN, "Start"); break; case FlowCode.Renewal_Package: taskWork = GenerateTask(flowCode, url, AssetActorAccount, AssetActorNameENUS, AssetActorNameZHCN, "Start"); break; case FlowCode.Renewal_ContractInfo: taskWork = GenerateTask(flowCode, url, AssetActorAccount, AssetActorNameENUS, AssetActorNameZHCN, "Start"); break; case FlowCode.Renewal_SiteInfo: taskWork = GenerateTask(flowCode, url, PMAccount, PMNameENUS, PMNameZHCN, "Start"); break; } return(taskWork); }
public override void PrepareTask(TaskWork taskWork) { var info = RenewalInfo.Get(ProjectId); if (taskWork.ReceiverAccount == info.AssetActorAccount && taskWork.ActivityName == "AssetActor") { ProjectInfo.FinishNode(ProjectId, this.WorkflowCode, NodeCode.Renewal_Tool_Approval); if (!ProjectInfo.IsFlowFinished(ProjectId, FlowCode.Renewal_ConsInfo)) { taskWork.Cancel(); } } }
public override string Edit() { var taskUrl = string.Format("/Rebuild/Main#/LegalReview?projectId={0}", ProjectId); using (var scope = new TransactionScope()) { var rbdInfo = RebuildInfo.Search(e => e.ProjectId.Equals(ProjectId)).FirstOrDefault(); if (rbdInfo == null) { throw new Exception("Could not find the Rebuild Info, please check it!"); } TaskWork.Cancel(t => t.RefID == ProjectId && t.Status == TaskWorkStatus.UnFinish && t.TypeCode == this.WorkflowCode);//取消老的流程实例的所有未完成任务 var task = rbdInfo.GenerateTaskWork(WorkflowCode, "RebuildLegalReview", "RebuildLegalReview", taskUrl); task.ActivityName = NodeCode.Start; task.ActionName = SetTaskActionName(ProjectId); TaskWork.Add(task); var package = RebuildPackage.GetRebuildPackageInfo(ProjectId); if (package != null) { package.ProjectId = ProjectId; package.CompleteActorPackageTask(rbdInfo.AssetActorAccount); } IsHistory = true; Update(this); ProjectInfo.Reset(ProjectId, WorkflowCode); Mapper.CreateMap <RebuildLegalReview, RebuildLegalReview>(); var newLeaseLR = Mapper.Map <RebuildLegalReview>(this); newLeaseLR.Id = Guid.Empty; newLeaseLR.ProcInstID = null; newLeaseLR.IsHistory = false; newLeaseLR.Comments = null; newLeaseLR.Save("Edit"); CopyAttachment(Id.ToString(), newLeaseLR.Id.ToString()); CopyAppUsers(Id.ToString(), newLeaseLR.Id.ToString()); scope.Complete(); } return(taskUrl); }
public override string Edit() { var info = RenewalInfo.Get(ProjectId); var analysis = Duplicator.AutoCopy(this); analysis.Id = Guid.NewGuid(); analysis.IsHistory = false; analysis.Add(); this.IsHistory = true; this.Update(); ProjectInfo.Reset(ProjectId, this.WorkflowCode); RenewalPackage package = RenewalPackage.Get(ProjectId); package.AnalysisId = analysis.Id; package.Update(); TaskWork.Cancel(e => e.TypeCode == FlowCode.Renewal_Analysis && e.RefID == ProjectId && e.Status == TaskWorkStatus.UnFinish); var task = info.GenerateSubmitTask(FlowCode.Renewal_Analysis); return(task.Url); }
public override string Edit() { var info = RenewalInfo.Get(ProjectId); var entity = Duplicator.AutoCopy(this); entity.Id = Guid.NewGuid(); entity.IsHistory = false; entity.Add(); this.IsHistory = true; this.Update(); var records = RenewalLLNegotiationRecord.GetRecords(this.Id); records.ForEach(rec => { rec.Id = Guid.NewGuid(); rec.RenewalLLNegotiationId = entity.Id; }); RenewalLLNegotiationRecord.Add(records.ToArray()); TaskWork.Cancel(e => e.TypeCode == this.WorkflowCode && e.RefID == ProjectId && e.Status == TaskWorkStatus.UnFinish); ProjectInfo.Reset(ProjectId, this.WorkflowCode); var task = info.GenerateSubmitTask(this.WorkflowCode); return(task.Url); }
public override string Edit() { if (!PreEdit(this.ProjectId)) { return(""); } var taskWork = TaskWork.Search(e => e.ReceiverAccount == ClientCookie.UserCode && e.SourceCode == FlowCode.Closure && e.TypeCode == FlowCode.Closure_LegalReview && e.RefID == this.ProjectId ).FirstOrDefault(); TaskWork.Cancel(t => t.RefID == ProjectId && t.Status == TaskWorkStatus.UnFinish && t.TypeCode == this.WorkflowCode);//取消老的流程实例的所有未完成任务 taskWork.Status = TaskWorkStatus.UnFinish; taskWork.StatusNameZHCN = "任务"; taskWork.StatusNameENUS = "任务"; var closureEntity = ClosureInfo.GetByProjectId(this.ProjectId); taskWork.ReceiverAccount = closureEntity.AssetActorAccount; taskWork.ReceiverNameENUS = closureEntity.AssetActorNameENUS; taskWork.ReceiverNameZHCN = closureEntity.AssetActorNameENUS; taskWork.Id = Guid.NewGuid(); taskWork.ProcInstID = null; taskWork.CreateTime = DateTime.Now; taskWork.Url = "/closure/Main#/LegalReview?projectId=" + this.ProjectId; taskWork.ActivityName = NodeCode.Start; taskWork.ActionName = SetTaskActionName(ProjectId); TaskWork.Add(taskWork); this.IsHistory = true; //TaskWork.SetTaskHistory(this.Id, this.ProcInstID); this.Save(); var _db = GetDb(); _db.Entry(this).State = EntityState.Modified; var objectCopy = new ObjectCopy(); var newEntity = objectCopy.AutoCopy(this); newEntity.Id = Guid.NewGuid(); newEntity.ProcInstID = 0; newEntity.LegalCommers = ""; newEntity.Save(); ProjectInfo.Reset(this.ProjectId, FlowCode.Closure_LegalReview); var attList = Attachment.Search(e => e.RefTableID == this.Id.ToString() && e.RefTableName == ClosureLegalReview.TableName).AsNoTracking().ToList(); var newList = new List <Attachment>(); foreach (var att in attList) { var newAtt = objCopy.AutoCopy(att); newAtt.RefTableID = newEntity.Id.ToString(); newAtt.ID = Guid.NewGuid(); newList.Add(newAtt); } Attachment.AddList(newList); _db.SaveChanges(); return(taskWork.Url); }
public void UpdateFromProjectList() { using (TransactionScope tranScope = new TransactionScope()) { var oldInfo = RenewalInfo.Get(this.ProjectId); var consInfo = RenewalConsInfo.Get(this.ProjectId); var analysis = RenewalAnalysis.Get(this.ProjectId); analysis.LeaseTenureAndTerm = string.Format("{0} years,from {1:yyyy-MM-dd} to {2:yyyy-MM-dd}", this.RenewalYears, this.NewLeaseStartDate, this.NewLeaseEndDate); analysis.Update(); if (oldInfo.NeedProjectCostEst != this.NeedProjectCostEst) { consInfo.HasReinvenstment = this.NeedProjectCostEst; consInfo.Update(); if (ProjectInfo.IsFlowFinished(this.ProjectId, FlowCode.Renewal_Letter) && ProjectInfo.IsFlowFinished(this.ProjectId, FlowCode.Renewal_LLNegotiation)) { if (!this.NeedProjectCostEst) { TaskWork.Cancel(e => e.RefID == this.ProjectId && e.Status == TaskWorkStatus.UnFinish && e.TypeCode == FlowCode.Renewal_ConsInfo); ProjectInfo.FinishProject(this.ProjectId, FlowCode.Renewal_ConsInfo); if (!ProjectInfo.IsFlowFinished(this.ProjectId, FlowCode.Renewal_Tool)) { if (!TaskWork.Any(e => e.RefID == this.ProjectId && e.Status == TaskWorkStatus.UnFinish && e.TypeCode == FlowCode.Renewal_Tool)) { GenerateSubmitTask(FlowCode.Renewal_Tool); } } } else { ProjectInfo.Reset(this.ProjectId, FlowCode.Renewal_ConsInfo); GenerateSubmitTask(FlowCode.Renewal_ConsInfo); if (!ProjectInfo.IsFlowFinished(this.ProjectId, FlowCode.Renewal_Tool)) { TaskWork.Cancel(e => e.RefID == this.ProjectId && e.TypeCode == FlowCode.Renewal_Tool && e.Status == TaskWorkStatus.UnFinish); ProjectInfo.Reset(this.ProjectId, FlowCode.Renewal_Tool); } } } } if (oldInfo.RenewalYears != this.RenewalYears) { if (ProjectInfo.IsFlowFinished(ProjectId, FlowCode.Renewal_Analysis)) { if (this.RenewalYears <= 2) { TaskWork.Finish(e => e.RefID == this.ProjectId && e.Status == TaskWorkStatus.UnFinish && e.TypeCode == FlowCode.Renewal_ClearanceReport); ProjectInfo.FinishProject(this.ProjectId, FlowCode.Renewal_ClearanceReport); } else { if (!TaskWork.Any(e => e.RefID == ProjectId && e.TypeCode == FlowCode.Renewal_ClearanceReport && e.Status == TaskWorkStatus.UnFinish)) { GenerateSubmitTask(FlowCode.Renewal_ClearanceReport); } } } } this.Update(); tranScope.Complete(); } }