public void Save(bool pushOrNot) { using (TransactionScope tranScope = new TransactionScope()) { var projectInfo = ProjectInfo.Get(Id); if (projectInfo == null) { ProjectId = ProjectInfo.CreateDLProject(Id, FlowCode.Reimage, USCode, NodeCode.Start, ClientCookie.UserCode, pushOrNot); var store = StoreBasicInfo.GetStorInfo(USCode); var reimageInfo = new ReimageInfo(); reimageInfo.Id = Guid.NewGuid(); reimageInfo.ProjectId = ProjectId; reimageInfo.USCode = USCode; reimageInfo.CreateDate = DateTime.Now; reimageInfo.CreateUserAccount = ClientCookie.UserCode; reimageInfo.CreateUserNameENUS = ClientCookie.UserNameENUS; reimageInfo.CreateUserNameZHCN = ClientCookie.UserNameZHCN; reimageInfo.AssetRepAccount = ""; reimageInfo.AssetRepNameZHCN = ""; reimageInfo.AssetRepNameENUS = ""; reimageInfo.AssetActorAccount = ""; reimageInfo.AssetActorNameZHCN = ""; reimageInfo.AssetActorNameENUS = ""; reimageInfo.FinanceAccount = ""; reimageInfo.FinanceNameZHCN = ""; reimageInfo.FinanceNameENUS = ""; reimageInfo.PMAccount = ""; reimageInfo.PMNameZHCN = ""; reimageInfo.PMNameENUS = ""; reimageInfo.LegalAccount = ""; reimageInfo.LegalNameZHCN = ""; reimageInfo.LegalNameENUS = ""; reimageInfo.StoreNameENUS = store.NameENUS; reimageInfo.StoreNameZHCN = store.NameZHCN; reimageInfo.GBDate = GBDate; reimageInfo.ReopenDate = ReopenDate; reimageInfo.Add(); var reimageConsInfo = new ReimageConsInfo(); reimageConsInfo.Id = Guid.NewGuid(); reimageConsInfo.ProjectId = ProjectId; reimageConsInfo.IsHistory = false; reimageConsInfo.CreateTime = DateTime.Now; reimageConsInfo.CreateUserAccount = ClientCookie.UserCode; reimageConsInfo.Add(); var reinvestmentBasicInfo = new ReinvestmentBasicInfo(); reinvestmentBasicInfo.ConsInfoID = reimageConsInfo.Id; reinvestmentBasicInfo.RightSizingSeatNo = RightSizingSeatNO; reinvestmentBasicInfo.NewDesignType = AfterReimageDesignType; reinvestmentBasicInfo.Add(); var reimageConsInvtChecking = new ReimageConsInvtChecking(); reimageConsInvtChecking.Id = Guid.NewGuid(); reimageConsInvtChecking.ProjectId = ProjectId; reimageConsInvtChecking.IsHistory = false; reimageConsInvtChecking.CreateTime = DateTime.Now; reimageConsInvtChecking.CreateUserAccount = ClientCookie.UserCode; reimageConsInvtChecking.Add(); var writeOffAmount = new WriteOffAmount(); writeOffAmount.Id = Guid.NewGuid(); writeOffAmount.ConsInfoID = reimageConsInvtChecking.Id; writeOffAmount.TotalWriteOff = Reimage_Total_WO_Proj; writeOffAmount.TotalActual = Reimage_Total_WO_Act; writeOffAmount.Add(); var reinvestmentCost = new ReinvestmentCost(); reinvestmentCost.Id = Guid.NewGuid(); reinvestmentCost.ConsInfoID = reimageConsInvtChecking.Id; reinvestmentCost.TotalReinvestmentBudget = Reimage_Total_Reinvestment_Proj; reinvestmentCost.TotalReinvestmentPMAct = Reimage_Total_Reinvestment_Act; reinvestmentCost.Add(); var reopenMemo = new ReopenMemo(); reopenMemo.Id = Guid.NewGuid(); reopenMemo.ProjectId = ProjectId; reopenMemo.NewMcCafe = false; reopenMemo.NewKiosk = false; reopenMemo.NewMDS = false; reopenMemo.Is24H = false; reopenMemo.AftARSN = AfterReimageSeatNO; reopenMemo.Add(); } else { ProjectId = projectInfo.ProjectId; projectInfo.IsPushed = pushOrNot; projectInfo.Update(); var store = StoreBasicInfo.GetStorInfo(USCode); var reimageInfo = ReimageInfo.FirstOrDefault(i => i.ProjectId == ProjectId); if (reimageInfo != null) { reimageInfo.GBDate = GBDate; reimageInfo.ReopenDate = ReopenDate; reimageInfo.Update(); } else { reimageInfo = new ReimageInfo(); reimageInfo.Id = Guid.NewGuid(); reimageInfo.ProjectId = ProjectId; reimageInfo.USCode = USCode; reimageInfo.CreateDate = DateTime.Now; reimageInfo.CreateUserAccount = ClientCookie.UserCode; reimageInfo.CreateUserNameENUS = ClientCookie.UserNameENUS; reimageInfo.CreateUserNameZHCN = ClientCookie.UserNameZHCN; reimageInfo.AssetRepAccount = ""; reimageInfo.AssetRepNameZHCN = ""; reimageInfo.AssetRepNameENUS = ""; reimageInfo.AssetActorAccount = ""; reimageInfo.AssetActorNameZHCN = ""; reimageInfo.AssetActorNameENUS = ""; reimageInfo.FinanceAccount = ""; reimageInfo.FinanceNameZHCN = ""; reimageInfo.FinanceNameENUS = ""; reimageInfo.PMAccount = ""; reimageInfo.PMNameZHCN = ""; reimageInfo.PMNameENUS = ""; reimageInfo.LegalAccount = ""; reimageInfo.LegalNameZHCN = ""; reimageInfo.LegalNameENUS = ""; reimageInfo.StoreNameENUS = store.NameENUS; reimageInfo.StoreNameZHCN = store.NameZHCN; reimageInfo.GBDate = GBDate; reimageInfo.ReopenDate = ReopenDate; reimageInfo.Add(); } var reimageConsInfo = ReimageConsInfo.FirstOrDefault(i => i.ProjectId == ProjectId && i.IsHistory == false); if (reimageConsInfo != null) { var reinvestmentBasicInfo = ReinvestmentBasicInfo.FirstOrDefault(i => i.ConsInfoID == reimageConsInfo.Id); if (reinvestmentBasicInfo != null) { reinvestmentBasicInfo.RightSizingSeatNo = RightSizingSeatNO; reinvestmentBasicInfo.NewDesignType = AfterReimageDesignType; reinvestmentBasicInfo.Update(); } else { reinvestmentBasicInfo = new ReinvestmentBasicInfo(); reinvestmentBasicInfo.ConsInfoID = reimageConsInfo.Id; reinvestmentBasicInfo.RightSizingSeatNo = RightSizingSeatNO; reinvestmentBasicInfo.NewDesignType = AfterReimageDesignType; reinvestmentBasicInfo.Add(); } } else { reimageConsInfo = new ReimageConsInfo(); reimageConsInfo.Id = Guid.NewGuid(); reimageConsInfo.ProjectId = ProjectId; reimageConsInfo.IsHistory = false; reimageConsInfo.CreateTime = DateTime.Now; reimageConsInfo.CreateUserAccount = ClientCookie.UserCode; reimageConsInfo.Add(); var reinvestmentBasicInfo = new ReinvestmentBasicInfo(); reinvestmentBasicInfo.ConsInfoID = reimageConsInfo.Id; reinvestmentBasicInfo.RightSizingSeatNo = RightSizingSeatNO; reinvestmentBasicInfo.NewDesignType = AfterReimageDesignType; reinvestmentBasicInfo.Add(); } var reimageConsInvtChecking = ReimageConsInvtChecking.FirstOrDefault(i => i.ProjectId == ProjectId && i.IsHistory == false); if (reimageConsInvtChecking != null) { var writeOffAmount = WriteOffAmount.FirstOrDefault(i => i.ConsInfoID == reimageConsInvtChecking.Id); if (writeOffAmount != null) { writeOffAmount.TotalWriteOff = Reimage_Total_WO_Proj; writeOffAmount.TotalActual = Reimage_Total_WO_Act; writeOffAmount.Update(); } else { writeOffAmount = new WriteOffAmount(); writeOffAmount.Id = Guid.NewGuid(); writeOffAmount.ConsInfoID = reimageConsInvtChecking.Id; writeOffAmount.TotalWriteOff = Reimage_Total_WO_Proj; writeOffAmount.TotalActual = Reimage_Total_WO_Act; writeOffAmount.Add(); } var reinvestmentCost = ReinvestmentCost.FirstOrDefault(i => i.ConsInfoID == reimageConsInvtChecking.Id); if (reinvestmentCost != null) { reinvestmentCost.TotalReinvestmentBudget = Reimage_Total_Reinvestment_Proj; reinvestmentCost.TotalReinvestmentPMAct = Reimage_Total_Reinvestment_Act; reinvestmentCost.Update(); } else { reinvestmentCost = new ReinvestmentCost(); reinvestmentCost.Id = Guid.NewGuid(); reinvestmentCost.ConsInfoID = reimageConsInvtChecking.Id; reinvestmentCost.TotalReinvestmentBudget = Reimage_Total_Reinvestment_Proj; reinvestmentCost.TotalReinvestmentPMAct = Reimage_Total_Reinvestment_Act; reinvestmentCost.Add(); } } else { reimageConsInvtChecking = new ReimageConsInvtChecking(); reimageConsInvtChecking.Id = Guid.NewGuid(); reimageConsInvtChecking.ProjectId = ProjectId; reimageConsInvtChecking.IsHistory = false; reimageConsInvtChecking.CreateTime = DateTime.Now; reimageConsInvtChecking.CreateUserAccount = ClientCookie.UserCode; reimageConsInvtChecking.Add(); var writeOffAmount = new WriteOffAmount(); writeOffAmount.Id = Guid.NewGuid(); writeOffAmount.ConsInfoID = reimageConsInvtChecking.Id; writeOffAmount.TotalWriteOff = Reimage_Total_WO_Proj; writeOffAmount.TotalActual = Reimage_Total_WO_Act; writeOffAmount.Add(); var reinvestmentCost = new ReinvestmentCost(); reinvestmentCost.Id = Guid.NewGuid(); reinvestmentCost.ConsInfoID = reimageConsInvtChecking.Id; reinvestmentCost.TotalReinvestmentBudget = Reimage_Total_Reinvestment_Proj; reinvestmentCost.TotalReinvestmentPMAct = Reimage_Total_Reinvestment_Act; reinvestmentCost.Add(); } var reopenMemo = ReopenMemo.FirstOrDefault(i => i.ProjectId == ProjectId); if (reopenMemo != null) { reopenMemo.AftARSN = AfterReimageSeatNO; reopenMemo.Update(); } else { reopenMemo = new ReopenMemo(); reopenMemo.Id = Guid.NewGuid(); reopenMemo.ProjectId = ProjectId; reopenMemo.NewMcCafe = false; reopenMemo.NewKiosk = false; reopenMemo.NewMDS = false; reopenMemo.Is24H = false; reopenMemo.AftARSN = AfterReimageSeatNO; reopenMemo.Add(); } } tranScope.Complete(); } }
public static ReimageGBMemo GetGBMemo(string projectId, string entityId = "") { var memo = (string.IsNullOrEmpty(entityId) ? FirstOrDefault(e => e.ProjectId.Equals(projectId) && !e.IsHistory) : FirstOrDefault(e => e.Id.ToString().Equals(entityId))) ?? new ReimageGBMemo(); memo.ProjectId = projectId; string usCode = ""; var rmgInfo = ReimageInfo.GetReimageInfo(projectId); memo.rmgInfo = rmgInfo; usCode = rmgInfo.USCode; memo.Store = StoreBasicInfo.GetStore(usCode); var consInfo = new ReimageConsInfo(); memo.ReinvestInfo = consInfo.GetReinvestmentBasicInfo(projectId); if (memo.Id == Guid.Empty) { memo.IsClosed = (memo.Store.StoreBasicInfo.statusName == "Closed"); memo.IsInOperation = false; if (memo.ReinvestInfo != null) { if ((memo.ReinvestInfo.NewAttachedKiosk.HasValue && memo.ReinvestInfo.NewAttachedKiosk.Value) || (memo.ReinvestInfo.NewRemoteKiosk.HasValue && memo.ReinvestInfo.NewRemoteKiosk.Value)) { memo.IsKiosk = true; } memo.IsMcCafe = memo.ReinvestInfo.NewMcCafe.HasValue && memo.ReinvestInfo.NewMcCafe.Value; memo.IsMDS = memo.ReinvestInfo.NewMDS.HasValue && memo.ReinvestInfo.NewMDS.Value; memo.Is24Hour = memo.ReinvestInfo.NewTwientyFourHour.HasValue && memo.ReinvestInfo.NewTwientyFourHour.Value; memo.GBDate = memo.ReinvestInfo.GBDate; memo.ConstCompletionDate = memo.ReinvestInfo.ConsCompletionDate; memo.ReopenDate = memo.ReinvestInfo.ReopenDate; } memo.Save(); } else { var projectInfo = ProjectInfo.FirstOrDefault(e => e.ProjectId == projectId && e.FlowCode == FlowCode.Reimage_GBMemo); if (projectInfo != null) { if (ClientCookie.UserCode.Equals(rmgInfo.PMAccount)) //if (reimageInfo != null) { var isExistTask = TaskWork.Any(e => e.RefID == projectId && e.TypeCode == FlowCode.Reimage_GBMemo && e.Status == TaskWorkStatus.UnFinish && e.ReceiverAccount == ClientCookie.UserCode && e.ActivityName == WorkflowActOriginator); memo.IsShowEdit = projectInfo.Status == ProjectStatus.Finished && !isExistTask; memo.IsShowRecall = CheckIfShowRecallByPojectStatus(projectInfo.Status) && !isExistTask; } } } if (ClientCookie.UserCode.Equals(rmgInfo.PMAccount)) { memo.IsShowSave = ProjectInfo.IsFlowSavable(projectId, FlowCode.Reimage_GBMemo); } PopulateAppUsers(memo); return(memo); }
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); }