public IHttpActionResult GetByProjectId(string projectID) { var entity = ClosureExecutiveSummary.FirstOrDefault(e => e.ProjectId == projectID && e.IsHistory == false); if (entity == null) { entity = new ClosureExecutiveSummary(); entity.ProjectId = projectID; entity.IsHistory = false; } bool enableEdit = false; bool enableRecall = false; var closureInfo = ClosureInfo.FirstOrDefault(e => e.ProjectId == projectID); var projectInfo = ProjectInfo.FirstOrDefault(e => e.ProjectId == projectID && e.FlowCode == FlowCode.Closure_ExecutiveSummary); if (projectInfo != null) { if (ClientCookie.UserCode.Equals(closureInfo.AssetActorAccount)) { var isExistTask = TaskWork.Any(e => e.RefID == projectID && e.TypeCode == FlowCode.Closure_ExecutiveSummary && e.Status == TaskWorkStatus.UnFinish && e.ReceiverAccount == ClientCookie.UserCode && e.ActivityName == "Originator"); var isPackgeStarted = ProjectInfo.IsFlowStarted(projectID, FlowCode.Closure_ClosurePackage); var isESStarted = ProjectInfo.IsFlowStarted(projectID, FlowCode.Closure_ExecutiveSummary); enableEdit = ProjectInfo.IsFlowEditable(projectID, FlowCode.Closure_ExecutiveSummary); enableRecall = ProjectInfo.IsFlowRecallable(projectID, FlowCode.Closure_ExecutiveSummary); } } return(Ok(new { entity = entity, enableEdit = enableEdit, enableReCall = enableRecall })); }
public IHttpActionResult UploadAttachement(string projectId) { HttpRequest request = System.Web.HttpContext.Current.Request; HttpFileCollection FileCollect = request.Files; if (FileCollect.Count > 0) //如果集合的数量大于0 { var entity = ClosureExecutiveSummary.FirstOrDefault(e => e.ProjectId == projectId && e.IsHistory == false); if (entity == null) { entity = new ClosureExecutiveSummary(); entity.Id = Guid.NewGuid(); entity.CreateTime = DateTime.Now; entity.CreatorAccount = ClientCookie.UserCode; entity.IsHistory = false; entity.ProjectId = projectId; ClosureExecutiveSummary.Add(entity); } for (int i = 0; i < FileCollect.Count; i++) { var fileSave = FileCollect[i]; //用key获取单个文件对象HttpPostedFile string fileName = Path.GetFileName(fileSave.FileName); string fileExtension = Path.GetExtension(fileSave.FileName); var current = System.Web.HttpContext.Current; string internalName = Guid.NewGuid() + fileExtension; string absolutePath = current.Server.MapPath("~/") + "UploadFiles/" + internalName; fileSave.SaveAs(absolutePath); Attachment att = new Attachment(); att.InternalName = internalName; att.RefTableName = "ClosureExecutiveSummary"; att.RefTableID = entity.Id.ToString(); att.RelativePath = "//"; att.Name = fileName; att.Extension = fileExtension; att.Length = FileCollect[0].ContentLength; att.CreateTime = DateTime.Now; att.ID = Guid.NewGuid(); att.TypeCode = "Attachment"; att.CreatorID = ClientCookie.UserCode; att.CreatorNameENUS = ClientCookie.UserNameENUS; att.CreatorNameZHCN = ClientCookie.UserNameZHCN; Attachment.Add(att); } } return(Ok()); }
public IHttpActionResult GetAttachments(string projectId) { var entity = ClosureExecutiveSummary.FirstOrDefault(i => i.ProjectId == projectId && i.IsHistory == false); if (entity == null) { return(Ok()); } var list = Attachment.GetList("ClosureExecutiveSummary", entity.Id.ToString(), ""); foreach (var item in list) { //item.FileURL = SiteFilePath.UploadFiles_URL + "/" + item.InternalName; item.FileURL = SiteInfo.ServiceUrl + "api/attachment/download?id=" + item.ID; } return(Ok(list)); }
public IHttpActionResult UploadTemplate(string projectid) { HttpRequest request = System.Web.HttpContext.Current.Request; HttpFileCollection FileCollect = request.Files; string internalName = string.Empty; if (FileCollect.Count > 0) //如果集合的数量大于0 { ClosureWOCheckList entity = new ClosureWOCheckList(); //用key获取单个文件对象HttpPostedFile HttpPostedFile fileSave = FileCollect[0]; string fileName = Path.GetFileName(fileSave.FileName); string fileExtension = Path.GetExtension(fileSave.FileName); internalName = Guid.NewGuid() + fileExtension; string absolutePath = SiteFilePath.UploadFiles_DIRECTORY + "\\" + internalName; //通过此对象获取文件名 fileSave.SaveAs(absolutePath); var woEntity = ClosureExecutiveSummary.FirstOrDefault(e => e.ProjectId == projectid && e.IsHistory == false); if (woEntity == null) { woEntity = new ClosureExecutiveSummary(); woEntity.ProjectId = projectid; woEntity.Id = Guid.NewGuid(); woEntity.CreateTime = DateTime.Now; woEntity.CreatorAccount = ClientCookie.UserCode; ClosureExecutiveSummary.Add(woEntity); } Attachment att = Attachment.GetAttachment("ClosureExecutiveSummary", woEntity.Id.ToString(), "Template"); if (att == null) { att = new Attachment(); att.RefTableName = "ClosureExecutiveSummary"; att.RefTableID = woEntity.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 = fileName; att.InternalName = internalName; att.Name = fileName; att.Extension = fileExtension; att.Length = FileCollect[0].ContentLength; Attachment.Add(att); } else { att.CreateTime = DateTime.Now; att.CreatorID = ClientCookie.UserCode; att.CreatorNameENUS = ClientCookie.UserNameENUS; att.CreatorNameZHCN = ClientCookie.UserNameZHCN; att.Name = fileName; att.InternalName = internalName; att.Extension = fileExtension; att.Length = FileCollect[0].ContentLength; Attachment.Update(att); } //var closureInfo = closureHandler.GetByProjectId(projectid); //Store store = new Store(); //var storeInfo = store.GetStoreEntity(closureInfo.USCode); //string filePath = SiteFilePath.UploadFiles_DIRECTORY + "\\" + internalName; //Excel excel = new Excel(); //excel.Open(filePath); //var sheet = excel.Sheets["PMT"]; //sheet.Cells[1, 1].StrValue = closureInfo.StoreNameZHCN; //sheet.Cells[2, 1].StrValue = closureInfo.USCode; //if (storeInfo != null) //{ // sheet.Cells[3, 1].StrValue = storeInfo.CityName; // sheet.Cells[4, 1].StrValue = storeInfo.MarketName; // if (storeInfo.OpenDate != null) // { // sheet.Cells[5, 1].StrValue = storeInfo.OpenDate.Value.ToString("yyyy-MM-dd"); // } // sheet.Cells[7, 1].StrValue = storeInfo.TotalLeasedArea; // sheet.Cells[8, 1].StrValue = storeInfo.TotalSeatsNo; // sheet.Cells[10, 1].StrValue = storeInfo.LeasePurchaseTerm; // if (storeInfo.RentCommencementDate != null) // { // sheet.Cells[11, 1].StrValue = storeInfo.RentCommencementDate.Value.ToString("yyyy-MM-dd"); // } // if (storeInfo.EndDate != null) // { // sheet.Cells[12, 1].StrValue = storeInfo.EndDate.Value.ToString("yyyy-MM-dd"); // } // sheet.Cells[13, 1].StrValue = storeInfo.RentType; // sheet.Cells[13, 1].StrValue = storeInfo.RentStructure; //} //excel.Save(); } //return Ok(result); ProjectInfo.FinishNode(projectid, FlowCode.Closure_ExecutiveSummary, NodeCode.Finish); var resultStr = SiteInfo.WebUrl + "UploadFiles/" + internalName; return(Ok(resultStr)); }