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)); }
private void uploadToolStripMenuItem_Click(object sender, EventArgs e) { #region upload treeview //if (!string.IsNullOrEmpty(treeView1.SelectedNode.FullPath)) //{ // string path; // if (treeView1.SelectedNode.FullPath.Contains('.')) // { // path = treeView1.SelectedNode.Parent.FullPath + "\\"; // } // else // { // path = treeView1.SelectedNode.FullPath + "\\"; // } // string folderPath = ""; // OpenFileDialog filedlg = new OpenFileDialog(); // if (filedlg.ShowDialog() == DialogResult.OK) // { // folderPath = filedlg.FileName; // } // if (!String.IsNullOrEmpty(folderPath)) // { // myDelegate = new RebuildInfo(RebuildMethod); // Thread downloadThread = new Thread(() => Upload(folderPath,path,this)); // downloadThread.IsBackground = true; // downloadThread.Start(); // } //} #endregion string folderPath = ""; OpenFileDialog filedlg = new OpenFileDialog(); if (filedlg.ShowDialog() == DialogResult.OK) { folderPath = filedlg.FileName; } if (!String.IsNullOrEmpty(folderPath)) { int ix = _controller.CurrentDirectory.IndexOf(client.login); string serverPath = _controller.CurrentDirectory; if (ix != -1) { serverPath = _controller.CurrentDirectory.Substring(ix); } //File.Create(_controller.CurrentDirectory + Path.GetFileName(folderPath)); //File.Copy(folderPath, _controller.CurrentDirectory + Path.GetFileName(folderPath), true); myDelegate = new RebuildInfo(RebuildMethod); Thread downloadThread = new Thread(() => Upload(folderPath, serverPath, this)); downloadThread.IsBackground = true; downloadThread.Start(); } }
public ActionResult StoreProjectRowsCount(string _USCode) { var resultData = new { ClosureRowsCount = ClosureInfo.Search(o => o.USCode == _USCode).ToList <ClosureInfo>().Count, RenewalRowsCount = RenewalInfo.Search(o => o.USCode == _USCode).ToList <RenewalInfo>().Count, RebuildRowsCount = RebuildInfo.Search(o => o.USCode == _USCode).ToList <RebuildInfo>().Count, MajorLeaseRowsCount = MajorLeaseInfo.Search(o => o.USCode == _USCode).ToList <MajorLeaseInfo>().Count, ReimageRowsCount = ReimageInfo.Search(o => o.USCode == _USCode).ToList <ReimageInfo>().Count, TempClosureRowsCount = TempClosureInfo.Search(o => o.USCode == _USCode).ToList <TempClosureInfo>().Count }; string result = Newtonsoft.Json.JsonConvert.SerializeObject(resultData); return(Content(result)); }
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 IHttpActionResult GetRebuildApprovers(string flowCode, string projectId = "", bool isNeedEntity = false) { if (string.IsNullOrEmpty(flowCode)) { throw new Exception("flowCode is NULL"); } RebuildInfo rbdInfo = null; if (!string.IsNullOrEmpty(projectId)) { rbdInfo = RebuildInfo.Search(e => e.ProjectId.Equals(projectId)).FirstOrDefault(); } if (rbdInfo == null) { throw new Exception("Could not find the Rebuild Info, please check it!"); } var dicUsers = new Dictionary <string, List <SimpleEmployee> >(); BaseWFEntity returnEntity = null; switch (flowCode) { case FlowCode.Rebuild_LegalReview: dicUsers.Add("Legals", new List <SimpleEmployee>() { new SimpleEmployee() { Code = rbdInfo.LegalAccount, NameENUS = rbdInfo.LegalNameENUS, NameZHCN = rbdInfo.LegalNameZHCN } }); if (isNeedEntity) { var entity = RebuildLegalReview.FirstOrDefault((e => e.ProjectId.Equals(projectId) && !e.IsHistory)); if (entity != null) { RebuildLegalReview.PopulateAppUsers(entity); returnEntity = entity; } } break; case FlowCode.Rebuild_FinanceAnalysis: dicUsers.Add("FMs", Employee.GetStoreEmployeesByRole(rbdInfo.USCode, RoleCode.Finance_Manager)); if (isNeedEntity) { var entity = RebuildFinancAnalysis.FirstOrDefault((e => e.ProjectId.Equals(projectId) && !e.IsHistory)); if (entity != null) { RebuildFinancAnalysis.PopulateAppUsers(entity); returnEntity = entity; } } break; case FlowCode.Rebuild_ConsInfo: dicUsers.Add("ConstructionManagers", Employee.GetStoreEmployeesByRole(rbdInfo.USCode, RoleCode.Cons_Mgr)); dicUsers.Add("MCCLConsManagers", Employee.GetStoreEmployeesByRole(rbdInfo.USCode, RoleCode.MCCL_Cons_Manager)); if (isNeedEntity) { var entity = RebuildConsInfo.FirstOrDefault((e => e.ProjectId.Equals(projectId) && !e.IsHistory)); if (entity != null) { RebuildConsInfo.PopulateAppUsers(entity); returnEntity = entity; } } break; case FlowCode.Rebuild_Package: dicUsers.Add("MarketMgrs", Employee.GetStoreEmployeesByRole(rbdInfo.USCode, RoleCode.Market_Asset_Mgr)); dicUsers.Add("RegionalMgrs", Employee.GetStoreEmployeesByRole(rbdInfo.USCode, RoleCode.Regional_Asset_Mgr)); dicUsers.Add("MDDs", Employee.GetStoreEmployeesByRole(rbdInfo.USCode, RoleCode.Market_DD)); dicUsers.Add("GMs", Employee.GetStoreEmployeesByRole(rbdInfo.USCode, RoleCode.GM)); dicUsers.Add("FCs", Employee.GetStoreEmployeesByRole(rbdInfo.USCode, RoleCode.Finance_Controller)); dicUsers.Add("RDDs", Employee.GetStoreEmployeesByRole(rbdInfo.USCode, RoleCode.Regional_DD)); dicUsers.Add("VPGMs", Employee.GetStoreEmployeesByRole(rbdInfo.USCode, RoleCode.VPGM)); dicUsers.Add("CDOs", Employee.GetEmployeesByRole(RoleCode.CDO)); dicUsers.Add("CFOs", Employee.GetEmployeesByRole(RoleCode.CFO)); dicUsers.Add("MngDirectors", Employee.GetEmployeesByRole(RoleCode.MD)); if (isNeedEntity) { var entity = RebuildPackage.FirstOrDefault((e => e.ProjectId.Equals(projectId) && !e.IsHistory)); if (entity != null) { RebuildPackage.PopulateAppUsers(entity); returnEntity = entity; } } break; case FlowCode.Rebuild_ConsInvtChecking: //dicUsers.Add("FMs", new List<SimpleEmployee>() //{ // new SimpleEmployee() // { // Code = rbdInfo.FinanceAccount, // NameENUS = rbdInfo.FinanceNameENUS, // NameZHCN = rbdInfo.FinanceNameZHCN // } //}); dicUsers.Add("FMs", Employee.GetStoreEmployeesByRole(rbdInfo.USCode, RoleCode.Finance_Manager)); dicUsers.Add("ConstructionManagers", Employee.GetStoreEmployeesByRole(rbdInfo.USCode, RoleCode.Cons_Mgr)); dicUsers.Add("FinanceControllers", Employee.GetStoreEmployeesByRole(rbdInfo.USCode, RoleCode.Finance_Controller)); dicUsers.Add("VPGMs", Employee.GetStoreEmployeesByRole(rbdInfo.USCode, RoleCode.VPGM)); if (isNeedEntity) { var entity = RebuildConsInvtChecking.FirstOrDefault((e => e.ProjectId.Equals(projectId) && !e.IsHistory)); if (entity != null) { RebuildConsInvtChecking.PopulateAppUsers(entity); returnEntity = entity; } } break; case FlowCode.Rebuild_GBMemo: dicUsers.Add("ConstructionManagers", Employee.GetStoreEmployeesByRole(rbdInfo.USCode, RoleCode.Cons_Mgr)); if (isNeedEntity) { var entity = GBMemo.FirstOrDefault((e => e.ProjectId.Equals(projectId) && !e.IsHistory)); if (entity != null) { GBMemo.PopulateAppUsers(entity); returnEntity = entity; } } break; } dicUsers.Add("MCCLAssetMgrs", Employee.GetStoreEmployeesByRole(rbdInfo.USCode, RoleCode.MCCL_Asset_Mgr)); dicUsers.Add("MCCLAssetDtrs", Employee.GetStoreEmployeesByRole(rbdInfo.USCode, RoleCode.MCCL_Asset_Director)); return(Ok(new { dicUsers, returnEntity, rbdInfo })); }
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 IHttpActionResult UploadAttachment(string flowCode, string typeCode, string usCode, Guid Id) { var refTableId = string.Empty; var refTableName = string.Empty; var projectInfo = ProjectInfo.Get(Id); var projectId = string.Empty; if (projectInfo == null) { projectId = ProjectInfo.CreateDLProject(Id, flowCode, usCode, NodeCode.Start, ClientCookie.UserCode, false); } else { projectId = projectInfo.ProjectId; } using (TransactionScope tranScope = new TransactionScope()) { switch (flowCode) { case FlowCode.Closure: refTableName = "ClosureInfo"; var closureInfo = ClosureInfo.FirstOrDefault(i => i.ProjectId == projectId); if (closureInfo != null) { refTableId = closureInfo.Id.ToString(); } else { closureInfo = new ClosureInfo(); closureInfo.Id = Guid.NewGuid(); closureInfo.ProjectId = projectId; closureInfo.USCode = usCode; closureInfo.CreateDate = DateTime.Now; closureInfo.CreateUserAccount = ClientCookie.UserCode; closureInfo.CreateUserNameENUS = ClientCookie.UserNameENUS; closureInfo.CreateUserNameZHCN = ClientCookie.UserNameZHCN; closureInfo.Add(); refTableId = closureInfo.Id.ToString(); } break; case FlowCode.Rebuild: refTableName = "RebuildInfo"; var rebuildInfo = RebuildInfo.FirstOrDefault(i => i.ProjectId == projectId); if (rebuildInfo != null) { refTableId = rebuildInfo.Id.ToString(); } else { rebuildInfo = new RebuildInfo(); rebuildInfo.Id = Guid.NewGuid(); rebuildInfo.ProjectId = projectId; rebuildInfo.USCode = usCode; rebuildInfo.CreateTime = DateTime.Now; rebuildInfo.CreateUserAccount = ClientCookie.UserCode; rebuildInfo.CreateUserNameENUS = ClientCookie.UserNameENUS; rebuildInfo.CreateUserNameZHCN = ClientCookie.UserNameZHCN; rebuildInfo.Add(); refTableId = rebuildInfo.Id.ToString(); } break; case FlowCode.MajorLease: refTableName = "MajorLeaseInfo"; var majorLeaseInfo = MajorLeaseInfo.FirstOrDefault(i => i.ProjectId == projectId); if (majorLeaseInfo != null) { refTableId = majorLeaseInfo.Id.ToString(); } else { majorLeaseInfo = new MajorLeaseInfo(); majorLeaseInfo.Id = Guid.NewGuid(); majorLeaseInfo.ProjectId = projectId; majorLeaseInfo.USCode = usCode; majorLeaseInfo.CreateTime = DateTime.Now; majorLeaseInfo.CreateUserAccount = ClientCookie.UserCode; majorLeaseInfo.CreateUserNameENUS = ClientCookie.UserNameENUS; majorLeaseInfo.CreateUserNameZHCN = ClientCookie.UserNameZHCN; majorLeaseInfo.Add(); refTableId = majorLeaseInfo.Id.ToString(); } break; case FlowCode.Renewal: refTableName = "RenewalInfo"; var renewalInfo = RenewalInfo.Get(projectId); if (renewalInfo != null) { refTableId = renewalInfo.Id.ToString(); } else { renewalInfo = new RenewalInfo(); renewalInfo.Id = Guid.NewGuid(); renewalInfo.ProjectId = projectId; renewalInfo.USCode = usCode; renewalInfo.CreateTime = DateTime.Now; renewalInfo.CreateUserAccount = ClientCookie.UserCode; renewalInfo.Add(); refTableId = renewalInfo.Id.ToString(); } break; case FlowCode.Reimage: refTableName = "ReimageInfo"; var reimageInfo = ReimageInfo.GetReimageInfo(projectId); if (reimageInfo != null) { refTableId = reimageInfo.Id.ToString(); } 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.Add(); refTableId = reimageInfo.Id.ToString(); } break; } if (!string.IsNullOrEmpty(refTableId)) { var files = HttpContext.Current.Request.Files; var file = files[0]; string fileName = Path.GetFileName(file.FileName); string fileExtension = Path.GetExtension(file.FileName); var current = System.Web.HttpContext.Current; string internalName = Guid.NewGuid() + fileExtension; string absolutePath = current.Server.MapPath("~/") + "UploadFiles/" + internalName; file.SaveAs(absolutePath); Attachment att = Attachment.FirstOrDefault(i => i.RefTableID == refTableId && i.RefTableName == refTableName && i.TypeCode == typeCode); if (att != null) { att.InternalName = internalName; att.RefTableName = refTableName; att.RefTableID = refTableId; att.RelativePath = "//"; att.Name = fileName; att.Extension = fileExtension; att.Length = file.ContentLength; att.CreateTime = DateTime.Now; att.CreatorNameZHCN = ClientCookie.UserNameZHCN; att.CreatorNameENUS = ClientCookie.UserNameENUS; att.CreatorID = ClientCookie.UserCode; Attachment.Update(att); } else { att = new Attachment(); att.InternalName = internalName; att.RefTableName = refTableName; att.RefTableID = refTableId; att.RelativePath = "//"; att.Name = fileName; att.Extension = fileExtension; att.Length = file.ContentLength; att.CreateTime = DateTime.Now; att.CreatorNameZHCN = ClientCookie.UserNameZHCN; att.CreatorNameENUS = ClientCookie.UserNameENUS; att.CreatorID = ClientCookie.UserCode; att.ID = Guid.NewGuid(); att.TypeCode = typeCode; Attachment.Add(att); } } tranScope.Complete(); 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()); }