or
/// <summary> /// Generate an invoice /// </summary> private Attachment GenerateInvoice(Guid orderid, string ordernumber, string att, string address, string att2, string address2) { try { rptInvoice report = new rptInvoice(); Filter f = new Filter(); f.Expression = "=Fields.OrderId"; f.Operator = FilterOperator.Equal; f.Value = orderid.ToString(); report.Filters.Add(f); // Invoice address report.Att = att; report.FullAddress = address; // Send address report.Att2 = att2 != string.Empty ? "VERZENDADRES:" + Environment.NewLine + att2 : string.Empty; report.FullAddress2 = address2; ReportProcessor processor = new ReportProcessor(); RenderingResult result = processor.RenderReport("PDF", report, null); string reportName = "Factuur-" + ordernumber + ".pdf"; string reportLocation = MapPath("~/Orders/"); using (FileStream fs = new FileStream(reportLocation + reportName, FileMode.Create)) { fs.Write(result.DocumentBytes, 0, result.DocumentBytes.Length); fs.Close(); fs.Dispose(); } report.Dispose(); processor = null; result = null; return new Attachment(reportLocation + reportName); } catch (Exception ex) { throw ex; } }