2024-05-22 10:14:48 +04:00
|
|
|
|
using FurnitureAssemblyBusinessLogic.OfficePackage.HelperEnums;
|
|
|
|
|
using FurnitureAssemblyBusinessLogic.OfficePackage.HelperModels;
|
|
|
|
|
using System;
|
2024-05-08 01:03:49 +04:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
|
|
namespace FurnitureAssemblyBusinessLogic.OfficePackage
|
|
|
|
|
{
|
|
|
|
|
public abstract class AbstractSaveToPdf
|
|
|
|
|
{
|
2024-05-22 10:14:48 +04:00
|
|
|
|
// Публичный метод создания документа. Описание методов ниже
|
2024-05-08 01:03:49 +04:00
|
|
|
|
public void CreateDoc(PdfInfo 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" });
|
|
|
|
|
|
|
|
|
|
CreateRow(new PdfRowParameters
|
|
|
|
|
{
|
|
|
|
|
Texts = new List<string> { "Номер", "Дата заказа", "Изделие", "Сумма", "Статус заказа" },
|
|
|
|
|
Style = "NormalTitle",
|
|
|
|
|
ParagraphAlignment = PdfParagraphAlignmentType.Center
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
foreach (var order in info.Orders)
|
|
|
|
|
{
|
|
|
|
|
CreateRow(new PdfRowParameters
|
|
|
|
|
{
|
|
|
|
|
Texts = new List<string> { order.Id.ToString(), order.DateCreate.ToShortDateString(), order.FurnitureName, order.Sum.ToString(), order.OrderStatus },
|
|
|
|
|
Style = "Normal",
|
|
|
|
|
ParagraphAlignment = PdfParagraphAlignmentType.Left
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CreateParagraph(new PdfParagraph
|
|
|
|
|
{
|
|
|
|
|
Text = $"\nИтого: {info.Orders.Sum(x => x.Sum)}\t",
|
|
|
|
|
Style = "Normal",
|
|
|
|
|
ParagraphAlignment = PdfParagraphAlignmentType.Right
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
SavePdf(info);
|
|
|
|
|
}
|
2024-05-22 10:14:48 +04:00
|
|
|
|
|
|
|
|
|
/// Создание Pdf-файла
|
2024-05-08 01:03:49 +04:00
|
|
|
|
protected abstract void CreatePdf(PdfInfo info);
|
2024-05-22 10:14:48 +04:00
|
|
|
|
|
|
|
|
|
/// Создание параграфа с текстом
|
2024-05-08 01:03:49 +04:00
|
|
|
|
protected abstract void CreateParagraph(PdfParagraph paragraph);
|
2024-05-22 10:14:48 +04:00
|
|
|
|
|
|
|
|
|
/// Создание таблицы
|
2024-05-08 01:03:49 +04:00
|
|
|
|
protected abstract void CreateTable(List<string> columns);
|
2024-05-22 10:14:48 +04:00
|
|
|
|
|
|
|
|
|
/// Создание и заполнение строки
|
2024-05-08 01:03:49 +04:00
|
|
|
|
protected abstract void CreateRow(PdfRowParameters rowParameters);
|
|
|
|
|
|
2024-05-22 10:14:48 +04:00
|
|
|
|
/// Сохранение файла
|
|
|
|
|
protected abstract void SavePdf(PdfInfo info);
|
2024-05-08 01:03:49 +04:00
|
|
|
|
}
|
|
|
|
|
}
|