Пример #1
0
        public override DocumentOperationResponse PerformOperation(DocumentOperationRequest request, PrintingSystemBase initialPrintingSystem, PrintingSystemBase printingSystemWithEditingFields)
        {
            string reportPath = @"c:\\Temp\Test.pdf";

            printingSystemWithEditingFields.ExportToPdf(reportPath);
            return(base.PerformOperation(request, initialPrintingSystem, printingSystemWithEditingFields));
        }
        public override DocumentOperationResponse PerformOperation(DocumentOperationRequest request, PrintingSystemBase initialPrintingSystem, PrintingSystemBase printingSystemWithEditingFields)
        {
            userName = request.CustomData;

            var reportStorage = ReportStorage.GetInstance(userName);

            objectSpace = reportStorage.Application.CreateObjectSpace();

            var dokumentPdf  = objectSpace.GetObject(reportStorage.Dokument);
            var memoryStream = new MemoryStream();

            printingSystemWithEditingFields.ExportToPdf(memoryStream);
            memoryStream.Seek(0, SeekOrigin.Begin);
            reportStorage.MemoryStream = memoryStream;

            if (memoryStream != null)
            {
                if (memoryStream.Length > 0)
                {
                    if (dokumentPdf.DokumentPdf is null)
                    {
                        dokumentPdf.DokumentPdf = objectSpace.CreateObject <FileData>();
                    }
                    dokumentPdf.DokumentPdf.LoadFromStream($"Dokument.Pdf", memoryStream);

                    //var emailService = new EmailService("email", "password");
                    //emailService.SendEmail(memoryStream, dokumentPdf.PacjentEmail);
                    objectSpace.CommitChanges();
                }
            }

            return(base.PerformOperation(request, initialPrintingSystem, printingSystemWithEditingFields));
        }
 public override DocumentOperationResponse PerformOperation(DocumentOperationRequest request, PrintingSystemBase initialPrintingSystem, PrintingSystemBase printingSystemWithEditingFields)
 {
     using (var stream = new MemoryStream()) {
         printingSystemWithEditingFields.ExportToPdf(stream);
         stream.Position = 0;
         var mailAddress = new MailAddress(request.CustomData);
         var recipients  = new MailAddressCollection()
         {
             mailAddress
         };
         var attachment = new Attachment(stream, System.Net.Mime.MediaTypeNames.Application.Pdf);
         return(SendEmail(recipients, "Enter_Mail_Subject", "Enter_Message_Body", attachment));
     }
 }
Пример #4
0
        void ExporToStream(string html, Stream stream)
        {
            using (RichEditDocumentServer server = new RichEditDocumentServer()) {
                server.HtmlText = html;
                string text = "<b>SOME SAMPLE TEXT</b>";
                AddHeaderToDocument(server.Document, text);
                AddFooterToDocument(server.Document, text);

                using (PrintingSystemBase ps = new PrintingSystemBase()) {
                    using (PrintableComponentLinkBase pcl = new PrintableComponentLinkBase(ps)) {
                        pcl.Component = server;
                        pcl.CreateDocument();
                        ps.ExportToPdf(stream);
                    }
                }
            }
        }