хехе
This commit is contained in:
parent
79f9710560
commit
896b02f70d
@ -110,28 +110,30 @@ namespace LawFirmBusinessLogic.BusinessLogics
|
||||
DateTo = model.DateTo
|
||||
});
|
||||
|
||||
foreach (CaseViewModel cas in cases)
|
||||
foreach (ClientViewModel client in clients)
|
||||
{
|
||||
foreach (VisitViewModel visit in visits)
|
||||
var record = new ReportClientsViewModel
|
||||
{
|
||||
foreach (int casId in cas.CaseClients.Keys)
|
||||
{
|
||||
if (visit.VisitClients.ContainsKey(casId))
|
||||
{
|
||||
foreach (var clId in cas.CaseClients.Values)
|
||||
{
|
||||
list.Add(new ReportClientsViewModel
|
||||
{
|
||||
Id = casId,
|
||||
FIO = clients.FirstOrDefault(x => x.Id == casId).FIO,
|
||||
CaseName = cas.Name,
|
||||
VisitDate = visit.VisitDate
|
||||
FIO = client.FIO,
|
||||
CaseName = new List<string>(),
|
||||
VisitDate = new List<DateTime>()
|
||||
};
|
||||
|
||||
});
|
||||
foreach (var cas in cases)
|
||||
{
|
||||
if (cas.CaseClients.ContainsKey(client.Id))
|
||||
{
|
||||
record.CaseName.Add(cas.Name);
|
||||
}
|
||||
}
|
||||
foreach (var vis in visits)
|
||||
{
|
||||
if (vis.VisitClients.ContainsKey(client.Id))
|
||||
{
|
||||
record.VisitDate.Add(vis.VisitDate);
|
||||
}
|
||||
}
|
||||
list.Add(record);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
@ -256,14 +258,14 @@ namespace LawFirmBusinessLogic.BusinessLogics
|
||||
return list;
|
||||
}
|
||||
|
||||
public List<ReportClientCaseHearingViewModel> GetCaseHearing(ReportClientCaseHearingBindingModel model)
|
||||
public List<ReportClientCaseHearingViewModel> GetClientCaseHearing(ReportClientCaseHearingBindingModel model)
|
||||
{
|
||||
var list = new List<ReportClientCaseHearingViewModel>();
|
||||
var clients = _clientStorage.GetFilteredList(new ClientSearchModel { Id = model.ClientId });
|
||||
var cases = _caseStorage.GetFilteredList(new CaseSearchModel { ExecutorId = model.ExecutorId });
|
||||
var hearings = _hearingStorage.GetFilteredList(new HearingSearchModel { DateFrom = model.DateFrom, DateTo = model.DateTo });
|
||||
var visits = _visitStorage.GetFilteredList(new VisitSearchModel { ExecutorId = model.ExecutorId });
|
||||
foreach (ClientViewModel client in clients)
|
||||
foreach (var client in clients)
|
||||
{
|
||||
var record = new ReportClientCaseHearingViewModel
|
||||
{
|
||||
@ -274,7 +276,7 @@ namespace LawFirmBusinessLogic.BusinessLogics
|
||||
{
|
||||
if (cas.CaseClients.ContainsKey(client.Id))
|
||||
{
|
||||
record.Case.Add(new(cas.DateCreate, cas.Name));
|
||||
record.Case.Add(new(cas.Name, cas.CaseType));
|
||||
}
|
||||
}
|
||||
foreach (var visit in visits)
|
||||
@ -368,7 +370,7 @@ namespace LawFirmBusinessLogic.BusinessLogics
|
||||
Title = "Отчёт по делам и слушаниям по выбранным клиентам",
|
||||
DateFrom = model.DateFrom,
|
||||
DateTo = model.DateTo,
|
||||
ClientCaseHearing = GetCaseHearing(model)
|
||||
ClientCaseHearing = GetClientCaseHearing(model)
|
||||
});
|
||||
}
|
||||
|
||||
@ -381,7 +383,6 @@ namespace LawFirmBusinessLogic.BusinessLogics
|
||||
DateFrom = model.DateFrom,
|
||||
DateTo = model.DateTo,
|
||||
CaseHearing = GetCaseHearing(model)
|
||||
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -25,8 +25,8 @@ namespace LawFirmBusinessLogic.MailWorker
|
||||
objMailMessage.Body = info.Text;
|
||||
objMailMessage.SubjectEncoding = Encoding.UTF8;
|
||||
objMailMessage.BodyEncoding = Encoding.UTF8;
|
||||
//Attachment attachment = new Attachment("E:\\reports\\pdf\\file.pdf", new ContentType(MediaTypeNames.Application.Pdf));
|
||||
Attachment attachment = new Attachment("D:\\CourseWork\\pdffile.pdf", new ContentType(MediaTypeNames.Application.Pdf));
|
||||
Attachment attachment = new Attachment("E:\\reports\\pdf\\file.pdf", new ContentType(MediaTypeNames.Application.Pdf));
|
||||
//Attachment attachment = new Attachment("D:\\CourseWork\\pdffile.pdf", new ContentType(MediaTypeNames.Application.Pdf));
|
||||
objMailMessage.Attachments.Add(attachment);
|
||||
|
||||
objSmtpClient.UseDefaultCredentials = false;
|
||||
|
@ -28,7 +28,7 @@ namespace LawFirmBusinessLogic.OfficePackages
|
||||
CreateTable(new List<string> { "3cm", "5cm", "5cm" });
|
||||
CreateRow(new PdfRowParameters
|
||||
{
|
||||
Texts = new List<string> { "Клиент", "Дело", "Дата начала дела" },
|
||||
Texts = new List<string> { "Клиент", "Дело", "Тип" },
|
||||
Style = "NormalTitle",
|
||||
ParagraphAlignment = PdfParagraphAlignmentType.Center
|
||||
});
|
||||
@ -45,7 +45,7 @@ namespace LawFirmBusinessLogic.OfficePackages
|
||||
foreach (var cas in ch.Case)
|
||||
CreateRow(new PdfRowParameters
|
||||
{
|
||||
Texts = new List<string> { " ", cas.CaseName, cas.CaseDate.ToShortDateString() },
|
||||
Texts = new List<string> { " ", cas.CaseName, cas.CaseType },
|
||||
Style = "Normal",
|
||||
ParagraphAlignment = PdfParagraphAlignmentType.Center
|
||||
});
|
||||
|
@ -31,11 +31,28 @@ namespace LawFirmBusinessLogic.OfficePackages
|
||||
{
|
||||
CreateRow(new PdfRowParameters
|
||||
{
|
||||
Texts = new List<string> { client.Id.ToString(), client.FIO,
|
||||
client.CaseName, client.VisitDate.ToString()},
|
||||
Texts = new List<string> { client.FIO, " ", " " },
|
||||
Style = "Normal",
|
||||
ParagraphAlignment = PdfParagraphAlignmentType.Left
|
||||
ParagraphAlignment = PdfParagraphAlignmentType.Center
|
||||
});
|
||||
foreach(var cas in client.CaseName)
|
||||
{
|
||||
CreateRow(new PdfRowParameters
|
||||
{
|
||||
Texts = new List<string> { " ", cas, " " },
|
||||
Style = "Normal",
|
||||
ParagraphAlignment = PdfParagraphAlignmentType.Center
|
||||
});
|
||||
}
|
||||
foreach (var vis in client.VisitDate)
|
||||
{
|
||||
CreateRow(new PdfRowParameters
|
||||
{
|
||||
Texts = new List<string> { " ", " ", vis.ToShortDateString() },
|
||||
Style = "Normal",
|
||||
ParagraphAlignment = PdfParagraphAlignmentType.Center
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
SavePdf(info);
|
||||
|
@ -12,5 +12,6 @@ namespace LawFirmContracts.BindingModels
|
||||
public DateTime? DateTo { get; set; }
|
||||
public int? ExecutorId { get; set; } //?
|
||||
public int? GuarantorId { get; set; }
|
||||
public string? Email { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -3,7 +3,7 @@
|
||||
public class ReportClientCaseHearingViewModel
|
||||
{
|
||||
public string ClientName { get; set; } = string.Empty;
|
||||
public List<(DateTime CaseDate, string CaseName)> Case { get; set; } = new();
|
||||
public List<(string CaseName, string CaseType)> Case { get; set; } = new();
|
||||
public List<(DateTime HearingDate, string Judge)> Hearing { get; set; } = new();
|
||||
}
|
||||
}
|
||||
|
@ -2,9 +2,8 @@
|
||||
{
|
||||
public class ReportClientsViewModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string FIO { get; set; } = string.Empty;
|
||||
public string CaseName { get; set; } = string.Empty;
|
||||
public DateTime VisitDate { get; set; } // ?
|
||||
public List<string> CaseName { get; set; } = new List<string>();
|
||||
public List<DateTime> VisitDate { get; set; } = new List<DateTime>();
|
||||
}
|
||||
}
|
||||
|
@ -132,5 +132,33 @@ namespace LawFirmExecutorApp.Controllers
|
||||
{
|
||||
return new PhysicalFileResult("E:\\reports\\excelclientsreport.xlsx", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public IActionResult SendMail()
|
||||
{
|
||||
ViewBag.Clients = APIClient.GetRequest<List<ClientViewModel>>($"api/client/getclientlist?executorid={APIClient.Executor.Id}");
|
||||
ViewBag.Report = new List<ReportClientCaseHearingBindingModel>();
|
||||
return View();
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void SendMail(DateTime dateFrom, DateTime dateTo, int clientId)
|
||||
{
|
||||
if (APIClient.Executor == null)
|
||||
{
|
||||
throw new Exception("Вы как суда попали? Суда вход только авторизованным");
|
||||
}
|
||||
APIClient.PostRequest("api/reportexecutor/mailsend", new ReportClientCaseHearingBindingModel
|
||||
{
|
||||
//FileName = "E:\\reports\\pdffile.pdf",
|
||||
ExecutorId = APIClient.Executor.Id,
|
||||
DateFrom = dateFrom,
|
||||
DateTo = dateTo,
|
||||
Email = APIClient.Executor.Email,
|
||||
ClientId = clientId
|
||||
});
|
||||
Response.Redirect("SendMail");
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ using LawFirmContracts.ViewModels;
|
||||
using LawFirmExecutorApp.Models;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using System.Diagnostics;
|
||||
using System.Globalization;
|
||||
|
||||
namespace LawFirmExecutorApp.Controllers
|
||||
{
|
||||
@ -143,5 +144,99 @@ namespace LawFirmExecutorApp.Controllers
|
||||
{
|
||||
return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
|
||||
}
|
||||
|
||||
public IActionResult Report()
|
||||
{
|
||||
ViewBag.Report = new List<ReportClientsViewModel>();
|
||||
return View();
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public string GetReport(DateTime dateFrom, DateTime dateTo)
|
||||
{
|
||||
if (APIClient.Executor == null)
|
||||
{
|
||||
throw new Exception("Вы как суда попали? Суда вход только авторизованным");
|
||||
}
|
||||
List<ReportClientsViewModel> result;
|
||||
try
|
||||
{
|
||||
string dateFromS = dateFrom.ToString("s", CultureInfo.InvariantCulture);
|
||||
string dateToS = dateTo.ToString("s", CultureInfo.InvariantCulture);
|
||||
result = APIClient.GetRequest<List<ReportClientsViewModel>>
|
||||
($"api/reportexecutor/getconsultationhearingreport?datefrom={dateFromS}&dateto={dateToS}&executorid={APIClient.Executor.Id}")!;
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка создания отчета");
|
||||
throw;
|
||||
}
|
||||
|
||||
string table = "";
|
||||
table += "<h2 class=\"text-custom-color-1\">Предварительный отчет</h2>";
|
||||
table += "<div class=\"table-responsive\">";
|
||||
table += "<table class=\"table table-striped table-bordered table-hover\">";
|
||||
table += "<thead class=\"table-dark\">";
|
||||
table += "<tr>";
|
||||
table += "<th scope=\"col\">Клиент</th>";
|
||||
table += "<th scope=\"col\">Цена консультации</th>";
|
||||
table += "<th scope=\"col\">Дата консультации</th>";
|
||||
table += "<th scope=\"col\">Суд</th>";
|
||||
table += "<th scope=\"col\">Дата слушания</th>";
|
||||
table += "</tr>";
|
||||
table += "</thead>";
|
||||
foreach (var client in result)
|
||||
{
|
||||
table += "<tbody>";
|
||||
table += "<tr>";
|
||||
table += $"<td>{client.FIO}</td>";
|
||||
table += $"<td></td>";
|
||||
table += $"<td></td>";
|
||||
table += $"<td></td>";
|
||||
table += $"<td></td>";
|
||||
table += "</tr>";
|
||||
foreach (var cons in client.CaseName)
|
||||
{
|
||||
table += "<tr>";
|
||||
table += $"<td></td>";
|
||||
table += $"<td>{cons}</td>";
|
||||
table += $"<td></td>";
|
||||
table += "</tr>";
|
||||
}
|
||||
foreach (var hear in client.VisitDate)
|
||||
{
|
||||
table += "<tr>";
|
||||
table += $"<td></td>";
|
||||
table += $"<td></td>";
|
||||
table += $"<td>{hear}</td>";
|
||||
table += "</tr>";
|
||||
}
|
||||
table += "</tbody>";
|
||||
}
|
||||
table += "</table>";
|
||||
table += "</div>";
|
||||
return table;
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void Report(DateTime dateFrom, DateTime dateTo)
|
||||
{
|
||||
if (APIClient.Executor == null)
|
||||
{
|
||||
throw new Exception("Вы как суда попали? Суда вход только авторизованным");
|
||||
}
|
||||
APIClient.PostRequest("api/reportexecutor/mailsend", new ReportBindingModel
|
||||
{
|
||||
FileName = "D:\\CourseWork\\pdfConsultationHearingsReport.pdf",
|
||||
ExecutorId = APIClient.Executor.Id,
|
||||
DateFrom = dateFrom,
|
||||
DateTo = dateTo,
|
||||
Email = APIClient.Executor.Email
|
||||
|
||||
});
|
||||
Response.Redirect("Report");
|
||||
|
||||
}
|
||||
}
|
||||
}
|
63
LawFim/LawFirmExecutorApp/Views/Client/SendMail.cshtml
Normal file
63
LawFim/LawFirmExecutorApp/Views/Client/SendMail.cshtml
Normal file
@ -0,0 +1,63 @@
|
||||
@{
|
||||
ViewData["Title"] = "SendMail";
|
||||
}
|
||||
|
||||
<div class="container">
|
||||
<div class="text-center mb-4">
|
||||
<h2 class="text-custom-color-1">Отправка на почту отчета по клиентам с расшифровкой по слушаниям и делам</h2>
|
||||
</div>
|
||||
|
||||
<form method="post">
|
||||
<div class="row">
|
||||
<div class="col-4">Юрист:</div>
|
||||
<div class="col-8">
|
||||
<select id="clientId" name="clientId" class="form-control" asp-items="@(new SelectList(@ViewBag.Clients,"Id", "FIO"))"></select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<div class="form-group">
|
||||
<label for="dateFrom" class="form-label text-custom-color-1">Начало периода:</label>
|
||||
<input type="datetime-local" id="dateFrom" name="dateFrom" class="form-control" placeholder="Выберите дату начала периода">
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<div class="form-group">
|
||||
<label for="dateTo" class="form-label text-custom-color-1">Окончание периода:</label>
|
||||
<input type="datetime-local" id="dateTo" name="dateTo" class="form-control" placeholder="Выберите дату окончания периода">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row mb-4">
|
||||
<div class="col-md-8"></div>
|
||||
<div class="col-md-4">
|
||||
<button type="submit" class="btn btn-outline-dark w-100 text-center d-flex justify-content-md-center">Отправить на почту</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</form>
|
||||
</div>
|
||||
|
||||
@section Scripts {
|
||||
<script>
|
||||
function check() {
|
||||
var dateFrom = $('#dateFrom').val();
|
||||
var dateTo = $('#dateTo').val();
|
||||
if (dateFrom && dateTo) {
|
||||
$.ajax({
|
||||
method: "GET",
|
||||
url: "/Client/SendMail",
|
||||
data: { dateFrom: dateFrom, dateTo: dateTo },
|
||||
success: function (result) {
|
||||
if (result != null) {
|
||||
$('#report').html(result);
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
}
|
||||
check();
|
||||
$('#demonstrate').on('click', (e) => check());
|
||||
</script>
|
||||
}
|
@ -75,6 +75,11 @@
|
||||
<button type="submit" class="btn btn-danger">Получить docx/xlsx файл</button>
|
||||
</form>
|
||||
</td>
|
||||
<td>
|
||||
<form action="/Client/SendMail">
|
||||
<button type="submit" class="btn btn-secondary">Отправить отчет на почту</button>
|
||||
</form>
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
</div>
|
58
LawFim/LawFirmExecutorApp/Views/Home/Report.cshtml
Normal file
58
LawFim/LawFirmExecutorApp/Views/Home/Report.cshtml
Normal file
@ -0,0 +1,58 @@
|
||||
@{
|
||||
ViewData["Title"] = "Report";
|
||||
}
|
||||
|
||||
<div class="container">
|
||||
<div class="text-center mb-4">
|
||||
<h2 class="text-custom-color-1">Отчет по клиентам за период</h2>
|
||||
</div>
|
||||
|
||||
<form method="post">
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<div class="form-group">
|
||||
<label for="dateFrom" class="form-label text-custom-color-1">Начало периода:</label>
|
||||
<input type="datetime-local" id="dateFrom" name="dateFrom" class="form-control" placeholder="Выберите дату начала периода">
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<div class="form-group">
|
||||
<label for="dateTo" class="form-label text-custom-color-1">Окончание периода:</label>
|
||||
<input type="datetime-local" id="dateTo" name="dateTo" class="form-control" placeholder="Выберите дату окончания периода">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row mb-4">
|
||||
<div class="col-md-8"></div>
|
||||
<div class="col-md-4">
|
||||
<button type="button" id="demonstrate" class="btn btn-outline-dark w-100 text-center d-flex justify-content-md-center">Продемонстрировать</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="report"></div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
@section Scripts {
|
||||
<script>
|
||||
function check() {
|
||||
var dateFrom = $('#dateFrom').val();
|
||||
var dateTo = $('#dateTo').val();
|
||||
if (dateFrom && dateTo) {
|
||||
$.ajax({
|
||||
method: "GET",
|
||||
url: "/Home/GetReport",
|
||||
data: { dateFrom: dateFrom, dateTo: dateTo },
|
||||
success: function (result) {
|
||||
if (result != null) {
|
||||
$('#report').html(result);
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
}
|
||||
check();
|
||||
$('#demonstrate').on('click', (e) => check());
|
||||
</script>
|
||||
}
|
@ -42,6 +42,26 @@ namespace LawFirmRestApi.Controllers
|
||||
}
|
||||
}
|
||||
[HttpPost]
|
||||
public void SaveCaseHearingToPdfFile(ReportClientCaseHearingBindingModel report)
|
||||
{
|
||||
try
|
||||
{
|
||||
_reportLogic.SaveClientCaseHearingToPdfFile(new ReportClientCaseHearingBindingModel
|
||||
{
|
||||
DateFrom = report.DateFrom,
|
||||
DateTo = report.DateTo,
|
||||
FileName = "E:\\reports\\pdfClientCaseHearingsReport.pdf",
|
||||
ExecutorId = report.ExecutorId,
|
||||
ClientId = report.ClientId,
|
||||
});
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка создания отчета");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
[HttpPost]
|
||||
public void SaveClientsWordFile(ReportBindingModel report)
|
||||
{
|
||||
try
|
||||
@ -76,7 +96,7 @@ namespace LawFirmRestApi.Controllers
|
||||
{
|
||||
DateFrom = report.DateFrom,
|
||||
DateTo = report.DateTo,
|
||||
FileName = report.FileName,
|
||||
FileName = "E:\\reports\\file.pdf",
|
||||
ExecutorId = report.ExecutorId,
|
||||
ClientId = report.ClientId,
|
||||
Email = report.Email,
|
||||
|
Loading…
Reference in New Issue
Block a user