using BankYouBankruptBusinessLogic.OfficePackage.HelperEnums; using BankYouBankruptBusinessLogic.OfficePackage.HelperModels; using BankYouBankruptDataModels.Enums; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace BankYouBankruptBusinessLogic.OfficePackage { public abstract class AbstractSaveToWord { //метод создания документа public void CreateDoc(WordInfo info, OfficeOperationEnum operationEnum) { if (operationEnum == OfficeOperationEnum.Между_cчетами) { CreateMoneyTransferWord(info); } if (operationEnum == OfficeOperationEnum.Пополнение_карт) { CreateCreditingWord(info); } if (operationEnum == OfficeOperationEnum.Cнятие_с_карты) { CreateDebitingWord(info); } if (operationEnum == OfficeOperationEnum.Для_кассира) { CreateCashierWord(info); } } private void CreateMoneyTransferWord(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.MoneyTransfer) { List> rowList = new() { new() { new("Номер счёта отправителя", new WordTextProperties { Bold = true, Size = "20" } ), new("Номер счёта получателя", new WordTextProperties { Bold = true, Size = "20" } ), new("Сумма операции", new WordTextProperties { Bold = true, Size = "20" } ), new("Дата перевода", new WordTextProperties { Bold = true, Size = "20" } ) } }; CreateParagraph(new WordParagraph { Texts = new List<(string, WordTextProperties)> { ("Перевод №" + transfer.Id.ToString(), new WordTextProperties { Bold = true, Size = "24" }) }, TextProperties = new WordTextProperties { Size = "24", JustificationType = WordJustificationType.Center } }); List<(string, WordTextProperties)> cellList = new() { new(transfer.AccountSenderNumber, new WordTextProperties { Size = "20" }), new(transfer.AccountPayeeNumber, new WordTextProperties { Size = "20" }), new(transfer.Sum.ToString(), new WordTextProperties { Size = "20"}), new(transfer.DateOperation.ToString(), new WordTextProperties { Size = "20"}), }; rowList.Add(cellList); CreateTable(new WordParagraph { RowTexts = rowList, TextProperties = new WordTextProperties { Size = "24", JustificationType = WordJustificationType.Center } }); } SaveWord(info); } private void CreateCreditingWord(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 crediting in info.Crediting) { List> rowList = new() { new() { new("Номер карты", new WordTextProperties { Bold = true, Size = "24" } ), new("Сумма пополнения", new WordTextProperties { Bold = true, Size = "24" } ), new("Дата выполнения", new WordTextProperties { Bold = true, Size = "24" } ) } }; CreateParagraph(new WordParagraph { Texts = new List<(string, WordTextProperties)> { ("Пополнение №" + crediting.Id.ToString(), new WordTextProperties { Bold = true, Size = "24" }) }, TextProperties = new WordTextProperties { Size = "24", JustificationType = WordJustificationType.Center } }); List<(string, WordTextProperties)> cellList = new() { new(crediting.CardNumber, new WordTextProperties { Size = "24" }), new(crediting.Sum.ToString(), new WordTextProperties { Size = "24" }), new(crediting.DateClose == null ? "В обработке" : crediting.DateClose.ToString(), new WordTextProperties { Size = "24" }) }; rowList.Add(cellList); CreateTable(new WordParagraph { RowTexts = rowList, TextProperties = new WordTextProperties { Size = "24", JustificationType = WordJustificationType.Center } }); } SaveWord(info); } private void CreateDebitingWord(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 crediting in info.Debiting) { List> rowList = new() { new() { new("Номер карты", new WordTextProperties { Bold = true, Size = "24" } ), new("Сумма снятия", new WordTextProperties { Bold = true, Size = "24" } ), new("Дата выполнения", new WordTextProperties { Bold = true, Size = "24" } ) } }; CreateParagraph(new WordParagraph { Texts = new List<(string, WordTextProperties)> { ("Снятие №" + crediting.Id.ToString(), new WordTextProperties { Bold = true, Size = "24" }) }, TextProperties = new WordTextProperties { Size = "24", JustificationType = WordJustificationType.Center } }); List<(string, WordTextProperties)> cellList = new() { new(crediting.CardNumber, new WordTextProperties { Size = "24" }), new(crediting.Sum.ToString(), new WordTextProperties { Size = "24" }), new(crediting.DateClose == null ? "В обработке" : crediting.DateClose.ToString(), new WordTextProperties { Size = "24" }) }; rowList.Add(cellList); CreateTable(new WordParagraph { RowTexts = rowList, TextProperties = new WordTextProperties { Size = "24", JustificationType = WordJustificationType.Center } }); } SaveWord(info); } private void CreateCashierWord(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 crediting in info.Debiting) { List> rowList = new() { new() { new("Сумма заявки", new WordTextProperties { Bold = true, Size = "24" } ), new("Дата открытия", new WordTextProperties { Bold = true, Size = "24" } ), new("Статус", new WordTextProperties { Bold = true, Size = "24" } ) } }; CreateParagraph(new WordParagraph { Texts = new List<(string, WordTextProperties)> { ("Заявка №" + crediting.Id.ToString(), new WordTextProperties { Bold = true, Size = "24" }) }, TextProperties = new WordTextProperties { Size = "24", JustificationType = WordJustificationType.Center } }); List<(string, WordTextProperties)> cellList = new() { new(crediting.Sum.ToString(), new WordTextProperties { Size = "24" }), new(crediting.DateOpen.ToString(), new WordTextProperties { Size = "24" }), new(crediting.Status.ToString(), new WordTextProperties { Size = "24" }) }; rowList.Add(cellList); CreateTable(new WordParagraph { RowTexts = rowList, TextProperties = new WordTextProperties { Size = "24", JustificationType = WordJustificationType.Center } }); } SaveWord(info); } // Создание doc-файла protected abstract void CreateWord(WordInfo info); // Создание абзаца с текстом protected abstract void CreateParagraph(WordParagraph paragraph); //Создание таблицы protected abstract void CreateTable(WordParagraph paragraph); // Сохранение файла protected abstract void SaveWord(WordInfo info); } }