using BusinessLogic.OfficePackage.HelperEnums; using BusinessLogic.OfficePackage.HelperModels; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace BusinessLogic.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 { "5cm", "10cm" }); foreach (var report in info.Reports) { CreateRow(new PdfRowParameters { Texts = new List { "Деталь", "Изделие" }, Style = "NormalTitle", ParagraphAlignment = PdfParagraphAlignmentType.Center }); CreateRow(new PdfRowParameters { Texts = new List { report.DetailName, "" }, Style = "Normal", ParagraphAlignment = PdfParagraphAlignmentType.Left }); foreach (var product in report.Products) CreateRow(new PdfRowParameters { Texts = new List {"", product }, Style = "Normal", ParagraphAlignment = PdfParagraphAlignmentType.Left }); CreateRow(new PdfRowParameters { Texts = new List { "", "Производство" }, Style = "NormalTitle", ParagraphAlignment = PdfParagraphAlignmentType.Center }); foreach (var production in report.Productions) CreateRow(new PdfRowParameters { Texts = new List { "", production }, Style = "Normal", ParagraphAlignment = PdfParagraphAlignmentType.Left }); } 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); } }