108 lines
3.9 KiB
C#
108 lines
3.9 KiB
C#
using System;
|
||
using System.Collections.Generic;
|
||
using System.Linq;
|
||
using System.Text;
|
||
using System.Threading.Tasks;
|
||
using PrecastConcretePlantBusinessLogic.OfficePackage.HelperEnums;
|
||
using PrecastConcretePlantBusinessLogic.OfficePackage.HelperModels;
|
||
|
||
namespace PrecastConcretePlantBusinessLogic.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
|
||
}
|
||
});
|
||
|
||
foreach (var reinforced in info.Reinforceds)
|
||
{
|
||
CreateParagraph(new WordParagraph
|
||
{
|
||
Texts = new List<(string, WordTextProperties)> {(reinforced.ReinforcedName + " - ", new WordTextProperties { Size = "24", Bold = true}),
|
||
(reinforced.Price.ToString(), new WordTextProperties { Size = "24", })},
|
||
TextProperties = new WordTextProperties
|
||
{
|
||
Size = "24",
|
||
JustificationType = WordJustificationType.Both
|
||
}
|
||
});
|
||
}
|
||
|
||
SaveWord(info);
|
||
}
|
||
|
||
public void CreateShopsTable(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
|
||
}
|
||
});
|
||
|
||
CreateTable(new List<string> { "3000", "3000", "3000" });
|
||
|
||
CreateRow(new WordParagraph
|
||
{
|
||
Texts = new List<(string, WordTextProperties)> { ("Название магазина", new WordTextProperties { Size = "24" }),
|
||
("Адрес", new WordTextProperties { Size = "24" }), ("Дата открытия", new WordTextProperties { Size = "24" }) },
|
||
TextProperties = new WordTextProperties
|
||
{
|
||
Size = "24",
|
||
Bold = true,
|
||
JustificationType = WordJustificationType.Center
|
||
}
|
||
});
|
||
|
||
foreach (var shop in info.Shops)
|
||
{
|
||
CreateRow(new WordParagraph
|
||
{
|
||
Texts = new List<(string, WordTextProperties)> { (shop.ShopName, new WordTextProperties { Size = "22" }),
|
||
(shop.Address, new WordTextProperties { Size = "22" }), (shop.DateOpening.ToString(), new WordTextProperties { Size = "22" })},
|
||
TextProperties = new WordTextProperties
|
||
{
|
||
Size = "22",
|
||
JustificationType = WordJustificationType.Center
|
||
}
|
||
});
|
||
}
|
||
|
||
SaveWord(info);
|
||
}
|
||
|
||
|
||
// Создание doc-файла
|
||
protected abstract void CreateWord(WordInfo info);
|
||
|
||
|
||
// Создание абзаца с текстом
|
||
protected abstract void CreateParagraph(WordParagraph paragraph);
|
||
|
||
// Создание таблицы
|
||
protected abstract void CreateTable(List<string> columns);
|
||
|
||
// Создание строки таблицы
|
||
protected abstract void CreateRow(WordParagraph paragraph);
|
||
|
||
//Сохранение файла
|
||
protected abstract void SaveWord(WordInfo info);
|
||
|
||
}
|
||
}
|