public JsonResult detailasjson(int pId) { return(Json(FolderDAO.GetAllFolders(pId), JsonRequestBehavior.AllowGet)); }
public ActionResult DownloadMeta() { int pId = Convert.ToInt32(Request["pid"]); List <FolderDTO> folders = new List <FolderDTO>(); folders = FolderDAO.GetAllFolders(pId); List <FolderDTO> tempfolders = new List <FolderDTO>(); foreach (var folder in folders) { tempfolders.AddRange(FolderDAO.GetAllFolders(folder.folderId)); } folders.AddRange(tempfolders); List <FileDTO> files; files = FileDAO.GetAllFiles(pId); List <FileDTO> tempfiles = new List <FileDTO>(); foreach (var file in files) { tempfiles.AddRange(FileDAO.GetAllFiles(file.parentFolderId)); } files.AddRange(tempfiles); PdfDocument pdf = new PdfDocument(); pdf.Info.Title = "Meta Data"; PdfPage pdfPage = pdf.AddPage(); XGraphics graph = XGraphics.FromPdfPage(pdfPage); XFont font = new XFont("Times New Roman", 10, XFontStyle.Regular); int i = 0; int j = 0; foreach (var folder in folders) { string foldername = FolderDAO.getFoldernameByid(folder.parentFolderId); if (folder.parentFolderId == 0) { foldername = "Root"; } graph.DrawString("Name: " + folder.folderName.ToString(), font, XBrushes.Black, new XRect(i, j, 250, 220), XStringFormats.TopLeft); graph.DrawString("Type: FOLDER", font, XBrushes.Black, new XRect(i, j + 10, 250, 220), XStringFormats.TopLeft); graph.DrawString("Parent: " + foldername, font, XBrushes.Black, new XRect(i, j + 20, 250, 220), XStringFormats.TopLeft); j = j + 40; } foreach (var file in files) { string foldername = FolderDAO.getFoldernameByid(file.parentFolderId); if (file.parentFolderId == 0) { foldername = "Root"; } graph.DrawString("Name: " + file.fileName, font, XBrushes.Black, new XRect(i, j, 250, 220), XStringFormats.TopLeft); graph.DrawString("Type: FILE", font, XBrushes.Black, new XRect(i, j + 10, 250, 220), XStringFormats.TopLeft); graph.DrawString("Size: " + file.fileSizeInKb + " KB", font, XBrushes.Black, new XRect(i, j + 20, 250, 220), XStringFormats.TopLeft); graph.DrawString("Parent: " + foldername, font, XBrushes.Black, new XRect(i, j + 30, 250, 220), XStringFormats.TopLeft); j = j + 50; } string pdfFilename = "MetaData.pdf"; //pdf.Save(pdfFilename); //var file = pdf; var ext = ".pdf"; var uniqueName = "MetaData" + ext; var rootPath = Server.MapPath("~/UploadedFiles"); var fileSavePath = System.IO.Path.Combine(rootPath, uniqueName); pdf.Save(fileSavePath); // Session["image"] = uniqueName; return(Download("MetaData.pdf")); }