контроллер для отчета одного
This commit is contained in:
parent
b306b67320
commit
572ad8e4a5
@ -35,13 +35,13 @@ namespace LawFirmBusinessLogic.OfficePackages
|
|||||||
StyleInfo = ExcelStyleInfoType.Text
|
StyleInfo = ExcelStyleInfoType.Text
|
||||||
});
|
});
|
||||||
rowIndex++;
|
rowIndex++;
|
||||||
foreach (var hearing in ch.Hearings)
|
foreach (var consultation in ch.Consultations)
|
||||||
{
|
{
|
||||||
InsertCellInWorksheet(new ExcelCellParameters
|
InsertCellInWorksheet(new ExcelCellParameters
|
||||||
{
|
{
|
||||||
ColumnName = "B",
|
ColumnName = "B",
|
||||||
RowIndex = rowIndex,
|
RowIndex = rowIndex,
|
||||||
Text = hearing.Court,
|
Text = consultation.Cost,
|
||||||
StyleInfo =
|
StyleInfo =
|
||||||
ExcelStyleInfoType.TextWithBroder
|
ExcelStyleInfoType.TextWithBroder
|
||||||
});
|
});
|
||||||
@ -49,7 +49,7 @@ namespace LawFirmBusinessLogic.OfficePackages
|
|||||||
{
|
{
|
||||||
ColumnName = "C",
|
ColumnName = "C",
|
||||||
RowIndex = rowIndex,
|
RowIndex = rowIndex,
|
||||||
Text = hearing.HearingDate.ToString(),
|
Text = consultation.ConsultationDate.ToString(),
|
||||||
StyleInfo =
|
StyleInfo =
|
||||||
ExcelStyleInfoType.TextWithBroder
|
ExcelStyleInfoType.TextWithBroder
|
||||||
});
|
});
|
||||||
|
@ -21,7 +21,7 @@ namespace LawFirmBusinessLogic.OfficePackages
|
|||||||
});
|
});
|
||||||
foreach (var clientsConsultation in info.ClientsConsultation)
|
foreach (var clientsConsultation in info.ClientsConsultation)
|
||||||
{
|
{
|
||||||
foreach (var hearing in clientsConsultation.Hearings)
|
foreach (var consultation in clientsConsultation.Consultations)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
@ -29,8 +29,8 @@ namespace LawFirmBusinessLogic.OfficePackages
|
|||||||
{
|
{
|
||||||
Texts = new List<(string, WordTextProperties)> {
|
Texts = new List<(string, WordTextProperties)> {
|
||||||
(clientsConsultation.ClientFIO, new WordTextProperties
|
(clientsConsultation.ClientFIO, new WordTextProperties
|
||||||
{ Size = "24", Bold=true}), (" " + hearing.Court, new WordTextProperties { Size = "24"}),
|
{ Size = "24", Bold=true}), (" " + consultation.Cost, new WordTextProperties { Size = "24"}),
|
||||||
(" " + hearing.HearingDate.ToString(), new WordTextProperties { Size = "24"})
|
(" " + consultation.ConsultationDate.ToString(), new WordTextProperties { Size = "24"})
|
||||||
},
|
},
|
||||||
TextProperties = new WordTextProperties
|
TextProperties = new WordTextProperties
|
||||||
{
|
{
|
||||||
|
@ -5,6 +5,6 @@
|
|||||||
public string ClientFIO { get; set; } = string.Empty;
|
public string ClientFIO { get; set; } = string.Empty;
|
||||||
public double? ConsultationCost { get; set; }
|
public double? ConsultationCost { get; set; }
|
||||||
public DateTime? ConsultationDate { get; set; }
|
public DateTime? ConsultationDate { get; set; }
|
||||||
// public List<(DateTime ConsultationDate, string Cost)> Consultations { get; set; } = new();
|
public List<(DateTime ConsultationDate, string Cost)> Consultations { get; set; } = new();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
102
LawFim/LawFirmRestApi/Controllers/ReportClientsController.cs
Normal file
102
LawFim/LawFirmRestApi/Controllers/ReportClientsController.cs
Normal file
@ -0,0 +1,102 @@
|
|||||||
|
using LawFirmBusinessLogic.MailWorker;
|
||||||
|
using LawFirmContracts.BindingModels.Mails;
|
||||||
|
using LawFirmContracts.BindingModels;
|
||||||
|
using LawFirmContracts.BusinessLogicContracts;
|
||||||
|
using LawFirmContracts.ViewModels;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
|
||||||
|
namespace LawFirmRestApi.Controllers
|
||||||
|
{
|
||||||
|
[Route("api/[controller]/[action]")]
|
||||||
|
[ApiController]
|
||||||
|
public class ReportClientsController : Controller
|
||||||
|
{
|
||||||
|
private readonly ILogger _logger;
|
||||||
|
private readonly IReportLogic _reportLogic;
|
||||||
|
|
||||||
|
private readonly AbstractMailWorker _mailWorker;
|
||||||
|
public ReportClientsController(ILogger<ReportClientsController> logger, IReportLogic reportLogic, AbstractMailWorker abstractMailWorker)
|
||||||
|
{
|
||||||
|
_logger = logger;
|
||||||
|
_reportLogic = reportLogic;
|
||||||
|
_mailWorker = abstractMailWorker;
|
||||||
|
}
|
||||||
|
[HttpPost]
|
||||||
|
public void SaveClientsPdfFile(ReportBindingModel report)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_reportLogic.SaveClientsToPdfFile(new ReportBindingModel
|
||||||
|
{
|
||||||
|
DateFrom = report.DateFrom,
|
||||||
|
DateTo = report.DateTo,
|
||||||
|
FileName = "D:\\CourseWork\\pdfclientsreport.pdf",
|
||||||
|
ClientId = report.ClientId,
|
||||||
|
ExecutorId = report.ExecutorId,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка создания отчета");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
[HttpPost]
|
||||||
|
public void SaveClientsWordFile(ReportBindingModel report)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_reportLogic.SaveClientsConsultationToWordFile(new ReportBindingModel { ExecutorId = report.ExecutorId, FileName = "D:\\CourseWork\\wordclientsreport.docx", ClientId = report.ClientId });
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка создания отчета");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
[HttpPost]
|
||||||
|
public void SaveClientsExcelFile(ReportBindingModel report)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_reportLogic.SaveClientsConsultationToExcelFile(new ReportBindingModel { ExecutorId = report.ExecutorId, FileName = "D:\\CourseWork\\excelclientsreport.xlsx", ClientId = report.ClientId });
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка создания отчета");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
[HttpPost]
|
||||||
|
public void MailSend(MailSendInfoBindingModel report)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_mailWorker.MailSendAsync(new MailSendInfoBindingModel
|
||||||
|
{
|
||||||
|
MailAddress = report.MailAddress,
|
||||||
|
Subject = report.Subject,
|
||||||
|
Text = report.Text
|
||||||
|
});
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка отправки письма");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
[HttpGet]
|
||||||
|
public List<ReportClientsViewModel> GetClientsReport(DateTime dateFrom, DateTime dateTo, int executorId)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return _reportLogic.GetGetClients(new ReportBindingModel { DateFrom = dateFrom, DateTo = dateTo, ExecutorId = executorId });
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка создания отчета");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,8 +1,12 @@
|
|||||||
using LawFirmBusinessLogic.BusinessLogics;
|
using LawFirmBusinessLogic.BusinessLogics;
|
||||||
|
using LawFirmBusinessLogic.MailWorker;
|
||||||
|
using LawFirmBusinessLogic.OfficePackages.Implements;
|
||||||
|
using LawFirmBusinessLogic.OfficePackages;
|
||||||
using LawFirmContracts.BusinessLogicContracts;
|
using LawFirmContracts.BusinessLogicContracts;
|
||||||
using LawFirmContracts.StoragesContracts;
|
using LawFirmContracts.StoragesContracts;
|
||||||
using LawFirmDatabaseImplement.Implements;
|
using LawFirmDatabaseImplement.Implements;
|
||||||
using Microsoft.OpenApi.Models;
|
using Microsoft.OpenApi.Models;
|
||||||
|
using LawFirmContracts.BindingModels.Mails;
|
||||||
|
|
||||||
var builder = WebApplication.CreateBuilder(args);
|
var builder = WebApplication.CreateBuilder(args);
|
||||||
|
|
||||||
@ -26,6 +30,7 @@ builder.Services.AddTransient<IGuarantorStorage, GuarantorStorage>();
|
|||||||
builder.Services.AddTransient<ICaseLogic, CaseLogic>();
|
builder.Services.AddTransient<ICaseLogic, CaseLogic>();
|
||||||
builder.Services.AddTransient<IVisitLogic, VisitLogic>();
|
builder.Services.AddTransient<IVisitLogic, VisitLogic>();
|
||||||
builder.Services.AddTransient<IClientLogic, ClientLogic>();
|
builder.Services.AddTransient<IClientLogic, ClientLogic>();
|
||||||
|
builder.Services.AddTransient<IReportLogic, ReportLogic>();
|
||||||
|
|
||||||
builder.Services.AddTransient<IConsultationLogic, ConsultationLogic>();
|
builder.Services.AddTransient<IConsultationLogic, ConsultationLogic>();
|
||||||
builder.Services.AddTransient<IHearingLogic, HearingLogic>();
|
builder.Services.AddTransient<IHearingLogic, HearingLogic>();
|
||||||
@ -34,6 +39,13 @@ builder.Services.AddTransient<ILawyerLogic, LawyerLogic>();
|
|||||||
builder.Services.AddTransient<IExecutorLogic, ExecutorLogic>();
|
builder.Services.AddTransient<IExecutorLogic, ExecutorLogic>();
|
||||||
builder.Services.AddTransient<IGuarantorLogic, GuarantorLogic>();
|
builder.Services.AddTransient<IGuarantorLogic, GuarantorLogic>();
|
||||||
|
|
||||||
|
builder.Services.AddTransient<AbstractSaveToExcelClientsConsultation, SaveToExcelClientsConsultation>();
|
||||||
|
builder.Services.AddTransient<AbstractSaveToExcelVisitsLawyer, SaveToExcelVisitsLawyer>();
|
||||||
|
builder.Services.AddTransient<AbstractSaveToWordClientsConsultation, SaveToWordClientsConsultation>();
|
||||||
|
builder.Services.AddTransient<AbstractSaveToWordVisitsLawyer, SaveToWordVisitsLawyer>();
|
||||||
|
builder.Services.AddTransient<AbstractSaveToPdfConsultationHearing, SaveToPdfConsultationHearing>();
|
||||||
|
builder.Services.AddTransient<AbstractSaveToPdfClients, SaveToPdfClients>();
|
||||||
|
builder.Services.AddTransient<AbstractMailWorker, MailKitWorker>();
|
||||||
|
|
||||||
builder.Services.AddControllers();
|
builder.Services.AddControllers();
|
||||||
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
|
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
|
||||||
@ -45,6 +57,17 @@ builder.Services.AddSwaggerGen(c => c.SwaggerDoc("v1", new OpenApiInfo
|
|||||||
}));
|
}));
|
||||||
|
|
||||||
var app = builder.Build();
|
var app = builder.Build();
|
||||||
|
var mailSender = app.Services.GetService<AbstractMailWorker>();
|
||||||
|
|
||||||
|
mailSender?.MailConfig(new MailConfigBindingModel
|
||||||
|
{
|
||||||
|
MailLogin = builder.Configuration?.GetSection("MailLogin")?.Value?.ToString() ?? string.Empty,
|
||||||
|
MailPassword = builder.Configuration?.GetSection("MailPassword")?.Value?.ToString() ?? string.Empty,
|
||||||
|
SmtpClientHost = builder.Configuration?.GetSection("SmtpClientHost")?.Value?.ToString() ?? string.Empty,
|
||||||
|
SmtpClientPort = Convert.ToInt32(builder.Configuration?.GetSection("SmtpClientPort")?.Value?.ToString()),
|
||||||
|
PopHost = builder.Configuration?.GetSection("PopHost")?.Value?.ToString() ?? string.Empty,
|
||||||
|
PopPort = Convert.ToInt32(builder.Configuration?.GetSection("PopPort")?.Value?.ToString())
|
||||||
|
});
|
||||||
|
|
||||||
// Configure the HTTP request pipeline.
|
// Configure the HTTP request pipeline.
|
||||||
if (app.Environment.IsDevelopment())
|
if (app.Environment.IsDevelopment())
|
||||||
|
Loading…
x
Reference in New Issue
Block a user