отчет в пдф работает и я в шоке...
This commit is contained in:
parent
572ad8e4a5
commit
209784fc73
@ -167,11 +167,16 @@ namespace LawFirmBusinessLogic.BusinessLogics
|
|||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<ReportConsultationHearingViewModel> GetConsultationHearing(ReportBindingModel model)
|
public List<ReportConsultationHearingViewModel> GetConsultationHearing(ReportConsultationHearingBindingModel model)
|
||||||
{
|
{
|
||||||
var list = new List<ReportConsultationHearingViewModel>();
|
var list = new List<ReportConsultationHearingViewModel>();
|
||||||
var lawyers = _lawyerStorage.GetFilteredList(new LawyerSearchModel { GuarantorId = model.GuarantorId });
|
var lawyers = _lawyerStorage.GetFilteredList(new LawyerSearchModel { GuarantorId = model.GuarantorId });
|
||||||
var consultations = _consultationStorage.GetFilteredList(new ConsultationSearchModel { GuarantorId = model.GuarantorId });
|
var consultations = _consultationStorage.GetFilteredList(new ConsultationSearchModel
|
||||||
|
{
|
||||||
|
GuarantorId = model.GuarantorId,
|
||||||
|
DateFrom = model.DateFrom,
|
||||||
|
DateTo = model.DateTo
|
||||||
|
});
|
||||||
var hearings = _hearingStorage.GetFilteredList(new HearingSearchModel
|
var hearings = _hearingStorage.GetFilteredList(new HearingSearchModel
|
||||||
{
|
{
|
||||||
GuarantorId = model.GuarantorId,
|
GuarantorId = model.GuarantorId,
|
||||||
@ -183,16 +188,15 @@ namespace LawFirmBusinessLogic.BusinessLogics
|
|||||||
var record = new ReportConsultationHearingViewModel
|
var record = new ReportConsultationHearingViewModel
|
||||||
{
|
{
|
||||||
LawyerName = lawyer.FIO,
|
LawyerName = lawyer.FIO,
|
||||||
Consultation = new List<(int Id, double Price)>(),
|
Consultation = new List<(DateTime ConsultationDate, double Price)>(),
|
||||||
Hearing = new List<(DateTime HearingDate, string Judge)>()
|
Hearing = new List<(DateTime HearingDate, string Judge)>()
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
foreach (var consultation in consultations)
|
foreach (var consultation in consultations)
|
||||||
{
|
{
|
||||||
if (consultation.ConsultationLawyers.ContainsKey(lawyer.Id))
|
if (consultation.ConsultationLawyers.ContainsKey(lawyer.Id))
|
||||||
{
|
{
|
||||||
record.Consultation.Add(new(consultation.Id, consultation.Cost));
|
record.Consultation.Add(new(consultation.ConsultationDate, consultation.Cost));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
foreach (var hearing in hearings)
|
foreach (var hearing in hearings)
|
||||||
@ -259,14 +263,14 @@ namespace LawFirmBusinessLogic.BusinessLogics
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SaveConsultationHearingToPdfFile(ReportBindingModel model)
|
public void SaveConsultationHearingToPdfFile(ReportConsultationHearingBindingModel model)
|
||||||
{
|
{
|
||||||
_saveToPdfConsultationHearing.CreateDoc(new PDFConsultationHearingInfo
|
_saveToPdfConsultationHearing.CreateDoc(new PDFConsultationHearingInfo
|
||||||
{
|
{
|
||||||
FileName = model.FileName,
|
FileName = model.FileName,
|
||||||
Title = "Отчёт по консультациям и слушаниям",
|
Title = "Отчёт по консультациям и слушаниям",
|
||||||
DateFrom = model.DateFrom!.Value,
|
DateFrom = model.DateFrom,
|
||||||
DateTo = model.DateTo!.Value,
|
DateTo = model.DateTo,
|
||||||
ConsultationHearing = GetConsultationHearing(model)
|
ConsultationHearing = GetConsultationHearing(model)
|
||||||
|
|
||||||
});
|
});
|
||||||
|
@ -23,7 +23,7 @@ namespace LawFirmBusinessLogic.OfficePackages
|
|||||||
CreateTable(new List<string> { "3cm", "5cm", "5cm" });
|
CreateTable(new List<string> { "3cm", "5cm", "5cm" });
|
||||||
CreateRow(new PdfRowParameters
|
CreateRow(new PdfRowParameters
|
||||||
{
|
{
|
||||||
Texts = new List<string> { "Юрист", "Номер консультации", "Цена консультации" },
|
Texts = new List<string> { "Юрист", "Цена консультации", "Дата консультации" },
|
||||||
Style = "NormalTitle",
|
Style = "NormalTitle",
|
||||||
ParagraphAlignment = PdfParagraphAlignmentType.Center
|
ParagraphAlignment = PdfParagraphAlignmentType.Center
|
||||||
});
|
});
|
||||||
@ -40,7 +40,7 @@ namespace LawFirmBusinessLogic.OfficePackages
|
|||||||
foreach (var cons in ch.Consultation)
|
foreach (var cons in ch.Consultation)
|
||||||
CreateRow(new PdfRowParameters
|
CreateRow(new PdfRowParameters
|
||||||
{
|
{
|
||||||
Texts = new List<string> { " ", cons.Id.ToString(), cons.Price.ToString() },
|
Texts = new List<string> { " ", cons.Price.ToString() + " рублей", cons.ConsultationDate.ToShortDateString() },
|
||||||
Style = "Normal",
|
Style = "Normal",
|
||||||
ParagraphAlignment = PdfParagraphAlignmentType.Center
|
ParagraphAlignment = PdfParagraphAlignmentType.Center
|
||||||
});
|
});
|
||||||
|
@ -0,0 +1,15 @@
|
|||||||
|
using LawFirmContracts.ViewModels;
|
||||||
|
|
||||||
|
namespace LawFirmContracts.BindingModels
|
||||||
|
{
|
||||||
|
public class ReportConsultationHearingBindingModel
|
||||||
|
{
|
||||||
|
public string FileName { get; set; } = string.Empty;
|
||||||
|
//public List<int> Hearings { get; set; } = new();
|
||||||
|
//public List<int> Consultations { get; set; } = new();
|
||||||
|
public DateTime DateFrom { get; set; } = DateTime.Now;
|
||||||
|
public DateTime DateTo { get; set; } = DateTime.Now;
|
||||||
|
public int? GuarantorId { get; set; }
|
||||||
|
//public string? Email { get; set; }
|
||||||
|
}
|
||||||
|
}
|
@ -8,13 +8,13 @@ namespace LawFirmContracts.BusinessLogicContracts
|
|||||||
List<ReportClientsConsultationViewModel> GetClientsConsultation(ReportBindingModel model);
|
List<ReportClientsConsultationViewModel> GetClientsConsultation(ReportBindingModel model);
|
||||||
List<ReportClientsViewModel> GetGetClients(ReportBindingModel model);
|
List<ReportClientsViewModel> GetGetClients(ReportBindingModel model);
|
||||||
List<ReportVisitLawyerViewModel> GetVisitLawyer(ReportBindingModel model);
|
List<ReportVisitLawyerViewModel> GetVisitLawyer(ReportBindingModel model);
|
||||||
List<ReportConsultationHearingViewModel> GetConsultationHearing(ReportBindingModel model);
|
List<ReportConsultationHearingViewModel> GetConsultationHearing(ReportConsultationHearingBindingModel model);
|
||||||
|
|
||||||
void SaveClientsConsultationToWordFile(ReportBindingModel model);
|
void SaveClientsConsultationToWordFile(ReportBindingModel model);
|
||||||
void SaveClientsConsultationToExcelFile(ReportBindingModel model);
|
void SaveClientsConsultationToExcelFile(ReportBindingModel model);
|
||||||
void SaveVisitLawyerToWordFile(ReportBindingModel model);
|
void SaveVisitLawyerToWordFile(ReportBindingModel model);
|
||||||
void SaveVisitLawyerToExcelFile(ReportBindingModel model);
|
void SaveVisitLawyerToExcelFile(ReportBindingModel model);
|
||||||
void SaveConsultationHearingToPdfFile(ReportBindingModel model);
|
void SaveConsultationHearingToPdfFile(ReportConsultationHearingBindingModel model);
|
||||||
void SaveClientsToPdfFile(ReportBindingModel model);
|
void SaveClientsToPdfFile(ReportBindingModel model);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
public class ReportConsultationHearingViewModel
|
public class ReportConsultationHearingViewModel
|
||||||
{
|
{
|
||||||
public string LawyerName { get; set; } = string.Empty;
|
public string LawyerName { get; set; } = string.Empty;
|
||||||
public List<(int Id, double Price)> Consultation { get; set; } = new();
|
public List<(DateTime ConsultationDate, double Price)> Consultation { get; set; } = new();
|
||||||
public List<(DateTime HearingDate, string Judge)> Hearing { get; set; } = new();
|
public List<(DateTime HearingDate, string Judge)> Hearing { get; set; } = new();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
107
LawFim/LawFirmRestApi/Controllers/ReportGuarantorController.cs
Normal file
107
LawFim/LawFirmRestApi/Controllers/ReportGuarantorController.cs
Normal file
@ -0,0 +1,107 @@
|
|||||||
|
using LawFirmBusinessLogic.BusinessLogics;
|
||||||
|
using LawFirmBusinessLogic.MailWorker;
|
||||||
|
using LawFirmContracts.BindingModels;
|
||||||
|
using LawFirmContracts.BindingModels.Mails;
|
||||||
|
using LawFirmContracts.BusinessLogicContracts;
|
||||||
|
using LawFirmContracts.ViewModels;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
|
||||||
|
namespace LawFirmRestApi.Controllers
|
||||||
|
{
|
||||||
|
[Route("api/[controller]/[action]")]
|
||||||
|
[ApiController]
|
||||||
|
public class ReportGuarantorController : Controller
|
||||||
|
{
|
||||||
|
private readonly ILogger _logger;
|
||||||
|
private readonly IReportLogic _reportLogic;
|
||||||
|
|
||||||
|
private readonly AbstractMailWorker _mailWorker;
|
||||||
|
public ReportGuarantorController(ILogger<ReportGuarantorController> logger, IReportLogic reportLogic, AbstractMailWorker abstractMailWorker)
|
||||||
|
{
|
||||||
|
_logger = logger;
|
||||||
|
_reportLogic = reportLogic;
|
||||||
|
_mailWorker = abstractMailWorker;
|
||||||
|
}
|
||||||
|
[HttpPost]
|
||||||
|
public void SaveConsultationHearingToPdfFile(ReportConsultationHearingBindingModel report)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_reportLogic.SaveConsultationHearingToPdfFile(new ReportConsultationHearingBindingModel
|
||||||
|
{
|
||||||
|
DateFrom = report.DateFrom,
|
||||||
|
DateTo = report.DateTo,
|
||||||
|
FileName = "D:\\CourseWork\\pdfConsultationHearingsReport.pdf",
|
||||||
|
GuarantorId = report.GuarantorId,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка создания отчета");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
[HttpPost]
|
||||||
|
public void SaveVisitLawyerToWordFile(ReportBindingModel report)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_reportLogic.SaveVisitLawyerToWordFile(new ReportBindingModel { GuarantorId = report.GuarantorId, FileName = "D:\\CourseWork\\wordVisitLawyerReport.docx", ClientId = report.ClientId });
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка создания отчета");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
[HttpPost]
|
||||||
|
public void SaveVisitLawyerToExcelFile(ReportBindingModel report)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_reportLogic.SaveVisitLawyerToExcelFile(new ReportBindingModel { GuarantorId = report.GuarantorId, FileName = "D:\\CourseWork\\excelVisitLawyerReport.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<ReportVisitLawyerViewModel> GetVisitLawyerReport(DateTime dateFrom, DateTime dateTo, int guarantorId)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
ReportBindingModel model = new();
|
||||||
|
model.DateFrom = dateFrom;
|
||||||
|
model.DateTo = dateTo;
|
||||||
|
model.GuarantorId = guarantorId;
|
||||||
|
return _reportLogic.GetVisitLawyer(model);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка создания отчета");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user