2023-05-18 00:04:33 +04:00
|
|
|
|
using BankYouBankruptBusinessLogic.BusinessLogics;
|
|
|
|
|
using BankYouBankruptContracts.BindingModels;
|
|
|
|
|
using BankYouBankruptContracts.BusinessLogicsContracts;
|
|
|
|
|
using BankYouBankruptContracts.SearchModels;
|
|
|
|
|
using BankYouBankruptContracts.ViewModels;
|
|
|
|
|
using BankYouBankruptRestApi.Controllers;
|
2023-05-18 21:57:14 +04:00
|
|
|
|
using DocumentFormat.OpenXml.Office2016.Drawing.ChartDrawing;
|
2023-05-18 00:04:33 +04:00
|
|
|
|
using Microsoft.AspNetCore.Mvc;
|
2023-05-18 21:57:14 +04:00
|
|
|
|
using Org.BouncyCastle.Utilities;
|
|
|
|
|
using System.Net;
|
2023-05-18 00:04:33 +04:00
|
|
|
|
|
|
|
|
|
namespace BankYouBankruptRestAPI.Controllers
|
|
|
|
|
{
|
|
|
|
|
//указание у контроллера, что Route будет строиться не только по наванию контроллера, но и по названию метода (так как у нас два Post-метода)
|
|
|
|
|
[Route("api/[controller]/[action]")]
|
|
|
|
|
[ApiController]
|
|
|
|
|
public class ReportController : Controller
|
|
|
|
|
{
|
|
|
|
|
private readonly ILogger _logger;
|
|
|
|
|
|
2023-05-18 02:17:27 +04:00
|
|
|
|
//private readonly IReportCashierLogic _reportCashierLogic;
|
2023-05-18 00:04:33 +04:00
|
|
|
|
|
|
|
|
|
private readonly IReportClientLogic _reportClientLogic;
|
|
|
|
|
|
2023-05-18 12:48:45 +04:00
|
|
|
|
private readonly IReportCashierLogic _reportCashierLogic;
|
|
|
|
|
|
2023-05-18 21:57:14 +04:00
|
|
|
|
private readonly IReportLoad _reportLoad;
|
2023-05-18 14:45:28 +04:00
|
|
|
|
|
2023-05-18 21:57:14 +04:00
|
|
|
|
public ReportController(ILogger<ReportController> logger, IReportClientLogic reportClientLogic, IReportCashierLogic reportCashierLogic, IReportLoad reportLoad)
|
2023-05-18 00:04:33 +04:00
|
|
|
|
{
|
|
|
|
|
_logger = logger;
|
|
|
|
|
_reportClientLogic = reportClientLogic;
|
2023-05-18 12:48:45 +04:00
|
|
|
|
_reportCashierLogic = reportCashierLogic;
|
2023-05-18 21:57:14 +04:00
|
|
|
|
_reportLoad = reportLoad;
|
2023-05-18 00:04:33 +04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//метод генерации отчёта за период по картам клиента
|
2023-05-18 02:17:27 +04:00
|
|
|
|
[HttpPost]
|
|
|
|
|
public void CreateClientReport(ReportSupportBindingModel model)
|
2023-05-18 00:04:33 +04:00
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
_reportClientLogic.SaveClientReportToPdfFile(new ReportBindingModel
|
|
|
|
|
{
|
2023-05-18 21:57:14 +04:00
|
|
|
|
FileName = "Отчёт_по_картам.pdf",
|
2023-05-18 02:17:27 +04:00
|
|
|
|
DateFrom = model.DateFrom,
|
|
|
|
|
DateTo = model.DateTo
|
2023-05-18 00:04:33 +04:00
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
_logger.LogError(ex, "Ошибка входа в систему");
|
|
|
|
|
throw;
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-05-18 12:48:45 +04:00
|
|
|
|
|
|
|
|
|
//метод генерации отчёта по всем счетм клиентов
|
|
|
|
|
[HttpPost]
|
|
|
|
|
public void CreateCashierReport(ReportSupportBindingModel model)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
_reportCashierLogic.SaveAccountsToPdfFile(new ReportBindingModel
|
|
|
|
|
{
|
2023-05-18 21:57:14 +04:00
|
|
|
|
FileName = "Отчёт_по_счетам.pdf",
|
2023-05-18 14:45:28 +04:00
|
|
|
|
ClientId = model.ClientId,
|
2023-05-18 12:48:45 +04:00
|
|
|
|
DateFrom = model.DateFrom,
|
|
|
|
|
DateTo = model.DateTo
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
_logger.LogError(ex, "Ошибка входа в систему");
|
|
|
|
|
throw;
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-05-18 21:57:14 +04:00
|
|
|
|
|
|
|
|
|
[HttpGet]
|
|
|
|
|
public PdfLoadViewModel LoadReport(bool whoRequested)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
PdfLoadViewModel model = new PdfLoadViewModel();
|
|
|
|
|
|
|
|
|
|
model.bytes = _reportLoad.LoadFile(whoRequested);
|
|
|
|
|
|
|
|
|
|
return model;
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
_logger.LogError(ex, "Ошибка входа в систему");
|
|
|
|
|
throw;
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-05-18 00:04:33 +04:00
|
|
|
|
}
|
|
|
|
|
}
|