2023-04-07 14:25:31 +04:00
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 AbstractSaveToPdfStudent
{
public void CreateDoc ( PdfInfoStudent 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" , "3cm" , "6cm" , "3cm" , "3cm" , "6cm" , "6cm" } ) ;
CreateRow ( new PdfRowParameters
{
2023-04-07 20:23:14 +04:00
Texts = new List < string > { "Интерес" , "Изделие" , "Дата" , "Поделка" , "Дата" } ,
2023-04-07 14:25:31 +04:00
Style = "NormalTitle" ,
ParagraphAlignment = PdfParagraphAlignmentType . Center
} ) ;
foreach ( var interest in info . Interests )
{
CreateRow ( new PdfRowParameters
{
2023-04-07 20:23:14 +04:00
Texts = new List < string > { interest . InterestTitle , interest . ProductTitle , interest . DateCreateProduct . ToShortDateString ( ) , interest . DiyTitle , interest . DateCreateDiy . ToShortDateString ( ) } ,
2023-04-07 14:25:31 +04:00
Style = "Normal" ,
ParagraphAlignment = PdfParagraphAlignmentType . Left
} ) ;
}
SavePdf ( info ) ;
}
/// <summary>
/// Создание doc-файла
/// </summary>
/// <param name="info"></param>
protected abstract void CreatePdf ( PdfInfoStudent 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 ( PdfInfoStudent info ) ;
}
}