89 lines
3.0 KiB
C#
89 lines
3.0 KiB
C#
using LawFirmBusinessLogic.OfficePackages.HelperEnums;
|
||
using LawFirmBusinessLogic.OfficePackages.HelperModels;
|
||
|
||
namespace LawFirmBusinessLogic.OfficePackages
|
||
{
|
||
public abstract class AbstractSaveToPdfClients
|
||
{
|
||
public void CreateDoc(PDFClientsInfo 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" });
|
||
CreateRow(new PdfRowParameters
|
||
{
|
||
Texts = new List<string> { "Номер", "Имя клиента", "Дело", "Дата визита" },
|
||
Style = "NormalTitle",
|
||
ParagraphAlignment = PdfParagraphAlignmentType.Center
|
||
});
|
||
foreach (var client in info.Clients)
|
||
{
|
||
CreateRow(new PdfRowParameters
|
||
{
|
||
Texts = new List<string> { client.FIO, " ", " " },
|
||
Style = "Normal",
|
||
ParagraphAlignment = PdfParagraphAlignmentType.Center
|
||
});
|
||
foreach(var cas in client.CaseName)
|
||
{
|
||
CreateRow(new PdfRowParameters
|
||
{
|
||
Texts = new List<string> { " ", cas, " " },
|
||
Style = "Normal",
|
||
ParagraphAlignment = PdfParagraphAlignmentType.Center
|
||
});
|
||
}
|
||
foreach (var vis in client.VisitDate)
|
||
{
|
||
CreateRow(new PdfRowParameters
|
||
{
|
||
Texts = new List<string> { " ", " ", vis.ToShortDateString() },
|
||
Style = "Normal",
|
||
ParagraphAlignment = PdfParagraphAlignmentType.Center
|
||
});
|
||
}
|
||
}
|
||
|
||
SavePdf(info);
|
||
}
|
||
/// <summary>
|
||
/// Создание doc-файла
|
||
/// </summary>
|
||
/// <param name="info"></param>
|
||
protected abstract void CreatePdf(PDFClientsInfo 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(PDFClientsInfo info);
|
||
}
|
||
}
|