Coursach/Course/BusinessLogic/OfficePackage/AbstractSaveToPdfGuarantor.cs

56 lines
1.7 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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 AbstractSaveToPdfGuarantor
{
public void CreateDoc(PdfInfoGuarantor 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.WorkshopName, "" },
Style = "Normal",
ParagraphAlignment = PdfParagraphAlignmentType.Left
});
foreach (var machine in report.Machines)
CreateRow(new PdfRowParameters
{
Texts = new List<string> { "", machine },
Style = "Normal",
ParagraphAlignment = PdfParagraphAlignmentType.Left
});
}
SavePdf(info);
}
protected abstract void CreatePdf(PdfInfoGuarantor info);
protected abstract void CreateParagraph(PdfParagraph paragraph);
protected abstract void CreateTable(List<string> columns);
protected abstract void CreateRow(PdfRowParameters rowParameters);
protected abstract void SavePdf(PdfInfoGuarantor info);
}
}