Changeset 10013 for branches/OaaS/HeuristicLab.Services.Optimization.Billing/BillingEngine/PlainTextInvoiceFormattingEngine.cs
- Timestamp:
- 10/01/13 13:18:19 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/OaaS/HeuristicLab.Services.Optimization.Billing/BillingEngine/PlainTextInvoiceFormattingEngine.cs
r9653 r10013 3 3 using System.IO; 4 4 using System.Linq; 5 using System.Text.RegularExpressions; 5 6 using System.Windows.Forms; 6 7 using HeuristicLab.Services.Optimization.Billing.Interfaces; … … 20 21 private PlainTextInvoiceFormat invoiceFormat; 21 22 private string invoiceOutputPath; 23 private IInvoiceDao invoiceDao; 24 25 private IInvoiceDao InvoiceDao { 26 get { 27 if (invoiceDao == null) { 28 invoiceDao = new FileSystemInvoiceDao(); 29 } 30 return invoiceDao; 31 } 32 } 22 33 23 34 public PlainTextInvoiceFormattingEngine() … … 82 93 invoiceText = invoiceText.Replace("{INVOICE_TOTAL}", invoice.Total.ToString("C2").PadLeft(14)); 83 94 95 // remove all escape sequences and replace directory separator with a hyphen 96 string customerName = Regex.Replace(invoice.User.ContactInformation.OrganizationName, "\\r\\n|\\[bnrt]", ""); 97 customerName = customerName.Replace("/", "-"); 98 84 99 if (invoiceFormat == PlainTextInvoiceFormat.RTF) { 85 invoiceOutputPath = string.Format("{0}_{1}_{2}.rtf", invoice.InvoiceId, invoice.InvoiceDate.ToString("yyyMMdd"), "{CUSTOMER}");100 invoiceOutputPath = string.Format("{0}_{1}_{2}.rtf", invoice.InvoiceId, invoice.InvoiceDate.ToString("yyyMMdd"), customerName); 86 101 87 102 RichTextBox richTextBox = new RichTextBox(); … … 90 105 richTextBox.SelectionFont = new Font("Consolas", 10, FontStyle.Regular); 91 106 92 File.WriteAllText(invoiceOutputPath, richTextBox.Rtf); 107 //File.WriteAllText(invoiceOutputPath, richTextBox.Rtf); 108 InvoiceDao.SaveDocument(invoiceOutputPath, richTextBox.Rtf); 93 109 } else if (invoiceFormat == PlainTextInvoiceFormat.TXT) { 94 invoiceOutputPath = string.Format("{0}_{1}_{2}.txt", invoice.InvoiceId, invoice.InvoiceDate.ToString("yyyMMdd"), "{CUSTOMER}");110 invoiceOutputPath = string.Format("{0}_{1}_{2}.txt", invoice.InvoiceId, invoice.InvoiceDate.ToString("yyyMMdd"), customerName); 95 111 96 File.WriteAllText(invoiceOutputPath, invoiceText); 112 //File.WriteAllText(invoiceOutputPath, invoiceText); 113 InvoiceDao.SaveDocument(invoiceOutputPath, invoiceText); 97 114 } else if (invoiceFormat == PlainTextInvoiceFormat.PDF) { 98 115 throw new Exception("PDF invoice format is currently not supported");
Note: See TracChangeset
for help on using the changeset viewer.