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 override string Edit() { var taskUrl = string.Format("/MajorLease/Main#/ConsInfo?projectId={0}", ProjectId); using (var scope = new TransactionScope()) { var majorLeaseInfo = MajorLeaseInfo.FirstOrDefault(e => e.ProjectId.Equals(ProjectId)); if (majorLeaseInfo == null) { throw new Exception("Could not find the Major Lease Info, please check it!"); } var task = majorLeaseInfo.GenerateTaskWork(FlowCode.MajorLease_ConsInfo, "ConsInfo", "ConsInfo", 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 == WFMajorLeaseConsInfo.TableName).AsNoTracking().ToList(); ProjectInfo.Reset(ProjectId, FlowCode.MajorLease_ConsInfo); Mapper.CreateMap <MajorLeaseConsInfo, MajorLeaseConsInfo>(); var form = Mapper.Map <MajorLeaseConsInfo>(this); form.Id = Guid.Empty; form.ProcInstID = null; form.IsHistory = false; form.Comments = null; form.Save("Edit"); var newAttachmentList = new List <Attachment>(); Mapper.CreateMap <Attachment, Attachment>(); foreach (var attachment in attachments) { var newAttachment = Mapper.Map <Attachment>(attachment); newAttachment.RefTableID = form.Id.ToString(); newAttachment.ID = Guid.NewGuid(); newAttachmentList.Add(newAttachment); } Attachment.Add(newAttachmentList.ToArray()); scope.Complete(); } return(taskUrl); }
public override void Finish(TaskWorkStatus status, TaskWork task) { using (var scope = new TransactionScope()) { switch (status) { case TaskWorkStatus.K2ProcessApproved: ProjectInfo.FinishNode(ProjectId, WorkflowCode, NodeCode.MajorLease_FinanceAnalysis_Confirm, ProjectStatus.Finished); var majorLeasePackage = new MajorLeaseChangePackage(); majorLeasePackage.GeneratePackageTask(ProjectId); break; } scope.Complete(); } }
public override void Finish(TaskWorkStatus status, TaskWork task) { switch (status) { case TaskWorkStatus.K2ProcessApproved: ProjectInfo.FinishNode(ProjectId, FlowCode.MajorLease_ConsInfo, NodeCode.MajorLease_ConsInfo_Confirm, ProjectStatus.Finished); var majorLeasePackage = new MajorLeaseChangePackage(); majorLeasePackage.GeneratePackageTask(ProjectId); UpdateConsInvtCheckingStatus(); break; } }
protected override void ChangeWorkflowApprovers(List <TaskWork> taskWorks, List <ApproveDialogUser> prevApprovers, ApproveUsers currApprover) { foreach (var taskWork in taskWorks) { List <ProcessDataField> dataFields = null; switch (taskWork.TypeCode) { case FlowCode.MajorLease_Package: var package = new MajorLeaseChangePackage(); package.AppUsers = currApprover; dataFields = package.SetWorkflowDataFields(null); var packageApprovers = prevApprovers.FirstOrDefault(e => e.FlowCode == FlowCode.MajorLease_Package); if (packageApprovers != null) { SimpleEmployee receiver = null; if (taskWork.ReceiverAccount == packageApprovers.MarketMgrCode && packageApprovers.MarketMgrCode != currApprover.MarketMgr.Code) { receiver = currApprover.MarketMgr; } if (taskWork.ReceiverAccount == packageApprovers.RegionalMgrCode && packageApprovers.RegionalMgrCode != currApprover.RegionalMgr.Code) { receiver = currApprover.RegionalMgr; } if (taskWork.ReceiverAccount == packageApprovers.MDDCode && packageApprovers.MDDCode != currApprover.MDD.Code) { receiver = currApprover.MDD; } if (taskWork.ReceiverAccount == packageApprovers.GMCode && packageApprovers.GMCode != currApprover.GM.Code) { receiver = currApprover.GM; } if (taskWork.ReceiverAccount == packageApprovers.FCCode && packageApprovers.FCCode != currApprover.FC.Code) { receiver = currApprover.FC; } if (taskWork.ReceiverAccount == packageApprovers.RDDCode && packageApprovers.RDDCode != currApprover.RDD.Code) { receiver = currApprover.RDD; } if (taskWork.ReceiverAccount == packageApprovers.VPGMCode && packageApprovers.VPGMCode != currApprover.VPGM.Code) { receiver = currApprover.VPGM; } if (taskWork.ReceiverAccount == packageApprovers.MCCLAssetDtrCode && packageApprovers.MCCLAssetDtrCode != currApprover.MCCLAssetDtr.Code) { receiver = currApprover.MCCLAssetDtr; } if (taskWork.ReceiverAccount == packageApprovers.CDOCode && packageApprovers.CDOCode != currApprover.CDO.Code) { receiver = currApprover.CDO; } if (taskWork.ReceiverAccount == packageApprovers.CFOCode && packageApprovers.CFOCode != currApprover.CFO.Code) { receiver = currApprover.CFO; } else { if (taskWork.ProcInstID.HasValue) { UpdateWorkflowDataField(taskWork.ProcInstID.Value, dataFields); } } if (receiver != null) { RedirectWorkflowTask(taskWork.K2SN, taskWork.ReceiverAccount, receiver.Code, dataFields); taskWork.ReceiverAccount = receiver.Code; taskWork.ReceiverNameENUS = receiver.NameENUS; taskWork.ReceiverNameZHCN = receiver.NameZHCN; } packageApprovers.MarketMgrCode = currApprover.MarketMgr.Code; packageApprovers.MarketMgrCode = currApprover.RegionalMgr.Code; packageApprovers.MarketMgrCode = currApprover.DD.Code; packageApprovers.MarketMgrCode = currApprover.GM.Code; packageApprovers.MarketMgrCode = currApprover.FC.Code; packageApprovers.MarketMgrCode = currApprover.RDD.Code; packageApprovers.MarketMgrCode = currApprover.VPGM.Code; packageApprovers.MarketMgrCode = currApprover.MCCLAssetDtr.Code; packageApprovers.MarketMgrCode = currApprover.CDO.Code; packageApprovers.MarketMgrCode = currApprover.CFO.Code; } break; } } }
public void Save(bool pushOrNot) { using (TransactionScope tranScope = new TransactionScope()) { var projectInfo = ProjectInfo.Get(Id); if (projectInfo == null) { ProjectId = ProjectInfo.CreateDLProject(Id, FlowCode.MajorLease, USCode, NodeCode.Start, ClientCookie.UserCode, pushOrNot); var mlcInfo = new MajorLeaseInfo(); mlcInfo.Id = Guid.NewGuid(); mlcInfo.ProjectId = ProjectId; mlcInfo.USCode = USCode; mlcInfo.ChangeRentalType = ChangeRentalType; mlcInfo.ChangeRentalTypeDESC = ChangeRentalTypeDESC; mlcInfo.ChangeRedLineType = ChangeRedLineType; mlcInfo.ChangeRedLineTypeDESC = ChangeRedLineTypeDESC; mlcInfo.ChangeLeaseTermType = ChangeLeaseTermType; mlcInfo.ChangeLeaseTermDESC = ChangeLeaseTermDESC; mlcInfo.CreateTime = DateTime.Now; mlcInfo.CreateUserAccount = ClientCookie.UserCode; mlcInfo.CreateUserNameENUS = ClientCookie.UserNameENUS; mlcInfo.CreateUserNameZHCN = ClientCookie.UserNameZHCN; mlcInfo.ChangeLandlordType = ChangeLandlordType; mlcInfo.ChangeLandLordDESC = ChangeLandLordDESC; mlcInfo.Add(); var mlcPackage = new MajorLeaseChangePackage(); mlcPackage.Id = Guid.NewGuid(); mlcPackage.ProjectId = ProjectId; mlcPackage.WriteOff = MLCNetWriteOff_Act; mlcPackage.IsHistory = false; mlcPackage.CreateUserAccount = ClientCookie.UserCode; mlcPackage.CreateTime = DateTime.Now; mlcPackage.Add(); var mlcConsInvtChecking = new MajorLeaseConsInvtChecking(); mlcConsInvtChecking.Id = Guid.NewGuid(); mlcConsInvtChecking.ProjectId = ProjectId; mlcConsInvtChecking.IsHistory = false; mlcConsInvtChecking.CreateTime = DateTime.Now; mlcConsInvtChecking.Add(); var reinvestmentCost = new ReinvestmentCost(); reinvestmentCost.Id = Guid.NewGuid(); reinvestmentCost.ConsInfoID = mlcConsInvtChecking.Id; reinvestmentCost.TotalReinvestmentFAAct = MLC_TotalReinvestment_Act; reinvestmentCost.Add(); var projectContractInfo = new ProjectContractInfo(); projectContractInfo.Id = Guid.NewGuid(); projectContractInfo.ProjectId = ProjectId; projectContractInfo.ContractInfoId = Guid.Empty; projectContractInfo.CreatedTime = DateTime.Now; projectContractInfo.WriteBack = false; projectContractInfo.EditMode = EditMode; projectContractInfo.PartyAFullName = PartyAFullName; projectContractInfo.McDLegalEntity = ContractEntityName; projectContractInfo.McDOwnership = McdOwnership; projectContractInfo.ContactPerson = ContactPerson; projectContractInfo.ContactMode = ContactMode; projectContractInfo.RentType = RentType; projectContractInfo.TotalLeasedArea = RentSize; projectContractInfo.LeasePurchaseTerm = ContractTerm; projectContractInfo.LeasePurchase = ContractType; projectContractInfo.StartDate = ContractStartDate; projectContractInfo.EndDate = ContraceEndDate; projectContractInfo.StartYear = ContractStartYear; projectContractInfo.EndYear = ContraceEndYear; projectContractInfo.RentCommencementDate = RentPaymentStartDate; projectContractInfo.DeadlineToNotice = DeadlineToNoticeLL; projectContractInfo.Changedafter2010 = ChangedAfter2010; projectContractInfo.RentStructure = RentStructure; projectContractInfo.WithEarlyTerminationClause = EarlyTerminationClause; projectContractInfo.EarlyTerminationClauseDetail = EarlyTerminationClauseDescription; projectContractInfo.RentPaymentArrangement = RentPaymentArrangement; projectContractInfo.HasDeposit = Deposit; projectContractInfo.DepositAmount = DepositAmount; projectContractInfo.RefundableDate = WhenRefund; projectContractInfo.WithPenaltyClause = withPenaltyClause; projectContractInfo.HasBankGuarantee = BankGuarantee; projectContractInfo.BGNumber = BankGuaranteeNumber; projectContractInfo.BGAmount = BankGuaranteeAmount; projectContractInfo.BGCommencementDate = BGCommencementDate; projectContractInfo.BGEndDate = BGEndDate; projectContractInfo.Add(); } else { ProjectId = projectInfo.ProjectId; projectInfo.IsPushed = pushOrNot; projectInfo.Update(); var mlcInfo = MajorLeaseInfo.FirstOrDefault(i => i.ProjectId == ProjectId); if (mlcInfo != null) { mlcInfo.ChangeRentalType = ChangeRentalType; mlcInfo.ChangeRentalTypeDESC = ChangeRentalTypeDESC; mlcInfo.ChangeRedLineType = ChangeRedLineType; mlcInfo.ChangeRedLineTypeDESC = ChangeRedLineTypeDESC; mlcInfo.ChangeLeaseTermType = ChangeLeaseTermType; mlcInfo.ChangeLeaseTermDESC = ChangeLeaseTermDESC; mlcInfo.ChangeLandlordType = ChangeLandlordType; mlcInfo.ChangeLandLordDESC = ChangeLandLordDESC; mlcInfo.Update(); } else { mlcInfo = new MajorLeaseInfo(); mlcInfo.Id = Guid.NewGuid(); mlcInfo.ProjectId = ProjectId; mlcInfo.USCode = USCode; mlcInfo.ChangeRentalType = ChangeRentalType; mlcInfo.ChangeRentalTypeDESC = ChangeRentalTypeDESC; mlcInfo.ChangeRedLineType = ChangeRedLineType; mlcInfo.ChangeRedLineTypeDESC = ChangeRedLineTypeDESC; mlcInfo.ChangeLeaseTermType = ChangeLeaseTermType; mlcInfo.ChangeLeaseTermDESC = ChangeLeaseTermDESC; mlcInfo.CreateTime = DateTime.Now; mlcInfo.CreateUserAccount = ClientCookie.UserCode; mlcInfo.CreateUserNameENUS = ClientCookie.UserNameENUS; mlcInfo.CreateUserNameZHCN = ClientCookie.UserNameZHCN; mlcInfo.ChangeLandlordType = ChangeLandlordType; mlcInfo.ChangeLandLordDESC = ChangeLandLordDESC; mlcInfo.Add(); } var mlcPackage = MajorLeaseChangePackage.GetMajorPackageInfo(ProjectId); if (mlcPackage != null) { mlcPackage.WriteOff = MLCNetWriteOff_Act; mlcPackage.Update(); } else { mlcPackage = new MajorLeaseChangePackage(); mlcPackage.Id = Guid.NewGuid(); mlcPackage.ProjectId = ProjectId; mlcPackage.WriteOff = MLCNetWriteOff_Act; mlcPackage.IsHistory = false; mlcPackage.CreateUserAccount = ClientCookie.UserCode; mlcPackage.CreateTime = DateTime.Now; mlcPackage.Add(); } var mlcConsInvtChecking = MajorLeaseConsInvtChecking.FirstOrDefault(i => i.ProjectId == ProjectId && i.IsHistory == false); if (mlcConsInvtChecking == null) { mlcConsInvtChecking = new MajorLeaseConsInvtChecking(); mlcConsInvtChecking.Id = Guid.NewGuid(); mlcConsInvtChecking.ProjectId = ProjectId; mlcConsInvtChecking.IsHistory = false; mlcConsInvtChecking.CreateTime = DateTime.Now; mlcConsInvtChecking.Add(); } var reinvestmentCost = ReinvestmentCost.GetByConsInfoId(mlcConsInvtChecking.Id); if (reinvestmentCost != null) { reinvestmentCost.TotalReinvestmentFAAct = MLC_TotalReinvestment_Act; reinvestmentCost.Update(); } else { reinvestmentCost = new ReinvestmentCost(); reinvestmentCost.Id = Guid.NewGuid(); reinvestmentCost.ConsInfoID = mlcConsInvtChecking.Id; reinvestmentCost.TotalReinvestmentFAAct = MLC_TotalReinvestment_Act; reinvestmentCost.Add(); } var projectContractInfo = ProjectContractInfo.FirstOrDefault(i => i.ProjectId == ProjectId); if (projectContractInfo != null) { projectContractInfo.EditMode = EditMode; projectContractInfo.PartyAFullName = PartyAFullName; projectContractInfo.McDLegalEntity = ContractEntityName; projectContractInfo.McDOwnership = McdOwnership; projectContractInfo.ContactPerson = ContactPerson; projectContractInfo.ContactMode = ContactMode; projectContractInfo.RentType = RentType; projectContractInfo.TotalLeasedArea = RentSize; projectContractInfo.LeasePurchaseTerm = ContractTerm; projectContractInfo.LeasePurchase = ContractType; projectContractInfo.StartDate = ContractStartDate; projectContractInfo.EndDate = ContraceEndDate; projectContractInfo.StartYear = ContractStartYear; projectContractInfo.EndYear = ContraceEndYear; projectContractInfo.RentCommencementDate = RentPaymentStartDate; projectContractInfo.DeadlineToNotice = DeadlineToNoticeLL; projectContractInfo.Changedafter2010 = ChangedAfter2010; projectContractInfo.RentStructure = RentStructure; projectContractInfo.WithEarlyTerminationClause = EarlyTerminationClause; projectContractInfo.EarlyTerminationClauseDetail = EarlyTerminationClauseDescription; projectContractInfo.RentPaymentArrangement = RentPaymentArrangement; projectContractInfo.HasDeposit = Deposit; projectContractInfo.DepositAmount = DepositAmount; projectContractInfo.RefundableDate = WhenRefund; projectContractInfo.WithPenaltyClause = withPenaltyClause; projectContractInfo.HasBankGuarantee = BankGuarantee; projectContractInfo.BGNumber = BankGuaranteeNumber; projectContractInfo.BGAmount = BankGuaranteeAmount; projectContractInfo.BGCommencementDate = BGCommencementDate; projectContractInfo.BGEndDate = BGEndDate; projectContractInfo.Update(); } else { projectContractInfo = new ProjectContractInfo(); projectContractInfo.Id = Guid.NewGuid(); projectContractInfo.ProjectId = ProjectId; projectContractInfo.ContractInfoId = Guid.Empty; projectContractInfo.CreatedTime = DateTime.Now; projectContractInfo.WriteBack = false; projectContractInfo.EditMode = EditMode; projectContractInfo.PartyAFullName = PartyAFullName; projectContractInfo.McDLegalEntity = ContractEntityName; projectContractInfo.McDOwnership = McdOwnership; projectContractInfo.ContactPerson = ContactPerson; projectContractInfo.ContactMode = ContactMode; projectContractInfo.RentType = RentType; projectContractInfo.TotalLeasedArea = RentSize; projectContractInfo.LeasePurchaseTerm = ContractTerm; projectContractInfo.LeasePurchase = ContractType; projectContractInfo.StartDate = ContractStartDate; projectContractInfo.EndDate = ContraceEndDate; projectContractInfo.StartYear = ContractStartYear; projectContractInfo.EndYear = ContraceEndYear; projectContractInfo.RentCommencementDate = RentPaymentStartDate; projectContractInfo.DeadlineToNotice = DeadlineToNoticeLL; projectContractInfo.Changedafter2010 = ChangedAfter2010; projectContractInfo.RentStructure = RentStructure; projectContractInfo.WithEarlyTerminationClause = EarlyTerminationClause; projectContractInfo.EarlyTerminationClauseDetail = EarlyTerminationClauseDescription; projectContractInfo.RentPaymentArrangement = RentPaymentArrangement; projectContractInfo.HasDeposit = Deposit; projectContractInfo.DepositAmount = DepositAmount; projectContractInfo.RefundableDate = WhenRefund; projectContractInfo.WithPenaltyClause = withPenaltyClause; projectContractInfo.HasBankGuarantee = BankGuarantee; projectContractInfo.BGNumber = BankGuaranteeNumber; projectContractInfo.BGAmount = BankGuaranteeAmount; projectContractInfo.BGCommencementDate = BGCommencementDate; projectContractInfo.BGEndDate = BGEndDate; projectContractInfo.Add(); } } tranScope.Complete(); } }