diff --git a/BankYouBankrupt/BankYouBankruptBusinessLogic/BusinessLogics/ReportCashierLogic.cs b/BankYouBankrupt/BankYouBankruptBusinessLogic/BusinessLogics/ReportCashierLogic.cs index 9b66f74..3d92073 100644 --- a/BankYouBankrupt/BankYouBankruptBusinessLogic/BusinessLogics/ReportCashierLogic.cs +++ b/BankYouBankrupt/BankYouBankruptBusinessLogic/BusinessLogics/ReportCashierLogic.cs @@ -29,14 +29,14 @@ namespace BankYouBankruptBusinessLogic.BusinessLogics private readonly AbstractSaveToExcel _saveToExcel; - private readonly AbstractSaveToWordCashier _saveToWord; + private readonly AbstractSaveToWord _saveToWord; private readonly AbstractSaveToPdf _saveToPdf; //инициализируем поля класса через контейнер public ReportCashierLogic(IMoneyTransferStorage moneyTransferStorage, ICashWithdrawalStorage cashWithdrawalStorage, IClientStorage clientStorage, AbstractSaveToExcel saveToExcel, - AbstractSaveToWordCashier saveToWord, AbstractSaveToPdf saveToPdf, + AbstractSaveToWord saveToWord, AbstractSaveToPdf saveToPdf, IDebitingStorage debitingStorage, ICardStorage cardStorage) { _moneyTransferStorage = moneyTransferStorage; @@ -124,7 +124,14 @@ namespace BankYouBankruptBusinessLogic.BusinessLogics //Сохранение мороженных в файл-Word public void SaveAccountsToWordFile(ReportBindingModel model) { - throw new NotImplementedException(); + _saveToWord.CreateDoc(new WordInfo + { + FileName = model.FileName, + + Title = "Заявки на снятия со счёта", + + Debiting = GetDebitings(model) + }, OfficeOperationEnum.Для_кассира); } //Сохранение заготовок с указаеним изделий в файл-Excel @@ -137,7 +144,7 @@ namespace BankYouBankruptBusinessLogic.BusinessLogics Title = "Заявки на счёт", Debiting = GetDebitings(model) - }, ExcelOperationEnum.Для_кассира); + }, OfficeOperationEnum.Для_кассира); } //Сохранение заказов в файл-Pdf diff --git a/BankYouBankrupt/BankYouBankruptBusinessLogic/BusinessLogics/ReportClientLogic.cs b/BankYouBankrupt/BankYouBankruptBusinessLogic/BusinessLogics/ReportClientLogic.cs index de204e4..f08fe3b 100644 --- a/BankYouBankrupt/BankYouBankruptBusinessLogic/BusinessLogics/ReportClientLogic.cs +++ b/BankYouBankrupt/BankYouBankruptBusinessLogic/BusinessLogics/ReportClientLogic.cs @@ -24,11 +24,11 @@ namespace BankYouBankruptBusinessLogic.BusinessLogics private readonly IMoneyTransferStorage _moneyTransferStorage; private readonly AbstractSaveToExcel _saveToExcel; - private readonly AbstractSaveToWordClient _saveToWord; + private readonly AbstractSaveToWord _saveToWord; private readonly AbstractSaveToPdf _saveToPdf; public ReportClientLogic(ICreditingStorage creditingStorage, IDebitingStorage debitingStorage, - AbstractSaveToExcel saveToExcel, AbstractSaveToWordClient saveToWord, AbstractSaveToPdf saveToPdf, + AbstractSaveToExcel saveToExcel, AbstractSaveToWord saveToWord, AbstractSaveToPdf saveToPdf, ICardStorage cardStorage, IMoneyTransferStorage moneyTransferStorage) { _creditingStorage = creditingStorage; @@ -136,9 +136,9 @@ namespace BankYouBankruptBusinessLogic.BusinessLogics return totalList; } - public void SaveToExcelFile(ReportBindingModel model, ExcelOperationEnum operationEnum) + public void SaveToExcelFile(ReportBindingModel model, OfficeOperationEnum operationEnum) { - if(operationEnum == ExcelOperationEnum.Между_cчетами) + if(operationEnum == OfficeOperationEnum.Между_cчетами) { _saveToExcel.CreateReport(new ExcelInfo { @@ -148,7 +148,7 @@ namespace BankYouBankruptBusinessLogic.BusinessLogics }, operationEnum); } - if (operationEnum == ExcelOperationEnum.Пополнение_карт) + if (operationEnum == OfficeOperationEnum.Пополнение_карт) { _saveToExcel.CreateReport(new ExcelInfo { @@ -158,7 +158,7 @@ namespace BankYouBankruptBusinessLogic.BusinessLogics }, operationEnum); } - if (operationEnum == ExcelOperationEnum.Cнятие_с_карты) + if (operationEnum == OfficeOperationEnum.Cнятие_с_карты) { _saveToExcel.CreateReport(new ExcelInfo { @@ -169,10 +169,38 @@ namespace BankYouBankruptBusinessLogic.BusinessLogics } } - public void SaveToWordFile(ReportBindingModel model) + public void SaveToWordFile(ReportBindingModel model, OfficeOperationEnum operationEnum) { - throw new NotImplementedException(); - } + if (operationEnum == OfficeOperationEnum.Между_cчетами) + { + _saveToWord.CreateDoc(new WordInfo + { + FileName = model.FileName, + Title = "Отчёт по переводам", + MoneyTransfer = GetMoneyTransfer(model) + }, operationEnum); + } + + if (operationEnum == OfficeOperationEnum.Пополнение_карт) + { + _saveToWord.CreateDoc(new WordInfo + { + FileName = model.FileName, + Title = "Отчёт по пополнениям (переводам из налички на карту)", + Crediting = GetExcelCrediting(model) + }, operationEnum); + } + + if (operationEnum == OfficeOperationEnum.Cнятие_с_карты) + { + _saveToWord.CreateDoc(new WordInfo + { + FileName = model.FileName, + Title = "Отчёт по снятиям денежных средств", + Debiting = GetExcelDebiting(model) + }, operationEnum); + } + } //отчёт в формате PDF для клиента public ReportClientViewModelForHTML SaveClientReportToPdfFile(ReportBindingModel model) diff --git a/BankYouBankrupt/BankYouBankruptBusinessLogic/OfficePackage/AbstractSaveToExcel.cs b/BankYouBankrupt/BankYouBankruptBusinessLogic/OfficePackage/AbstractSaveToExcel.cs index 30c4179..d35fa44 100644 --- a/BankYouBankrupt/BankYouBankruptBusinessLogic/OfficePackage/AbstractSaveToExcel.cs +++ b/BankYouBankrupt/BankYouBankruptBusinessLogic/OfficePackage/AbstractSaveToExcel.cs @@ -12,24 +12,24 @@ namespace BankYouBankruptBusinessLogic.OfficePackage public abstract class AbstractSaveToExcel { //Создание отчета. Описание методов ниже - public void CreateReport(ExcelInfo info, ExcelOperationEnum operationEnum) + public void CreateReport(ExcelInfo info, OfficeOperationEnum operationEnum) { - if(operationEnum == ExcelOperationEnum.Между_cчетами) + if(operationEnum == OfficeOperationEnum.Между_cчетами) { CreateMoneyTransferExcel(info); } - if (operationEnum == ExcelOperationEnum.Пополнение_карт) + if (operationEnum == OfficeOperationEnum.Пополнение_карт) { CreateCreditingExcel(info); } - if (operationEnum == ExcelOperationEnum.Cнятие_с_карты) + if (operationEnum == OfficeOperationEnum.Cнятие_с_карты) { CreateDebitingExcel(info); } - if (operationEnum == ExcelOperationEnum.Для_кассира) + if (operationEnum == OfficeOperationEnum.Для_кассира) { CreateCashierExcel(info); } @@ -130,6 +130,26 @@ namespace BankYouBankruptBusinessLogic.OfficePackage }); rowIndex++; + + //Вставляет слово "Сумма перевода" + InsertCellInWorksheet(new ExcelCellParameters + { + ColumnName = "A", + RowIndex = rowIndex, + Text = "Дата операции: ", + StyleInfo = ExcelStyleInfoType.Text + }); + + //подсчитывает общее кол-во заготовок в изделии + InsertCellInWorksheet(new ExcelCellParameters + { + ColumnName = "C", + RowIndex = rowIndex, + Text = mt.DateOperation.ToString(), + StyleInfo = ExcelStyleInfoType.Text + }); + + rowIndex++; } rowIndex++; @@ -442,6 +462,26 @@ namespace BankYouBankruptBusinessLogic.OfficePackage }); rowIndex++; + + //строчка с номером счёта получателя + InsertCellInWorksheet(new ExcelCellParameters + { + ColumnName = "B", + RowIndex = rowIndex, + Text = "Дата: ", + StyleInfo = ExcelStyleInfoType.TextWithBorder + }); + + //вставка номера отправителя + InsertCellInWorksheet(new ExcelCellParameters + { + ColumnName = "C", + RowIndex = rowIndex, + Text = cr.DateClose == null ? "В обработке" : cr.DateClose.ToString(), + StyleInfo = ExcelStyleInfoType.TextWithBorder + }); + + rowIndex++; } rowIndex++; diff --git a/BankYouBankrupt/BankYouBankruptBusinessLogic/OfficePackage/AbstractSaveToExcelCashier.cs b/BankYouBankrupt/BankYouBankruptBusinessLogic/OfficePackage/AbstractSaveToExcelCashier.cs deleted file mode 100644 index dee00d6..0000000 --- a/BankYouBankrupt/BankYouBankruptBusinessLogic/OfficePackage/AbstractSaveToExcelCashier.cs +++ /dev/null @@ -1,51 +0,0 @@ -using BankYouBankruptBusinessLogic.OfficePackage.HelperEnums; -using BankYouBankruptBusinessLogic.OfficePackage.HelperModels; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace BankYouBankruptBusinessLogic.OfficePackage -{ - public abstract class AbstractSaveToExcelCashier - { - //Создание отчета. Описание методов ниже - public void CreateReport(ExcelInfo info) - { - CreateExcel(info); - - InsertCellInWorksheet(new ExcelCellParameters - { - ColumnName = "A", - RowIndex = 1, - Text = info.Title, - StyleInfo = ExcelStyleInfoType.Title - }); - - MergeCells(new ExcelMergeParameters - { - CellFromName = "A1", - CellToName = "C1" - }); - - uint rowIndex = 2; - - ///TODO - - SaveExcel(info); - } - - //Создание excel-файла - protected abstract void CreateExcel(ExcelInfo info); - - //Добавляем новую ячейку в лист - protected abstract void InsertCellInWorksheet(ExcelCellParameters excelParams); - - //Объединение ячеек - protected abstract void MergeCells(ExcelMergeParameters excelParams); - - //Сохранение файла - protected abstract void SaveExcel(ExcelInfo info); - } -} diff --git a/BankYouBankrupt/BankYouBankruptBusinessLogic/OfficePackage/AbstractSaveToWord.cs b/BankYouBankrupt/BankYouBankruptBusinessLogic/OfficePackage/AbstractSaveToWord.cs new file mode 100644 index 0000000..0f012a3 --- /dev/null +++ b/BankYouBankrupt/BankYouBankruptBusinessLogic/OfficePackage/AbstractSaveToWord.cs @@ -0,0 +1,286 @@ +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); + } +} diff --git a/BankYouBankrupt/BankYouBankruptBusinessLogic/OfficePackage/AbstractSaveToWordClient.cs b/BankYouBankrupt/BankYouBankruptBusinessLogic/OfficePackage/AbstractSaveToWordClient.cs deleted file mode 100644 index 1547b3a..0000000 --- a/BankYouBankrupt/BankYouBankruptBusinessLogic/OfficePackage/AbstractSaveToWordClient.cs +++ /dev/null @@ -1,43 +0,0 @@ -using BankYouBankruptBusinessLogic.OfficePackage.HelperEnums; -using BankYouBankruptBusinessLogic.OfficePackage.HelperModels; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace BankYouBankruptBusinessLogic.OfficePackage -{ - public abstract class AbstractSaveToWordClient - { - //метод создания документа - 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 - } - }); - - //TODO - - SaveWord(info); - } - - // Создание doc-файла - protected abstract void CreateWord(WordInfo info); - - // Создание абзаца с текстом - protected abstract void CreateParagraph(WordParagraph paragraph); - - // Сохранение файла - protected abstract void SaveWord(WordInfo info); - } -} diff --git a/BankYouBankrupt/BankYouBankruptBusinessLogic/OfficePackage/HelperModels/WordInfo.cs b/BankYouBankrupt/BankYouBankruptBusinessLogic/OfficePackage/HelperModels/WordInfo.cs index c79d66f..00c3122 100644 --- a/BankYouBankrupt/BankYouBankruptBusinessLogic/OfficePackage/HelperModels/WordInfo.cs +++ b/BankYouBankrupt/BankYouBankruptBusinessLogic/OfficePackage/HelperModels/WordInfo.cs @@ -1,4 +1,5 @@ using BankYouBankruptContracts.ViewModels; +using BankYouBankruptContracts.ViewModels.Client.Default; using System; using System.Collections.Generic; using System.Linq; @@ -14,7 +15,12 @@ namespace BankYouBankruptBusinessLogic.OfficePackage.HelperModels public string Title { get; set; } = string.Empty; - //списки для формирования отчёта клиента - public List Accounts { get; set; } = new(); - } + //списки для отчёта клиента + public List MoneyTransfer { get; set; } = new(); + + public List Crediting { get; set; } = new(); + + //список для отчёта кассира и клиента + public List Debiting { get; set; } = new(); + } } diff --git a/BankYouBankrupt/BankYouBankruptBusinessLogic/OfficePackage/HelperModels/WordParagraph.cs b/BankYouBankrupt/BankYouBankruptBusinessLogic/OfficePackage/HelperModels/WordParagraph.cs index d326090..a2277e0 100644 --- a/BankYouBankrupt/BankYouBankruptBusinessLogic/OfficePackage/HelperModels/WordParagraph.cs +++ b/BankYouBankrupt/BankYouBankruptBusinessLogic/OfficePackage/HelperModels/WordParagraph.cs @@ -14,5 +14,7 @@ namespace BankYouBankruptBusinessLogic.OfficePackage.HelperModels //свойства параграфа, если они есть public WordTextProperties? TextProperties { get; set; } - } + + public List> RowTexts { get; set; } = new(); + } } diff --git a/BankYouBankrupt/BankYouBankruptBusinessLogic/OfficePackage/Implements/SaveToWord.cs b/BankYouBankrupt/BankYouBankruptBusinessLogic/OfficePackage/Implements/SaveToWord.cs index 3da7708..c4e87e8 100644 --- a/BankYouBankrupt/BankYouBankruptBusinessLogic/OfficePackage/Implements/SaveToWord.cs +++ b/BankYouBankrupt/BankYouBankruptBusinessLogic/OfficePackage/Implements/SaveToWord.cs @@ -8,7 +8,7 @@ using DocumentFormat.OpenXml.Wordprocessing; namespace BankYouBankruptBusinessLogic.OfficePackage.Implements { //реализация абстрактного класса сохранения в word - public class SaveToWord : AbstractSaveToWordClient + public class SaveToWord : AbstractSaveToWord { private WordprocessingDocument? _wordDocument; @@ -135,8 +135,79 @@ namespace BankYouBankruptBusinessLogic.OfficePackage.Implements _docBody.AppendChild(docParagraph); } - //метод сохранения документа - protected override void SaveWord(WordInfo info) + //метод, отвечающий за создание таблицы + protected override void CreateTable(WordParagraph paragraph) + { + if (_docBody == null || paragraph == null) + { + return; + } + + Table table = new Table(); + + var tableProp = new TableProperties(); + + tableProp.AppendChild(new TableLayout { Type = TableLayoutValues.Fixed }); + tableProp.AppendChild(new TableBorders( + new TopBorder() { Val = new EnumValue(BorderValues.Single), Size = 4 }, + new LeftBorder() { Val = new EnumValue(BorderValues.Single), Size = 4 }, + new RightBorder() { Val = new EnumValue(BorderValues.Single), Size = 4 }, + new BottomBorder() { Val = new EnumValue(BorderValues.Single), Size = 4 }, + new InsideHorizontalBorder() { Val = new EnumValue(BorderValues.Single), Size = 4 }, + new InsideVerticalBorder() { Val = new EnumValue(BorderValues.Single), Size = 4 } + )); + tableProp.AppendChild(new TableWidth { Type = TableWidthUnitValues.Auto }); + + table.AppendChild(tableProp); + + TableGrid tableGrid = new TableGrid(); + + for (int j = 0; j < paragraph.RowTexts[0].Count; ++j) + { + tableGrid.AppendChild(new GridColumn() { Width = "2500" }); + } + + table.AppendChild(tableGrid); + + for (int i = 0; i < paragraph.RowTexts.Count; ++i) + { + TableRow docRow = new TableRow(); + + for (int j = 0; j < paragraph.RowTexts[i].Count; ++j) + { + var docParagraph = new Paragraph(); + + docParagraph.AppendChild(CreateParagraphProperties(paragraph.RowTexts[i][j].Item2)); + + var docRun = new Run(); + + var properties = new RunProperties(); + + properties.AppendChild(new FontSize { Val = paragraph.RowTexts[i][j].Item2.Size }); + + if (paragraph.RowTexts[i][j].Item2.Bold) + { + properties.AppendChild(new Bold()); + } + + docRun.AppendChild(properties); + + docRun.AppendChild(new Text { Text = paragraph.RowTexts[i][j].Item1, Space = SpaceProcessingModeValues.Preserve }); + + docParagraph.AppendChild(docRun); + TableCell docCell = new TableCell(); + docCell.AppendChild(docParagraph); + docRow.AppendChild(docCell); + } + + table.AppendChild(docRow); + } + + _docBody.AppendChild(table); + } + + //метод сохранения документа + protected override void SaveWord(WordInfo info) { if (_docBody == null || _wordDocument == null) { diff --git a/BankYouBankrupt/BankYouBankruptBusinessLogic/OfficePackage/Implements/SaveToWordCashier.cs b/BankYouBankrupt/BankYouBankruptBusinessLogic/OfficePackage/Implements/SaveToWordCashier.cs deleted file mode 100644 index 19655b9..0000000 --- a/BankYouBankrupt/BankYouBankruptBusinessLogic/OfficePackage/Implements/SaveToWordCashier.cs +++ /dev/null @@ -1,27 +0,0 @@ -using BankYouBankruptBusinessLogic.OfficePackage.HelperModels; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace BankYouBankruptBusinessLogic.OfficePackage.Implements -{ - public class SaveToWordCashier : AbstractSaveToWordCashier - { - protected override void CreateParagraph(WordParagraph paragraph) - { - throw new NotImplementedException(); - } - - protected override void CreateWord(WordInfo info) - { - throw new NotImplementedException(); - } - - protected override void SaveWord(WordInfo info) - { - throw new NotImplementedException(); - } - } -} diff --git a/BankYouBankrupt/BankYouBankruptContracts/BusinessLogicsContracts/IReportClientLogic.cs b/BankYouBankrupt/BankYouBankruptContracts/BusinessLogicsContracts/IReportClientLogic.cs index ba06d3c..bdf3bfc 100644 --- a/BankYouBankrupt/BankYouBankruptContracts/BusinessLogicsContracts/IReportClientLogic.cs +++ b/BankYouBankrupt/BankYouBankruptContracts/BusinessLogicsContracts/IReportClientLogic.cs @@ -18,10 +18,10 @@ namespace BankYouBankruptContracts.BusinessLogicsContracts List? GetDebiting(ReportBindingModel model); //Сохранение отчёта по картам в файл-Word - void SaveToWordFile(ReportBindingModel model); + void SaveToWordFile(ReportBindingModel model, OfficeOperationEnum operationEnum); //Сохранение отчёта по картам в файл-Excel - void SaveToExcelFile(ReportBindingModel model, ExcelOperationEnum operationEnum); + void SaveToExcelFile(ReportBindingModel model, OfficeOperationEnum operationEnum); //Сохранение отчёта по картам в файл-Pdf ReportClientViewModelForHTML SaveClientReportToPdfFile(ReportBindingModel model); diff --git a/BankYouBankrupt/BankYouBankruptDataModels/Enums/ExcelOperationEnum.cs b/BankYouBankrupt/BankYouBankruptDataModels/Enums/OfficeOperationEnum.cs similarity index 90% rename from BankYouBankrupt/BankYouBankruptDataModels/Enums/ExcelOperationEnum.cs rename to BankYouBankrupt/BankYouBankruptDataModels/Enums/OfficeOperationEnum.cs index bafa9e4..70e345f 100644 --- a/BankYouBankrupt/BankYouBankruptDataModels/Enums/ExcelOperationEnum.cs +++ b/BankYouBankrupt/BankYouBankruptDataModels/Enums/OfficeOperationEnum.cs @@ -6,7 +6,7 @@ using System.Threading.Tasks; namespace BankYouBankruptDataModels.Enums { - public enum ExcelOperationEnum + public enum OfficeOperationEnum { Между_cчетами = 0, diff --git a/BankYouBankrupt/BankYouBankruptRestAPI/Controllers/ReportController.cs b/BankYouBankrupt/BankYouBankruptRestAPI/Controllers/ReportController.cs index 83b592b..386f998 100644 --- a/BankYouBankrupt/BankYouBankruptRestAPI/Controllers/ReportController.cs +++ b/BankYouBankrupt/BankYouBankruptRestAPI/Controllers/ReportController.cs @@ -35,6 +35,8 @@ namespace BankYouBankruptRestAPI.Controllers _reportCashierLogic = reportCashierLogic; } + #region Работа с pdf + //метод генерации отчёта за период по картам клиента [HttpPost] public ReportClientViewModelForHTML CreateClientReport(ReportSupportBindingModel model) @@ -80,20 +82,9 @@ namespace BankYouBankruptRestAPI.Controllers } } - /*//передача данных из отчёта кассира - [HttpGet] - public ReportCashierViewModelForHTML GetDataOfCashierReport() - { - try - { - return _reportCashierViewModelForHTML; - } - catch (Exception ex) - { - _logger.LogError(ex, "Ошибка входа в систему"); - throw; - } - }*/ + #endregion + + #region Работа с Excel //отчёт клиента Excel по переводу денег [HttpPost] @@ -103,9 +94,9 @@ namespace BankYouBankruptRestAPI.Controllers { _reportClientLogic.SaveToExcelFile(new ReportBindingModel { - FileName = "Отчёт по переводам.xls", + FileName = "Отчёт по переводам.xlsx", CardList = model.CardList - }, ExcelOperationEnum.Между_cчетами); + }, OfficeOperationEnum.Между_cчетами); } catch (Exception ex) { @@ -122,9 +113,9 @@ namespace BankYouBankruptRestAPI.Controllers { _reportClientLogic.SaveToExcelFile(new ReportBindingModel { - FileName = "Отчёт по пополнениям.xls", + FileName = "Отчёт по пополнениям.xlsx", CardList = model.CardList - }, ExcelOperationEnum.Пополнение_карт); + }, OfficeOperationEnum.Пополнение_карт); } catch (Exception ex) { @@ -141,9 +132,9 @@ namespace BankYouBankruptRestAPI.Controllers { _reportClientLogic.SaveToExcelFile(new ReportBindingModel { - FileName = "Отчёт по снятиям.xls", + FileName = "Отчёт по снятиям.xlsx", CardList = model.CardList - }, ExcelOperationEnum.Cнятие_с_карты); + }, OfficeOperationEnum.Cнятие_с_карты); } catch (Exception ex) { @@ -160,7 +151,7 @@ namespace BankYouBankruptRestAPI.Controllers { _reportCashierLogic.SaveAccountsToExcelFile(new ReportBindingModel { - FileName = "Отчёт по зявкам на снятие.xls", + FileName = "Отчёт по зявкам на снятие.xlsx", AccountId = model.AccountId }); } @@ -171,5 +162,86 @@ namespace BankYouBankruptRestAPI.Controllers } } + #endregion + + #region Работа с word + + //отчёт клиента Word по переводу денег + [HttpPost] + public void CreateWordClient(ReportSupportBindingModel model) + { + try + { + _reportClientLogic.SaveToWordFile(new ReportBindingModel + { + FileName = "Отчёт по переводам.docx", + CardList = model.CardList + }, OfficeOperationEnum.Между_cчетами); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка входа в систему"); + throw; + } + } + + //отчёт клиента Word по переводу денег + [HttpPost] + public void CreateWordCrediting(ReportSupportBindingModel model) + { + try + { + _reportClientLogic.SaveToWordFile(new ReportBindingModel + { + FileName = "Отчёт по пополнениям.docx", + CardList = model.CardList + }, OfficeOperationEnum.Пополнение_карт); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка входа в систему"); + throw; + } + } + + //отчёт клиента Word по выдаче денег + [HttpPost] + public void CreateWordDebiting(ReportSupportBindingModel model) + { + try + { + _reportClientLogic.SaveToWordFile(new ReportBindingModel + { + FileName = "Отчёт по снятиям.docx", + CardList = model.CardList + }, OfficeOperationEnum.Cнятие_с_карты); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка входа в систему"); + throw; + } + } + + //отчёт клиента Word по переводу денег + [HttpPost] + public void CreateWordCashier(ReportSupportBindingModel model) + { + try + { + _reportCashierLogic.SaveAccountsToWordFile(new ReportBindingModel + { + FileName = "Отчёт по зявкам на снятие.docx", + AccountId = model.AccountId + }); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка входа в систему"); + throw; + } + } + + #endregion } } diff --git a/BankYouBankrupt/BankYouBankruptRestAPI/Program.cs b/BankYouBankrupt/BankYouBankruptRestAPI/Program.cs index 4bfc224..922ac20 100644 --- a/BankYouBankrupt/BankYouBankruptRestAPI/Program.cs +++ b/BankYouBankrupt/BankYouBankruptRestAPI/Program.cs @@ -42,11 +42,8 @@ builder.Services.AddTransient(); //общие классы формировани отчётов builder.Services.AddTransient(); - builder.Services.AddTransient(); - -builder.Services.AddTransient(); -builder.Services.AddTransient(); +builder.Services.AddTransient(); builder.Services.AddControllers(); diff --git a/BankYouBankrupt/BankYouBankruptRestAPI/Отчёт по зявкам на снятие.docx b/BankYouBankrupt/BankYouBankruptRestAPI/Отчёт по зявкам на снятие.docx new file mode 100644 index 0000000..3b25952 Binary files /dev/null and b/BankYouBankrupt/BankYouBankruptRestAPI/Отчёт по зявкам на снятие.docx differ diff --git a/BankYouBankrupt/BankYouBankruptRestAPI/Отчёт по зявкам на снятие.xlsx b/BankYouBankrupt/BankYouBankruptRestAPI/Отчёт по зявкам на снятие.xlsx new file mode 100644 index 0000000..8ac2f30 Binary files /dev/null and b/BankYouBankrupt/BankYouBankruptRestAPI/Отчёт по зявкам на снятие.xlsx differ diff --git a/BankYouBankrupt/BankYouBankruptRestAPI/Отчёт по переводам.docx b/BankYouBankrupt/BankYouBankruptRestAPI/Отчёт по переводам.docx new file mode 100644 index 0000000..dcf9c9d Binary files /dev/null and b/BankYouBankrupt/BankYouBankruptRestAPI/Отчёт по переводам.docx differ diff --git a/BankYouBankrupt/BankYouBankruptRestAPI/Отчёт по переводам.xls b/BankYouBankrupt/BankYouBankruptRestAPI/Отчёт по переводам.xls index 5ca769e..236f01a 100644 Binary files a/BankYouBankrupt/BankYouBankruptRestAPI/Отчёт по переводам.xls and b/BankYouBankrupt/BankYouBankruptRestAPI/Отчёт по переводам.xls differ diff --git a/BankYouBankrupt/BankYouBankruptRestAPI/Отчёт по пополнениям.docx b/BankYouBankrupt/BankYouBankruptRestAPI/Отчёт по пополнениям.docx new file mode 100644 index 0000000..2621260 Binary files /dev/null and b/BankYouBankrupt/BankYouBankruptRestAPI/Отчёт по пополнениям.docx differ diff --git a/BankYouBankrupt/BankYouBankruptRestAPI/Отчёт по снятиям.docx b/BankYouBankrupt/BankYouBankruptRestAPI/Отчёт по снятиям.docx new file mode 100644 index 0000000..d582918 Binary files /dev/null and b/BankYouBankrupt/BankYouBankruptRestAPI/Отчёт по снятиям.docx differ