2023-05-18 00:04:33 +04:00
|
|
|
|
using BankYouBankruptBusinessLogic.BusinessLogics;
|
|
|
|
|
using BankYouBankruptContracts.BindingModels;
|
|
|
|
|
using BankYouBankruptContracts.BusinessLogicsContracts;
|
|
|
|
|
using BankYouBankruptContracts.SearchModels;
|
|
|
|
|
using BankYouBankruptContracts.ViewModels;
|
2023-05-19 20:11:24 +04:00
|
|
|
|
using BankYouBankruptDataModels.Enums;
|
2023-05-18 00:04:33 +04:00
|
|
|
|
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;
|
|
|
|
|
|
|
|
|
|
private readonly IReportClientLogic _reportClientLogic;
|
|
|
|
|
|
2023-05-18 12:48:45 +04:00
|
|
|
|
private readonly IReportCashierLogic _reportCashierLogic;
|
|
|
|
|
|
2023-05-19 01:12:27 +04:00
|
|
|
|
//хранят данные для отображения отчёта на вебе
|
|
|
|
|
private ReportClientViewModelForHTML _reportClientViewModelForHTML;
|
|
|
|
|
|
|
|
|
|
private ReportCashierViewModelForHTML _reportCashierViewModelForHTML;
|
2023-05-18 14:45:28 +04:00
|
|
|
|
|
2023-05-19 01:12:27 +04:00
|
|
|
|
public ReportController(ILogger<ReportController> logger, IReportClientLogic reportClientLogic, IReportCashierLogic reportCashierLogic)
|
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 00:04:33 +04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//метод генерации отчёта за период по картам клиента
|
2023-05-18 02:17:27 +04:00
|
|
|
|
[HttpPost]
|
2023-05-19 02:18:52 +04:00
|
|
|
|
public ReportClientViewModelForHTML CreateClientReport(ReportSupportBindingModel model)
|
2023-05-19 01:12:27 +04:00
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
2023-05-19 02:18:52 +04:00
|
|
|
|
var result = _reportClientLogic.SaveClientReportToPdfFile(new ReportBindingModel
|
2023-05-19 01:12:27 +04:00
|
|
|
|
{
|
|
|
|
|
FileName = "Отчёт_по_картам.pdf",
|
|
|
|
|
DateFrom = model.DateFrom,
|
|
|
|
|
DateTo = model.DateTo
|
|
|
|
|
});
|
2023-05-19 02:18:52 +04:00
|
|
|
|
|
|
|
|
|
return result;
|
2023-05-19 01:12:27 +04:00
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
_logger.LogError(ex, "Ошибка входа в систему");
|
|
|
|
|
throw;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//метод генерации отчёта по всем счетм клиентов
|
|
|
|
|
[HttpPost]
|
2023-05-19 11:35:31 +04:00
|
|
|
|
public ReportCashierViewModelForHTML CreateCashierReport(ReportSupportBindingModel model)
|
2023-05-19 01:12:27 +04:00
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
2023-05-19 11:35:31 +04:00
|
|
|
|
var result = _reportCashierLogic.SaveAccountsToPdfFile(new ReportBindingModel
|
2023-05-19 01:12:27 +04:00
|
|
|
|
{
|
|
|
|
|
FileName = "Отчёт_по_счетам.pdf",
|
|
|
|
|
ClientId = model.ClientId,
|
|
|
|
|
DateFrom = model.DateFrom,
|
|
|
|
|
DateTo = model.DateTo
|
|
|
|
|
});
|
2023-05-19 11:35:31 +04:00
|
|
|
|
|
|
|
|
|
return result;
|
2023-05-19 01:12:27 +04:00
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
_logger.LogError(ex, "Ошибка входа в систему");
|
|
|
|
|
throw;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-05-19 20:11:24 +04:00
|
|
|
|
/*//передача данных из отчёта кассира
|
2023-05-19 01:12:27 +04:00
|
|
|
|
[HttpGet]
|
|
|
|
|
public ReportCashierViewModelForHTML GetDataOfCashierReport()
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
return _reportCashierViewModelForHTML;
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
_logger.LogError(ex, "Ошибка входа в систему");
|
|
|
|
|
throw;
|
|
|
|
|
}
|
2023-05-19 20:11:24 +04:00
|
|
|
|
}*/
|
2023-05-19 01:12:27 +04:00
|
|
|
|
|
2023-05-19 20:11:24 +04:00
|
|
|
|
//отчёт клиента Excel по переводу денег
|
2023-05-19 01:12:27 +04:00
|
|
|
|
[HttpPost]
|
2023-05-19 20:11:24 +04:00
|
|
|
|
public void CreateExcelClient(ReportSupportBindingModel model)
|
2023-05-18 00:04:33 +04:00
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
2023-05-19 20:11:24 +04:00
|
|
|
|
_reportClientLogic.SaveToExcelFile(new ReportBindingModel
|
2023-05-18 00:04:33 +04:00
|
|
|
|
{
|
2023-05-19 20:11:24 +04:00
|
|
|
|
FileName = "Отчёт по переводам.xls",
|
|
|
|
|
CardList = model.CardList
|
|
|
|
|
}, ExcelOperationEnum.Между_cчетами);
|
2023-05-18 00:04:33 +04:00
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
_logger.LogError(ex, "Ошибка входа в систему");
|
|
|
|
|
throw;
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-05-18 12:48:45 +04:00
|
|
|
|
|
2023-05-19 20:11:24 +04:00
|
|
|
|
//отчёт клиента Excel по переводу денег
|
2023-05-18 12:48:45 +04:00
|
|
|
|
[HttpPost]
|
2023-05-19 20:11:24 +04:00
|
|
|
|
public void CreateExcelCrediting(ReportSupportBindingModel model)
|
2023-05-18 12:48:45 +04:00
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
2023-05-19 20:11:24 +04:00
|
|
|
|
_reportClientLogic.SaveToExcelFile(new ReportBindingModel
|
2023-05-18 12:48:45 +04:00
|
|
|
|
{
|
2023-05-19 20:11:24 +04:00
|
|
|
|
FileName = "Отчёт по пополнениям.xls",
|
|
|
|
|
CardList = model.CardList
|
|
|
|
|
}, ExcelOperationEnum.Пополнение_карт);
|
2023-05-18 12:48:45 +04:00
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
_logger.LogError(ex, "Ошибка входа в систему");
|
|
|
|
|
throw;
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-05-19 20:32:27 +04:00
|
|
|
|
|
|
|
|
|
//отчёт клиента Excel по выдаче денег
|
|
|
|
|
[HttpPost]
|
|
|
|
|
public void CreateExcelDebiting(ReportSupportBindingModel model)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
_reportClientLogic.SaveToExcelFile(new ReportBindingModel
|
|
|
|
|
{
|
|
|
|
|
FileName = "Отчёт по снятиям.xls",
|
|
|
|
|
CardList = model.CardList
|
|
|
|
|
}, ExcelOperationEnum.Cнятие_с_карты);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
_logger.LogError(ex, "Ошибка входа в систему");
|
|
|
|
|
throw;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//отчёт клиента Excel по переводу денег
|
|
|
|
|
[HttpPost]
|
|
|
|
|
public void CreateExcelCashier(ReportSupportBindingModel model)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
2023-05-19 20:40:03 +04:00
|
|
|
|
_reportCashierLogic.SaveAccountsToExcelFile(new ReportBindingModel
|
2023-05-19 20:32:27 +04:00
|
|
|
|
{
|
2023-05-19 21:09:54 +04:00
|
|
|
|
FileName = "Отчёт по зявкам на снятие.xls",
|
2023-05-19 20:40:03 +04:00
|
|
|
|
AccountId = model.AccountId
|
|
|
|
|
});
|
2023-05-19 20:32:27 +04:00
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
_logger.LogError(ex, "Ошибка входа в систему");
|
|
|
|
|
throw;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-05-18 00:04:33 +04:00
|
|
|
|
}
|
|
|
|
|
}
|