protected override void OnSaving() { base.OnSaving(); ModifiedBy = Session.GetObjectByKey <Employee>(SecuritySystem.CurrentUserId); ModifyDate = DateTime.Now; IsDocumentAttached = (Attachment != null); if (IsDocumentAttached) { if (Attachment.FileName.Contains("pdf")) { using (MemoryStream ms = new MemoryStream()) { Attachment.SaveToStream(ms); using (PdfHandling pdfHandling = new PdfHandling(ms)) { AttachmentMetaData = pdfHandling.DocumentText; } } } Attachment.FileName = ResourceNumber + "." + Attachment.FileName.Split('.').Last(); } else { AttachmentMetaData = string.Empty; } }
protected override void OnSaving() { base.OnSaving(); IsDocumentAttached = (Attachment != null); if (IsDocumentAttached) { using (MemoryStream ms = new MemoryStream()) { Attachment.SaveToStream(ms); using (PdfHandling pdfHandling = new PdfHandling(ms)) { Excerpt = pdfHandling.DocumentText; Pages = pdfHandling.PageCount; } } Attachment.FileName = RegistrationNumber + "." + Attachment.FileName.Split('.').Last(); } else { Excerpt = string.Empty; ScanDate = DateTime.MinValue; ScannedBy = null; Pages = 0; } ModifyDate = DateTime.Now; ModifiedBy = Session.GetObjectByKey <Employee>(SecuritySystem.CurrentUserId); }
private void ExtractTextFromPDFAction_Execute(object sender, SimpleActionExecuteEventArgs e) { Marbid.Module.BusinessObjects.LibrarianSystem.Document doc = (Marbid.Module.BusinessObjects.LibrarianSystem.Document)View.CurrentObject; if (doc.Attachment != null) { using (MemoryStream ms = new MemoryStream()) { doc.Attachment.SaveToStream(ms); using (PdfHandling handling = new PdfHandling(ms)) { doc.Excerpt = handling.DocumentText; } } } if (View is DetailView && ((DetailView)View).ViewEditMode == ViewEditMode.View) { View.ObjectSpace.CommitChanges(); } }