This commit is contained in:
Artyom_Yashin 2024-05-26 16:24:27 +04:00
parent 611652dfd0
commit ad94885dad
3 changed files with 51 additions and 35 deletions

View File

@ -76,7 +76,7 @@ namespace BankBusinessLogic.BusinessLogic
public void SaveTransfersToWordFile(ReportBindingModel model)
{
_saveToWord.CreateDoc(new WordInfo
_saveToWord.CreateTransfersDoc(new WordInfo
{
FileName = model.FileName,
Title = "Список переводов",

View File

@ -11,39 +11,37 @@ namespace BankBusinessLogic.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 transfer in info.Transfers)
{
CreateParagraph(new WordParagraph
{
Texts = new List<(string, WordTextProperties)> { (transfer.CardNumber, new WordTextProperties { Size = "24", Bold = true}),
(" - цена " + transfer.Transfers.ToString(), new WordTextProperties { Size = "24"})
},
TextProperties = new WordTextProperties
{
Size = "24",
JustificationType = WordJustificationType.Both,
}
});
}
SaveWord(info);
}
/// <summary>
/// Создание doc-файла
/// </summary>
/// <param name="info"></param>
protected abstract void CreateWord(WordInfo info);
public void CreateTransfersDoc(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);
}
/// <summary>
/// Создание doc-файла
/// </summary>
/// <param name="info"></param>
protected abstract void CreateWord(WordInfo info);
/// <summary>
/// Создание абзаца с текстом
/// </summary>
@ -55,5 +53,8 @@ namespace BankBusinessLogic.OfficePackage
/// </summary>
/// <param name="info"></param>
protected abstract void SaveWord(WordInfo info);
}
protected abstract void CreateTable(WordTable table);
}
}

View File

@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BankBusinessLogic.OfficePackage.HelperModels
{
public class WordTable
{
public List<string> Headers { get; set; } = new();
public List<List<string>> RowText { get; set; } = new();
public int Columns { get; set; }
}
}