Coursach/Course/BusinessLogic/OfficePackage/AbstractSaveToPdfImplementer.cs

69 lines
2.8 KiB
C#
Raw Normal View History

2024-05-28 19:21:01 +04:00
using BusinessLogic.OfficePackage.HelperEnums;
using BusinessLogic.OfficePackage.HelperModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BusinessLogic.OfficePackage
{
public abstract class AbstractSaveToPdfImplementer
{
public void CreateDoc(PdfInfoImplementer 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> { "5cm", "10cm" });
foreach (var report in info.Reports)
{
CreateRow(new PdfRowParameters
{
Texts = new List<string> { "Деталь", "Изделие" },
Style = "NormalTitle",
ParagraphAlignment = PdfParagraphAlignmentType.Center
});
CreateRow(new PdfRowParameters
{
Texts = new List<string> { report.DetailName, "" },
Style = "Normal",
ParagraphAlignment = PdfParagraphAlignmentType.Left
});
foreach (var product in report.Products)
CreateRow(new PdfRowParameters
{
Texts = new List<string> {"", product },
Style = "Normal",
ParagraphAlignment = PdfParagraphAlignmentType.Left
});
CreateRow(new PdfRowParameters
{
Texts = new List<string> { "", "Производство" },
Style = "NormalTitle",
ParagraphAlignment = PdfParagraphAlignmentType.Center
});
foreach (var production in report.Productions)
CreateRow(new PdfRowParameters
{
Texts = new List<string> { "", production },
Style = "Normal",
ParagraphAlignment = PdfParagraphAlignmentType.Left
});
}
SavePdf(info);
}
protected abstract void CreatePdf(PdfInfoImplementer info);
protected abstract void CreateParagraph(PdfParagraph paragraph);
protected abstract void CreateTable(List<string> columns);
protected abstract void CreateRow(PdfRowParameters rowParameters);
protected abstract void SavePdf(PdfInfoImplementer info);
}
}