public override string Edit() { var taskUrl = string.Format("/MajorLease/Main#/GBMemo?projectId={0}", ProjectId); using (var scope = new TransactionScope()) { var rbdInfo = MajorLeaseInfo.Search(e => e.ProjectId.Equals(ProjectId)).FirstOrDefault(); if (rbdInfo == null) { throw new Exception("Could not find the Rebuild Info, please check it!"); } var task = rbdInfo.GenerateTaskWork(WorkflowCode, "MajorLease GBMemo", "MajorLease GBMemo", taskUrl); task.ActivityName = NodeCode.Start; task.ActionName = SetTaskActionName(ProjectId); TaskWork.Add(task); CompleteNotifyTask(ProjectId); AttachmentsMemoProcessInfo.UpdateNotifyDate(ProjectId, FlowCode.GBMemo, false); IsHistory = true; Update(this); Mapper.CreateMap <MajorLeaseGBMemo, MajorLeaseGBMemo>(); var entity = Mapper.Map <MajorLeaseGBMemo>(this); entity.Id = Guid.Empty; entity.ProcInstID = null; entity.IsHistory = false; entity.Comments = null; entity.Save("Edit"); CopyAppUsers(Id.ToString(), entity.Id.ToString()); scope.Complete(); } return(taskUrl); }
public void GenerateConsInvtCheckingTask(bool isScheduled = false) { if (CheckIfNeedGenerateConsInvtCheckingTask()) { var taskUrl = string.Format("/MajorLease/Main#/ConsInvtChecking?projectId={0}", ProjectId); var majorLeaseInfo = MajorLeaseInfo.Search(e => e.ProjectId.Equals(ProjectId)).AsNoTracking().FirstOrDefault(); if (majorLeaseInfo == null) { throw new Exception("Could not find the Major Lease Info, please check it!"); } var task = majorLeaseInfo.GenerateTaskWork(WorkflowCode, WorkflowCode, WorkflowCode, taskUrl); task.ActivityName = NodeCode.Start; task.ActionName = SetTaskActionName(ProjectId); task.CreateTime = DateTime.Now; if (!isScheduled) { TaskWork.Add(task); } else { var consInfoRepos = new MajorLeaseConsInfo(); var consInfo = consInfoRepos.GetConsInfo(ProjectId); //到达Cons Info中的工程完工时间后60天 发出任务 if (consInfo.ReinBasicInfo != null && consInfo.ReinBasicInfo.ConsCompletionDate.HasValue) { ScheduleLog.GenerateTaskSchedule(consInfo.ReinBasicInfo.ConsCompletionDate.Value.AddDays(60), task, ClientCookie.UserCode, ProjectId, WorkflowCode, majorLeaseInfo.USCode); } } } }
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 MajorLeaseConsInfo GetConsInfo(string strProjectId, string entityId = "") { MajorLeaseConsInfo entity = null; var majorLeaseInfo = MajorLeaseInfo.Search(e => e.ProjectId == strProjectId).FirstOrDefault(); if (string.IsNullOrEmpty(entityId)) { entity = Search(e => e.ProjectId.Equals(strProjectId) && !e.IsHistory).FirstOrDefault(); } else { entity = Search(e => e.Id.ToString().Equals(entityId)).FirstOrDefault(); } if (entity != null) { entity.IsProjectFreezed = CheckIfFreezeProject(strProjectId); entity.ReinCost = ReinvestmentCost.GetByConsInfoId(entity.Id); entity.ReinBasicInfo = ReinvestmentBasicInfo.GetByConsInfoId(entity.Id); if (entity.ReinBasicInfo == null) { entity.ReinBasicInfo = new ReinvestmentBasicInfo { GBDate = majorLeaseInfo.GBDate, ReopenDate = majorLeaseInfo.ReopenDate }; } entity.WriteOff = WriteOffAmount.GetByConsInfoId(entity.Id); entity.IsShowEdit = ProjectInfo.IsFlowEditable(strProjectId, WorkflowCode); entity.IsShowRecall = ProjectInfo.IsFlowRecallable(strProjectId, WorkflowCode); } else { if (majorLeaseInfo != null) { entity = new MajorLeaseConsInfo { ReinBasicInfo = new ReinvestmentBasicInfo { GBDate = majorLeaseInfo.GBDate, ReopenDate = majorLeaseInfo.ReopenDate }, IsProjectFreezed = CheckIfFreezeProject(strProjectId), ReinvenstmentType = 1 }; } } entity.IsShowSave = ProjectInfo.IsFlowSavable(strProjectId, FlowCode.MajorLease_ConsInfo); PopulateAppUsers(entity); return(entity); }
public override void Finish(TaskWorkStatus status, TaskWork task) { using (var scope = new TransactionScope()) { switch (status) { case TaskWorkStatus.K2ProcessApproved: var mjInfo = MajorLeaseInfo.Search(e => e.ProjectId.Equals(ProjectId)).FirstOrDefault(); var pmTaskUrl = string.Format(@"/MajorLease/Main#/GBMemo/Process/Notify?projectId={0}", ProjectId); var pmTask = mjInfo.GenerateTaskWork(WorkflowCode, "MajorLease GBMemo", "MajorLease GBMemo", pmTaskUrl); pmTask.ActivityName = "Notify"; pmTask.ActionName = "Notify"; TaskWork.Add(pmTask); break; } scope.Complete(); } }
public void Submit(List <ProjectContractRevision> revisions, string flowCode) { revisions = revisions ?? new List <ProjectContractRevision>(); using (TransactionScope tranScope = new TransactionScope()) { StoreContractInfo contractInfo = this.ToStoreContractInfo(); ProjectContractRevision reInfo = new ProjectContractRevision(); #region 初始化项目的Revision信息 reInfo.Id = Guid.NewGuid(); reInfo.ProjectId = this.ProjectId; Guid srId = Guid.NewGuid(); reInfo.ProjectContractId = this.Id; reInfo.RevisionId = srId; reInfo.StoreContractInfoId = contractInfo.Id; reInfo.StoreID = this.StoreId; reInfo.StoreCode = this.StoreCode; reInfo.LeaseRecapID = this.LeaseRecapID; reInfo.ChangeDate = DateTime.Now; if (flowCode == FlowCode.MajorLease_ContractInfo) { MajorLeaseInfo info = MajorLeaseInfo.Search(e => e.ProjectId == ProjectId).FirstOrDefault(); reInfo.Rent = info.ChangeRentalType.HasValue && info.ChangeRentalType.Value ? "Y" : null; reInfo.Size = info.ChangeRedLineType.HasValue && info.ChangeRedLineType.Value ? "Y" : null; reInfo.LeaseTerm = info.ChangeLeaseTermType.HasValue && info.ChangeLeaseTermType.Value ? "Y" : null; reInfo.Entity = info.ChangeLandlordType.HasValue && info.ChangeLandlordType.Value ? "Y" : null; reInfo.Others = info.ChangeOtherType.HasValue && info.ChangeOtherType.Value ? "Y" : null; reInfo.RentStructureOld = info.OldRentalStructure; reInfo.RentStructureNew = info.NewRentalStructure; reInfo.RedlineAreaOld = info.OldChangeRedLineRedLineArea.HasValue ? info.OldChangeRedLineRedLineArea.ToString() : null; reInfo.RedlineAreaNew = info.NewChangeRedLineRedLineArea.HasValue ? info.NewChangeRedLineRedLineArea.ToString() : null; reInfo.LeaseChangeExpiryOld = info.OldChangeLeaseTermExpiraryDate; reInfo.LeaseChangeExpiryNew = info.NewChangeLeaseTermExpiraryDate; reInfo.LandlordOld = info.OldLandlord; reInfo.LandlordNew = info.NewLandlord; reInfo.OthersDescription = info.Others; reInfo.Description = info.LeaseChangeDescription; } else if (flowCode == FlowCode.Rebuild_ContractInfo) { RebuildPackage info = RebuildPackage.GetRebuildPackageInfo(ProjectId); reInfo.Rent = info.ChangeRentalType.HasValue && info.ChangeRentalType.Value ? "Y" : null; reInfo.Size = info.ChangeRedLineType.HasValue && info.ChangeRedLineType.Value ? "Y" : null; reInfo.LeaseTerm = info.ChangeLeaseTermType.HasValue && info.ChangeLeaseTermType.Value ? "Y" : null; reInfo.Entity = info.ChangeLandlordType.HasValue && info.ChangeLandlordType.Value ? "Y" : null; reInfo.Others = info.ChangeOtherType.HasValue && info.ChangeOtherType.Value ? "Y" : null; reInfo.RentStructureOld = info.OldRentalStructure; reInfo.RentStructureNew = info.NewRentalStructure; reInfo.RedlineAreaOld = info.OldChangeRedLineRedLineArea.HasValue ? info.OldChangeRedLineRedLineArea.ToString() : null; reInfo.RedlineAreaNew = info.NewChangeRedLineRedLineArea.HasValue ? info.NewChangeRedLineRedLineArea.ToString() : null; reInfo.LeaseChangeExpiryOld = info.OldChangeLeaseTermExpiraryDate; reInfo.LeaseChangeExpiryNew = info.NewChangeLeaseTermExpiraryDate; reInfo.LandlordOld = info.OldLandlord; reInfo.LandlordNew = info.NewLandlord; reInfo.OthersDescription = info.Others; reInfo.Description = info.LeaseChangeDescription; } #endregion if (this.EditMode == "EDIT") { if (flowCode == FlowCode.Closure_ContractInfo) { revisions = revisions.OrderBy(r => r.ChangeDate).ToList(); revisions.ForEach(r => { var sr = r.ToStoreContractRevision(); sr.Save(); r.RevisionId = sr.Id; //回写到ContractInfo中 if (sr.Rent == "Y") { this.RentStructure = sr.RentStructureNew; } if (sr.Size == "Y") { this.TotalLeasedArea = sr.RedlineAreaNew; } if (sr.LeaseTerm == "Y") { this.EndDate = sr.LeaseChangeExpiryNew; } if (sr.Entity == "Y") { this.PartyAFullName = sr.LandlordNew; } }); contractInfo = this.ToStoreContractInfo(); var sRIds = revisions.Select(e => e.RevisionId).ToList(); StoreContractRevision.Delete(e => e.StoreContractInfoId == contractInfo.Id && !sRIds.Contains(e.Id)); this.Save(revisions); } else { this.Save(); reInfo.Save(); var sr = reInfo.ToStoreContractRevision(); sr.Id = srId; sr.Save(); } contractInfo.Update(); } else { contractInfo.Id = Guid.NewGuid(); contractInfo.CreatedTime = DateTime.Now; contractInfo.Add(); this.ContractInfoId = contractInfo.Id; if (Any(e => e.Id == this.Id)) { this.Update(); } else { this.Add(); } //新增时不需要带入修订信息 ProjectContractRevision.Delete(r => r.ProjectContractId == this.Id); //if (flowCode != FlowCode.Renewal_ContractInfo) //{ // reInfo.StoreContractInfoId = contractInfo.Id; // reInfo.Save(); // var sr = reInfo.ToStoreContractRevision(); // sr.Id = srId; // sr.Save(); //} } //关闭任务 var task = TaskWork.FirstOrDefault(e => e.ReceiverAccount == ClientCookie.UserCode && e.TypeCode.Contains("ContractInfo") && e.RefID == this.ProjectId); if (task != null) { task.Finish(); } var projectInfo = ProjectInfo.FirstOrDefault(e => e.ProjectId == this.ProjectId && e.FlowCode.Contains("ContractInfo")); ProjectInfo.FinishNode(this.ProjectId, projectInfo.FlowCode, NodeCode.Finish, ProjectStatus.Finished); ProjectInfo.CompleteMainIfEnable(this.ProjectId); if (projectInfo.FlowCode == FlowCode.Renewal_ContractInfo) { if (ProjectInfo.IsFlowFinished(ProjectId, FlowCode.Renewal_SiteInfo)) { ProjectProgress.SetProgress(ProjectId, "100%"); } } tranScope.Complete(); } }