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 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(); } }