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 AbstractSaveToWord
|
|
|
|
|
{
|
2024-05-22 10:14:48 +04:00
|
|
|
|
// Метод создания документа
|
2024-05-08 01:03:49 +04:00
|
|
|
|
public void CreateDoc(WordInfo info)
|
|
|
|
|
{
|
|
|
|
|
CreateWord(info);
|
|
|
|
|
|
2024-05-22 10:14:48 +04:00
|
|
|
|
// Создание ряда абзацев
|
2024-05-08 01:03:49 +04:00
|
|
|
|
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-05-22 10:14:48 +04:00
|
|
|
|
// Заполнение абзацев текстом
|
2024-05-08 01:03:49 +04:00
|
|
|
|
foreach (var furniture in info.Furnitures)
|
|
|
|
|
{
|
|
|
|
|
CreateParagraph(new WordParagraph
|
|
|
|
|
{
|
|
|
|
|
Texts = new List<(string, WordTextProperties)> { (furniture.FurnitureName + " ", new WordTextProperties { Bold = true, Size = "24", }),
|
|
|
|
|
(furniture.Price.ToString(), new WordTextProperties { Size = "24" }) },
|
|
|
|
|
TextProperties = new WordTextProperties
|
|
|
|
|
{
|
|
|
|
|
Size = "24",
|
|
|
|
|
JustificationType = WordJustificationType.Both
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SaveWord(info);
|
|
|
|
|
}
|
|
|
|
|
|
2024-05-22 10:14:48 +04:00
|
|
|
|
// Создание Doc-файла
|
2024-05-08 01:03:49 +04:00
|
|
|
|
protected abstract void CreateWord(WordInfo info);
|
2024-05-22 10:14:48 +04:00
|
|
|
|
|
|
|
|
|
// Создание абзаца с текстом
|
2024-05-08 01:03:49 +04:00
|
|
|
|
protected abstract void CreateParagraph(WordParagraph paragraph);
|
|
|
|
|
|
2024-05-22 10:14:48 +04:00
|
|
|
|
// Сохранение файла
|
|
|
|
|
protected abstract void SaveWord(WordInfo info);
|
2024-05-08 01:03:49 +04:00
|
|
|
|
}
|
|
|
|
|
}
|