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()); }
protected static BaseWFEntity GetEmptyWorkflowEntity(string flowCode) { BaseWFEntity wfEntity = null; switch (flowCode) { case FlowCode.MajorLease: wfEntity = new MajorLeaseInfo(); wfEntity.IsMainProject = true; break; case FlowCode.MajorLease_LegalReview: wfEntity = new MajorLeaseLegalReview(); break; case FlowCode.MajorLease_FinanceAnalysis: wfEntity = new MajorLeaseFinancAnalysis(); break; case FlowCode.MajorLease_ConsInfo: wfEntity = new MajorLeaseConsInfo(); break; case FlowCode.MajorLease_Package: wfEntity = new MajorLeaseChangePackage(); break; case FlowCode.MajorLease_ConsInvtChecking: wfEntity = new MajorLeaseConsInvtChecking(); break; case FlowCode.MajorLease_GBMemo: wfEntity = new MajorLeaseGBMemo(); break; case FlowCode.Closure: wfEntity = new ClosureInfo(); wfEntity.IsMainProject = true; break; case FlowCode.Closure_ClosurePackage: wfEntity = new ClosurePackage(); break; case FlowCode.Closure_ClosureTool: wfEntity = new ClosureTool(); break; case FlowCode.Closure_ConsInvtChecking: wfEntity = new ClosureConsInvtChecking(); break; case FlowCode.Closure_LegalReview: wfEntity = new ClosureLegalReview(); break; case FlowCode.Closure_WOCheckList: wfEntity = new ClosureWOCheckList(); break; case FlowCode.Closure_ExecutiveSummary: wfEntity = new ClosureExecutiveSummary(); break; case FlowCode.TempClosure: wfEntity = new TempClosureInfo(); wfEntity.IsMainProject = true; break; case FlowCode.TempClosure_LegalReview: wfEntity = new TempClosureLegalReview(); break; case FlowCode.TempClosure_ClosurePackage: wfEntity = new TempClosurePackage(); break; case FlowCode.Rebuild: wfEntity = new RebuildInfo(); wfEntity.IsMainProject = true; break; case FlowCode.Rebuild_LegalReview: wfEntity = new RebuildLegalReview(); break; case FlowCode.Rebuild_FinanceAnalysis: wfEntity = new RebuildFinancAnalysis(); break; case FlowCode.Rebuild_ConsInfo: wfEntity = new RebuildConsInfo(); break; case FlowCode.Rebuild_Package: wfEntity = new RebuildPackage(); break; case FlowCode.Rebuild_ConsInvtChecking: wfEntity = new RebuildConsInvtChecking(); break; case FlowCode.Rebuild_GBMemo: wfEntity = new GBMemo(); break; case FlowCode.Renewal: wfEntity = new RenewalInfo(); wfEntity.IsMainProject = true; break; case FlowCode.Renewal_Letter: wfEntity = new RenewalLetter(); break; case FlowCode.Renewal_LLNegotiation: wfEntity = new RenewalLLNegotiation(); break; case FlowCode.Renewal_ConsInfo: wfEntity = new RenewalConsInfo(); break; case FlowCode.Renewal_Tool: wfEntity = new RenewalTool(); break; case FlowCode.Renewal_Analysis: wfEntity = new RenewalAnalysis(); break; case FlowCode.Renewal_ClearanceReport: wfEntity = new RenewalClearanceReport(); break; case FlowCode.Renewal_ConfirmLetter: wfEntity = new RenewalConfirmLetter(); break; case FlowCode.Renewal_LegalApproval: wfEntity = new RenewalLegalApproval(); break; case FlowCode.Renewal_Package: wfEntity = new RenewalPackage(); break; case FlowCode.Renewal_GBMemo: wfEntity = new RenewalGBMemo(); break; case FlowCode.Reimage: wfEntity = new ReimageInfo(); wfEntity.IsMainProject = true; break; case FlowCode.Reimage_ConsInfo: wfEntity = new ReimageConsInfo(); break; case FlowCode.Reimage_Summary: wfEntity = new ReimageSummary(); break; case FlowCode.Reimage_Package: wfEntity = new ReimagePackage(); break; case FlowCode.Reimage_ConsInvtChecking: wfEntity = new ReimageConsInvtChecking(); break; case FlowCode.Reimage_GBMemo: wfEntity = new ReimageGBMemo(); break; } return(wfEntity); }
public Guid?GetRefId(string projectId, string flowTable) { Guid?refId = null; switch (flowTable) { case "MajorLeaseConsInfo": var majorConsInfo = MajorLeaseConsInfo.FirstOrDefault(e => e.ProjectId == projectId && !e.IsHistory); if (majorConsInfo != null && majorConsInfo.Id != Guid.Empty) { refId = majorConsInfo.Id; } else { refId = Guid.NewGuid(); majorConsInfo = new MajorLeaseConsInfo { Id = refId.Value, ProjectId = projectId, CreateTime = DateTime.Now, IsHistory = false }; MajorLeaseConsInfo.Add(majorConsInfo); } break; case "MajorLeaseConsInvtChecking": var checkInfo = MajorLeaseConsInvtChecking.Search(e => e.ProjectId == projectId && !e.IsHistory).FirstOrDefault(); if (checkInfo != null && checkInfo.Id != Guid.Empty) { refId = checkInfo.Id; } else { refId = Guid.NewGuid(); checkInfo = new MajorLeaseConsInvtChecking { Id = refId.Value, ProjectId = projectId, CreateTime = DateTime.Now, IsHistory = false }; MajorLeaseConsInvtChecking.Add(checkInfo); } break; case "ReimageConsInfo": var reimageConsInfo = ReimageConsInfo.FirstOrDefault(e => e.ProjectId == projectId && !e.IsHistory); if (reimageConsInfo != null && reimageConsInfo.Id != Guid.Empty) { refId = reimageConsInfo.Id; } else { refId = Guid.NewGuid(); reimageConsInfo = new ReimageConsInfo { Id = refId.Value, ProjectId = projectId, IsHistory = false, CreateTime = DateTime.Now, CreateUserAccount = ClientCookie.UserCode }; ReimageConsInfo.Add(reimageConsInfo); } break; case "ReimageConsInvtChecking": var reimageCheckInfo = ReimageConsInvtChecking.Search(e => e.ProjectId == projectId && !e.IsHistory).FirstOrDefault(); if (reimageCheckInfo != null && reimageCheckInfo.Id != Guid.Empty) { refId = reimageCheckInfo.Id; } else { refId = Guid.NewGuid(); reimageCheckInfo = new ReimageConsInvtChecking { Id = refId.Value, ProjectId = projectId, CreateTime = DateTime.Now, IsHistory = false }; ReimageConsInvtChecking.Add(reimageCheckInfo); } break; case "RebuildConsInfo": var rbdConsInfo = RebuildConsInfo.FirstOrDefault(e => e.ProjectId == projectId && !e.IsHistory); if (rbdConsInfo != null && rbdConsInfo.Id != Guid.Empty) { refId = rbdConsInfo.Id; } else { refId = Guid.NewGuid(); rbdConsInfo = new RebuildConsInfo { Id = refId.Value, ProjectId = projectId, IsHistory = false, CreateTime = DateTime.Now, LastUpdateTime = DateTime.Now, CreateUserAccount = ClientCookie.UserCode, CreateUserNameENUS = ClientCookie.UserNameENUS, CreateUserNameZHCN = ClientCookie.UserNameZHCN }; RebuildConsInfo.Add(rbdConsInfo); } break; case "RebuildConsInvtChecking": var rbdCheckInfo = RebuildConsInvtChecking.Search(e => e.ProjectId == projectId && !e.IsHistory).FirstOrDefault(); if (rbdCheckInfo != null && rbdCheckInfo.Id != Guid.Empty) { refId = rbdCheckInfo.Id; } else { refId = Guid.NewGuid(); rbdCheckInfo = new RebuildConsInvtChecking { Id = refId.Value, ProjectId = projectId, IsHistory = false, CreateTime = DateTime.Now, LastUpdateTime = DateTime.Now, CreateUserAccount = ClientCookie.UserCode, CreateUserNameENUS = ClientCookie.UserNameENUS, CreateUserNameZHCN = ClientCookie.UserNameZHCN }; RebuildConsInvtChecking.Add(rbdCheckInfo); } ProjectInfo.FinishNode(projectId, FlowCode.Rebuild_ConsInvtChecking, NodeCode.Rebuild_ConsInvtChecking_Downlod); ProjectInfo.FinishNode(projectId, FlowCode.Rebuild_ConsInvtChecking, NodeCode.Rebuild_ConsInvtChecking_Input); ProjectInfo.FinishNode(projectId, FlowCode.Rebuild_ConsInvtChecking, NodeCode.Rebuild_ConsInvtChecking_Upload); break; case "ClosureWOCheckList": var closureWOCheckList = ClosureWOCheckList.Get(projectId); if (closureWOCheckList != null && closureWOCheckList.Id != Guid.Empty) { refId = closureWOCheckList.Id; _woCheckList = closureWOCheckList; } else { refId = Guid.NewGuid(); closureWOCheckList = new ClosureWOCheckList { Id = refId.Value, ProjectId = projectId, CreateTime = DateTime.Now, CreateUserAccount = ClientCookie.UserCode, CreateUserName = ClientCookie.UserNameENUS, IsHistory = false }; ClosureWOCheckList.Add(closureWOCheckList); } break; } return(refId); }