public FileResult DownloadDoc(int Id, int CaseheaderId) { SupportingDocs supportdoc = CMSService.DownloadDocument(Id); string folderName = System.Configuration.ConfigurationManager.AppSettings["_SupportDocuments"] + CaseheaderId + '\\' + codeTable.ListOfFolders.Where(f => f.Id == supportdoc.FolderTypeId).FirstOrDefault().Description.Replace(" ", ""); var fileSavePath = Path.Combine(folderName, supportdoc.FileName); byte[] fileBytes = System.IO.File.ReadAllBytes(fileSavePath); return(File(fileBytes, System.Net.Mime.MediaTypeNames.Application.Octet, supportdoc.FileName)); }
public ActionResult UploadSupportDocs(viewCaseHeader model) { int clientid = 0; int caseheaderid = 0; try { if (HttpContext.Request.Files.AllKeys.Any()) { for (int i = 0; i <= HttpContext.Request.Files.Count; i++) { var file = HttpContext.Request.Files["files" + i]; if (file != null) { int folderid = Convert.ToInt32(Request.Form["folderId"]); caseheaderid = Convert.ToInt32(Request.Form["caseheaderId"]); viewCaseHeader viewcaseheader = CMSService.GetCaseHeader(clientid); string folderName = System.Configuration.ConfigurationManager.AppSettings["_SupportDocuments"] + caseheaderid + '\\' + codeTable.ListOfFolders.Where(f => f.Id == folderid).FirstOrDefault().Description.Replace(" ", ""); if (!Directory.Exists(folderName)) { Directory.CreateDirectory(folderName); } var fileSavePath = Path.Combine(folderName, System.IO.Path.GetFileName(file.FileName)); file.SaveAs(fileSavePath.Replace(" ", "")); SupportingDocs supportdoc = new SupportingDocs(); supportdoc.FileName = System.IO.Path.GetFileName(file.FileName.Replace(" ", "")); supportdoc.FolderTypeId = folderid; supportdoc.CaseheaderId = caseheaderid; CMSService.SaveFileDetails(supportdoc); } } } } catch (Exception e) { throw e; } //return RedirectToAction("ManageCase", "Case", new { Id = clientid, CaseheaderId = caseheaderid }); var redirectUrl = new UrlHelper(Request.RequestContext).Action("ManageCase", "Case", new { CaseheaderId = caseheaderid }); return(Json(new { Url = redirectUrl })); }
public FileResult DownloadDoc(int Id) { //SupportingDocs supportdoc = CMSService.DownloadDocument(Id); SupportingDocs supportdoc = CMSService.DownloadFile(Id); // LMD: they were calling the wrong method. string folderName = System.Configuration.ConfigurationManager.AppSettings["_QualityAssuranceReviews"]; var fileSavePath = Path.Combine(folderName, supportdoc.FileName); byte[] fileBytes = System.IO.File.ReadAllBytes(fileSavePath); return(File(fileBytes, System.Net.Mime.MediaTypeNames.Application.Octet, supportdoc.FileName)); }
public ActionResult UploadSupportDocs() { //int var = Request.Files.Count; //int[] fileIds = new int[var]; List <SupportingDocs> Files = new List <SupportingDocs>(); if (HttpContext.Request.Files.AllKeys.Any()) { for (int i = 0; i <= HttpContext.Request.Files.Count; i++) { var file = HttpContext.Request.Files["files" + i]; if (file != null) { //int folderid = Convert.ToInt32(Request.Form["folderId"]); string folderName = System.Configuration.ConfigurationManager.AppSettings["_QualityAssuranceReviews"]; if (!Directory.Exists(folderName)) { Directory.CreateDirectory(folderName); } var fileSavePath = Path.Combine(folderName, System.IO.Path.GetFileName(file.FileName)); file.SaveAs(fileSavePath); SupportingDocs supportdoc = new SupportingDocs(); supportdoc.FileName = System.IO.Path.GetFileName(file.FileName); supportdoc.UserCreated = ViewBag.UserName; //supportdoc.StatusDescription = CaseStatus.Submitted.ToString(); //supportdoc.UserCreated = ViewBag.UserName; //supportdoc.UserUpdated = ViewBag.UserName; int id = CMSService.UploadFile(supportdoc); SupportingDocs doc = new SupportingDocs(); doc = CMSService.DownloadFile(id); Files.Add(doc); } } } //for (int i = 0; i < Request.Files.Count; i++) //{ // var file = Request.Files[i]; // SupportingDocs supportdoc = new SupportingDocs(); // supportdoc.ContentLength = file.ContentLength; // supportdoc.ContentType = file.ContentType; // supportdoc.FileName = file.FileName; // supportdoc.InputStream = ConvertToBytes(file.InputStream, supportdoc.ContentLength); // fileIds[i] = CMSService.UploadFile(supportdoc); // SupportingDocs doc = new SupportingDocs(); // doc = CMSService.DownloadFile(fileIds[i]); // Files.Add(doc); //} return(Json(new { Files, JsonRequestBehavior.AllowGet })); }