CourseWork_SchoolStudyAgain/SchoolAgainStudy/SchoolAgainStudyBusinessLogic/OfficePackage/AbstractSaveToPdfTeacher.cs
2023-04-07 14:25:31 +04:00

75 lines
2.8 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using SchoolAgainStudyBusinessLogic.OfficePackage.HelperEnums;
using SchoolAgainStudyBusinessLogic.OfficePackage.HelperModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SchoolAgainStudyBusinessLogic.OfficePackage
{
public abstract class AbstractSaveToPdfTeacher
{
public void CreateDoc(PdfInfoTeacher 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<string> { "2cm", "4cm", "6cm", "4cm", "6cm" });
CreateRow(new PdfRowParameters
{
Texts = new List<string> { "Номер","Занятие", "Дата занятия", "Задание", "Дата выдачи задания" },
Style = "NormalTitle",
ParagraphAlignment = PdfParagraphAlignmentType.Center
});
foreach (var taskLesson in info.LessonTasks)
{
CreateRow(new PdfRowParameters
{
Texts = new List<string> { taskLesson.Id.ToString(), taskLesson.TitleLesson, taskLesson.DateEventLesson.ToShortDateString(), taskLesson.TitleTask, taskLesson.DateIssueTask.ToShortDateString()},
Style = "Normal",
ParagraphAlignment = PdfParagraphAlignmentType.Left
});
}
SavePdf(info);
}
/// <summary>
/// Создание doc-файла
/// </summary>
/// <param name="info"></param>
protected abstract void CreatePdf(PdfInfoTeacher info);
/// <summary>
/// Создание параграфа с текстом
/// </summary>
/// <param name="title"></param>
/// <param name="style"></param>
protected abstract void CreateParagraph(PdfParagraph paragraph);
/// <summary>
/// Создание таблицы
/// </summary>
/// <param name="title"></param>
/// <param name="style"></param>
protected abstract void CreateTable(List<string> columns);
/// <summary>
/// Создание и заполнение строки
/// </summary>
/// <param name="rowParameters"></param>
protected abstract void CreateRow(PdfRowParameters rowParameters);
/// <summary>
/// Сохранение файла
/// </summary>
/// <param name="info"></param>
protected abstract void SavePdf(PdfInfoTeacher info);
}
}