Example #1
0
        public void SendEmailWithPdf(string lang)
        {
            var fileName = $"Audit_ID{this.Id}_{DateTime.Now.ToString("yyyyMMdd")}.pdf";
            var subject  = $"Printout {this.TypeName} | {this.Target}";
            var body     = "";
            var email    = AppUser.GetUserMail(this.AuditorLogin);

            if (email == null)
            {
                throw new Exception("You can not send an e-mail with the report - no e-mail in the system / wrong format!");
            }
            var report = AuditTypes.GetXtraReport(this, lang);

            using (MemoryStream stream = new MemoryStream())
            {
                report.ExportToPdf(stream);
                stream.Position = 0;
                var attach = new Attachment(stream, fileName, "application/pdf");
                MailUtils.SendEmail(subject, body, new List <string> {
                    email
                }, new List <Attachment> {
                    attach
                });
            }
            throw new Exception("An email with a PDF printout has been sent! Check your inbox!");
        }
Example #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            var id = Utils.ConvertToNullableInt(Request.QueryString["id"]);

            lblInfo.Text = string.Empty;
            if (id != null)
            {
                if (Audit.AuditExist((int)id))
                {
                    var report         = AuditTypes.GetXtraReport(new Audit((int)id), Languages.Polish);
                    var reportFileName = $"Audit_{id}";
                    Utils.PrintPDF(report, reportFileName);
                }
                else
                {
                    lblInfo.Text = $"Printing of the document failed!{Environment.NewLine}Audit does not exist!";
                }
            }
            else
            {
                lblInfo.Text = $"Printing of the document failed!{Environment.NewLine}Wrong parameter!";
            }
        }