2024-03-26 16:57:52 +04:00
|
|
|
|
using FlowerShopBusinessLogic.OfficePackage.HelperEnums;
|
|
|
|
|
using FlowerShopBusinessLogic.OfficePackage.HelperModels;
|
2024-04-04 11:38:58 +04:00
|
|
|
|
using DocumentFormat.OpenXml.Office2010.ExcelAc;
|
2024-03-26 16:57:52 +04:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
|
|
namespace FlowerShopBusinessLogic.OfficePackage
|
|
|
|
|
{
|
|
|
|
|
public abstract class AbstractSaveToWord
|
|
|
|
|
{
|
|
|
|
|
public void CreateDoc(WordInfo info)
|
|
|
|
|
{
|
|
|
|
|
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
|
|
|
|
|
}
|
|
|
|
|
});
|
2024-03-26 22:55:11 +04:00
|
|
|
|
foreach (var flower in info.Flowers)
|
2024-03-26 16:57:52 +04:00
|
|
|
|
{
|
|
|
|
|
CreateParagraph(new WordParagraph
|
|
|
|
|
{
|
2024-03-27 11:50:55 +04:00
|
|
|
|
Texts = new List<(string, WordTextProperties)> { (flower.FlowerName, new WordTextProperties { Size = "24", Bold = true }),
|
|
|
|
|
(" - цена " + flower.Price.ToString(), new WordTextProperties { Size = "24" }) },
|
2024-03-26 16:57:52 +04:00
|
|
|
|
TextProperties = new WordTextProperties
|
|
|
|
|
{
|
|
|
|
|
Size = "24",
|
|
|
|
|
JustificationType = WordJustificationType.Both
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
SaveWord(info);
|
|
|
|
|
}
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Создание doc-файла
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="info"></param>
|
|
|
|
|
protected abstract void CreateWord(WordInfo info);
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Создание абзаца с текстом
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="paragraph"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
protected abstract void CreateParagraph(WordParagraph paragraph);
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Сохранение файла
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="info"></param>
|
|
|
|
|
protected abstract void SaveWord(WordInfo info);
|
2024-04-04 11:38:58 +04:00
|
|
|
|
protected abstract void CreateTable(WordTable table);
|
|
|
|
|
|
|
|
|
|
public void CreateTableDoc(WordInfo info)
|
|
|
|
|
{
|
|
|
|
|
CreateWord(info);
|
|
|
|
|
List<List<string>> list = new List<List<string>>();
|
|
|
|
|
foreach (var shop in info.Shops)
|
|
|
|
|
{
|
|
|
|
|
var ls = new List<string>
|
|
|
|
|
{
|
|
|
|
|
shop.ShopName,
|
|
|
|
|
shop.Address,
|
|
|
|
|
shop.DateOpen.ToShortDateString()
|
|
|
|
|
};
|
|
|
|
|
list.Add(ls);
|
|
|
|
|
}
|
|
|
|
|
var wordTable = new WordTable
|
|
|
|
|
{
|
|
|
|
|
Headers = new List<string> {
|
|
|
|
|
"Название",
|
|
|
|
|
"Адрес",
|
|
|
|
|
"Дата открытия"},
|
|
|
|
|
Columns = 3,
|
|
|
|
|
RowText = list
|
|
|
|
|
};
|
|
|
|
|
CreateTable(wordTable);
|
|
|
|
|
SaveWord(info);
|
|
|
|
|
}
|
2024-03-26 16:57:52 +04:00
|
|
|
|
}
|
|
|
|
|
}
|