public ContentResult UploadFileFromDefault() { var conflictId = int.Parse(Request.Form["conflictId"]); string uid = Request.Form["uid"]; List <ProofFile> fileIds = new List <ProofFile>(); foreach (string file in Request.Files) { HttpPostedFileBase hpf = Request.Files[file] as HttpPostedFileBase; if (hpf.ContentLength == 0) { continue; } var blockBlob = AzureFileHelper.AddFile(conflictId, hpf); var f = new ProofFile(); f.FilePath = blockBlob.Uri.AbsoluteUri; f.IdConflict = conflictId; f.Name = blockBlob.Name; f.uid = uid; f = BLLConflicts.AddFile(f); fileIds.Add(f); } return(new ContentResult() { Content = JsonHelper.GetJsonString(fileIds), ContentType = "application/json" }); }
public static ProofFile AddFile(ProofFile file) { using (var repo = new CRUDRepository <ProofFile>()) { return(repo.Add(file)); } }
public ProofFile AddProofFile(int taskId, string proofId, string fullName, string displayName, string url, string processName) { var task = sdc.ProofTasks.SingleOrDefault(p => p.Id == taskId); var proof = sdc.ProofOrders.Include(t => t.ProofStyle).SingleOrDefault(p => p.ProofOrderId == proofId); ProofFile pf = new ProofFile() { FullName = fullName, DisplayName = displayName, Url = url, ProofStyleId = proof.ProofStyle.ProofStyleId, }; pf.SetCreateUser(_user.UserName); if (processName == "工艺") { pf.FileType = SG.Interface.Sys.FileType.TechnologyFile; } else if (processName == "程序") { pf.FileType = SG.Interface.Sys.FileType.PlatemakingFile; } sdc.ProofFiles.Add(pf); task.TaskFiles.Add(pf); proof.ProofStyle.ProofFiles.Add(pf); sdc.SaveChanges(); return(pf); }
public ActionResult MailDebateAdd(int debatId, string mailBody) { var debate = BLLDebates.GetDebate(debatId); if (String.IsNullOrWhiteSpace(mailBody) && Request.Files["FileUpload"] != null && Request.Files["FileUpload"].ContentLength > 0) { HttpPostedFileBase hpf = Request.Files["FileUpload"] as HttpPostedFileBase; var blockBlob = AzureFileHelper.AddFile(debate.Event.IdConflict, hpf); var f = new ProofFile(); f.FilePath = blockBlob.Uri.AbsoluteUri; f.IdConflict = debate.Event.IdConflict; f.Name = blockBlob.Name; var file = BLLConflicts.AddFile(f); var mailDebate = BLLDebates.AddMailDebate(new MailDebate() { IdDebate = debatId, Body = "<a href='" + file.FilePath + "'>" + file.Name + "</a>", CreateDate = DateTime.Now, CreatedBy = User.Identity.GetId(), IdFile = file.Id }); foreach (var item in BLLDebates.GetUsersForDebate(debatId)) { Guid guid = Guid.NewGuid(); FastArbitreEmails.YouHaveMail(item, debate, Url.Action("MailDebate", "Arbitre", new { debatId = debate.Id }, this.Request.Url.Scheme) + "#mail_" + mailDebate.Id, Request.UrlReferrer.DnsSafeHost + Url.Action("Index", "Email", new { id = guid.ToString() }), guid); } } else { var mailDebate = BLLDebates.AddMailDebate(new MailDebate() { IdDebate = debatId, Body = mailBody, CreateDate = DateTime.Now, CreatedBy = User.Identity.GetId() }); foreach (var item in BLLDebates.GetUsersForDebate(debatId)) { Guid guid = Guid.NewGuid(); FastArbitreEmails.YouHaveMail(item, debate, Url.Action("MailDebate", "Arbitre", new { debatId = debate.Id }, this.Request.Url.Scheme) + "#mail_" + mailDebate.Id, Request.UrlReferrer.DnsSafeHost + Url.Action("Index", "Email", new { id = guid.ToString() }), guid); } } return(RedirectToAction("MailDebate", new { debatId = debatId })); }
public bool CreateProofOrder(ProofObj obj) { ProofOrder _proofOrder = new ProofOrder(); ProofStyle _proofSryle = new ProofStyle(); if (CheckObj(obj)) { _proofSryle.ProofStyleId = obj.ProofStyleId; _proofSryle.ProofType = sdc.ProofTypes.SingleOrDefault(p => p.TypeName == obj.ProofType); _proofSryle.ProofStyleNo = obj.ProofStyleNo; _proofSryle.ClentName = obj.ClentName; _proofSryle.ClientNo = obj.ClientNo; _proofSryle.StyleName = obj.StyleName; _proofSryle.Counts = obj.Counts; _proofSryle.Material = obj.Material; _proofSryle.Weight = obj.Weight; _proofSryle.Gauge = obj.Gauge; _proofSryle.ProofOrderId = obj.ProofOrderId; obj.FileListItems.ForEach(f => { ProofFile npf = new ProofFile { FullName = f.FullName, DisplayName = f.DisplayName, Url = f.Url, ProofStyleId = _proofSryle.ProofStyleId, FileType = FileType.ClientFile }; npf.SetCreateUser(_user.UserName); _proofSryle.ProofFiles.Add(npf); }); _proofOrder.ProofStyle = _proofSryle; _proofOrder.ProofOrderId = obj.ProofOrderId; _proofOrder.ProofApplyUserDdId = _user.DdId; _proofOrder.DesignatedCX = obj.DesignatedCX; _proofOrder.DesignatedGY = obj.DesignatedGY; _proofOrder.Remark = obj.Remark; _proofOrder.Urgency = obj.Urgency; _proofOrder.ProofApplyUserName = _user.UserName; _proofOrder.ProofApplyDeptName = _user.DepartName; _proofOrder.ProofStatus = ProofStatus.草拟; _proofOrder.RequiredDate = obj.FinshDate; _proofOrder.ProofNum = obj.ProofNum; _proofSryle.SetCreateUser(_user.UserName); _proofOrder.SetCreateUser(_user.UserName); } sdc.ProofStyles.Add(_proofSryle); sdc.ProofOrders.Add(_proofOrder); return(true); }
public static ProofFile AddFile(ProofFile file, int eventId) { using (var repo = new CRUDRepository <Event>()) { var evt = repo.GetQuery <Event>(c => c.Id == eventId).FirstOrDefault(); if (evt != null) { file.UploadDate = DateTime.Now; evt.ProofFiles.Add(file); } repo.Update(evt); return(file); } }
private ProofFileFolder GetFolder(string folderPath, ref int index, int parentIndex = -1) { ProofFileFolder proofFileFolder = new ProofFileFolder(); proofFileFolder.Name = folderPath.Replace(System.IO.Path.GetDirectoryName(folderPath), string.Empty).Substring(1); proofFileFolder.ParentIndex = parentIndex; proofFileFolder.Index = index++; proofFileFolderArr.Add(proofFileFolder); foreach (string file in Directory.GetFiles(folderPath)) { ProofFile proofFile = new ProofFile(); proofFile.Name = System.IO.Path.GetFileNameWithoutExtension(file); proofFile.Path = file; switch (System.IO.Path.GetExtension(file).ToLower()) { case ".png": case ".jpg": case ".jpeg": case ".bmp": case ".gif": proofFile.FileType = FileTypeEnum.Img; break; case ".doc": case ".docx": proofFile.FileType = FileTypeEnum.Word; break; case "xls": case "xlsx": proofFile.FileType = FileTypeEnum.Excel; break; case ".pdf": proofFile.FileType = FileTypeEnum.Pdf; break; default: throw new Exception("未知文件格式"); } proofFile.Length = File.ReadAllBytes(file).Length; proofFileFolder.Files.Add(proofFile); } foreach (string folder in Directory.GetDirectories(folderPath)) { proofFileFolder.Folders.Add(GetFolder(folder, ref index, proofFileFolder.Index)); } return(proofFileFolder); }
public ContentResult UploadFile() { var conflictId = int.Parse(Request.Form["conflictId"]); var eventId = Request.Form["EventId"]; foreach (string file in Request.Files) { HttpPostedFileBase hpf = Request.Files[file] as HttpPostedFileBase; if (hpf.ContentLength == 0) { continue; } var blockBlob = AzureFileHelper.AddFile(conflictId, hpf); var f = new ProofFile(); f.FilePath = blockBlob.Uri.AbsoluteUri; f.IdConflict = conflictId; f.Name = blockBlob.Name; if (eventId == "0") { var resultFile = BLLConflicts.AddFile(f); return(new ContentResult() { Content = JsonHelper.GetJsonString(resultFile), ContentType = "application/json" }); } else { var resultFile = BLLConflicts.AddFile(f, int.Parse(eventId)); return(new ContentResult() { Content = JsonHelper.GetJsonString(resultFile), ContentType = "application/json" }); } } return(new ContentResult()); }
public IHttpActionResult UpLoadFile() { string webPath = HttpContext.Current.Server.MapPath("~") + Config.GetSampleConfig().ProofFilePath; string filePath = webPath + @"gyzb\"; HttpFileCollection files = HttpContext.Current.Request.Files; string proofId = HttpContext.Current.Request.Form["ProofOrderId"]; string TaskId = HttpContext.Current.Request.Form["TaskId"]; string ProcessName = HttpContext.Current.Request.Form["ProcessName"]; ProofFile pf = new ProofFile(); if (proofId != "" && TaskId != "" && ProcessName != "") { string filename = ""; string url = ""; foreach (string key in files.AllKeys) { HttpPostedFile file = files[key];//file.ContentLength文件长度 if (string.IsNullOrEmpty(file.FileName) == false) { string DisplayName = file.FileName; filename = proofId + "_" + ProcessName + "_" + DateTimeHelper.GetDataSecStr() + "_" + file.FileName; UploadHelper.FileUpload(file, filePath, filename); url = @"\src\proof\gyzb\" + filename; ProofTaskOper pto = new ProofTaskOper(SessionManage.CurrentUser); int tid = int.Parse(TaskId); pf = pto.AddProofFile(tid, proofId, filename, DisplayName, url, ProcessName); } } return(Ok(pf)); } else { return(BadRequest("上传文件参数错误!")); } }
public void AgreeFinsh(string pid) { ApproveOper ao = new ApproveOper(_oper); var re = ao.GetApprove(pid); var po = sdc.ProofOrders.SingleOrDefault(p => p.DdFinshApprovalCode == pid); if (po != null) { re.FormComponentValues.ForEach(p => { if (p.Name == "评分") { int Rating = 3; if (p.Value != null) { if (p.Value.IndexOf('1') > 0) { Rating = 1; } else if (p.Value.IndexOf('2') > 0) { Rating = 2; } else if (p.Value.IndexOf('3') > 0) { Rating = 3; } else if (p.Value.IndexOf('4') > 0) { Rating = 4; } else if (p.Value.IndexOf('5') > 0) { Rating = 5; } } ; po.Rating = Rating; po.ProofTasks.ForEach(pt => pt.Rating = Rating); } if (p.Name == "样衣图片") { var picList = JsonHelper.JsonToList <string>(p.Value); picList.ForEach(f => { var fdata = HttpHelper.DownloadData(f); string name = f.Substring(f.LastIndexOf('/') + 1); string fullname = po.ProofStyle.ProofStyleId + "_" + name; File.WriteAllBytes(SysPath + PicPath + fullname, fdata); ProofFile pf = new ProofFile { FullName = fullname, DisplayName = name, Url = PicPath + fullname, FileType = SG.Interface.Sys.FileType.Pic, ProofStyleId = po.ProofStyle.ProofStyleId, }; pf.SetCreateUser("钉钉审批"); po.ProofStyle.ProofFiles.Add(pf); }); } }); po.ProofStatus = ProofStatus.完成; sdc.SaveChanges(); } }
public bool UpdateProofOrder(ProofObj obj) { ProofOrder po = sdc.ProofOrders.Include(t => t.ProofStyle).Include(t => t.ProofStyle.ProofFiles).Include(t => t.ProofStyle.ProofType).Where(p => p.ProofOrderId == obj.ProofOrderId).SingleOrDefault(); if (po != null) { ProofOrder _proofOrder = po; ProofStyle _proofSryle = po.ProofStyle; if (CheckObj(obj)) { _proofSryle.ProofStyleId = obj.ProofStyleId; _proofSryle.ProofType = sdc.ProofTypes.SingleOrDefault <ProofType>(p => p.TypeName == obj.ProofType); _proofSryle.ProofStyleNo = obj.ProofStyleNo; _proofSryle.ClentName = obj.ClentName; _proofSryle.ClientNo = obj.ClientNo; _proofSryle.StyleName = obj.StyleName; _proofSryle.Counts = obj.Counts; _proofSryle.Material = obj.Material; _proofSryle.Weight = obj.Weight; _proofSryle.Gauge = obj.Gauge; _proofSryle.ProofOrderId = obj.ProofOrderId; _proofSryle.ProofFiles.ForEach(f => { if (obj.FileListItems.Count(p => p.Id == f.Id) == 0) { f.Delete(_user.UserName); } }); obj.FileListItems.ForEach(f => { if (f.Id == 0) { ProofFile npf = new ProofFile { FullName = f.FullName, DisplayName = f.DisplayName, Url = f.Url, ProofStyleId = _proofSryle.ProofStyleId, FileType = FileType.ClientFile }; npf.SetCreateUser(_user.UserName); _proofSryle.ProofFiles.Add(npf); } }); _proofOrder.ProofOrderId = obj.ProofOrderId; _proofOrder.ProofApplyUserDdId = _user.DdId; _proofOrder.ProofApplyUserName = _user.UserName; _proofOrder.ProofApplyDeptName = _user.DepartName; _proofOrder.DesignatedCX = obj.DesignatedCX; _proofOrder.DesignatedGY = obj.DesignatedGY; _proofOrder.Remark = obj.Remark; _proofOrder.Urgency = obj.Urgency; _proofOrder.ProofStatus = ProofStatus.草拟; _proofOrder.RequiredDate = obj.FinshDate; _proofOrder.ProofNum = obj.ProofNum; _proofSryle.SetEditUser(_user.UserName); _proofOrder.SetEditUser(_user.UserName); } return(true); } return(false); }
private ProofFileFolder GetProofFileFolderRoot() { Dictionary <int, ProofFileFolder> folders = new Dictionary <int, ProofFileFolder>(); IList <ProofFileFolder> _folders = new List <ProofFileFolder>(); FileStream idxFs = null; byte[] buffer = null; int[] folderFileCountArray = null; int[] folderNameLengthArray = null; int[][] fileNameLengthArray = null; try { idxFs = new FileStream(proofIndexFileName, FileMode.Open, FileAccess.Read); buffer = new byte[sizeof(int)]; idxFs.Read(buffer, 0, buffer.Length); int folderCount = BitConverter.ToInt32(buffer, 0); folderFileCountArray = new int[folderCount]; folderNameLengthArray = new int[folderCount]; fileNameLengthArray = new int[folderCount][]; for (int i = 0; i < folderFileCountArray.Length; i++) { buffer = new byte[sizeof(int)]; idxFs.Read(buffer, 0, buffer.Length); folderFileCountArray[i] = BitConverter.ToInt32(buffer, 0); ProofFileFolder folder = new ProofFileFolder(); _folders.Add(folder); for (int j = 0; j < folderFileCountArray[i]; j++) { ProofFile proofFile = new ProofFile(); folder.Files.Add(proofFile); } } for (int i = 0; i < folderFileCountArray.Length; i++) { buffer = new byte[sizeof(int)]; idxFs.Read(buffer, 0, buffer.Length); _folders[i].Index = BitConverter.ToInt32(buffer, 0); folders.Add(_folders[i].Index, _folders[i]); } for (int i = 0; i < folderFileCountArray.Length; i++) { buffer = new byte[sizeof(int)]; idxFs.Read(buffer, 0, buffer.Length); _folders[i].ParentIndex = BitConverter.ToInt32(buffer, 0); } for (int i = 0; i < folderCount; i++) { buffer = new byte[sizeof(int)]; idxFs.Read(buffer, 0, buffer.Length); folderNameLengthArray[i] = BitConverter.ToInt32(buffer, 0); } for (int i = 0; i < folderFileCountArray.Length; i++) { fileNameLengthArray[i] = new int[folderFileCountArray[i]]; for (int j = 0; j < folderFileCountArray[i]; j++) { buffer = new byte[sizeof(int)]; idxFs.Read(buffer, 0, buffer.Length); fileNameLengthArray[i][j] = BitConverter.ToInt32(buffer, 0); } } for (int i = 0; i < folderFileCountArray.Length; i++) { buffer = new byte[folderNameLengthArray[i]]; idxFs.Read(buffer, 0, buffer.Length); _folders[i].Name = UTF8Encoding.UTF8.GetString(buffer); } for (int i = 0; i < folderFileCountArray.Length; i++) { for (int j = 0; j < folderFileCountArray[i]; j++) { buffer = new byte[fileNameLengthArray[i][j]]; idxFs.Read(buffer, 0, buffer.Length); _folders[i].Files[j].Name = UTF8Encoding.UTF8.GetString(buffer); } } for (int i = 0; i < folderFileCountArray.Length; i++) { for (int j = 0; j < folderFileCountArray[i]; j++) { buffer = new byte[sizeof(int)]; idxFs.Read(buffer, 0, buffer.Length); _folders[i].Files[j].FileType = (FileTypeEnum)BitConverter.ToInt32(buffer, 0); } } for (int i = 0; i < folderFileCountArray.Length; i++) { for (int j = 0; j < folderFileCountArray[i]; j++) { buffer = new byte[sizeof(long)]; idxFs.Read(buffer, 0, buffer.Length); _folders[i].Files[j].StartIndex = BitConverter.ToInt64(buffer, 0); buffer = new byte[sizeof(long)]; idxFs.Read(buffer, 0, buffer.Length); _folders[i].Files[j].Length = BitConverter.ToInt64(buffer, 0); } } for (int i = 0; i < folderFileCountArray.Length; i++) { if (_folders[i].ParentIndex == -1) { continue; } folders[_folders[i].ParentIndex].Folders.Add(_folders[i]); } return(folders[0]); } finally { if (idxFs != null) { idxFs.Dispose(); } } }