public PrintController(IOrdersManager manager, IInvoicesManager invoicesManager, IInvoiceStornosManager invoiceStornosManager, ITaxesManager taxesManager, ITransportOrdersManager transportOrdersManager, IPrinterManager printerManager, ITermsManager termsManager) : base() { this.taxesManager = taxesManager; this.invoicesManager = invoicesManager; this.invoiceStornosManager = invoiceStornosManager; this.transportOrdersManager = transportOrdersManager; this.printerManager = printerManager; this.termsManager = termsManager; Manager = manager; FilterExpressionCreator = new FilterExpressionCreator(); }
public TransportOffersController(ITransportOrdersManager manager, ICustomersManager customerManager, IUniqueNumberProvider numberProvider) { this.manager = manager; this.customerManager = customerManager; this.numberProvider = numberProvider; }
private string ReplaceFields(IOrdersManager ordersManager, int id, PrintTypes printType, string xmlMainXMLDoc, IInvoicesManager invoicesManager, ITaxesManager taxesManager, Invoices invoice = null, IInvoiceStornosManager invoiceStornosManager = null, ITransportOrdersManager transportOrdersManager = null, ITermsManager termsManager = null, IEnumerable<Image> images = null) { string result = xmlMainXMLDoc; switch (printType) { case PrintTypes.Order: var order = ordersManager.GetById(id); result = ReplaceCommonFields(order, result); result = ReplaceBaseOrderFields(order, result); result = result.Replace("#SignatureDate", order.CreateDate.AddDays(2).ToShortDateString()); result = ReplaceRentPositions(order, result, taxesManager); result = ReplaceTotalPrice(order, result, taxesManager); result = ReplaceRentAdditionalCostPositions(order, result); break; case PrintTypes.Offer: order = ordersManager.GetById(id); result = ReplaceCommonFields(order, result); result = ReplaceBaseOfferFields(order, result); result = ReplaceBaseOrderFields(order, result); result = ReplaceRentPositions(order, result, taxesManager); result = ReplaceRentAdditionalCostPositions(order, result); break; case PrintTypes.Invoice: if (invoice == null) { invoice = invoicesManager.GetById(id); } order = invoice.Orders; result = ReplaceCommonFields(order, result); result = ReplaceBaseOrderFields(order, result); result = ReplaceBaseInvoiceFields(invoice, result, printType); bool manualPricePrinted = false; result = ReplaceInvoicePositions(invoice, invoice.InvoicePositions.ToList(), result, "#PositionDescription", "#PositionPrice", "Leistungen: ", ref manualPricePrinted); result = ReplaceInvoicePrices(invoice, result); break; case PrintTypes.InvoiceStorno: var invoiceStorno = invoiceStornosManager.GetById(id); invoice = invoiceStorno.Invoices; order = invoice.Orders; result = ReplaceCommonFields(order, result); result = ReplaceBaseOrderFields(order, result); result = ReplaceBaseInvoiceFields(invoice, result, printType); result = ReplaceInvoiceStornoPrices(invoiceStorno, result); result = ReplaceFieldValue(result, "#FreeText", invoiceStorno.FreeText); break; case PrintTypes.ReminderMail: invoice = invoicesManager.GetById(id); order = invoice.Orders; result = ReplaceCommonFields(order, result); result = ReplaceReminderPositions(invoice.InvoicePositions.ToList(), result); result = ReplaceReminderTotalPrice(invoice, result, taxesManager); break; case PrintTypes.DeliveryNote: var term = termsManager.GetById(id); result = ReplaceCommonFields(term.Orders, result); result = ReplaceBaseOrderFields(term.Orders, result); result = result.Replace("#DeliveryNoteType", "Lieferschein"); result = result.Replace("#DateType", "Liefertermin"); result = result.Replace("#AdressType", "Lieferanschrift"); result = result.Replace("#OrderNumber", term.Orders.OrderNumber); result = ReplacePositionWithDescription(term, result); if (term.DeliveryNoteSignatures.Count != 0) { var doc = XDocument.Parse(result); var signatureElement = doc.Descendants().FirstOrDefault(o => o.Value.Equals("#Signature", StringComparison.InvariantCultureIgnoreCase)); if (signatureElement != null && images != null && images.Count() != 0) { var currentElement = signatureElement; for (var i = 0; i < images.Count(); i++) { var image = images.ElementAt(images.Count() - i - 1); //TODO doesnt work (( //pkg.CreateRelationship(uri, TargetMode.Internal, // "Http://schemas.openxmlformats.org/officeDocument/2006/relationships/image", // "barcodeImageId"); //insert image XmlElement tagDrawing = GetImageTag(image.Width, image.Height, term.DeliveryNoteSignatures.Count - i); signatureElement.AddAfterSelf(XDocument.Parse(tagDrawing.InnerXml).Root); } signatureElement.Remove(); result = doc.Root.ToString(); } else { result = result.Replace("#Signature", String.Empty); } } else { result = result.Replace("#Signature", String.Empty); } break; default: throw new NotImplementedException(); } return result; }
private MemoryStream PrepareCommonOrderPrintData(IOrdersManager ordersManager, int id, string path, PrintTypes type, IInvoicesManager invoicesManager, ITaxesManager taxesManager, IInvoiceStornosManager invoiceStornosManager = null, ITransportOrdersManager transportOrdersManager = null, ITermsManager termsManager = null) { var result = new MemoryStream(); try { Package pkg; PackagePart part; XmlReader xmlReader; XDocument xmlMainXMLDoc; GetXmlDoc(path, result, out pkg, out part, out xmlReader, out xmlMainXMLDoc); var images = new List<Image>(); if (type == PrintTypes.DeliveryNote) { var term = termsManager.GetById(id); for (var i = 0; i < term.DeliveryNoteSignatures.Count; i++) { var deliveryNoteSignature = term.DeliveryNoteSignatures.ElementAt(term.DeliveryNoteSignatures.Count - i - 1); //TODO doesnt work (( //pkg.CreateRelationship(uri, TargetMode.Internal, // "Http://schemas.openxmlformats.org/officeDocument/2006/relationships/image", // "barcodeImageId"); byte[] bytes = Convert.FromBase64String(deliveryNoteSignature.Signature.Replace("data:image/png;base64,", "")); Image image; using (MemoryStream ms = new MemoryStream(bytes)) { image = Image.FromStream(ms); } images.Add(image); } } //replace fields var templateBody = ReplaceFields(ordersManager, id, type, xmlMainXMLDoc.Root.ToString(), invoicesManager, taxesManager, null, invoiceStornosManager, transportOrdersManager, termsManager, images); xmlMainXMLDoc = SaveDoc(result, pkg, part, xmlReader, xmlMainXMLDoc, templateBody); InsertImages(result, images); var doc = new Spire.Doc.Document(); doc.LoadFromStream(result, Spire.Doc.FileFormat.Docx); doc.JPEGQuality = 100; result = new MemoryStream(); doc.SaveToStream(result, Spire.Doc.FileFormat.PDF); } catch { } return result; }
public CloseTransportOrderController(ITransportOrdersManager manager) { this.manager = manager; }