From d873c30b2135810c89023487431cbabe38413cf9 Mon Sep 17 00:00:00 2001 From: Programmist73 Date: Fri, 19 May 2023 01:12:27 +0400 Subject: [PATCH] =?UTF-8?q?=D0=9F=D0=BE=D0=BF=D1=8B=D1=82=D0=BA=D0=B0=20?= =?UTF-8?q?=D0=B2=20=D0=BE=D1=82=D1=87=D1=91=D1=8C=20=D0=BD=D0=B0=20=D0=B2?= =?UTF-8?q?=D0=B5=D0=B1=D0=B5.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BusinessLogics/ReportLoad.cs | 36 ------- .../BankYouBankruptClientApp/APIClient.cs | 4 +- .../Controllers/HomeController.cs | 8 +- .../Views/Home/CreateReport.cshtml | 91 +++++++++++++++++- .../BusinessLogicsContracts/IReportLoad.cs | 13 --- .../Controllers/ReportController.cs | 91 ++++++++++++++++-- .../BankYouBankruptRestAPI/Program.cs | 7 +- .../Отчёт_по_картам.pdf | Bin 34878 -> 34882 bytes 8 files changed, 180 insertions(+), 70 deletions(-) delete mode 100644 BankYouBankrupt/BankYouBankruptBusinessLogic/BusinessLogics/ReportLoad.cs delete mode 100644 BankYouBankrupt/BankYouBankruptContracts/BusinessLogicsContracts/IReportLoad.cs diff --git a/BankYouBankrupt/BankYouBankruptBusinessLogic/BusinessLogics/ReportLoad.cs b/BankYouBankrupt/BankYouBankruptBusinessLogic/BusinessLogics/ReportLoad.cs deleted file mode 100644 index f359d10..0000000 --- a/BankYouBankrupt/BankYouBankruptBusinessLogic/BusinessLogics/ReportLoad.cs +++ /dev/null @@ -1,36 +0,0 @@ -using BankYouBankruptContracts.BusinessLogicsContracts; -using DocumentFormat.OpenXml.ExtendedProperties; -using Org.BouncyCastle.Asn1.Ocsp; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection.Metadata; -using System.Text; -using System.Threading.Tasks; - -namespace BankYouBankruptBusinessLogic.BusinessLogics -{ - public class ReportLoad : IReportLoad - { - public byte[] LoadFile(bool whoRequested) - { - string pdfFilePath; - - //если пришло true, то загружаем отчёт клиента - if (whoRequested) - { - pdfFilePath = "C:\\Users\\Programmist73\\Desktop\\Практика\\2-й курс\\4-й семестр\\CourseWork_BankYouBankrupt\\BankYouBankrupt\\BankYouBankruptRestAPI\\Отчёт_по_картам.pdf"; - } - else - { - pdfFilePath = "C:\\Users\\Programmist73\\Desktop\\Практика\\2-й курс\\4-й семестр\\CourseWork_BankYouBankrupt\\BankYouBankrupt\\BankYouBankruptRestAPI\\Отчёт_по_счетам.pdf"; - } - - byte[] bytes = System.IO.File.ReadAllBytes(pdfFilePath); - - System.IO.File.WriteAllBytes(pdfFilePath, bytes); - - return bytes; - } - } -} diff --git a/BankYouBankrupt/BankYouBankruptClientApp/APIClient.cs b/BankYouBankrupt/BankYouBankruptClientApp/APIClient.cs index bf69f31..e05164d 100644 --- a/BankYouBankrupt/BankYouBankruptClientApp/APIClient.cs +++ b/BankYouBankrupt/BankYouBankruptClientApp/APIClient.cs @@ -35,8 +35,8 @@ namespace BankYouBankruptСlientApp } } - //Post-запрос - public static void PostRequest(string requestUrl, T model) + //Post-запрос + public static void PostRequest(string requestUrl, T model) { var json = JsonConvert.SerializeObject(model); var data = new StringContent(json, Encoding.UTF8, "application/json"); diff --git a/BankYouBankrupt/BankYouBankruptClientApp/Controllers/HomeController.cs b/BankYouBankrupt/BankYouBankruptClientApp/Controllers/HomeController.cs index b4035b6..67e5e93 100644 --- a/BankYouBankrupt/BankYouBankruptClientApp/Controllers/HomeController.cs +++ b/BankYouBankrupt/BankYouBankruptClientApp/Controllers/HomeController.cs @@ -258,7 +258,9 @@ namespace BankYouBankruptClientApp.Controllers return Redirect("~/Home/Enter"); } - return View(); + ViewBag.DataOfClientReport = null; + + return View(); } [HttpPost] @@ -269,12 +271,14 @@ namespace BankYouBankruptClientApp.Controllers throw new Exception("Не авторизованы"); } - APIClient.PostRequest("api/Report/CreateClientReport", new ReportSupportBindingModel() + APIClient.PostRequest("api/Report/CreateClientReport", new ReportSupportBindingModel() { DateFrom = dateFrom, DateTo = dateTo }); + ViewBag.DataOfClientReport = APIClient.GetRequest($"api/Report/GetDataOfClientReport"); + return View(); } diff --git a/BankYouBankrupt/BankYouBankruptClientApp/Views/Home/CreateReport.cshtml b/BankYouBankrupt/BankYouBankruptClientApp/Views/Home/CreateReport.cshtml index cd8ccf4..a25346c 100644 --- a/BankYouBankrupt/BankYouBankruptClientApp/Views/Home/CreateReport.cshtml +++ b/BankYouBankrupt/BankYouBankruptClientApp/Views/Home/CreateReport.cshtml @@ -1,4 +1,8 @@ -@{ +@using BankYouBankruptContracts.ViewModels; + +@model ReportClientViewModelForHTML + +@{ ViewData["Title"] = "Создание отчёта"; } @@ -24,6 +28,87 @@ -
-
+ @if (Model != null) + { +
+

Отчёт по пополнениям

+ + + + + + + + + + + @foreach (var item in Model.ReportCrediting) + { + + + + + + + } + +
+ Номер операции + + Номер карты + + Сумма + + Дата операции +
+ @Html.DisplayFor(modelItem => item.OperationId) + + @Html.DisplayFor(modelItem => item.CardNumber) + + @Html.DisplayFor(modelItem => item.SumOperation) + + @Html.DisplayFor(modelItem => item.DateComplite) +
+
+
+

Отчёт по снятиям

+ + + + + + + + + + + @foreach (var item in Model.ReportDebiting) + { + + + + + + + } + +
+ Номер операции + + Номер карты + + Сумма + + Дата операции +
+ @Html.DisplayFor(modelItem => item.OperationId) + + @Html.DisplayFor(modelItem => item.CardNumber) + + @Html.DisplayFor(modelItem => item.SumOperation) + + @Html.DisplayFor(modelItem => item.DateComplite) +
+
+ } diff --git a/BankYouBankrupt/BankYouBankruptContracts/BusinessLogicsContracts/IReportLoad.cs b/BankYouBankrupt/BankYouBankruptContracts/BusinessLogicsContracts/IReportLoad.cs deleted file mode 100644 index 4c25831..0000000 --- a/BankYouBankrupt/BankYouBankruptContracts/BusinessLogicsContracts/IReportLoad.cs +++ /dev/null @@ -1,13 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace BankYouBankruptContracts.BusinessLogicsContracts -{ - public interface IReportLoad - { - byte[] LoadFile(bool whoRequested); - } -} diff --git a/BankYouBankrupt/BankYouBankruptRestAPI/Controllers/ReportController.cs b/BankYouBankrupt/BankYouBankruptRestAPI/Controllers/ReportController.cs index cde358e..fbff12f 100644 --- a/BankYouBankrupt/BankYouBankruptRestAPI/Controllers/ReportController.cs +++ b/BankYouBankrupt/BankYouBankruptRestAPI/Controllers/ReportController.cs @@ -18,29 +18,29 @@ namespace BankYouBankruptRestAPI.Controllers { private readonly ILogger _logger; - //private readonly IReportCashierLogic _reportCashierLogic; - private readonly IReportClientLogic _reportClientLogic; private readonly IReportCashierLogic _reportCashierLogic; - private readonly IReportLoad _reportLoad; + //хранят данные для отображения отчёта на вебе + private ReportClientViewModelForHTML _reportClientViewModelForHTML; - public ReportController(ILogger logger, IReportClientLogic reportClientLogic, IReportCashierLogic reportCashierLogic, IReportLoad reportLoad) + private ReportCashierViewModelForHTML _reportCashierViewModelForHTML; + + public ReportController(ILogger logger, IReportClientLogic reportClientLogic, IReportCashierLogic reportCashierLogic) { _logger = logger; _reportClientLogic = reportClientLogic; _reportCashierLogic = reportCashierLogic; - _reportLoad = reportLoad; } //метод генерации отчёта за период по картам клиента [HttpPost] - public ReportClientViewModelForHTML CreateClientReport(ReportSupportBindingModel model) + public void CreateClientReport(ReportSupportBindingModel model) { try { - return _reportClientLogic.SaveClientReportToPdfFile(new ReportBindingModel + _reportClientViewModelForHTML = _reportClientLogic.SaveClientReportToPdfFile(new ReportBindingModel { FileName = "Отчёт_по_картам.pdf", DateFrom = model.DateFrom, @@ -56,11 +56,11 @@ namespace BankYouBankruptRestAPI.Controllers //метод генерации отчёта по всем счетм клиентов [HttpPost] - public ReportCashierViewModelForHTML CreateCashierReport(ReportSupportBindingModel model) + public void CreateCashierReport(ReportSupportBindingModel model) { try { - return _reportCashierLogic.SaveAccountsToPdfFile(new ReportBindingModel + _reportCashierViewModelForHTML = _reportCashierLogic.SaveAccountsToPdfFile(new ReportBindingModel { FileName = "Отчёт_по_счетам.pdf", ClientId = model.ClientId, @@ -74,5 +74,78 @@ namespace BankYouBankruptRestAPI.Controllers throw; } } + + //передача данных из отчёта клиента + [HttpGet] + public ReportClientViewModelForHTML GetDataOfClientReport() + { + try + { + return _reportClientViewModelForHTML; + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка входа в систему"); + throw; + } + } + + //передача данных из отчёта кассира + [HttpGet] + public ReportCashierViewModelForHTML GetDataOfCashierReport() + { + try + { + return _reportCashierViewModelForHTML; + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка входа в систему"); + throw; + } + } + + /* + //метод генерации отчёта за период по картам клиента + [HttpPost] + public void CreateClientReport(ReportSupportBindingModel model) + { + try + { + _reportClientViewModelForHTML = _reportClientLogic.SaveClientReportToPdfFile(new ReportBindingModel + { + FileName = "Отчёт_по_картам.pdf", + DateFrom = model.DateFrom, + DateTo = model.DateTo + }); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка входа в систему"); + throw; + } + } + + //метод генерации отчёта по всем счетм клиентов + [HttpPost] + public void CreateCashierReport(ReportSupportBindingModel model) + { + try + { + _reportCashierViewModelForHTML = _reportCashierLogic.SaveAccountsToPdfFile(new ReportBindingModel + { + FileName = "Отчёт_по_счетам.pdf", + ClientId = model.ClientId, + DateFrom = model.DateFrom, + DateTo = model.DateTo + }); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка входа в систему"); + throw; + } + } + */ } } diff --git a/BankYouBankrupt/BankYouBankruptRestAPI/Program.cs b/BankYouBankrupt/BankYouBankruptRestAPI/Program.cs index ff42f0f..4592562 100644 --- a/BankYouBankrupt/BankYouBankruptRestAPI/Program.cs +++ b/BankYouBankrupt/BankYouBankruptRestAPI/Program.cs @@ -34,14 +34,11 @@ builder.Services.AddTransient(); builder.Services.AddTransient(); builder.Services.AddTransient(); -builder.Services.AddTransient(); - -//для отправки файла в приложение -builder.Services.AddTransient(); +builder.Services.AddSingleton(); builder.Services.AddTransient(); -builder.Services.AddSingleton(); +builder.Services.AddTransient(); //теперь общий builder.Services.AddTransient(); diff --git a/BankYouBankrupt/BankYouBankruptRestAPI/Отчёт_по_картам.pdf b/BankYouBankrupt/BankYouBankruptRestAPI/Отчёт_по_картам.pdf index 2ad147401535f6a07d0d234ea2416d7b2b5737bd..818a3b90ec6cdf7fe4cd94e99887688c17ae58b7 100644 GIT binary patch delta 2504 zcmaizXHXM}7KJxK0)#4M1p^3#BGrWS0FfR*kSP(s^YPmQ%Br-tp>-CJfuHA zPu_jfmuBqwhkq81pNB*(PQ}*c@vS{uE}A!-tO(1O8Z1w=B0LXX8EaOz%PROXm0#^b zp9=O)yHhY7(CqW1?_{*^{uRJ%_58VnFo0D!zrXiLT}V=z2u{}{#PdS9o_9r*LEPTj z&f~&l6k+%&fiu54X3E8rcBq%!G}@_+7J5w=Xq$@X8Ofw-(0C$gR?|LZtWWclbD$t! z=JDor=c(hp6QF+C`x@iP_4A7E_-^_rjcHL9M!6s=Jk_s~E#Ef1Sh`cfj}f_B zowsum@|_W(&7sPh_q3qXP4r|FN{OWQ4d=MZzjXPI9rX@n)l1zOuNHQaKdqZsTB;jO z3wv{eAW<*?ELL^c*znOwNlUP{3Gw3==Nbk2RexLI+z;2TjZNF|j2>b_bt#>?HH=j?4ny3t~xeRiT5;pH4Z>`KX znZpCU+DfLOkX-Nlj8T_F-Vdp!qK-867hlypYG8!sW#)OxEjBA=<@X3ujHA{e{2D3Sf490p{8qr!2Y;ssp9?PlQnA=*RCEW z31=l_aAYD2QT?BdTL5Jiv^ZgV@{Z!0OV9?1ABJh%mrXSLg>WrY98O3D}j$Y%YZua;T(jZkkPem-lge|u-pT-p{ zlp6t`2o4?WyRs{xH>z=&3$OKR7U|0OGbhC(bMgKI#y!z|RII=Kg_MEX$^3YaXYFXx z287TyIIirlsMA7VVYh50uXZp2i-PuoQwi*Q7h{7-$-8sjBm{NwXXvj+2nrg2OyK31 zIG!g?j5BDbb#B$6v^93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