public IHttpActionResult GetByProjectId(string projectId) { var entity = ClosureConsInvtChecking.FirstOrDefault(e => e.ProjectId == projectId && e.IsHistory == false); if (entity != null) { var closureInfo = ClosureInfo.GetByProjectId(projectId); entity.USCode = closureInfo.USCode; ProjectCommentCondition condition = new ProjectCommentCondition(); condition.RefTableId = entity.Id; condition.RefTableName = ClosureWOCheckList.TableName; condition.UserAccount = ClientCookie.UserCode; condition.Status = ProjectCommentStatus.Save; var commentList = ProjectComment.SearchList(condition); if (commentList != null && commentList.Count > 0) { entity.Comments = commentList[0].Content; } if (string.IsNullOrEmpty(entity.PMSupervisor)) { var puser = ProjectUsers.FirstOrDefault(i => i.ProjectId == entity.ProjectId && i.RoleCode == ProjectUserRoleCode.CM); if (puser != null) { entity.PMSupervisor = puser.UserAccount; } } } return(Ok(entity)); }
public IHttpActionResult GetById(string Id) { Guid _Id; if (!Guid.TryParse(Id, out _Id)) { return(Ok()); } var entity = ClosureWOCheckList.Get(_Id); if (entity != null) { ProjectCommentCondition condition = new ProjectCommentCondition(); condition.RefTableId = entity.Id; condition.RefTableName = ClosureWOCheckList.TableName; condition.UserAccount = ClientCookie.UserCode; condition.Status = ProjectCommentStatus.Save; var commentList = ProjectComment.SearchList(condition); if (commentList != null && commentList.Count > 0) { entity.Comments = commentList[0].Content; } var closureEntity = ClosureInfo.GetByProjectId(entity.ProjectId); entity.USCode = closureEntity.USCode; entity.UserAccount = ClientCookie.UserCode; } return(Ok(entity)); }
public IHttpActionResult GetCreateFlowInfo(string projectId, string flowCode) { Object entity = null; if (flowCode.ToLower() == "rebuild") { entity = new RebuildInfo().GetRebuildInfo(projectId); } else if (flowCode.ToLower() == "reimage") { entity = ReimageInfo.GetReimageInfo(projectId); } else if (flowCode.ToLower() == "renewal") { entity = RenewalInfo.Get(projectId); } else if (flowCode.ToLower() == "tempclosure") { entity = TempClosureInfo.Get(projectId); } else if (flowCode.ToLower() == "closure") { entity = ClosureInfo.GetByProjectId(projectId); } else if (flowCode.ToLower() == "majorlease") { entity = new MajorLeaseInfo().GetMajorLeaseInfo(projectId); } return(Ok(entity)); }
public IHttpActionResult PostClosureConsInvtChecking(ClosureConsInvtChecking entity) { //ClosureInfo closure = new ClosureInfo(); //closure = closure.GetByProjectId(entity.ProjectId.Value); var task = TaskWork.FirstOrDefault( e => e.ReceiverAccount == ClientCookie.UserCode && e.Status == 0 && e.SourceCode == FlowCode.Closure && e.TypeCode == FlowCode.Closure_ConsInvtChecking && e.RefID == entity.ProjectId); task.Finish(); // Start K2 Process string _procCode = WFConsInvtChecking.ProcessCode; List <ProcessDataField> _listDataFields = new List <ProcessDataField>(); var _diff = CalDiff(entity);; /* * Total Variance <= +-5% : 1 +-5% < Total Variance <= +- 10% : 2 * Total Variance > +- 10% : 3 */ var closureEntity = ClosureInfo.GetByProjectId(entity.ProjectId); _listDataFields.Add(new ProcessDataField("flag_DiffRangeType", _diff)); //传偏差值范围 1, 2, 3 //_listDataFields.Add(new ProcessDataField("dest_Creator", ClientCookie.UserCode)); _listDataFields.Add(new ProcessDataField("dest_Creator", entity.CreateUserAccount)); // 发起人也变成工程PM,不是actor _listDataFields.Add(new ProcessDataField("dest_EngPM", entity.PMSupervisor)); _listDataFields.Add(new ProcessDataField("dest_Fin", entity.FinControllerAccount)); _listDataFields.Add(new ProcessDataField("dest_VPGM", entity.VPGMAccount)); _listDataFields.Add(new ProcessDataField("dest_Group1", entity.FinanceAccount + ";" + entity.PMSupervisor)); _listDataFields.Add(new ProcessDataField("ProcessCode", _procCode)); //_listDataFields.Add(new ProcessDataField("dest_Receiver", "")); 知会人 //将 WFConsInvtChecking 的任务传给K2 var taskJson = Newtonsoft.Json.JsonConvert.SerializeObject(task); _listDataFields.Add(new ProcessDataField("ProjectTaskInfo", taskJson)); int _procInstID = K2FxContext.Current.StartProcess(_procCode, ClientCookie.UserCode, _listDataFields); if (_procInstID > 0) { // 更新 ConsInvtChecking 表的ProcInstId entity.ProcInstID = _procInstID; ClosureConsInvtChecking.Update(entity); SaveCommers(entity, ProjectAction.Submit, ProjectCommentStatus.Submit); ProjectInfo.FinishNode(entity.ProjectId, FlowCode.Closure_ConsInvtChecking, NodeCode.Closure_ConsInvtChecking_ResultUpload); } return(Ok()); }
public IHttpActionResult GetOnline(string projectID) { var closure = ClosureInfo.GetByProjectId(projectID); var store = StoreBasicInfo.GetStore(closure.USCode); var toolEntity = ClosureTool.Get(closure.ProjectId); var woEntity = ClosureWOCheckList.Get(closure.ProjectId); List <StoreBEInfo> remoteBeList = new List <StoreBEInfo>(); List <StoreBEInfo> attachedBeList = new List <StoreBEInfo>(); StoreBEInfo mds = null; StoreBEInfo mcCafe = null; StoreBEInfo hour24 = null; if (store.StoreBEInfoList.Count > 0) { foreach (var beInfo in store.StoreBEInfoList) { switch (beInfo.BETypeName) { case "Remote Kiosk": remoteBeList.Add(beInfo); break; case "Attach Kiosk": attachedBeList.Add(beInfo); break; case "MDS": mds = beInfo; break; case "McCafe": mcCafe = beInfo; break; case "24 Hour": hour24 = beInfo; break; } } } return(Ok(new { Store = store, ClosureTool = toolEntity, WOCheckList = woEntity, RemoteBeList = remoteBeList, AttachedBeList = attachedBeList, MDS = mds, McCafe = mcCafe, Hour24 = hour24 })); }
public IHttpActionResult DownLoadTemplate(string projectID) { var current = System.Web.HttpContext.Current; string path = SiteFilePath.Template_DIRECTORY + "\\" + SiteFilePath.FAWrite_offTool_Template; Excel excel = new Excel(); string templatePath = path; string tempFilePath = current.Server.MapPath("~/") + "Temp\\" + Guid.NewGuid() + ".xlsx"; var closure = ClosureInfo.GetByProjectId(projectID); excel.Open(path); excel.Save(tempFilePath); var store = _db.StoreBasicInfo.First(e => e.StoreCode == closure.USCode); Excel tempExcel = new Excel(); tempExcel.Open(tempFilePath); var sheet = tempExcel.Sheets["PMT"]; sheet.Cells[1, 1].StrValue = store.RegionENUS; sheet.Cells[2, 1].StrValue = store.MarketENUS; sheet.Cells[3, 1].StrValue = store.NameENUS; sheet.Cells[4, 1].StrValue = store.StoreCode; sheet.Cells[5, 1].StrValue = store.StoreTypeName; if (closure.ActualCloseDate != null) { sheet.Cells[6, 1].StrValue = closure.ActualCloseDate.Value.ToString("yyyy-MM-dd"); } sheet.Cells[7, 1].StrValue = closure.PMNameZHCN; tempExcel.Save(tempFilePath); var currentNode = NodeInfo.GetCurrentNode(projectID, FlowCode.Closure_WOCheckList); var newNode = NodeInfo.GetNodeInfo(NodeCode.Closure_WOCheckList_DownLoadTemplate); if (newNode.Sequence > currentNode.Sequence) { ProjectInfo.FinishNode(projectID, FlowCode.Closure_WOCheckList, NodeCode.Closure_WOCheckList_DownLoadTemplate); } current.Response.AppendHeader("Content-Disposition", "attachment;filename=" + SiteFilePath.GetTemplateFileName(closure.USCode, FlowCode.Closure_WOCheckList, SiteFilePath.FAWrite_offTool_Template)); current.Response.ContentType = "application/octet-stream"; current.Response.WriteFile("" + tempFilePath + ""); current.Response.End(); return(Ok()); }
public IHttpActionResult GetByProjectId(string projectId) { var entity = ClosureWOCheckList.Get(projectId); if (entity != null) { ProjectCommentCondition condition = new ProjectCommentCondition(); condition.RefTableId = entity.Id; condition.RefTableName = ClosureWOCheckList.TableName; condition.UserAccount = ClientCookie.UserCode; condition.Status = ProjectCommentStatus.Save; var commentList = ProjectComment.SearchList(condition); if (commentList != null && commentList.Count > 0) { entity.Comments = commentList[0].Content; } var closureEntity = ClosureInfo.GetByProjectId(entity.ProjectId); entity.USCode = closureEntity.USCode; entity.UserAccount = ClientCookie.UserCode; if (string.IsNullOrEmpty(entity.PMSupervisorAccount)) { var puser = ProjectUsers.FirstOrDefault(i => i.ProjectId == entity.ProjectId && i.RoleCode == ProjectUserRoleCode.CM); if (puser != null) { entity.PMSupervisorAccount = puser.UserAccount; } } // entity.Comments = GetCommers(entity); //string pmAccount = closureEntity.PMAccount; //entity.PMSupervisorAccount = userPositionHandler.GetReportToAccounts(pmAccount); //string[] accounts = {UserPositionHandler.IT,UserPositionHandler.MCCL_Construction_Mgr}; //var positionlist = userPositionHandler.SearchUserPosition(closureEntity.USCode,accounts); //string mcclApprover = userPositionHandler.GetAccounts(positionlist); //entity.MCCLApproverAccount = mcclApprover; } return(Ok(entity)); }
public IHttpActionResult Save(ClosureMemo entity) { using (TransactionScope tranScope = new TransactionScope()) { if (entity.Id != Guid.Empty) { ClosureMemo.Update(entity); } else { entity.Id = Guid.NewGuid(); entity.CreateTime = DateTime.Now; entity.Creator = ClientCookie.UserCode; ClosureMemo.Add(entity); } ClosureInfo closure = ClosureInfo.GetByProjectId(entity.ProjectId); closure.ActualCloseDate = entity.ClosureDate; closure.Update(); ProjectInfo.FinishNode(entity.ProjectId, FlowCode.Closure_Memo, NodeCode.Closure_ClosureMemo_Input); tranScope.Complete(); } return(Ok()); }
private void GenerateCover(string projectId, string refTableName) { string coverPath = string.Empty; string coverName = "Cover"; string coverTempPath = SiteFilePath.UploadFiles_DIRECTORY + "\\" + Guid.NewGuid() + ".xlsx"; string coverExtention = Path.GetExtension(coverTempPath); switch (refTableName) { case "MajorLeaseChangePackage": coverPath = SiteFilePath.Template_DIRECTORY + "\\" + SiteFilePath.MajorLeaseChangeCove_Template; var majorLeaseChangePackage = MajorLeaseChangePackage.GetMajorPackageInfo(projectId); majorLeaseChangePackage.GenerateCoverEexcel(coverPath, coverTempPath); break; case "ReimagePackage": var rmgPackage = ReimagePackage.Get(projectId); if (rmgPackage == null) { return; } if (!Attachment.Any(i => i.TypeCode == "Cover" && i.RefTableName == ReimagePackage.TableName && i.RefTableID.ToString() == rmgPackage.Id.ToString())) { var reimageInfoEntity = ReimageInfo.GetReimageInfo(projectId); //生成cover文件 coverPath = SiteFilePath.Template_DIRECTORY + "\\" + SiteFilePath.Store_Reimage_Cover_Template; var store = StoreBasicInfo.FirstOrDefault(e => e.StoreCode == reimageInfoEntity.USCode); File.Copy(coverPath, coverTempPath); var excelOutputDirector = new ExcelDataInputDirector(new FileInfo(coverTempPath), ExcelDataInputType.ReimageCover); var inputInfo = new ExcelInputDTO { Region = store.Region, Province = store.ProvinceENUS, City = store.CityENUS, StoreName = store.NameENUS, USCode = reimageInfoEntity.USCode, OpenDate = store.OpenDate }; excelOutputDirector.Input(inputInfo); var coverItem = new Attachment(); coverItem.Name = coverName + coverExtention; coverItem.InternalName = Path.GetFileName(coverTempPath); coverItem.RefTableName = ReimagePackage.TableName; coverItem.RefTableID = rmgPackage.Id.ToString(); coverItem.RelativePath = "//"; coverItem.Extension = coverExtention; coverItem.CreateTime = DateTime.Now; coverItem.TypeCode = coverName; coverItem.CreatorID = ClientCookie.UserCode; coverItem.RequirementId = AttachmentRequirement.FirstOrDefault(e => e.FlowCode == FlowCode.Reimage_Package && e.NameENUS == "Cover").Id; coverItem.CreatorNameENUS = ClientCookie.UserNameENUS; coverItem.CreatorNameZHCN = ClientCookie.UserNameZHCN; using (FileStream stream = new FileStream(coverTempPath, FileMode.Open)) { coverItem.Length = (int)stream.Length; } Attachment.SaveSigleFile(coverItem); } break; case "TempClosurePackage": var tempClosurePackage = TempClosurePackage.Get(projectId); if (tempClosurePackage == null) { return; } if (!Attachment.Any(i => i.TypeCode == "Cover" && i.RefTableName == tempClosurePackage.TableName && i.RefTableID.ToString() == tempClosurePackage.Id.ToString())) { var tempClosureInfoEntity = TempClosureInfo.Get(projectId); //生成cover文件 coverPath = SiteFilePath.Template_DIRECTORY + "\\" + SiteFilePath.Store_TempClosure_Cover_Template; var store = StoreBasicInfo.FirstOrDefault(e => e.StoreCode == tempClosureInfoEntity.USCode); File.Copy(coverPath, coverTempPath); var excelOutputDirector = new ExcelDataInputDirector(new FileInfo(coverTempPath), ExcelDataInputType.TempClosureCover); var inputInfo = new ExcelInputDTO { StoreNameEN = store.NameENUS, USCode = tempClosureInfoEntity.USCode, City = store.CityENUS, Market = store.MarketENUS, ActualCloseDate = tempClosureInfoEntity.ActualTempClosureDate.ToString("yyyy-MM-dd") }; excelOutputDirector.Input(inputInfo); var coverItem = new Attachment(); coverItem.Name = coverName + coverExtention; coverItem.InternalName = Path.GetFileName(coverTempPath); coverItem.RefTableName = tempClosurePackage.TableName; coverItem.RefTableID = tempClosurePackage.Id.ToString(); coverItem.RelativePath = "//"; coverItem.Extension = coverExtention; coverItem.CreateTime = DateTime.Now; coverItem.TypeCode = coverName; coverItem.CreatorID = ClientCookie.UserCode; //coverItem.RequirementId = AttachmentRequirement.FirstOrDefault(e => e.FlowCode == FlowCode.TempClosure_ClosurePackage && e.NameENUS == "Cover").Id; coverItem.CreatorNameENUS = ClientCookie.UserNameENUS; coverItem.CreatorNameZHCN = ClientCookie.UserNameZHCN; using (FileStream stream = new FileStream(coverTempPath, FileMode.Open)) { coverItem.Length = (int)stream.Length; } Attachment.SaveSigleFile(coverItem); } break; case "ClosurePackage": var closurePackage = ClosurePackage.Get(projectId); if (closurePackage == null) { return; } if (!Attachment.Any(i => i.TypeCode == "Cover" && i.RefTableName == ClosurePackage.TableName && i.RefTableID.ToString() == closurePackage.Id.ToString())) { var closureInfoEntity = ClosureInfo.GetByProjectId(projectId); //生成cover文件 coverPath = SiteFilePath.Template_DIRECTORY + "\\" + SiteFilePath.Store_Closure_Cover_Template; var store = StoreBasicInfo.FirstOrDefault(e => e.StoreCode == closureInfoEntity.USCode); File.Copy(coverPath, coverTempPath); var excelOutputDirector = new ExcelDataInputDirector(new FileInfo(coverTempPath), ExcelDataInputType.ClosureCover); var inputInfo = new ExcelInputDTO { StoreNameEN = store.NameENUS, USCode = closureInfoEntity.USCode, City = store.CityENUS, Market = store.MarketENUS, ActualCloseDate = closureInfoEntity.ActualCloseDate.Value.ToString("yyyy-MM-dd") }; excelOutputDirector.Input(inputInfo); var coverItem = new Attachment(); coverItem.Name = coverName + coverExtention; coverItem.InternalName = Path.GetFileName(coverTempPath); coverItem.RefTableName = ClosurePackage.TableName; coverItem.RefTableID = closurePackage.Id.ToString(); coverItem.RelativePath = "//"; coverItem.Extension = coverExtention; coverItem.CreateTime = DateTime.Now; coverItem.TypeCode = coverName; coverItem.CreatorID = ClientCookie.UserCode; //coverItem.RequirementId = AttachmentRequirement.FirstOrDefault(e => e.FlowCode == FlowCode.TempClosure_ClosurePackage && e.NameENUS == "Cover").Id; coverItem.CreatorNameENUS = ClientCookie.UserNameENUS; coverItem.CreatorNameZHCN = ClientCookie.UserNameZHCN; using (FileStream stream = new FileStream(coverTempPath, FileMode.Open)) { coverItem.Length = (int)stream.Length; } Attachment.SaveSigleFile(coverItem); } break; } }
public IHttpActionResult DownLoadTemplate(string projectID) { var current = System.Web.HttpContext.Current; string path = SiteFilePath.Template_DIRECTORY + "\\" + SiteFilePath.Executive_Summary_Template; string tempFilePath = current.Server.MapPath("~/") + "Temp\\" + Guid.NewGuid() + ".xlsx"; File.Copy(path, tempFilePath); var fileInfo = new FileInfo(tempFilePath); var excelDirector = new ExcelDataInputDirector(fileInfo, ExcelDataInputType.ClosureExecutiveSummary); var closure = ClosureInfo.GetByProjectId(projectID); var store = StoreBasicInfo.GetStore(closure.USCode); var inputInfo = new ExcelInputDTO { StoreNameCN = store.StoreBasicInfo.NameZHCN, USCode = store.StoreBasicInfo.StoreCode, City = store.StoreBasicInfo.CityENUS, Market = store.StoreBasicInfo.MarketENUS, OpenDate = store.StoreBasicInfo.OpenDate, Floor = store.StoreSTLocation.Floor, TotalArea = store.StoreSTLocation.TotalArea, TotalSeatsNo = store.StoreSTLocation.TotalSeatsNo, BE = store.StoreBEInfoList.Count, RentType = store.StoreContractInfo.RentType, RentStructure = store.StoreContractInfo.RentStructure }; var leaseRecapID = StoreContractInfo.SearchByProject(projectID).FirstOrDefault().LeaseRecapID ?? 0; var storeAtt = StoreContractInfoAttached.Search(c => c.LeaseRecapID == leaseRecapID.ToString()).OrderByDescending(e => e.CreateDate).FirstOrDefault(); if (storeAtt != null) { inputInfo.LeasingTerm = store.StoreContractInfo.LeasePurchaseTerm; } if (store.StoreContractInfo.RentCommencementDate.HasValue) { inputInfo.RentCommencementDate = store.StoreContractInfo.RentCommencementDate.Value; } if (store.StoreContractInfo.EndDate.HasValue) { inputInfo.LeaseExpirationDate = store.StoreContractInfo.EndDate.Value; } var toolEntity = ClosureTool.Get(closure.ProjectId); if (toolEntity != null) { if (toolEntity.TotalSales_Adjustment_RMB != null) { inputInfo.TotalSales_TTM = string.Format("{0:f}", toolEntity.TotalSales_Adjustment_RMB); } if (toolEntity.CompSales_Adjustment != null) { inputInfo.SalesComp_TTM = string.Format("{0:f}", toolEntity.CompSales_Adjustment); } if (toolEntity.CompCG_Adjustment != null) { inputInfo.GCComp_TTM = string.Format("{0:f}", toolEntity.CompCG_Adjustment); } if (toolEntity.PAC_RMB_Adjustment != null) { inputInfo.PAC_TTM = string.Format("{0:f}", toolEntity.PAC_RMB_Adjustment); } if (toolEntity.SOI_Adjustment != null) { inputInfo.SOI_TTM = string.Format("{0:f}", toolEntity.SOI_Adjustment); } if (toolEntity.CashFlow_RMB_Adjustment != null) { inputInfo.CASHFLOW_TTM = string.Format("{0:f}", toolEntity.CashFlow_RMB_Adjustment); } if (toolEntity.TotalSales_TTMY1 != null) { inputInfo.TotalSales_TTMY1 = string.Format("{0:f}", toolEntity.TotalSales_TTMY1); } if (toolEntity.CompSales_TTMY1 != null) { inputInfo.CompSales_TTMY1 = string.Format("{0:f}", toolEntity.CompSales_TTMY1); } if (toolEntity.CompGC_TTMY1 != null) { inputInfo.CompGC_TTMY1 = string.Format("{0:f}", toolEntity.CompGC_TTMY1); } if (toolEntity.PAC_TTMY1 != null) { inputInfo.PAC_TTMY1 = string.Format("{0:f}", toolEntity.PAC_TTMY1); } if (toolEntity.SOI_TTMY1 != null) { inputInfo.SOI_TTMY1 = string.Format("{0:f}", toolEntity.SOI_TTMY1); } if (toolEntity.CashFlow_TTMY1 != null) { inputInfo.CashFlow_TTMY1 = string.Format("{0:f}", toolEntity.CashFlow_TTMY1); } if (toolEntity.TotalSales_TTMY2 != null) { inputInfo.TotalSales_TTMY2 = string.Format("{0:f}", toolEntity.TotalSales_TTMY2); } if (toolEntity.CompSales_TTMY2 != null) { inputInfo.CompSales_TTMY2 = string.Format("{0:f}", toolEntity.CompSales_TTMY2); } if (toolEntity.CompGC_TTMY2 != null) { inputInfo.CompGC_TTMY2 = string.Format("{0:f}", toolEntity.CompGC_TTMY2); } if (toolEntity.PAC_TTMY2 != null) { inputInfo.PAC_TTMY2 = string.Format("{0:f}", toolEntity.PAC_TTMY2); } if (toolEntity.SOI_TTMY2 != null) { inputInfo.SOI_TTMY2 = string.Format("{0:f}", toolEntity.SOI_TTMY2); } if (toolEntity.CashFlow_TTMY2 != null) { inputInfo.CashFlow_TTMY2 = string.Format("{0:f}", toolEntity.CashFlow_TTMY2); } List <StoreBEInfo> remoteBeList = new List <StoreBEInfo>(); List <StoreBEInfo> attachedBeList = new List <StoreBEInfo>(); StoreBEInfo mds = null; StoreBEInfo mcCafe = null; StoreBEInfo hour24 = null; if (store.StoreBEInfoList.Count > 0) { foreach (var beInfo in store.StoreBEInfoList) { switch (beInfo.BETypeName) { case "Remote Kiosk": remoteBeList.Add(beInfo); break; case "Attached Kiosk": attachedBeList.Add(beInfo); break; case "MDS": mds = beInfo; break; case "McCafe": mcCafe = beInfo; break; case "24 Hour": hour24 = beInfo; break; } } } if (remoteBeList.Count > 0) { inputInfo.RemoteKiosk1_Status = remoteBeList[0].IsSingleContract == 1 ? "Yes" : "No"; inputInfo.RemoteKiosk1_OpenDate = remoteBeList[0].LaunchDate; if (remoteBeList.Count > 1) { inputInfo.RemoteKiosk2_Status = remoteBeList[1].IsSingleContract == 1 ? "Yes" : "No"; inputInfo.RemoteKiosk2_OpenDate = remoteBeList[1].LaunchDate; if (remoteBeList.Count > 2) { inputInfo.RemoteKiosk3_Status = remoteBeList[2].IsSingleContract == 1 ? "Yes" : "No"; inputInfo.RemoteKiosk3_OpenDate = remoteBeList[2].LaunchDate; } } } if (attachedBeList.Count > 0) { inputInfo.AttachedKiosk1_Status = attachedBeList[0].IsSingleContract == 1 ? "Yes" : "No"; inputInfo.AttachedKiosk1_OpenDate = attachedBeList[0].LaunchDate; if (attachedBeList.Count > 1) { inputInfo.AttachedKiosk2_Status = attachedBeList[1].IsSingleContract == 1 ? "Yes" : "No"; inputInfo.AttachedKiosk2_OpenDate = attachedBeList[1].LaunchDate; if (attachedBeList.Count > 2) { inputInfo.AttachedKiosk3_Status = attachedBeList[2].IsSingleContract == 1 ? "Yes" : "No"; inputInfo.AttachedKiosk3_OpenDate = attachedBeList[2].LaunchDate; } } } if (mds != null) { inputInfo.MDS_Status = mds.IsSingleContract == 1 ? "Yes" : "No"; inputInfo.MDS_OpenDate = mds.LaunchDate; } if (mcCafe != null) { inputInfo.McCafe_Status = mcCafe.IsSingleContract == 1 ? "Yes" : "No"; inputInfo.McCafe_OpenDate = mcCafe.LaunchDate; } if (hour24 != null) { inputInfo.TwentyFourHour_Status = hour24.IsSingleContract == 1 ? "Yes" : "No"; inputInfo.TwentyFourHour_OpenDate = hour24.LaunchDate; } var woEntity = ClosureWOCheckList.Get(closure.ProjectId); if (woEntity != null) { if (woEntity.LHI_NBV != null) { inputInfo.LHI_NBV = string.Format("{0:f}", woEntity.LHI_NBV); } if (woEntity.ESSD_NBV != null) { inputInfo.ESSD_NBV = string.Format("{0:f}", woEntity.ESSD_NBV); } if (woEntity.TotalCost_NBV != null) { inputInfo.TotalCost_NBV = string.Format("{0:f}", woEntity.TotalCost_NBV); } } } excelDirector.Input(inputInfo); current.Response.AppendHeader("Content-Disposition", "attachment;filename=" + DataConverter.ToHexString(SiteFilePath.Executive_Summary_Template)); current.Response.ContentType = "application/octet-stream"; current.Response.WriteFile("" + tempFilePath + ""); current.Response.End(); return(Ok()); }
public IHttpActionResult GenExecutiveSummaty(ClosureExecutiveSummary entity) { if (!ClosureExecutiveSummary.Any(i => i.ProjectId == entity.ProjectId && i.IsHistory == false)) { if (entity.Id == Guid.Empty || entity.Id == null) { entity.Id = Guid.NewGuid(); } entity.CreateTime = DateTime.Now; entity.CreatorAccount = ClientCookie.UserCode; ClosureExecutiveSummary.Add(entity); } else { ClosureExecutiveSummary.Update(entity); } var current = System.Web.HttpContext.Current; string path = SiteFilePath.Template_DIRECTORY + "\\" + SiteFilePath.Executive_Summary_Template; string internalFileName = Guid.NewGuid() + ".xlsx"; string filePath = SiteFilePath.UploadFiles_DIRECTORY + "\\" + internalFileName; File.Copy(path, filePath); var fileInfo = new FileInfo(filePath); var excelPMTDirector = new ExcelDataInputDirector(fileInfo, ExcelDataInputType.ClosureExecutiveSummary); var closure = ClosureInfo.GetByProjectId(entity.ProjectId); var store = StoreBasicInfo.GetStore(closure.USCode); var inputInfo = new ExcelInputDTO { StoreNameCN = store.StoreBasicInfo.NameZHCN, USCode = store.StoreBasicInfo.StoreCode, City = store.StoreBasicInfo.CityENUS, Market = store.StoreBasicInfo.MarketENUS, OpenDate = store.StoreBasicInfo.OpenDate, Floor = store.StoreSTLocation.Floor, TotalArea = store.StoreSTLocation.TotalArea, TotalSeatsNo = store.StoreSTLocation.TotalSeatsNo, BE = store.StoreBEInfoList.Count, RentType = store.StoreContractInfo.RentType, RentStructure = store.StoreContractInfo.RentStructure, MiniMarket = entity.MiniMarket, StoreLocation = entity.StoreLocation, CurrentSituation = entity.CurrentSituation, NegotiationHistory = entity.NegotiationHistory, ProposedSolution = entity.ProposedSolution, SalesTransfer = entity.SalesTransfer }; var leaseRecapID = StoreContractInfo.SearchByProject(entity.ProjectId).FirstOrDefault().LeaseRecapID ?? 0; var storeAtt = StoreContractInfoAttached.Search(c => c.LeaseRecapID == leaseRecapID.ToString()).OrderByDescending(e => e.CreateDate).FirstOrDefault(); if (storeAtt != null) { inputInfo.LeasingTerm = store.StoreContractInfo.LeasePurchaseTerm; } if (store.StoreContractInfo.RentCommencementDate.HasValue) { inputInfo.RentCommencementDate = store.StoreContractInfo.RentCommencementDate.Value; } if (store.StoreContractInfo.EndDate.HasValue) { inputInfo.LeaseExpirationDate = store.StoreContractInfo.EndDate.Value; } var toolEntity = ClosureTool.Get(closure.ProjectId); if (toolEntity != null) { if (toolEntity.TotalSales_Adjustment_RMB != null) { inputInfo.TotalSales_TTM = string.Format("{0:f}", toolEntity.TotalSales_Adjustment_RMB); } if (toolEntity.CompSales_Adjustment != null) { inputInfo.SalesComp_TTM = string.Format("{0:f}", toolEntity.CompSales_Adjustment); } if (toolEntity.CompCG_Adjustment != null) { inputInfo.GCComp_TTM = string.Format("{0:f}", toolEntity.CompCG_Adjustment); } if (toolEntity.PAC_Adjustment != null) { inputInfo.PAC_TTM = string.Format("{0:f}", toolEntity.PAC_Adjustment); } if (toolEntity.SOI_Adjustment != null) { inputInfo.SOI_TTM = string.Format("{0:f}", toolEntity.SOI_Adjustment); } if (toolEntity.CashFlow_RMB_Adjustment != null) { inputInfo.CASHFLOW_TTM = string.Format("{0:f}", toolEntity.CashFlow_RMB_Adjustment); } if (toolEntity.TotalSales_TTMY1 != null) { inputInfo.TotalSales_TTMY1 = string.Format("{0:f}", toolEntity.TotalSales_TTMY1); } if (toolEntity.CompSales_TTMY1 != null) { inputInfo.CompSales_TTMY1 = string.Format("{0:f}", toolEntity.CompSales_TTMY1); } if (toolEntity.CompGC_TTMY1 != null) { inputInfo.CompGC_TTMY1 = string.Format("{0:f}", toolEntity.CompGC_TTMY1); } if (toolEntity.PAC_TTMY1 != null) { inputInfo.PAC_TTMY1 = string.Format("{0:f}", toolEntity.PAC_TTMY1); } if (toolEntity.SOI_TTMY1 != null) { inputInfo.SOI_TTMY1 = string.Format("{0:f}", toolEntity.SOI_TTMY1); } if (toolEntity.CashFlow_TTMY1 != null) { inputInfo.CashFlow_TTMY1 = string.Format("{0:f}", toolEntity.CashFlow_TTMY1); } if (toolEntity.TotalSales_TTMY2 != null) { inputInfo.TotalSales_TTMY2 = string.Format("{0:f}", toolEntity.TotalSales_TTMY2); } if (toolEntity.CompSales_TTMY2 != null) { inputInfo.CompSales_TTMY2 = string.Format("{0:f}", toolEntity.CompSales_TTMY2); } if (toolEntity.CompGC_TTMY2 != null) { inputInfo.CompGC_TTMY2 = string.Format("{0:f}", toolEntity.CompGC_TTMY2); } if (toolEntity.PAC_TTMY2 != null) { inputInfo.PAC_TTMY2 = string.Format("{0:f}", toolEntity.PAC_TTMY2); } if (toolEntity.SOI_TTMY2 != null) { inputInfo.SOI_TTMY2 = string.Format("{0:f}", toolEntity.SOI_TTMY2); } if (toolEntity.CashFlow_TTMY2 != null) { inputInfo.CashFlow_TTMY2 = string.Format("{0:f}", toolEntity.CashFlow_TTMY2); } List <StoreBEInfo> remoteBeList = new List <StoreBEInfo>(); List <StoreBEInfo> attachedBeList = new List <StoreBEInfo>(); StoreBEInfo mds = null; StoreBEInfo mcCafe = null; StoreBEInfo hour24 = null; if (store.StoreBEInfoList.Count > 0) { foreach (var beInfo in store.StoreBEInfoList) { switch (beInfo.BETypeName) { case "Remote Kiosk": remoteBeList.Add(beInfo); break; case "Attach Kiosk": attachedBeList.Add(beInfo); break; case "MDS": mds = beInfo; break; case "McCafe": mcCafe = beInfo; break; case "24 Hour": hour24 = beInfo; break; } } } inputInfo.RemoteKiosk1_Status = "No"; inputInfo.RemoteKiosk2_Status = "No"; inputInfo.RemoteKiosk3_Status = "No"; inputInfo.AttachedKiosk1_Status = "No"; inputInfo.AttachedKiosk2_Status = "No"; inputInfo.AttachedKiosk3_Status = "No"; inputInfo.MDS_Status = "No"; inputInfo.McCafe_Status = "No"; inputInfo.TwentyFourHour_Status = "No"; if (remoteBeList.Count > 0) { inputInfo.RemoteKiosk1_Status = "Yes"; inputInfo.RemoteKiosk1_OpenDate = remoteBeList[0].LaunchDate; if (remoteBeList.Count > 1) { inputInfo.RemoteKiosk2_Status = "Yes"; inputInfo.RemoteKiosk2_OpenDate = remoteBeList[1].LaunchDate; if (remoteBeList.Count > 2) { inputInfo.RemoteKiosk3_Status = "Yes"; inputInfo.RemoteKiosk3_OpenDate = remoteBeList[2].LaunchDate; } } } if (attachedBeList.Count > 0) { inputInfo.AttachedKiosk1_Status = "Yes"; inputInfo.AttachedKiosk1_OpenDate = attachedBeList[0].LaunchDate; if (attachedBeList.Count > 1) { inputInfo.AttachedKiosk2_Status = "Yes"; inputInfo.AttachedKiosk2_OpenDate = attachedBeList[1].LaunchDate; if (attachedBeList.Count > 2) { inputInfo.AttachedKiosk3_Status = "Yes"; inputInfo.AttachedKiosk3_OpenDate = attachedBeList[2].LaunchDate; } } } if (mds != null) { inputInfo.MDS_Status = "Yes"; inputInfo.MDS_OpenDate = mds.LaunchDate; } if (mcCafe != null) { inputInfo.McCafe_Status = "Yes"; inputInfo.McCafe_OpenDate = mcCafe.LaunchDate; } if (hour24 != null) { inputInfo.TwentyFourHour_Status = "Yes"; inputInfo.TwentyFourHour_OpenDate = hour24.LaunchDate; } var woEntity = ClosureWOCheckList.Get(closure.ProjectId); if (woEntity != null) { if (woEntity.LHI_NBV != null) { inputInfo.LHI_NBV = string.Format("{0:f}", woEntity.LHI_NBV); } if (woEntity.ESSD_NBV != null) { inputInfo.ESSD_NBV = string.Format("{0:f}", woEntity.ESSD_NBV); } if (woEntity.TotalCost_NBV != null) { inputInfo.TotalCost_NBV = string.Format("{0:f}", woEntity.TotalCost_NBV); } } } excelPMTDirector.Input(inputInfo); Attachment att = Attachment.GetAttachment("ClosureExecutiveSummary", entity.Id.ToString(), "Template"); if (att == null) { att = new Attachment(); att.RefTableName = "ClosureExecutiveSummary"; att.RefTableID = entity.Id.ToString(); att.CreateTime = DateTime.Now; att.ID = Guid.NewGuid(); att.TypeCode = "Template"; att.CreatorID = ClientCookie.UserCode; att.CreatorNameENUS = ClientCookie.UserNameENUS; att.CreatorNameZHCN = ClientCookie.UserNameZHCN; att.Name = SiteFilePath.Executive_Summary_Template; att.InternalName = internalFileName; att.Extension = fileInfo.Extension; att.Length = Convert.ToInt32(fileInfo.Length); att.RequirementId = new Guid("79258ffb-c2ef-4eff-897d-ba8376c90071"); Attachment.Add(att); } else { att.CreateTime = DateTime.Now; att.CreatorID = ClientCookie.UserCode; att.CreatorNameENUS = ClientCookie.UserNameENUS; att.CreatorNameZHCN = ClientCookie.UserNameZHCN; att.Name = SiteFilePath.Executive_Summary_Template; att.InternalName = internalFileName; att.Extension = fileInfo.Extension; att.Length = Convert.ToInt32(fileInfo.Length); att.RequirementId = new Guid("79258ffb-c2ef-4eff-897d-ba8376c90071"); Attachment.Update(att); } ProjectInfo.FinishNode(entity.ProjectId, FlowCode.Closure_ExecutiveSummary, NodeCode.Closure_ExecutiveSummary_Generate); return(Ok()); }
//private string GetCellValue(decimal? val) //{ // string result = string.Empty; // if (val.HasValue) // { // result = val.Value.ToString("f2"); // } // return result; //} public override void Input(OfficeOpenXml.ExcelWorksheet worksheet, ExcelInputDTO inputInfo) { var closureInfo = ClosureInfo.GetByProjectId(inputInfo.ProjectId); var storeInfo = StoreBasicInfo.FirstOrDefault(s => s.StoreCode == closureInfo.USCode); var storeContract = StoreContractInfo.Get(storeInfo.StoreCode); ClosureTool closureTool = ClosureTool.Get(inputInfo.ProjectId); //ClosureWOCheckList closureWoCheckList = ClosureWOCheckList.Get(inputInfo.ProjectId); worksheet.Cells["B2"].Value = storeInfo.Market; worksheet.Cells["B3"].Value = storeInfo.StoreCode; worksheet.Cells["B4"].Value = storeInfo.NameZHCN; worksheet.Cells["B5"].Value = storeInfo.OpenDate.ToString("yyyy-MM-dd"); if (storeContract != null) { worksheet.Cells["B6"].Value = storeContract.PartyAFullName; worksheet.Cells["B7"].Value = storeContract.EndDate.HasValue ? storeContract.EndDate.Value.ToString("yyyy-MM-dd") : ""; } worksheet.Cells["B8"].Value = closureInfo.ClosureTypeNameZHCN; if (closureInfo.ActualCloseDate != null) { worksheet.Cells["B9"].Value = closureInfo.ActualCloseDate.Value.ToString("yyyy-MM-dd"); } worksheet.Cells["B10"].Value = closureTool.Product_Sales_RMB_Adjustment; worksheet.Cells["B11"].Value = closureTool.PAC_RMB_Adjustment; worksheet.Cells["B12"].Value = closureTool.Rent_RMB_Adjustment; worksheet.Cells["B13"].Value = closureTool.DepreciationLHI_RMB_Adjustment; worksheet.Cells["B14"].Value = closureTool.InterestLHI_RMB_Adjustment; //INTEREST LHI // worksheet.Cells[15, 2].Value = closureTool..ToString(); worksheet.Cells["B15"].Value = closureTool.ServiceFee_RMB_Adjustment; worksheet.Cells["B16"].Value = closureTool.Accounting_RMB_Adjustment; worksheet.Cells["B17"].Value = closureTool.Accounting_RMB_Adjustment; worksheet.Cells["B18"].Value = closureTool.TaxesLicenses_RMB_Adjustment; worksheet.Cells["B19"].Value = closureTool.Depreciation_ESSD_RMB_Adjustment; worksheet.Cells["B20"].Value = closureTool.Interest_ESSD_RMB_Adjustment; worksheet.Cells["B21"].Value = closureTool.OtherIncExp_RMB_Adjustment; worksheet.Cells["B22"].Value = closureTool.NonProduct_Sales_RMB_Adjustment; worksheet.Cells["B23"].Value = closureTool.NonProduct_Costs_RMB_Adjustment; worksheet.Cells["B24"].Value = closureTool.CompSalesMacket_Adjustment; worksheet.Cells["B25"].Value = closureTool.CompCG_Adjustment; worksheet.Cells["B26"].Value = closureTool.CompCGMacket_Adjustment; worksheet.Cells["B27"].Value = closureTool.PACMarket_Adjustment; worksheet.Cells["B28"].Value = closureTool.SOIMarket_Adjustment; worksheet.Cells["B29"].Value = closureTool.TotalSales_TTMY1; worksheet.Cells["B30"].Value = closureTool.CompSales_TTMY1; worksheet.Cells["B31"].Value = closureTool.CompSales_Market_TTMY1; worksheet.Cells["B32"].Value = closureTool.CompGC_TTMY1; worksheet.Cells["B33"].Value = closureTool.CompGCMarket_TTMY1; worksheet.Cells["B34"].Value = closureTool.PAC_TTMY1; worksheet.Cells["B35"].Value = closureTool.PACMarket_TTMY1; worksheet.Cells["B36"].Value = closureTool.SOI_TTMY1; worksheet.Cells["B37"].Value = closureTool.SOIMarket_TTMY1; worksheet.Cells["B38"].Value = closureTool.CashFlow_TTMY1; worksheet.Cells["B39"].Value = closureTool.TotalSales_TTMY2; //sheet.Cells[36, 2].Value = closureTool.cashflow.ToString(); worksheet.Cells["B40"].Value = closureTool.CompSales_TTMY2; worksheet.Cells["B41"].Value = closureTool.CompSales_Market_TTMY2; worksheet.Cells["B42"].Value = closureTool.CompGC_TTMY2; worksheet.Cells["B43"].Value = closureTool.CompGCMarket_TTMY2; worksheet.Cells["B44"].Value = closureTool.PAC_TTMY2; worksheet.Cells["B45"].Value = closureTool.PACMarket_TTMY2; worksheet.Cells["B46"].Value = closureTool.SOI_TTMY2; worksheet.Cells["B47"].Value = closureTool.SOIMarket_TTMY2; worksheet.Cells["B48"].Value = closureTool.CashFlow_TTMY2; worksheet.Cells["B49"].Value = DateTime.Now.Year + " July"; var woEntity = ClosureWOCheckList.Get(closureTool.ProjectId); if (woEntity != null) { worksheet.Cells["B50"].Value = woEntity.RE_Original; worksheet.Cells["B51"].Value = woEntity.LHI_Original; worksheet.Cells["B52"].Value = woEntity.ESSD_Original; worksheet.Cells["B53"].Value = woEntity.RE_NBV; worksheet.Cells["B54"].Value = woEntity.LHI_NBV; worksheet.Cells["B55"].Value = woEntity.ESSD_NBV; worksheet.Cells["B56"].Value = woEntity.EquipmentTransfer; worksheet.Cells["B57"].Value = woEntity.ClosingCost; } var list = ClosureToolImpactOtherStore.Search(e => e.ClosureId == closureTool.Id).AsNoTracking().ToList(); if (list.Count > 0) { worksheet.Cells["B58"].Value = list[0].StoreCode; worksheet.Cells["B59"].Value = list[0].NameZHCN; worksheet.Cells["B60"].Value = list[0].ImpactSaltes; } if (list.Count > 1) { worksheet.Cells["B61"].Value = list[1].StoreCode; worksheet.Cells["B62"].Value = list[1].NameZHCN; worksheet.Cells["B63"].Value = list[1].ImpactSaltes; } worksheet.Cells["B64"].Value = closureTool.McppcoMargin; worksheet.Cells["B65"].Value = closureTool.MccpcoCashFlow; worksheet.Cells["B66"].Value = closureTool.Compensation; worksheet.Cells["B67"].Value = closureTool.CompAssumption; worksheet.Cells["B68"].Value = closureTool.CashflowGrowth; if (closureTool.IsOptionOffered.HasValue) { worksheet.Cells["B69"].Value = closureTool.IsOptionOffered.Value ? "Yes" : "No"; } worksheet.Cells["B70"].Value = closureTool.LeaseTerm; worksheet.Cells["B71"].Value = closureTool.Investment; worksheet.Cells["B72"].Value = closureTool.NPVRestaurantCashflows; if (closureTool.Yr1SOI != null) { worksheet.Cells["B73"].Value = closureTool.Yr1SOI; } if (closureTool.Yr1SOI != null) { worksheet.Cells["B74"].Value = closureTool.IRR; } if (closureTool.ConclusionComment != null) { worksheet.Cells["B76"].Value = closureTool.ConclusionComment; } }
public IHttpActionResult PostClosureLegalReview(ClosureLegalReview entity) { var task = _db.TaskWork.First( e => e.ReceiverAccount == ClientCookie.UserCode && e.Status == 0 && e.SourceCode == FlowCode.Closure && e.TypeCode == FlowCode.Closure_LegalReview && e.RefID == entity.ProjectId ); task.Status = TaskWorkStatus.Finished; task.FinishTime = DateTime.Now; task.Url = SiteInfo.GetProjectViewPageUrl(FlowCode.Closure_LegalReview, task.RefID); //var enableExecutiveSummary = handler.EnableExecutiveSummary(entity.ProjectId.Value); _db.TaskWork.Attach(task); _db.Entry(task).State = EntityState.Modified; var entityInfo = ClosureLegalReview.Get(entity.ProjectId); //GUID通过页面JS生成需要判断否存在 if (entityInfo == null) { //entity = new ClosureLegalReview(); entity.CreateTime = DateTime.Now; entity.CreateUserAccount = ClientCookie.UserCode; entity.Id = Guid.NewGuid(); entity.IsHistory = false; _db.ClosureLegalReview.Add(entity); //} } else { try { //entityInfo.LegalCommers = entity.Comments; _db.ClosureLegalReview.Attach(entityInfo); _db.Entry(entityInfo).State = EntityState.Modified; } catch (Exception ex) { throw ex; } } //bllActionLog.Add(new ActionLog //{ // Id = Guid.NewGuid(), // ProjectId = entity.ProjectId, // Action = ActionType.Submit, // CreateTime = DateTime.Now, // Operator = entity.CreateUserAccount, // OperatorENUS = entity.UserNameENUS, // OperatorZHCN = entity.UserNameZHCN, // Remark = "提交LegalReview流程", // OperatorTitle = "提交LegalReview流程" //}); var result = _db.SaveChanges(); if (result > 0) { // Start K2 Process string _procCode = WFClosureLegalReview.ProcessCode; List <ProcessDataField> _listDataFields = new List <ProcessDataField>(); _listDataFields.Add(new ProcessDataField("dest_Creator", ClientCookie.UserCode)); // 发起人 var closureInfo = ClosureInfo.GetByProjectId(entity.ProjectId); //string legalAccount = userPositionHandler.GetAccounts(entity.ProjectId.Value, // UserPositionHandler.LegalCounselCode ); string legalAccount = entity.LegalAccount; _listDataFields.Add(new ProcessDataField("dest_Legal", legalAccount));//entity. Legal _listDataFields.Add(new ProcessDataField("ProcessCode", _procCode)); //_listDataFields.Add(new ProcessDataField("dest_Receiver", "")); 知会人 if (_listDataFields.Exists(o => string.IsNullOrEmpty(o.DataFieldValue))) { result = 0; } else { //将TaskWork生成任务传给K2 var taskJson = TaskWork.ConvertToJson(task); _listDataFields.Add(new ProcessDataField("ProjectTaskInfo", taskJson)); var _debugInfo = string.Format("[Ln 326] DataFields: {0}", JsonConvert.SerializeObject(_listDataFields)); Log4netHelper.WriteInfoLog(_debugInfo, this.GetType(), "PostClosureLegalReview"); int _procInstID = 0; try { _procInstID = K2FxContext.Current.StartProcess(_procCode, ClientCookie.UserCode, _listDataFields); } catch (Exception ex) { _debugInfo = string.Format("[Ln 339] Result: {0}", ex.Message); Log4netHelper.Log4netWriteErrorLog(_debugInfo, ex); Log4netHelper.WriteErrorLog(_debugInfo); Log4netHelper.WriteInfoLog(_debugInfo); throw ex; } _debugInfo = string.Format("[Ln 345] Result: {0}", _procInstID); Log4netHelper.WriteInfoLog(_debugInfo, this.GetType(), "PostClosureLegalReview"); if (_procInstID > 0) { if (entityInfo == null) { _db.ClosureLegalReview.Attach(entity); _db.Entry(entity).State = EntityState.Modified; } else { entity.Id = entityInfo.Id; entityInfo.ProcInstID = _procInstID; _db.ClosureLegalReview.Attach(entityInfo); _db.Entry(entityInfo).State = EntityState.Modified; } entity.ProcInstID = _procInstID; SaveCommers(entity, ProjectCommentAction.Submit, ProjectCommentStatus.Submit); result = _db.SaveChanges(); } } } ProjectInfo.FinishNode(entity.ProjectId, FlowCode.Closure_LegalReview, NodeCode.Closure_LegalReview_Input); return(Ok(result)); }
public IHttpActionResult DownLoadTemplate(string templateType, string projectId, string consInfoID = "", string NormType = "", string flowCode = "") { var current = HttpContext.Current; ExcelDataInputType outputType; if (!Enum.TryParse(templateType, out outputType)) { throw new Exception("Cannot find the specific template type!"); } if (string.IsNullOrEmpty(projectId)) { throw new Exception("Porject Id is Empty !"); } var siteFilePath = default(string); switch (outputType) { case ExcelDataInputType.WriteOffAmount: siteFilePath = SiteFilePath.FAWrite_offTool_Template_X; break; case ExcelDataInputType.ReinvestmentCost: siteFilePath = SiteFilePath.FATool_Update_Template; break; case ExcelDataInputType.ClosureWOCheckList: siteFilePath = SiteFilePath.Closure_FAWrite_offTool_Template; break; } var path = string.Format(@"{0}\{1}", SiteFilePath.Template_DIRECTORY, siteFilePath); var tempFilePath = current.Server.MapPath("~/") + "Temp\\" + Guid.NewGuid() + ".xlsx"; bool isNotUploadExcel = false; if (!string.IsNullOrEmpty(consInfoID)) { string refTableName = "MajorLeaseConsInfo"; if (projectId.ToLower().IndexOf("rebuild") != -1) { refTableName = "RebuildConsInfo"; } if (projectId.ToLower().IndexOf("reimage") != -1) { refTableName = "ReimageConsInfo"; } var strFileName = GetAttatchFile(refTableName, templateType, consInfoID);//download consifno upload file if (string.IsNullOrEmpty(strFileName)) { isNotUploadExcel = true; tempFilePath = current.Server.MapPath("~/") + "UploadFiles\\" + Guid.NewGuid() + ".xlsx"; } else { tempFilePath = current.Server.MapPath("~/") + "UploadFiles\\" + strFileName; } } if (isNotUploadExcel) { consInfoID = null;// if not upload file in consinfo flow,then we get empty template } var projectInfo = ProjectInfo.FirstOrDefault(e => e.ProjectId == projectId); if (projectInfo == null) { throw new Exception("Cannot find the project info!"); } if (string.IsNullOrEmpty(consInfoID)) { File.Copy(path, tempFilePath); var excelOutputDirector = new ExcelDataInputDirector(new FileInfo(tempFilePath), outputType); var store = StoreBasicInfo.Search(e => e.StoreCode == projectInfo.USCode).FirstOrDefault(); if (store == null) { throw new Exception("Cannot find Store info!"); } var inputInfo = new ExcelInputDTO { Region = store.RegionENUS, Market = store.MarketENUS, City = store.CityENUS, StoreNameCN = store.NameZHCN, StoreNameEN = store.NameENUS, StoreName = store.NameZHCN, USCode = store.StoreCode, StoreType = store.StoreType, StoreTypeName = store.StoreTypeName, OpenDate = store.OpenDate, ClosureDate = store.CloseDate.HasValue ? store.CloseDate.Value : default(DateTime) }; switch (outputType) { case ExcelDataInputType.ReinvestmentCost: Guid consInfoId = Guid.Empty; if (projectId.ToLower().IndexOf("rebuild") != -1) { var rbdInfo = new RebuildConsInfo(); consInfoId = rbdInfo.GetConsInfo(projectId).Id; } else if (projectId.ToLower().IndexOf("majorlease") != -1) { var mjInfo = new MajorLeaseConsInfo(); consInfoId = mjInfo.GetConsInfo(projectId).Id; } else if (projectId.ToLower().IndexOf("reimage") != -1) { consInfoId = ReimageConsInfo.GetConsInfo(projectId).Id; } var reinvestmentBasicInfo = ReinvestmentBasicInfo.FirstOrDefault(e => e.ConsInfoID == consInfoId); if (reinvestmentBasicInfo != null) { inputInfo.NewDesignType = reinvestmentBasicInfo.NewDesignType; inputInfo.NormType = MappingNormType(NormType); inputInfo.GBDate = reinvestmentBasicInfo.GBDate; inputInfo.ConsCompletionDate = reinvestmentBasicInfo.ConsCompletionDate; inputInfo.EstimatedSeatNO = reinvestmentBasicInfo.EstimatedSeatNo; inputInfo.NewDTSiteArea = reinvestmentBasicInfo.NewDTSiteArea; inputInfo.NewOperationArea = reinvestmentBasicInfo.NewOperationSize; inputInfo.NewDiningArea = reinvestmentBasicInfo.NewDiningArea; inputInfo.WallPanelArea = reinvestmentBasicInfo.WallPanelArea; inputInfo.WallGraphicArea = reinvestmentBasicInfo.WallGraphicArea; inputInfo.FacadeACMArea = reinvestmentBasicInfo.FacadeACMArea; inputInfo.NewRemoteKiosk = reinvestmentBasicInfo.NewRemoteKiosk; inputInfo.NewAttachedKiosk = reinvestmentBasicInfo.NewAttachedKiosk; inputInfo.NewMcCafe = reinvestmentBasicInfo.NewMcCafe; inputInfo.NewMDS = reinvestmentBasicInfo.NewMDS; } break; case ExcelDataInputType.WriteOffAmount: string pmName = string.Empty; if (projectId.ToLower().IndexOf("rebuild") != -1) { var rbdInfo = new RebuildInfo(); pmName = rbdInfo.GetRebuildInfo(projectId).PMNameENUS; } else if (projectId.ToLower().IndexOf("majorlease") != -1) { var mjInfo = new MajorLeaseInfo(); pmName = mjInfo.GetMajorLeaseInfo(projectId).PMNameENUS; } else if (projectId.ToLower().IndexOf("reimage") != -1) { pmName = ReimageInfo.GetReimageInfo(projectId).PMNameENUS; } inputInfo.PMNameENUS = pmName; break; case ExcelDataInputType.ClosureWOCheckList: var closure = ClosureInfo.GetByProjectId(projectId); if (closure != null) { inputInfo.ActualCloseDate = closure.ActualCloseDate.HasValue ? closure.ActualCloseDate.Value.ToString("yyyy-MM-dd") : ""; inputInfo.PMNameENUS = closure.PMNameENUS; } break; } excelOutputDirector.Input(inputInfo); } current.Response.AppendHeader("Content-Disposition", "attachment;filename=" + SiteFilePath.GetTemplateFileName(projectInfo.USCode, flowCode, siteFilePath)); current.Response.ContentType = "application/octet-stream"; current.Response.WriteFile("" + tempFilePath + ""); current.Response.End(); return(Ok()); }
public ClosureInfo GetByProjectId(string projectId) { var entity = ClosureInfo.GetByProjectId(projectId); return(entity); }
public EmailSendingResultType SendEmail(Guid id, string[] emailToEids, string workflowName, string projectID, string tableName) { var closureInfo = ClosureInfo.GetByProjectId(projectID); var store = StoreBasicInfo.GetStore(closureInfo.USCode); var storeBasic = store.StoreBasicInfo; EmailServiceClient emailClient = new EmailServiceClient(); var bllProjectComment = new ProjectComment(); EmailMessage email = new EmailMessage(); //邮件模板中的数据 Dictionary <string, string> bodyValues = new Dictionary <string, string>(); //邮件内容中的键值对 bodyValues.Add("ApplicantName", ClientCookie.UserNameENUS);//--提交人 bodyValues.Add("WorkflowName", workflowName); bodyValues.Add("StoreCode", storeBasic.StoreCode); bodyValues.Add("StoreName", storeBasic.NameENUS + @" \ " + storeBasic.NameZHCN); bodyValues.Add("Actor", closureInfo.AssetActorNameENUS);////--呈递人 var viewPage = string.Format("{0}/TempClosure/Main#/ClosurePackage/View/param?projectId={1}", HttpContext.Current.Request.Url.Authority, projectID); bodyValues.Add("FormUrl", viewPage); email.EmailBodyValues = bodyValues; Dictionary <string, string> templateFileds = new Dictionary <string, string>(); templateFileds.Add("WorkflowName", SystemCode.Instance.GetCodeName(FlowCode.TempClosure, ClientCookie.Language)); templateFileds.Add("ProjectID", projectID); templateFileds.Add("USCode", storeBasic.StoreCode); templateFileds.Add("Region", storeBasic.Region); templateFileds.Add("StoreNameEN", storeBasic.NameENUS); templateFileds.Add("Market", storeBasic.Market); templateFileds.Add("StoreNameCN", storeBasic.NameZHCN); templateFileds.Add("City", storeBasic.CityZHCN); templateFileds.Add("StoreAge", ""); templateFileds.Add("OpenDate", storeBasic.OpenDate.ToString("yyyy-MM-dd")); var currentLeaseENDYear = store.CurrentYear - int.Parse(store.StoreContractInfo.EndYear); templateFileds.Add("CurrentLeaseENDYear", currentLeaseENDYear.ToString()); templateFileds.Add("AssetsManager", closureInfo.AssetManagerNameENUS); templateFileds.Add("AssetsActor", closureInfo.AssetActorNameENUS); templateFileds.Add("AssetsRep", closureInfo.AssetRepNameENUS); if (closureInfo.ActualCloseDate.HasValue && closureInfo.ActualCloseDate.Value.Year == 1900) { templateFileds.Add("ClosureDate", string.Empty); } else { templateFileds.Add("ClosureDate", closureInfo.ActualCloseDate.HasValue ? closureInfo.ActualCloseDate.Value.ToString("yyyy-MM-dd") : ""); } templateFileds.Add("ClosureType", closureInfo.ClosureTypeNameENUS); templateFileds.Add("LandlordName", ""); templateFileds.Add("LeaseExpireDate", ""); templateFileds.Add("OriginalCFNPV", ""); List <SubmissionApprovalRecord> approveRecords = new List <SubmissionApprovalRecord>(); if (id != new Guid()) { approveRecords = ProjectComment.GetList(tableName, id, ProjectCommentStatus.Submit).Select(pc => new SubmissionApprovalRecord { OperatorID = pc.UserAccount, OperatorName = pc.UserNameENUS, OperatorTitle = pc.TitleNameENUS, OperationDate = pc.CreateTime.HasValue ? pc.CreateTime.Value : DateTime.Now, ActionName = pc.ActivityName, Comments = pc.Content }).ToList(); } string imgPath = HtmlConversionUtility.ConvertToImage(HtmlTempalteType.Default, templateFileds, approveRecords); List <string> emailAddresses = Employee.Search(e => emailToEids.Contains(e.Code)).Select(e => e.Mail).ToList(); emailAddresses.Add("*****@*****.**"); emailAddresses.Add("*****@*****.**"); emailAddresses.Add("*****@*****.**"); //emailAddresses.Add("*****@*****.**"); email.To = string.Join(";", emailAddresses); email.Attachments = imgPath; //EmailSendingResultType result = emailClient.SendEmail(email); return(new EmailSendingResultType()); }
public IHttpActionResult DownLoadTemplate(string projectId) { var current = System.Web.HttpContext.Current; //string path = SiteFilePath.Template_DIRECTORY + "\\" + SiteFilePath.FAWrite_offTool_Template; //Excel excel = new Excel(); //string templatePath = path; //string tempFilePath = current.Server.MapPath("~/") + "Temp\\" + Guid.NewGuid() + ".xls"; //var closure = ClosureInfo.GetByProjectId(projectId); //excel.Open(path); //excel.Save(tempFilePath); //var store = StoreBasicInfo.FirstOrDefault(e => e.StoreCode == closure.USCode); //Excel tempExcel = new Excel(); //tempExcel.Open(tempFilePath); //var sheet = tempExcel.Sheets["PMT"]; //sheet.Cells[1, 1].StrValue = store.RegionENUS; //sheet.Cells[2, 1].StrValue = store.MarketENUS; //sheet.Cells[3, 1].StrValue = store.NameZHCN; //sheet.Cells[4, 1].StrValue = closure.USCode; //sheet.Cells[5, 1].StrValue = store.StoreTypeName; //if (closure.ActualCloseDate != null) //{ // sheet.Cells[6, 1].StrValue = closure.ActualCloseDate.Value.ToString("yyyy-MM-dd"); //} //sheet.Cells[7, 1].StrValue = "";//TODO::-Cary GetPM //sheet.Cells[0, 7].StrValue = ConsInvtCheckingVersion; //tempExcel.Save(tempFilePath); //直接下载writeoff文件 McdAMEntities _db = new McdAMEntities(); var closureInfo = ClosureInfo.GetByProjectId(projectId); var wo = ClosureWOCheckList.Get(projectId); if (wo != null) { var att = _db.Attachment.FirstOrDefault(a => a.RefTableID == wo.Id.ToString() && a.TypeCode == "Template"); string absolutePath = current.Server.MapPath("~/") + "UploadFiles/" + att.InternalName; string tempFilePath = current.Server.MapPath("~/") + "Temp\\" + Guid.NewGuid() + Path.GetExtension(absolutePath); File.Copy(absolutePath, tempFilePath); ExcelHelper.UpdateExcelVersionNumber(tempFilePath, ConsInvtCheckingVersion); var currentNode = NodeInfo.GetCurrentNode(projectId, FlowCode.Closure_ConsInvtChecking); var newNode = NodeInfo.GetNodeInfo(NodeCode.Closure_ConsInvtChecking_DownLoadTemplate); if (newNode.Sequence > currentNode.Sequence) { ProjectInfo.FinishNode(projectId, FlowCode.Closure_ConsInvtChecking, NodeCode.Closure_ConsInvtChecking_DownLoadTemplate); } current.Response.AppendHeader("Content-Disposition", "attachment;filename=" + SiteFilePath.GetTemplateFileName(closureInfo.USCode, FlowCode.Closure_ConsInvtChecking, SiteFilePath.FAWrite_offTool_Template)); current.Response.ContentType = "application/octet-stream"; current.Response.WriteFile("" + tempFilePath + ""); current.Response.End(); } else { string path = SiteFilePath.Template_DIRECTORY + "\\" + SiteFilePath.FAWrite_offTool_Template; current.Response.AppendHeader("Content-Disposition", "attachment;filename=" + SiteFilePath.GetTemplateFileName(closureInfo.USCode, FlowCode.Closure_ConsInvtChecking, SiteFilePath.FAWrite_offTool_Template)); current.Response.ContentType = "application/octet-stream"; current.Response.WriteFile("" + path + ""); current.Response.End(); } return(Ok()); }
public IHttpActionResult GetAttachments(Guid Id, string flowCode) { var refTableId = string.Empty; var refTableName = string.Empty; var projectInfo = ProjectInfo.Get(Id); if (projectInfo != null) { switch (flowCode) { case FlowCode.Closure: refTableName = "ClosureInfo"; var closureInfo = ClosureInfo.GetByProjectId(projectInfo.ProjectId); if (closureInfo != null) { refTableId = closureInfo.Id.ToString(); } break; case FlowCode.Rebuild: refTableName = "RebuildInfo"; var rebuildInfo = RebuildInfo.FirstOrDefault(i => i.ProjectId == projectInfo.ProjectId); if (rebuildInfo != null) { refTableId = rebuildInfo.Id.ToString(); } break; case FlowCode.MajorLease: refTableName = "MajorLeaseInfo"; var majorLeaseInfo = MajorLeaseInfo.FirstOrDefault(i => i.ProjectId == projectInfo.ProjectId); if (majorLeaseInfo != null) { refTableId = majorLeaseInfo.Id.ToString(); } break; case FlowCode.Renewal: refTableName = "RenewalInfo"; var renewalInfo = RenewalInfo.Get(projectInfo.ProjectId); if (renewalInfo != null) { refTableId = renewalInfo.Id.ToString(); } break; case FlowCode.Reimage: refTableName = "ReimageInfo"; var reimageInfo = ReimageInfo.GetReimageInfo(projectInfo.ProjectId); if (reimageInfo != null) { refTableId = reimageInfo.Id.ToString(); } break; } if (!string.IsNullOrEmpty(refTableId)) { var list = Attachment.Search(i => i.RefTableName == refTableName && i.RefTableID == refTableId).ToList(); foreach (var item in list) { item.FileURL = SiteInfo.ServiceUrl + "api/attachment/download?id=" + item.ID; } return(Ok(list)); } } return(Ok()); }