public static void CreateMemberDocument(CMSDataContext db, CMSImageDataContext idb, string docname, int orgId, Person person, HttpPostedFileBase file) { string docName = $"{docname}_{person.LastName}_{person.FirstName}_{person.PeopleId}"; var document = db.OrgMemberDocuments.SingleOrDefault(o => o.DocumentName == docName & o.PeopleId == person.PeopleId & o.OrganizationId == orgId); if (document != null) { db.OrgMemberDocuments.DeleteOnSubmit(document); Image.Delete(idb, document.ImageId); db.SubmitChanges(); } int imageId = DocumentsData.StoreImageFromDocument(idb, file); db.OrgMemberDocuments.InsertOnSubmit(new OrgMemberDocument() { DocumentName = docName, ImageId = imageId, PeopleId = person.PeopleId, OrganizationId = orgId, CreatedDate = DateTime.Now }); db.SubmitChanges(); }
public static void CreateTemporaryDocument(CMSDataContext db, CMSImageDataContext idb, string docname, int orgId, string emailAddress, string lastName, string firstName, HttpPostedFileBase file) { var document = db.OrgTemporaryDocuments.SingleOrDefault(o => o.DocumentName == docname & o.LastName == lastName & o.FirstName == firstName & o.EmailAddress == emailAddress); if (document != null) { db.OrgTemporaryDocuments.DeleteOnSubmit(document); Image.Delete(idb, document.ImageId); db.SubmitChanges(); } int imageId = DocumentsData.StoreImageFromDocument(idb, file); db.OrgTemporaryDocuments.InsertOnSubmit(new OrgTemporaryDocuments() { DocumentName = docname, ImageId = imageId, LastName = lastName, FirstName = firstName, EmailAddress = emailAddress, OrganizationId = orgId, CreatedDate = DateTime.Now }); db.SubmitChanges(); }
private static void SeedDocuments(DocumentContext context) { List <Document> startingDocuments = DocumentsData.GenerateStartingDocuments(); SetStartingDocuments(context, startingDocuments); List <AnonymousObject> startingAnons = AnonymousObjectData.GenerateStartingAnons(); SetStartingAnons(context, startingAnons); }
private string GetDirectoriesFilter() { string filter = DocumentsData.GetFilesFoldersFilter(selectedRecorderOffice, txtSearchExpression.Value); if (filter.Length != 0) { filter += " AND "; } filter += "([FilesFolderStatus] IN ('" + (char) FilesFolderStatus.Pending + "', '" + (char) FilesFolderStatus.Obsolete + "'))"; return filter; }
protected sealed override DataView LoadDataSource() { if (base.SelectedTabStrip == 0) { return DocumentsData.GetFilesFolders(RecordBookDirectory.DirectoryType, GetDirectoriesFilter(), "FilesFolderDisplayName DESC"); } else if (base.SelectedTabStrip == 1) { return RecordingBooksData.GetVolumeRecordingBooks(selectedRecorderOffice, RecordingBookStatus.Pending, GetRecordingBooksFilter(), "RecordingBookFullName DESC"); } else if (base.SelectedTabStrip == 2) { return RecordingBooksData.GetVolumeRecordingBooks(selectedRecorderOffice, RecordingBookStatus.Assigned, GetRecordingBooksFilter(), "RecordingBookFullName DESC"); } else if (base.SelectedTabStrip == 3) { return RecordingBooksData.GetVolumeRecordingBooks(selectedRecorderOffice, RecordingBookStatus.Revision, GetRecordingBooksFilter(), "RecordingBookFullName"); } else if (base.SelectedTabStrip == 4) { return RecordingBooksData.GetVolumeRecordingBooks(selectedRecorderOffice, RecordingBookStatus.Closed, GetRecordingBooksFilter(), "RecordingBookFullName"); } else { return new DataView(); } }
public IHttpActionResult MergeDocs(DocumentsData documentsData) { System.IO.Directory.CreateDirectory(resultPath + documentsData.unique_filepath); this.resultPdf = new iText.Kernel.Pdf.PdfDocument(new iText.Kernel.Pdf.PdfWriter(resultPath + documentsData.unique_filepath + "\\resultMerge" + documentsData.unique_filepath + ".pdf")); this.returnResult = resultPath + documentsData.unique_filepath + "\\resultMerge" + documentsData.unique_filepath + ".pdf"; this.remoteHost = HttpContext.Current.Request.Url.Host.ToString().Trim(); foreach (string filename in documentsData.filenames) { string[] filename_parts = filename.Split('.'); string sourceFilePath = this.remoteHost + "/" + documentsData.filepath + "/" + filename; if (filename_parts[1] == "docx") { Microsoft.Office.Interop.Word.Application app = new Microsoft.Office.Interop.Word.Application(); var docs = app.Documents; var doc = docs.Open(sourceFilePath, true, true, false); doc.Activate(); string printPath = resultPath + documentsData.unique_filepath + "\\" + filename_parts[0] + ".pdf"; doc.ExportAsFixedFormat(printPath.ToString(), Microsoft.Office.Interop.Word.WdExportFormat.wdExportFormatPDF); doc.Close(); Marshal.FinalReleaseComObject(doc); Marshal.FinalReleaseComObject(docs); app.Quit(); Marshal.FinalReleaseComObject(app); app = null; doc = null; docs = null; GC.Collect(); GC.WaitForPendingFinalizers(); GC.Collect(); GC.WaitForPendingFinalizers(); this.GenerateSinglePdf(printPath); } else if (filename_parts[1] == "xlsx") { Microsoft.Office.Interop.Excel.Application app = new Microsoft.Office.Interop.Excel.Application(); var wbs = app.Workbooks; var wb = wbs.Open(sourceFilePath); wb.Activate(); string printPath = resultPath + documentsData.unique_filepath + "\\" + filename_parts[0] + ".pdf"; wb.ExportAsFixedFormat(Microsoft.Office.Interop.Excel.XlFixedFormatType.xlTypePDF, printPath.ToString()); wb.Close(); Marshal.FinalReleaseComObject(wb); wbs.Close(); Marshal.FinalReleaseComObject(wbs); app.Quit(); Marshal.FinalReleaseComObject(app); app = null; wb = null; wbs = null; GC.Collect(); GC.WaitForPendingFinalizers(); GC.Collect(); GC.WaitForPendingFinalizers(); this.GenerateSinglePdf(printPath); } else { throw new Exception("Wrong file format. Only docx/xlsx 2007-2013/16 file formats are supported."); } } this.resultPdf.Close(); GC.Collect(); GC.WaitForPendingFinalizers(); GC.Collect(); GC.WaitForPendingFinalizers(); byte[] byteArray = File.ReadAllBytes(this.returnResult); /* MemoryStream ms = new MemoryStream(); * ms.Write(byteArray, 0 , byteArray.Length); // FOR LARGER FILES SEND FILESTREAM CONTENT TO THE RESPONSE IF NEEDED * ms.Position = 0;*/ IHttpActionResult response; HttpResponseMessage responseMsg = new HttpResponseMessage(HttpStatusCode.OK); responseMsg.Content = new ByteArrayContent(byteArray); responseMsg.Content.Headers.ContentDisposition = new System.Net.Http.Headers.ContentDispositionHeaderValue("attachment"); responseMsg.Content.Headers.ContentDisposition.FileName = "resultMerge_" + documentsData.unique_filepath + ".pdf"; responseMsg.Content.Headers.ContentType = new MediaTypeHeaderValue("application/pdf"); response = ResponseMessage(responseMsg); return(response); }