using ComputerShopBusinessLogic.OfficePackage.HelperEnums; using ComputerShopBusinessLogic.OfficePackage.HelperModels; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ComputerShopBusinessLogic.OfficePackage { public abstract class AbstractSaveToPdfImplementer { public void CreateDoc(PdfInfoImplementer info) { CreatePdf(info); CreateParagraph(new PdfParagraph { Text = info.Title, Style = "NormalTitle", ParagraphAlignment = PdfParagraphAlignmentType.Center }); CreateParagraph(new PdfParagraph { Text = $"с {info.DateFrom.ToShortDateString()} по {info.DateTo.ToShortDateString()}", Style = "Normal", ParagraphAlignment = PdfParagraphAlignmentType.Center }); //!!!МБ ТУТ НЕЛЬЗЯ ДРОБНЫЕ ЧИСЛА ИЛИ МОЖНО С ТОЧКОЙ CreateTable(new List { "2cm", "2.5cm", "2cm", "2cm", "2cm", "4cm", "2.5cm", "3.5cm", "3.5cm", "2.5cm" }); CreateRow(new PdfRowParameters { Texts = new List { "ID заказа", "Дата заказа", "Сумма заказа", "Статус заказа", "ID заявки", "ФИО клиента", "Дата заявки", "Название сборки", "Категория сборки", "Цена сборки" }, Style = "NormalTitle", ParagraphAlignment = PdfParagraphAlignmentType.Center }); foreach (var order in info.Orders) { //!!!СЮДА if (order.RequestsAssemblies.Count < 1) { CreateRow(new PdfRowParameters { Texts = new List { order.OrderId.ToString(), order.DateCreateOrder.ToShortDateString(), order.OrderSum.ToString(), order.OrderStatus.ToString(), "Заказ без заявок", "Неизвестно", "Неизвестно", "Неизвестно", "Неизвестно", "0" } }); } foreach (var request in order.RequestsAssemblies) { CreateRow(new PdfRowParameters { Texts = new List { order.OrderId.ToString(), order.DateCreateOrder.ToShortDateString(), order.OrderSum.ToString(), order.OrderStatus.ToString(), request.RequestId.ToString(), request.ClientFIO, request.DateRequest.ToShortDateString(), string.IsNullOrEmpty(request.AssemblyName) ? "Сборка не привязана" : request.AssemblyName, string.IsNullOrEmpty(request.AssemblyCategory) ? "Неизвестно" : request.AssemblyCategory, request.AssemblyPrice.ToString() } //}, //Style = "Normal", //ParagraphAlignment = PdfParagraphAlignmentType.Left }); } } //CreateParagraph(new PdfParagraph { Text = $"Итого: {info.Orders.Sum(x => x.Sum)}\t", Style = "Normal", ParagraphAlignment = PdfParagraphAlignmentType.Rigth }); SavePdf(info); } protected abstract void CreatePdf(PdfInfoImplementer info); protected abstract void CreateParagraph(PdfParagraph paragraph); protected abstract void CreateTable(List columns); protected abstract void CreateRow(PdfRowParameters rowParameters); protected abstract void SavePdf(PdfInfoImplementer info); } }