CourseWork_CompShop/ComputerShopProvider/ComputerShopBusinessLogic/OfficePackage/AbstractSaveToPdf.cs

55 lines
2.4 KiB
C#
Raw Normal View History

2023-05-24 20:22:06 +04:00
using ComputerShopBusinessLogic.OfficePackage.HelperEnums;
using ComputerShopBusinessLogic.OfficePackage.HelperModels;
2023-05-25 09:17:38 +04:00
using ComputerShopDataModels.Enums;
using DocumentFormat.OpenXml.Bibliography;
2023-05-24 20:22:06 +04:00
using System;
2023-04-09 16:55:38 +04:00
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ComputerShopBusinessLogic.OfficePackage
{
2023-05-24 20:22:06 +04:00
public abstract class AbstractSaveToPdf
2023-04-09 16:55:38 +04:00
{
2023-05-24 20:22:06 +04:00
public void CreateDoc(PdfInfoProvider info)
{
CreatePdf(info);
CreateParagraph(new PdfParagraph
{
Text = info.Title,
Style = "NormalTitle",
ParagraphAlignment = PdfParagraphAlignmentType.Center
});
CreateParagraph(new PdfParagraph
{
2023-05-24 21:14:10 +04:00
Text = $"с {info.DateFrom.ToString()} по {info.DateTo.ToString()}",
2023-05-24 20:22:06 +04:00
Style = "Normal",
ParagraphAlignment = PdfParagraphAlignmentType.Center
});
CreateTable(new List<string> { "4cm", "5cm", "3cm", "4cm", "2cm" });
CreateRow(new PdfRowParameters
{
Texts = new List<string> { "ID закупки", "Название компонента", "Дата создания закупки", "Дата создания поставки", "Статус поставки" },
Style = "NormalTitle",
ParagraphAlignment = PdfParagraphAlignmentType.Center
});
foreach (var supplyPurchase in info.SupplyPurchases)
{
CreateRow(new PdfRowParameters
{
2023-05-25 09:17:38 +04:00
Texts = new List<string> { supplyPurchase.Purchase.Id.ToString(), supplyPurchase.Purchase.ComponentName, supplyPurchase.Purchase.DateCreate.ToString(), supplyPurchase.Supply.DateCreate.ToString(), Enum.GetName(typeof(SupplyStatus), supplyPurchase.Supply.Status) },
2023-05-24 20:22:06 +04:00
Style = "Normal",
ParagraphAlignment = PdfParagraphAlignmentType.Left
});
}
SavePdf(info);
}
protected abstract void CreatePdf(PdfInfoProvider info);
protected abstract void CreateParagraph(PdfParagraph paragraph);
protected abstract void CreateTable(List<string> columns);
protected abstract void CreateRow(PdfRowParameters rowParameters);
protected abstract void SavePdf(PdfInfoProvider info);
2023-04-09 16:55:38 +04:00
}
}