2023-03-01 16:42:58 +04:00
|
|
|
|
using ConfectioneryBusinessLogic.OfficePackage.HelperEnums;
|
|
|
|
|
using ConfectioneryBusinessLogic.OfficePackage.HelperModels;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
|
|
namespace ConfectioneryBusinessLogic.OfficePackage
|
|
|
|
|
{
|
|
|
|
|
public abstract class AbstractSaveToWord
|
|
|
|
|
{
|
2023-03-08 16:05:07 +04:00
|
|
|
|
public void CreateDocTable(WordInfoTable info)
|
2023-03-01 16:42:58 +04:00
|
|
|
|
{
|
|
|
|
|
CreateWord(info);
|
|
|
|
|
|
|
|
|
|
CreateParagraph(new WordParagraph
|
|
|
|
|
{
|
|
|
|
|
Texts = new List<(string, WordTextProperties)> { (info.Title, new WordTextProperties { Bold = true, Size = "24", }) },
|
|
|
|
|
TextProperties = new WordTextProperties
|
|
|
|
|
{
|
|
|
|
|
Size = "24",
|
|
|
|
|
JustificationType = WordJustificationType.Center
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
2023-03-02 02:49:25 +04:00
|
|
|
|
CreateTable(new()
|
2023-03-01 16:42:58 +04:00
|
|
|
|
{
|
2023-03-02 02:49:25 +04:00
|
|
|
|
("Название", 3000),
|
|
|
|
|
("Дата", null),
|
|
|
|
|
("Адрес открытия", 4500),
|
|
|
|
|
},
|
|
|
|
|
info.Shops
|
|
|
|
|
.Select(x => new List<string>
|
|
|
|
|
{
|
|
|
|
|
x.Name,
|
|
|
|
|
Convert.ToString(x.DateOpening),
|
|
|
|
|
x.Address,
|
|
|
|
|
})
|
|
|
|
|
.ToList());
|
2023-03-01 16:42:58 +04:00
|
|
|
|
|
|
|
|
|
SaveWord(info);
|
|
|
|
|
}
|
|
|
|
|
|
2023-03-08 16:05:07 +04:00
|
|
|
|
public void CreateDoc(WordInfo info)
|
|
|
|
|
{
|
|
|
|
|
CreateWord(new() { FileName = info.FileName });
|
|
|
|
|
|
|
|
|
|
CreateParagraph(new WordParagraph
|
|
|
|
|
{
|
|
|
|
|
Texts = new List<(string, WordTextProperties)> { (info.Title, new WordTextProperties { Bold = true, Size = "24", }) },
|
|
|
|
|
TextProperties = new WordTextProperties
|
|
|
|
|
{
|
|
|
|
|
Size = "24",
|
|
|
|
|
JustificationType = WordJustificationType.Center
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
foreach (var pastry in info.Pastries)
|
|
|
|
|
{
|
|
|
|
|
CreateParagraph(new WordParagraph
|
|
|
|
|
{
|
|
|
|
|
Texts = new List<(string, WordTextProperties)>
|
|
|
|
|
{
|
|
|
|
|
(pastry.PastryName , new WordTextProperties { Size = "24", Bold = true}),
|
|
|
|
|
(" - цена: " + pastry.Price.ToString(), new WordTextProperties { Size = "24" })
|
|
|
|
|
},
|
|
|
|
|
TextProperties = new WordTextProperties
|
|
|
|
|
{
|
|
|
|
|
Size = "24",
|
|
|
|
|
JustificationType = WordJustificationType.Both
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SaveWord(new());
|
|
|
|
|
}
|
|
|
|
|
|
2023-03-01 16:42:58 +04:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Создание doc-файла
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="info"></param>
|
2023-03-08 16:05:07 +04:00
|
|
|
|
protected abstract void CreateWord(WordInfoTable info);
|
2023-03-01 16:42:58 +04:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Создание абзаца с текстом
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="paragraph"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
protected abstract void CreateParagraph(WordParagraph paragraph);
|
|
|
|
|
|
2023-03-02 02:49:25 +04:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Создание таблицы в файле
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="nameAndWidthColumns">Строчка заголовок таблицы, определяет текст и ширину каждого столбца</param>
|
|
|
|
|
/// <param name="rows">The rows.</param>
|
|
|
|
|
protected abstract void CreateTable(List<(string, int?)> nameAndWidthColumns, List<List<string>> rows);
|
|
|
|
|
|
2023-03-01 16:42:58 +04:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Сохранение файла
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="info"></param>
|
2023-03-08 16:05:07 +04:00
|
|
|
|
protected abstract void SaveWord(WordInfoTable info);
|
2023-03-01 16:42:58 +04:00
|
|
|
|
}
|
|
|
|
|
}
|