using UniversityBusinessLogic.OfficePackage.HelperEnums; using UniversityBusinessLogic.OfficePackage.HelperModels; namespace UniversityBusinessLogic.OfficePackage { public abstract class AbstractSaveToPdfWorker { public void CreateDoc(PdfInfoWorker info) { CreatePdf(info); CreateParagraph(new PdfParagraph { Text = info.Title, Style = "NormalTitle", ParagraphAlignment = PdfParagraphAlignmentType.Center }); CreateTable(new List { "4cm", "5cm", "6cm", "5cm", "5 cm" }); CreateRow(new PdfRowParameters { Texts = new List { "Номер", "План обучения", "Студент", "Дисциплина" }, Style = "NormalTitle", ParagraphAlignment = PdfParagraphAlignmentType.Center }); foreach (var item in info.PlanOfStudyAndStudent) { foreach (var studentName in item.StudentName) { var rowTexts = new List { item.Id.ToString(), item.PlanOfStudyName, studentName }; if (item.DisciplineName.Any()) { foreach (var disciplineName in item.DisciplineName) { rowTexts.Add(disciplineName); CreateRow(new PdfRowParameters { Texts = rowTexts, Style = "Normal", ParagraphAlignment = PdfParagraphAlignmentType.Left }); rowTexts.RemoveAt(rowTexts.Count - 1); } } else { // Если нет дисциплин, добавляем пустую строку rowTexts.Add(""); CreateRow(new PdfRowParameters { Texts = rowTexts, Style = "Normal", ParagraphAlignment = PdfParagraphAlignmentType.Left }); } } } SavePdf(info); } /// /// Создание doc-файла /// /// protected abstract void CreatePdf(PdfInfoWorker info); /// /// Создание параграфа с текстом /// /// /// protected abstract void CreateParagraph(PdfParagraph paragraph); /// /// Создание таблицы /// /// /// protected abstract void CreateTable(List columns); /// /// Создание и заполнение строки /// /// protected abstract void CreateRow(PdfRowParameters rowParameters); /// /// Сохранение файла /// /// protected abstract void SavePdf(PdfInfoWorker info); } }