using LawFirmBusinessLogic.OfficePackages.HelperEnums; using LawFirmBusinessLogic.OfficePackages.HelperModels; namespace LawFirmBusinessLogic.OfficePackages { public abstract class AbstractSaveToPdfCaseHearing { public void CreateDoc(PDFCaseHearingInfo 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 { "3cm", "5cm", "5cm" }); CreateRow(new PdfRowParameters { Texts = new List { "Юрист", "Название дела", "Тип производства" }, Style = "NormalTitle", ParagraphAlignment = PdfParagraphAlignmentType.Center }); foreach (var ch in info.CaseHearing) { CreateRow(new PdfRowParameters { Texts = new List { ch.LawyerName, " ", " " }, Style = "Normal", ParagraphAlignment = PdfParagraphAlignmentType.Center }); foreach (var @case in ch.Case) CreateRow(new PdfRowParameters { Texts = new List { " ", @case.CaseName, @case.CaseType }, Style = "Normal", ParagraphAlignment = PdfParagraphAlignmentType.Center }); CreateRow(new PdfRowParameters { Texts = new List { " ", " ", "Итого: " + ch.Case.Count.ToString() }, Style = "Normal", ParagraphAlignment = PdfParagraphAlignmentType.Rigth }); } CreateTable(new List { "3cm", "5cm", "5cm" }); CreateRow(new PdfRowParameters { Texts = new List { "Юрист", "Суд", "Дата слушания" }, Style = "NormalTitle", ParagraphAlignment = PdfParagraphAlignmentType.Center }); foreach (var ch in info.CaseHearing) { CreateRow(new PdfRowParameters { Texts = new List { ch.LawyerName, " ", " " }, Style = "Normal", ParagraphAlignment = PdfParagraphAlignmentType.Center }); foreach (var hear in ch.Hearing) CreateRow(new PdfRowParameters { Texts = new List { " ", hear.Judge, hear.HearingDate.ToShortDateString() }, Style = "Normal", ParagraphAlignment = PdfParagraphAlignmentType.Left }); CreateRow(new PdfRowParameters { Texts = new List { " ", " ", "Итого: " + ch.Hearing.Count.ToString() }, Style = "Normal", ParagraphAlignment = PdfParagraphAlignmentType.Rigth }); } SavePdf(info); } /// /// Создание doc-файла /// /// protected abstract void CreatePdf(PDFCaseHearingInfo info); /// /// Создание параграфа с текстом /// /// /// protected abstract void CreateParagraph(PdfParagraph paragraph); /// /// Создание таблицы /// /// /// protected abstract void CreateTable(List columns); /// /// Создание и заполнение строки /// /// protected abstract void CreateRow(PdfRowParameters rowParameters); /// /// Сохранение файла /// /// protected abstract void SavePdf(PDFCaseHearingInfo info); } }