public Object getThumbnail(string uniqueName) { FolderBAL fb = new FolderBAL(); FileDTO filedto = fb.GetFileByUniqueID(uniqueName); var rootPath = HttpContext.Current.Server.MapPath("~/UploadedFiles"); var fileFullPath = System.IO.Path.Combine(rootPath, uniqueName); ShellFile shellFile = ShellFile.FromFilePath(fileFullPath); Bitmap shellThumb = shellFile.Thumbnail.SmallBitmap; if (filedto != null) { HttpResponseMessage response = new HttpResponseMessage(HttpStatusCode.OK); byte[] file = ImageToBytes(shellThumb); MemoryStream ms = new MemoryStream(file); response.Content = new ByteArrayContent(file); response.Content.Headers.ContentDisposition = new System.Net.Http.Headers.ContentDispositionHeaderValue("attachment"); response.Content.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue(filedto.ContentTpye); response.Content.Headers.ContentDisposition.FileName = filedto.FileUniqueName; return(response); } else { HttpResponseMessage response = new HttpResponseMessage(HttpStatusCode.NotFound); return(response); } }
public ActionResult search(string Actualname) { List <FileDTO> list = new List <FileDTO>(); FolderBAL fb = new FolderBAL(); FileDTO fd = new FileDTO(); list = fb.search(Actualname); return(View(list)); }
public ActionResult getcombine() { FolderBAL fb = new FolderBAL(); var id = Session["parid"]; int id1 = (int)id; var cm = fb.combine(id1); return(View("file", cm)); }
public ActionResult NormalUser() { @ViewBag.name = Session["username"]; @ViewBag.userid = Session["userid"]; FolderBAL fb = new FolderBAL(); FolderDTO fd = new FolderDTO(); var folders = fb.GetAllFolders(); return(View(folders)); }
public void UploadFile() { var uniqueName = ""; if (HttpContext.Current.Request.Files.Count > 0) { try { foreach (var FileName in HttpContext.Current.Request.Files.AllKeys) { HttpPostedFile file = HttpContext.Current.Request.Files[FileName]; if (file != null) { FileDTO fileDTO = new FileDTO(); fileDTO.fileActualName = file.FileName; fileDTO.FileExt = Path.GetExtension(file.FileName); fileDTO.ContentTpye = file.ContentType; fileDTO.Size = file.ContentLength; String createdby = HttpContext.Current.Request["createdby"]; String parid = HttpContext.Current.Request["parid"]; fileDTO.CreatedBy = int.Parse(createdby); fileDTO.ParentFolderid = int.Parse(parid); fileDTO.UploadedOn = DateTime.Now; fileDTO.IsActive = true; /* var rootpath = HttpContext.Current.Server.MapPath("~/UploadedFiles"); * var fileSavePath = System.IO.Path.Combine(rootpath, fileDTO.FileUniqueName, fileDTO.FileExt); * file.SaveAs(fileSavePath);*/ var ext = System.IO.Path.GetExtension(file.FileName); //Generate a unique name using Guid uniqueName = Guid.NewGuid().ToString() + ext; fileDTO.FileUniqueName = uniqueName; //Get physical path of our folder where we want to save images var rootPath = HttpContext.Current.Server.MapPath("~/UploadedFiles"); var fileSavePath = System.IO.Path.Combine(rootPath, uniqueName); // Save the uploaded file to "UploadedFiles" folder file.SaveAs(fileSavePath); FolderBAL fb = new FolderBAL(); int id = fb.SaveFile(fileDTO); } } } catch (Exception e) { } } }
public void saveMetaData() { String dest = "C:\\Users\\aa\\Documents\\asp projects\\Assignment8\\Apicontroller\\UploadFiles\\Meta.pdf"; var writer = new PdfWriter(dest); var pdf = new PdfDocument(writer); var doc1 = new Document(pdf); FolderBAL fb = new FolderBAL(); List <FolderDTO> fdto = new List <FolderDTO>(); fdto = fb.GetAllFolders(); foreach (var item in fdto) { doc1.Add(new Paragraph("FolderName :" + item.Name)); doc1.Add(new Paragraph("Type :" + "Folder")); doc1.Add(new Paragraph("size :" + "none")); doc1.Add(new Paragraph("parentFolder :" + "Root")); var subf = fb.getsubfolder(item.FolderId); if (subf.Count > 0) { foreach (var item1 in subf) { doc1.Add(new Paragraph("FolderName :" + item1.Name)); doc1.Add(new Paragraph("Type :" + "Folder")); doc1.Add(new Paragraph("size :" + "none")); doc1.Add(new Paragraph("parentFolder :" + item.Name)); } } var subfiles = fb.getsubfiles(item.FolderId); if (subfiles.Count > 0) { foreach (var item2 in subfiles) { doc1.Add(new Paragraph("FileName :" + item2.FileUniqueName)); doc1.Add(new Paragraph("Type :" + "File")); doc1.Add(new Paragraph("size :" + item2.Size)); doc1.Add(new Paragraph("parentFolder :" + item.Name)); } } } doc1.Close(); return; }
public JsonResult deleteFolder(string folderid) { int folderid1 = int.Parse(folderid); @ViewBag.name = Session["username"]; FolderBAL fb = new FolderBAL(); FolderDTO fd = new FolderDTO(); if (fb.DeleteProduct(folderid1) > 0 && fb.Deletefile(folderid1) > 0 && fb.deletefolder(folderid1) > 0) { Url.Content("~/Home/NormalUser"); } return(Json(JsonRequestBehavior.AllowGet)); }
public void savefolder() { var name = HttpContext.Current.Request["name"]; String createdby = HttpContext.Current.Request["createdby"]; String parid = HttpContext.Current.Request["parid"]; FolderDTO fd = new FolderDTO(); fd.CreatedBy = int.Parse(createdby); fd.ParentFolderId = int.Parse(parid); fd.CreatedOn = DateTime.Now; fd.Name = name; fd.IsActive = true; FolderBAL fb = new FolderBAL(); fb.Save(fd); }
/* public ActionResult parfolder() * { * * @ViewBag.name = Session["username"]; * @ViewBag.userid = Session["userid"]; * var id = Session["parid"]; * int id1 = (int)id; * FolderBAL fb = new FolderBAL(); * FolderDTO fd = new FolderDTO(); * * var folders = fb.GetAllParFolders(id1); * * return View("file",folders); * * * }*/ public ActionResult deleteparFolder() { string id = Request.QueryString["folderid"]; int folderid1 = int.Parse(id); @ViewBag.name = Session["username"]; FolderBAL fb = new FolderBAL(); FolderDTO fd = new FolderDTO(); if (fb.DeleteProduct(folderid1) > 0) { return(Redirect("http://localhost:50362/Home/getcombine")); } return(View("file")); }
public ActionResult deletefile() { string id = Request.QueryString["uniqueName"]; int uniquename = int.Parse(id); @ViewBag.name = Session["username"]; FolderBAL fb = new FolderBAL(); FolderDTO fd = new FolderDTO(); if (fb.deletefile(uniquename) > 0) { return(Redirect("http://localhost:50362/Home/getcombine")); } return(View("file")); }
public ActionResult file() { string id = Request.QueryString["folderid"]; int folderid = int.Parse(id); @ViewBag.folderid = folderid; Session["parid"] = folderid; FolderBAL fb = new FolderBAL(); FolderDTO fd = new FolderDTO(); string name = fb.getName(folderid); Session["name"] = name; var cm = fb.combine(folderid); return(View("file", cm)); }
public ActionResult Index() { DateTime dTime = DateTime.Now; var filePath = Server.MapPath("~/docs") + "\\" + DateTime.Now.Ticks.ToString() + ".pdf"; var doc1 = new Document(); //Create Document Instance and load in 'doc1' var streamObj = new System.IO.FileStream(filePath, System.IO.FileMode.CreateNew); PdfWriter.GetInstance(doc1, streamObj); doc1.Open(); combine cm = new combine(); FolderBAL fb = new FolderBAL(); var id = Session["parid"]; int id1 = (int)id; cm = fb.combine(id1); string name = fb.getName(id1); foreach (var item in cm.allfolders) { doc1.Add(new Paragraph("FolderName :" + item.Name)); doc1.Add(new Paragraph("Type :" + "Folder")); doc1.Add(new Paragraph("size :" + "none")); doc1.Add(new Paragraph("parentFolder :" + name)); } foreach (var item in cm.allfiles) { doc1.Add(new Paragraph("FileName : " + item.FileUniqueName)); doc1.Add(new Paragraph("Type : " + "File")); doc1.Add(new Paragraph("size :" + item.Size)); doc1.Add(new Paragraph("parentFolder :" + name)); } doc1.Close(); return(Redirect("http://localhost:47496/api/pdfdownload/downloadpdf?path=" + filePath)); }
public HttpResponseMessage DownloadMetaDataDocument(int ParentFolderId, int UserId) { HttpResponseMessage result = null; var dest = HttpContext.Current.Server.MapPath("~/Uploads/MetaDataDocument.pdf"); if (File.Exists(dest)) { File.Delete(dest); } var writer = new PdfWriter(dest); var pdf = new iText.Kernel.Pdf.PdfDocument(writer); var document = new Document(pdf); Queue <FolderDTO> folderDTOsQueue = new Queue <FolderDTO>(); FolderDTO folderDTO = FolderBAL.GetFolderByFolderIdAndUserId(ParentFolderId, UserId); folderDTOsQueue.Enqueue(folderDTO); while (folderDTOsQueue.Count > 0) { folderDTO = folderDTOsQueue.Dequeue(); document.Add(new Paragraph("Name: " + folderDTO.Name + "\nType: Folder\nSize: None\nParent: " + folderDTO.ParentFolderName)); List <FilesDTO> fileDTOsList = FilesBAL.GetFilesByParentFolderIdAndUserId(folderDTO.Id, folderDTO.CreatedBy); foreach (FilesDTO fileDTO in fileDTOsList) { document.Add(new Paragraph("Name: " + fileDTO.Name + "\nType: File\nSize: " + fileDTO.FileSizeInKB + " KB\nParent: " + folderDTO.ParentFolderName)); } List <FolderDTO> folderDTOsList = FolderBAL.GetFoldersWithParentFolderNameByParentFolderIdAndUserId(folderDTO.Id, folderDTO.CreatedBy); foreach (FolderDTO tempDTO in folderDTOsList) { folderDTOsQueue.Enqueue(tempDTO); } } document.Close(); result = Request.CreateResponse(HttpStatusCode.OK); result.Content = new StreamContent(new FileStream(dest, FileMode.Open, FileAccess.Read)); result.Content.Headers.ContentDisposition = new System.Net.Http.Headers.ContentDispositionHeaderValue("attachment"); result.Content.Headers.ContentDisposition.FileName = "MetaDataDocument.pdf"; return(result); }
public Object DownloadFile(String UniqueName) { var rootpath = System.Web.HttpContext.Current.Server.MapPath("~/UploadedFiles"); FolderBAL fb = new FolderBAL(); var fileDTO = fb.GetFileByUniqueID(UniqueName); if (fileDTO != null) { HttpResponseMessage response = new HttpResponseMessage(HttpStatusCode.OK); var filefullpath = System.IO.Path.Combine(rootpath, fileDTO.FileUniqueName); byte[] file = System.IO.File.ReadAllBytes(filefullpath); System.IO.MemoryStream ms = new System.IO.MemoryStream(file); response.Content = new ByteArrayContent(file); response.Content.Headers.ContentDisposition = new ContentDispositionHeaderValue("attachment"); response.Content.Headers.ContentType = new MediaTypeHeaderValue(fileDTO.ContentTpye); response.Content.Headers.ContentDisposition.FileName = fileDTO.fileActualName; return(response); } else { HttpResponseMessage response = new HttpResponseMessage(HttpStatusCode.NotFound); return(response); } }
public void getMetaData() { String dest = "C:\\Users\\aa\\Documents\\asp projects\\Assignment8\\Apicontroller\\UploadFiles\\Meta.pdf"; var writer = new PdfWriter(dest); var pdf = new PdfDocument(writer); var doc1 = new Document(pdf); combine cm = new combine(); FolderBAL fb = new FolderBAL(); string id = HttpContext.Current.Request["parid"]; int id1 = int.Parse(id); cm = fb.combine(id1); string name = fb.getName(id1); foreach (var item in cm.allfolders) { doc1.Add(new Paragraph("FolderName :" + item.Name)); doc1.Add(new Paragraph("Type :" + "Folder")); doc1.Add(new Paragraph("size :" + "none")); doc1.Add(new Paragraph("parentFolder :" + name)); } foreach (var item in cm.allfiles) { doc1.Add(new Paragraph("FileName : " + item.FileUniqueName)); doc1.Add(new Paragraph("Type : " + "File")); doc1.Add(new Paragraph("size :" + item.Size)); doc1.Add(new Paragraph("parentFolder :" + name)); } doc1.Close(); return; }
public bool DeleteFolderByFolderIdAndUserId(FolderDTO folderDTO) { return(FolderBAL.DeleteFolderByFolderIdAndUserId(folderDTO.Id, folderDTO.CreatedBy)); }
public List <FolderDTO> GetNavigationByFolderIdAndUserId(FolderDTO folderDTO) { return(FolderBAL.GetNavigationByFolderIdAndUserId(folderDTO.Id, folderDTO.CreatedBy)); }
public int CreateFolder(FolderDTO folderDTO) { folderDTO.CreatedOn = DateTime.Now; folderDTO.IsActive = true; return(FolderBAL.CreateNewFolder(folderDTO)); }
public List <FolderDTO> GetFoldersByParentFolderIdAndUserId(FolderDTO folderDTO) { return(FolderBAL.GetFoldersByParentFolderIdAndUserId(folderDTO.ParentFolderId, folderDTO.CreatedBy)); }