public static ConsInfoDTO <RenewalInfo, RenewalConsInfo> InitPage(string projectId, string id = "") { RenewalInfo info = RenewalInfo.Get(projectId); var consInfo = RenewalConsInfo.Get(projectId, id); if (consInfo == null) { consInfo = new RenewalConsInfo(); consInfo.ProjectId = projectId; } var isOriginator = ClientCookie.UserCode == info.PMAccount; consInfo.IsProjectFreezed = consInfo.CheckIfFreezeProject(projectId); var nextRefTableId = new Guid(FlowInfo.GetRefTableId("RenewalTool", projectId)); var nextFlowStarted = ProjectInfo.IsFlowStarted(projectId, FlowCode.Renewal_Tool); var haveTask = TaskWork.Any(t => t.RefID == projectId && t.TypeCode == FlowCode.Renewal_Tool && t.Status == TaskWorkStatus.UnFinish && t.ReceiverAccount == ClientCookie.UserCode); var projectComment = ProjectComment.GetSavedComment(consInfo.Id, "RenewalConsInfo", ClientCookie.UserCode); if (string.IsNullOrEmpty(id)) { consInfo.HasReinvenstment = info.NeedProjectCostEst; } ConsInfoDTO <RenewalInfo, RenewalConsInfo> dto = new ConsInfoDTO <RenewalInfo, RenewalConsInfo>(); dto.Entity = consInfo; dto.Info = info; dto.ReinBasicInfo = ReinvestmentBasicInfo.GetByConsInfoId(consInfo.Id); dto.ReinCost = ReinvestmentCost.GetByConsInfoId(consInfo.Id); dto.WriteOff = WriteOffAmount.GetByConsInfoId(consInfo.Id); dto.ProjectComment = projectComment != null ? projectComment.Content : ""; dto.Editable = ProjectInfo.IsFlowEditable(projectId, FlowCode.Renewal_ConsInfo); dto.Recallable = ProjectInfo.IsFlowRecallable(projectId, FlowCode.Renewal_ConsInfo); dto.Savable = ProjectInfo.IsFlowSavable(projectId, FlowCode.Renewal_ConsInfo) && string.IsNullOrEmpty(id); return(dto); }
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 static RenewalAnalysisDTO InitPage(string projectId) { RenewalAnalysisDTO dto = new RenewalAnalysisDTO(); var consInfo = RenewalConsInfo.Get(projectId); var analysis = Get(projectId); if (consInfo.HasReinvenstment) { var reinBasic = ReinvestmentBasicInfo.GetByConsInfoId(consInfo.Id) ?? new ReinvestmentBasicInfo(); analysis.OperationSize = reinBasic.NewOperationSize; } dto.Info = RenewalInfo.Get(projectId); analysis.LastRemodeling = GetLastRemodeling(dto.Info.USCode); dto.Entity = analysis; dto.HasReinvenstment = consInfo.HasReinvenstment; dto.StoreInfo = PrepareStoreInfo(projectId, dto.Info.USCode); dto.Editable = ProjectInfo.IsFlowEditable(projectId, FlowCode.Renewal_Analysis); dto.Recallable = ProjectInfo.IsFlowRecallable(projectId, FlowCode.Renewal_Analysis); dto.Savable = ProjectInfo.IsFlowSavable(projectId, FlowCode.Renewal_Analysis); return(dto); }
public static ReimageConsInfo GetConsInfo(string strProjectId, string entityId = "") { ReimageConsInfo entity = null; if (string.IsNullOrEmpty(entityId)) { entity = Search(e => e.ProjectId.Equals(strProjectId) && !e.IsHistory).FirstOrDefault(); } else { entity = Search(e => e.Id.ToString().Equals(entityId)).FirstOrDefault(); } var reimageInfo = ReimageInfo.FirstOrDefault(e => e.ProjectId == strProjectId); if (entity != null) { entity.IsProjectFreezed = entity.CheckIfFreezeProject(strProjectId); entity.ReinCost = ReinvestmentCost.GetByConsInfoId(entity.Id); entity.ReinBasicInfo = ReinvestmentBasicInfo.GetByConsInfoId(entity.Id); if (entity.ReinBasicInfo != null) { entity.ReinBasicInfo.GBDate = reimageInfo.GBDate; entity.ReinBasicInfo.ReopenDate = reimageInfo.ReopenDate; } else { entity.ReinBasicInfo = new ReinvestmentBasicInfo { GBDate = reimageInfo.GBDate, ReopenDate = reimageInfo.ReopenDate }; } entity.WriteOff = WriteOffAmount.GetByConsInfoId(entity.Id); var attachmentReinCost = Attachment.FirstOrDefault(e => e.RefTableID == entity.Id.ToString() && e.TypeCode == "ReinCost"); if (attachmentReinCost != null && entity.ReinCost != null) { entity.ReinCost.ReinCostUser = attachmentReinCost.CreatorNameENUS; entity.ReinCost.ReinCostTime = attachmentReinCost.CreateTime; } var attachmentWriteOff = Attachment.FirstOrDefault(e => e.RefTableID == entity.Id.ToString() && e.TypeCode == "WriteOff"); if (attachmentWriteOff != null) { entity.WriteOff.WriteOffUser = attachmentWriteOff.CreatorNameENUS; entity.WriteOff.WriteOffTime = attachmentWriteOff.CreateTime; } //entity.ProcInstID = entity.ProcInstId; entity.IsShowEdit = ProjectInfo.IsFlowEditable(strProjectId, FlowCode.Reimage_ConsInfo); entity.IsShowRecall = ProjectInfo.IsFlowRecallable(strProjectId, FlowCode.Reimage_ConsInfo); } else { //var reimage = ReimageInfo.FirstOrDefault(e => e.ProjectId == strProjectId); //if (reimage != null) //{ // entity = new ReimageConsInfo // { // ReinBasicInfo = // new ReinvestmentBasicInfo // { // GBDate = reimage.GBDate, // ReopenDate = reimage.ReopenDate // }, // IsProjectFreezed =entity.CheckIfFreezeProject(strProjectId), // ReinvenstmentType = 1 // }; //} entity.IsProjectFreezed = entity.CheckIfFreezeProject(strProjectId); entity.ReinBasicInfo = ReinvestmentBasicInfo.GetByConsInfoId(entity.Id); if (entity.ReinBasicInfo != null) { entity.ReinBasicInfo.GBDate = reimageInfo.GBDate; entity.ReinBasicInfo.ReopenDate = reimageInfo.ReopenDate; } else { entity.ReinBasicInfo = new ReinvestmentBasicInfo { GBDate = reimageInfo.GBDate, ReopenDate = reimageInfo.ReopenDate }; } } entity.IsShowSave = ProjectInfo.IsFlowSavable(strProjectId, FlowCode.Reimage_ConsInfo); entity.PopulateAppUsers(); return(entity); }
public RebuildConsInfo GetConsInfo(string strProjectId, string entityId = "") { RebuildConsInfo entity = null; 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); var attachmentReinCost = Attachment.FirstOrDefault(e => e.RefTableID == entity.Id.ToString() && e.TypeCode == "ReinCost"); if (entity.ReinCost != null && attachmentReinCost != null) { entity.ReinCost.ReinCostUser = attachmentReinCost.CreatorNameENUS; entity.ReinCost.ReinCostTime = attachmentReinCost.CreateTime; } if (entity.ReinBasicInfo == null) { var rbdInfo = RebuildInfo.FirstOrDefault(e => e.ProjectId == strProjectId); if (rbdInfo != null) { entity.ReinBasicInfo = new ReinvestmentBasicInfo { GBDate = rbdInfo.GBDate, ReopenDate = rbdInfo.ReopenDate, ConsCompletionDate = rbdInfo.ConstCompletionDate }; } } entity.WriteOff = WriteOffAmount.GetByConsInfoId(entity.Id); var attachmentWriteOff = Attachment.FirstOrDefault(e => e.RefTableID == entity.Id.ToString() && e.TypeCode == "WriteOff"); if (entity.WriteOff != null && attachmentWriteOff != null) { entity.WriteOff.WriteOffUser = attachmentWriteOff.CreatorNameENUS; entity.WriteOff.WriteOffTime = attachmentWriteOff.CreateTime; } entity.IsShowEdit = ProjectInfo.IsFlowEditable(strProjectId, FlowCode.Rebuild_ConsInfo); entity.IsShowRecall = ProjectInfo.IsFlowRecallable(strProjectId, FlowCode.Rebuild_ConsInfo); entity.IsShowSave = ProjectInfo.IsFlowSavable(strProjectId, FlowCode.Rebuild_ConsInfo); } else { var rbdInfo = RebuildInfo.FirstOrDefault(e => e.ProjectId == strProjectId); if (rbdInfo != null) { entity = new RebuildConsInfo { ReinBasicInfo = new ReinvestmentBasicInfo { GBDate = rbdInfo.GBDate, ReopenDate = rbdInfo.ReopenDate }, IsProjectFreezed = CheckIfFreezeProject(strProjectId), ProjectId = strProjectId }; } } PopulateAppUsers(entity); return(entity); }
public override string Edit() { using (var tranScope = new TransactionScope()) { var info = RenewalInfo.Get(this.ProjectId); var consInfo = Duplicator.AutoCopy(this); consInfo.Id = Guid.NewGuid(); consInfo.IsHistory = false; consInfo.CreateUserAccount = ClientCookie.UserCode; consInfo.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 = consInfo.Id.ToString(); att.ID = Guid.NewGuid(); }); Attachment.Add(attachments.ToArray()); var reinBasic = ReinvestmentBasicInfo.GetByConsInfoId(this.Id); if (reinBasic != null) { var newReinBasic = Duplicator.AutoCopy(reinBasic); newReinBasic.Id = 0; newReinBasic.ConsInfoID = consInfo.Id; newReinBasic.Add(); } var wf = WriteOffAmount.GetByConsInfoId(this.Id); if (wf != null) { var newWf = Duplicator.AutoCopy(wf); newWf.Id = Guid.NewGuid(); newWf.ConsInfoID = consInfo.Id; newWf.Add(); } var reinCost = ReinvestmentCost.GetByConsInfoId(this.Id); if (reinCost != null) { var newReinCost = Duplicator.AutoCopy(reinCost); newReinCost.Id = Guid.NewGuid(); newReinCost.ConsInfoID = consInfo.Id; newReinCost.Add(); } var oldTasks = TaskWork.Search(t => t.RefID == ProjectId && t.Status == TaskWorkStatus.UnFinish && new string[] { FlowCode.Renewal_ConsInfo, FlowCode.Renewal_Tool }.Contains(t.TypeCode)).ToList(); oldTasks.ForEach(t => { t.Status = TaskWorkStatus.Cancel; }); TaskWork.Update(oldTasks.ToArray()); var toolUploadTask = TaskWork.FirstOrDefault(t => t.RefID == ProjectId && t.TypeCode == FlowCode.Renewal_Tool && t.ReceiverAccount == info.AssetActorAccount && t.ActivityName == "AssetActor" && t.Status == TaskWorkStatus.UnFinish); if (toolUploadTask != null) { toolUploadTask.Status = TaskWorkStatus.Cancel; toolUploadTask.Update(); } CompleteRenewalToolTask(); var task = info.GenerateSubmitTask(this.WorkflowCode); tranScope.Complete(); return(task.Url); } }
public static ReopenMemo GetReopenMemo(string projectId) { var memo = FirstOrDefault(e => e.ProjectId.Equals(projectId)); bool isEmptyMemo = false; if (memo == null) { memo = new ReopenMemo(); isEmptyMemo = true; } memo.ProjectId = projectId; if (projectId.ToLower().IndexOf("rebuild") >= 0) { var rbdInfo = new RebuildInfo(); memo.RbdInfo = rbdInfo.GetRebuildInfo(projectId); memo.Store = StoreBasicInfo.GetStore(memo.RbdInfo.USCode); var consInfo = new RebuildConsInfo(); consInfo = consInfo.GetConsInfo(projectId); var rein = ReinvestmentBasicInfo.GetByConsInfoId(consInfo.Id) ?? new ReinvestmentBasicInfo(); memo.ReinvestInfo = rein; var recos = ReinvestmentCost.GetByConsInfoId(consInfo.Id) ?? new ReinvestmentCost(); memo.TotalReinvestmentBudget = recos.TotalReinvestmentBudget; if (!memo.ReopenDate.HasValue) { memo.ReopenDate = memo.ReinvestInfo.ReopenDate; } if (!memo.GBDate.HasValue) { memo.GBDate = memo.ReinvestInfo.GBDate; } var gbMemo = GBMemo.GetGBMemo(projectId); if (!memo.CompletionDate.HasValue && gbMemo != null) { memo.CompletionDate = gbMemo.ConstCompletionDate; } //if (string.IsNullOrEmpty(memo.DesignConcept)) // memo.DesignConcept = memo.ReinvestInfo.NewDesignType; var writeoff = WriteOffAmount.GetByConsInfoId(consInfo.Id) ?? new WriteOffAmount(); memo.WriteOff = writeoff; } else if (projectId.ToLower().IndexOf("reimage") >= 0) { memo.RmgInfo = ReimageInfo.GetReimageInfo(projectId); memo.Store = StoreBasicInfo.GetStore(memo.RmgInfo.USCode); var consInfo = ReimageConsInfo.GetConsInfo(projectId); var rein = ReinvestmentBasicInfo.GetByConsInfoId(consInfo.Id) ?? new ReinvestmentBasicInfo(); memo.ReinvestInfo = rein; var recos = ReinvestmentCost.GetByConsInfoId(consInfo.Id) ?? new ReinvestmentCost(); memo.TotalReinvestmentBudget = recos.TotalReinvestmentBudget; if (!memo.ReopenDate.HasValue) { memo.ReopenDate = memo.ReinvestInfo.ReopenDate; } if (!memo.GBDate.HasValue) { memo.GBDate = memo.ReinvestInfo.GBDate; } var gbMemo = ReimageGBMemo.GetGBMemo(projectId); if (!memo.CompletionDate.HasValue && gbMemo != null) { memo.CompletionDate = gbMemo.ConstCompletionDate; } //if (string.IsNullOrEmpty(memo.DesignConcept)) // memo.DesignConcept = memo.ReinvestInfo.NewDesignType; var writeoff = WriteOffAmount.GetByConsInfoId(consInfo.Id) ?? new WriteOffAmount(); memo.WriteOff = writeoff; } else if (projectId.ToLower().IndexOf("majorlease") >= 0) { var mjrInfo = new MajorLeaseInfo().GetMajorLeaseInfo(projectId); memo.ReopenDate = mjrInfo.ReopenDate; memo.Store = StoreBasicInfo.GetStore(mjrInfo.USCode); var consInfo = new MajorLeaseConsInfo().GetConsInfo(projectId); var rein = ReinvestmentBasicInfo.GetByConsInfoId(consInfo.Id) ?? new ReinvestmentBasicInfo(); memo.ReinvestInfo = rein; var recos = ReinvestmentCost.GetByConsInfoId(consInfo.Id) ?? new ReinvestmentCost(); memo.TotalReinvestmentBudget = recos.TotalReinvestmentBudget; if (!memo.ReopenDate.HasValue) { memo.ReopenDate = memo.ReinvestInfo.ReopenDate; } if (!memo.GBDate.HasValue) { memo.GBDate = memo.ReinvestInfo.GBDate; } var gbMemo = MajorLeaseGBMemo.GetGBMemo(projectId); if (!memo.CompletionDate.HasValue && gbMemo != null) { memo.CompletionDate = gbMemo.ConstCompletionDate; } //if (string.IsNullOrEmpty(memo.DesignConcept)) // memo.DesignConcept = memo.ReinvestInfo.NewDesignType; var writeoff = WriteOffAmount.GetByConsInfoId(consInfo.Id) ?? new WriteOffAmount(); memo.WriteOff = writeoff; } else if (projectId.ToLower().IndexOf("renewal") >= 0) { var renewalInfo = RenewalInfo.Get(projectId); memo.ReopenDate = renewalInfo.NewLeaseStartDate; memo.Store = StoreBasicInfo.GetStore(renewalInfo.USCode); var consInfo = RenewalConsInfo.Get(projectId); var rein = ReinvestmentBasicInfo.GetByConsInfoId(consInfo.Id) ?? new ReinvestmentBasicInfo(); memo.ReinvestInfo = rein; var recos = ReinvestmentCost.GetByConsInfoId(consInfo.Id) ?? new ReinvestmentCost(); memo.TotalReinvestmentBudget = recos.TotalReinvestmentBudget; if (!memo.ReopenDate.HasValue) { memo.ReopenDate = memo.ReinvestInfo.ReopenDate; } if (!memo.GBDate.HasValue) { memo.GBDate = memo.ReinvestInfo.GBDate; } var gbMemo = RenewalGBMemo.GetGBMemo(projectId); if (!memo.CompletionDate.HasValue && gbMemo != null) { memo.CompletionDate = gbMemo.ConstCompletionDate; } //if (string.IsNullOrEmpty(memo.DesignConcept)) // memo.DesignConcept = memo.ReinvestInfo.NewDesignType; var writeoff = WriteOffAmount.GetByConsInfoId(consInfo.Id) ?? new WriteOffAmount(); memo.WriteOff = writeoff; } if (isEmptyMemo) { if (memo.ReinvestInfo != null) { if (memo.ReinvestInfo.NewMcCafe.HasValue && memo.ReinvestInfo.NewMcCafe.Value) { memo.NewMcCafe = true; } if ((memo.ReinvestInfo.NewAttachedKiosk.HasValue && memo.ReinvestInfo.NewAttachedKiosk.Value) || (memo.ReinvestInfo.NewRemoteKiosk.HasValue && memo.ReinvestInfo.NewRemoteKiosk.Value)) { memo.NewKiosk = true; } if (memo.ReinvestInfo.NewMDS.HasValue && memo.ReinvestInfo.NewMDS.Value) { memo.NewMDS = true; } if (memo.ReinvestInfo.NewTwientyFourHour.HasValue && memo.ReinvestInfo.NewTwientyFourHour.Value) { memo.Is24H = true; } //if (!string.IsNullOrEmpty(memo.ReinvestInfo.NewOperationSize)) //{ // memo.AftOperationSize = memo.ReinvestInfo.NewOperationSize; //} //if (!string.IsNullOrEmpty(memo.ReinvestInfo.EstimatedSeatNo)) //{ // memo.AftARSN = memo.ReinvestInfo.EstimatedSeatNo; //} } memo.TTMNetSales = GetTTFinanceData(memo.Store.StoreBasicInfo.StoreCode); } memo.PriceTiter = GetPriceTier(memo.Store.StoreBasicInfo.StoreCode); //if (string.IsNullOrEmpty(memo.AftARPT)) //{ // memo.AftARPT = memo.PriceTiter; //} //if (memo.Store != null) //{ // memo.OriginalOperationSize = memo.Store.StoreSTLocation.TotalArea; // memo.OriginalSeatNumber = memo.Store.StoreSTLocation.TotalSeatsNo; //} memo.YearMonthList = GetSelectYearMonth(memo.Store.StoreBasicInfo.StoreCode); if (isEmptyMemo) { SaveReopenMemo(memo); } return(memo); }