починили списки
This commit is contained in:
parent
7122302b23
commit
f108c6d8f0
@ -1,4 +1,5 @@
|
|||||||
using CaseAccountingBusinessLogic.OfficePackage;
|
using CaseAccountingBusinessLogic.BusinessLogic.OfficePackage;
|
||||||
|
using CaseAccountingBusinessLogic.OfficePackage;
|
||||||
using CaseAccountingBusinessLogic.OfficePackage.HelperModels;
|
using CaseAccountingBusinessLogic.OfficePackage.HelperModels;
|
||||||
using CaseAccountingContracts.BindingModels;
|
using CaseAccountingContracts.BindingModels;
|
||||||
using CaseAccountingContracts.BusinessLogicContracts;
|
using CaseAccountingContracts.BusinessLogicContracts;
|
||||||
@ -22,9 +23,11 @@ namespace CaseAccountingBusinessLogic.BusinessLogics
|
|||||||
private readonly ISpecializationStorage _specializationStorage;
|
private readonly ISpecializationStorage _specializationStorage;
|
||||||
private readonly WordBuilderCustomer _wordBuilder;
|
private readonly WordBuilderCustomer _wordBuilder;
|
||||||
private readonly ExcelBuilderCustomer _excelBuilder;
|
private readonly ExcelBuilderCustomer _excelBuilder;
|
||||||
|
private readonly PdfBuilderCustomer _pdfBuilder;
|
||||||
|
private readonly MailSender _mailSender;
|
||||||
|
|
||||||
public ReportCustomerLogic(ICaseStorage caseStorage, IHearingStorage hearingStorage, ILawyerStorage lawyerStorage, ISpecializationStorage specializationStorage,
|
public ReportCustomerLogic(ICaseStorage caseStorage, IHearingStorage hearingStorage, ILawyerStorage lawyerStorage, ISpecializationStorage specializationStorage,
|
||||||
WordBuilderCustomer wordBuilder, ExcelBuilderCustomer excelBuilder)
|
WordBuilderCustomer wordBuilder, ExcelBuilderCustomer excelBuilder, PdfBuilderCustomer pdfBuilder, MailSender mailSender)
|
||||||
{
|
{
|
||||||
_caseStorage = caseStorage;
|
_caseStorage = caseStorage;
|
||||||
_hearingStorage = hearingStorage;
|
_hearingStorage = hearingStorage;
|
||||||
@ -32,6 +35,8 @@ namespace CaseAccountingBusinessLogic.BusinessLogics
|
|||||||
_specializationStorage = specializationStorage;
|
_specializationStorage = specializationStorage;
|
||||||
_wordBuilder = wordBuilder;
|
_wordBuilder = wordBuilder;
|
||||||
_excelBuilder = excelBuilder;
|
_excelBuilder = excelBuilder;
|
||||||
|
_pdfBuilder = pdfBuilder ?? throw new ArgumentNullException(nameof(pdfBuilder));
|
||||||
|
_mailSender = mailSender ?? throw new ArgumentNullException(nameof(mailSender));
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<ReportHearingSpecializationViewModel> GetHearingSpecialization(ReportBindingModel model)
|
public List<ReportHearingSpecializationViewModel> GetHearingSpecialization(ReportBindingModel model)
|
||||||
@ -98,5 +103,29 @@ namespace CaseAccountingBusinessLogic.BusinessLogics
|
|||||||
}
|
}
|
||||||
return file;
|
return file;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void SendByMailStatusReport(ReportBindingModel reportModel)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
/*public void SendByMailStatusReport(ReportBindingModel reportModel)
|
||||||
|
{
|
||||||
|
byte[] file = _pdfBuilder.GetHearingSpecializationReportFile(new()
|
||||||
|
{
|
||||||
|
Title = "Отчет по слушаниям",
|
||||||
|
DateFrom = reportModel.DateFrom,
|
||||||
|
DateTo = reportModel.DateTo,
|
||||||
|
//Records = GetHearingLawyer(reportModel)
|
||||||
|
});
|
||||||
|
_mailSender.SendMailAsync(new()
|
||||||
|
{
|
||||||
|
MailAddress = reportModel.UserEmail,
|
||||||
|
Subject = "Отчет по слушаниям",
|
||||||
|
Text = $"За период с {reportModel.DateFrom.ToShortDateString()} " +
|
||||||
|
$"по {reportModel.DateTo.ToShortDateString()}.",
|
||||||
|
File = file
|
||||||
|
});
|
||||||
|
}*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,185 @@
|
|||||||
|
using CaseAccountingBusinessLogic.OfficePackage.HelperEnums;
|
||||||
|
using CaseAccountingBusinessLogic.OfficePackage.HelperModels;
|
||||||
|
using CaseAccountingContracts.ViewModels;
|
||||||
|
using MigraDoc.DocumentObjectModel;
|
||||||
|
using MigraDoc.Rendering;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using MigraDoc.DocumentObjectModel.Tables;
|
||||||
|
|
||||||
|
namespace CaseAccountingBusinessLogic.OfficePackage
|
||||||
|
{
|
||||||
|
public class PdfBuilderCustomer
|
||||||
|
{
|
||||||
|
private readonly string tempFileName = "temp.pdf";
|
||||||
|
private Document? document;
|
||||||
|
private Section? section;
|
||||||
|
private Table? table;
|
||||||
|
|
||||||
|
private static ParagraphAlignment GetParagraphAlignment(PdfParagraphAlignmentType type)
|
||||||
|
{
|
||||||
|
return type switch
|
||||||
|
{
|
||||||
|
PdfParagraphAlignmentType.Center => ParagraphAlignment.Center,
|
||||||
|
PdfParagraphAlignmentType.Left => ParagraphAlignment.Left,
|
||||||
|
_ => ParagraphAlignment.Justify,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
private void DefineStyles(Document document)
|
||||||
|
{
|
||||||
|
var style = document.Styles["Normal"];
|
||||||
|
style.Font.Name = "Times New Roman";
|
||||||
|
style.Font.Size = 14;
|
||||||
|
|
||||||
|
style = document.Styles.AddStyle("NormalTitle", "Normal");
|
||||||
|
style.Font.Bold = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void CreateDocument()
|
||||||
|
{
|
||||||
|
document = new Document();
|
||||||
|
DefineStyles(document);
|
||||||
|
section = document.AddSection();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void CreateParagraph(PdfParagraph pdfParagraph)
|
||||||
|
{
|
||||||
|
if (section == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var paragraph = section.AddParagraph(pdfParagraph.Text);
|
||||||
|
paragraph.Format.SpaceAfter = "1cm";
|
||||||
|
paragraph.Format.Alignment = GetParagraphAlignment(pdfParagraph.ParagraphAlignment);
|
||||||
|
paragraph.Style = pdfParagraph.Style;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void CreateTable(List<string> columns)
|
||||||
|
{
|
||||||
|
if (document == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
table = document.LastSection.AddTable();
|
||||||
|
foreach (var elem in columns)
|
||||||
|
{
|
||||||
|
table.AddColumn(elem);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void CreateRow(PdfRowParameters rowParameters)
|
||||||
|
{
|
||||||
|
if (table == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var row = table.AddRow();
|
||||||
|
for (int i = 0; i < rowParameters.Texts.Count; ++i)
|
||||||
|
{
|
||||||
|
row.Cells[i].AddParagraph(rowParameters.Texts[i]);
|
||||||
|
if (!string.IsNullOrEmpty(rowParameters.Style))
|
||||||
|
{
|
||||||
|
row.Cells[i].Style = rowParameters.Style;
|
||||||
|
}
|
||||||
|
Unit borderWidth = 0.5;
|
||||||
|
row.Cells[i].Borders.Left.Width = borderWidth;
|
||||||
|
row.Cells[i].Borders.Right.Width = borderWidth;
|
||||||
|
row.Cells[i].Borders.Top.Width = borderWidth;
|
||||||
|
row.Cells[i].Borders.Bottom.Width = borderWidth;
|
||||||
|
row.Cells[i].Format.Alignment = GetParagraphAlignment(rowParameters.ParagraphAlignment);
|
||||||
|
row.Cells[i].VerticalAlignment = VerticalAlignment.Center;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Save()
|
||||||
|
{
|
||||||
|
|
||||||
|
// Регистрация провайдера кодировки для кодировки 1252, без этого ошибОчка была
|
||||||
|
Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
|
||||||
|
|
||||||
|
var renderer = new PdfDocumentRenderer(true)
|
||||||
|
{
|
||||||
|
Document = document
|
||||||
|
};
|
||||||
|
renderer.RenderDocument();
|
||||||
|
renderer.PdfDocument.Save(tempFileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
public byte[] GetFile()
|
||||||
|
{
|
||||||
|
Save();
|
||||||
|
byte[] file = File.ReadAllBytes(tempFileName);
|
||||||
|
File.Delete(tempFileName);
|
||||||
|
return file;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*public byte[] GetHearingSpecializationReportFile(PdfData<ReportHearingSpecializationViewModel> data)
|
||||||
|
{
|
||||||
|
CreateDocument();
|
||||||
|
|
||||||
|
CreateParagraph(new PdfParagraph
|
||||||
|
{
|
||||||
|
Text = data.Title,
|
||||||
|
Style = "NormalTitle",
|
||||||
|
ParagraphAlignment = PdfParagraphAlignmentType.Center
|
||||||
|
});
|
||||||
|
|
||||||
|
CreateParagraph(new PdfParagraph
|
||||||
|
{
|
||||||
|
Text = $"за период с {data.DateFrom.ToShortDateString()} " +
|
||||||
|
$"по {data.DateTo.ToShortDateString()}",
|
||||||
|
Style = "Normal",
|
||||||
|
ParagraphAlignment = PdfParagraphAlignmentType.Center
|
||||||
|
});
|
||||||
|
|
||||||
|
CreateTable(new List<string> { "4cm", "5cm", "3cm", "3cm" });
|
||||||
|
|
||||||
|
CreateRow(new PdfRowParameters
|
||||||
|
{
|
||||||
|
Texts = new List<string> { "Номер слушания", "Дело", "Дата проведения", "Юрист" },
|
||||||
|
Style = "NormalTitle",
|
||||||
|
ParagraphAlignment = PdfParagraphAlignmentType.Center
|
||||||
|
});
|
||||||
|
|
||||||
|
foreach (var record in data.Records)
|
||||||
|
{
|
||||||
|
List<> casesAndLawyes = record.CaseLawyers;
|
||||||
|
int recordHeight = casesAndLawyes.Count + 1;
|
||||||
|
for (int i = 0; i < recordHeight; i++)
|
||||||
|
{
|
||||||
|
List<string> cellsData = new() { "", "", "", "" };
|
||||||
|
if (i == 0)
|
||||||
|
{
|
||||||
|
cellsData[0] = record.Hearing;
|
||||||
|
CreateRow(new PdfRowParameters
|
||||||
|
{
|
||||||
|
Texts = cellsData,
|
||||||
|
Style = "Normal",
|
||||||
|
ParagraphAlignment = PdfParagraphAlignmentType.Left
|
||||||
|
});
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
int k = i - 1;
|
||||||
|
if (k < casesAndLawyes.Count)
|
||||||
|
{
|
||||||
|
cellsData[1] = casesAndLawyes[k].Case;
|
||||||
|
cellsData[2] = casesAndLawyes[k].Date.ToString("yyyy-MM-dd");
|
||||||
|
cellsData[3] = casesAndLawyes[k].Lawyer;
|
||||||
|
}
|
||||||
|
CreateRow(new PdfRowParameters
|
||||||
|
{
|
||||||
|
Texts = cellsData,
|
||||||
|
Style = "Normal",
|
||||||
|
ParagraphAlignment = PdfParagraphAlignmentType.Left
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return GetFile();
|
||||||
|
}*/
|
||||||
|
}
|
||||||
|
}
|
@ -15,5 +15,7 @@ namespace CaseAccountingContracts.BusinessLogicContracts
|
|||||||
List<ReportHearingSpecializationViewModel> GetHearingSpecialization(ReportBindingModel model);
|
List<ReportHearingSpecializationViewModel> GetHearingSpecialization(ReportBindingModel model);
|
||||||
|
|
||||||
byte[] SaveListFile(LawyerHearingListBindingModel model);
|
byte[] SaveListFile(LawyerHearingListBindingModel model);
|
||||||
|
|
||||||
|
void SendByMailStatusReport(ReportBindingModel reportModel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,55 @@
|
|||||||
|
@{
|
||||||
|
ViewData["Title"] = "Отчет";
|
||||||
|
}
|
||||||
|
|
||||||
|
<div class="text-center">
|
||||||
|
<h1 class="display-4">Отчет по слушаниям</h1>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="error-div-shell" class="error-div-shell mb-2">
|
||||||
|
<div>
|
||||||
|
<p id="error-p" class="error-p"></p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="d-flex flex-wrap gap-1 align-items-end mb-2">
|
||||||
|
<div class="mb-2">
|
||||||
|
<p class="mb-0">Дата начала:</p>
|
||||||
|
<input id="date-from-input" class="form-control" type="date" />
|
||||||
|
</div>
|
||||||
|
<div class="mb-2">
|
||||||
|
<p class="mb-0">Дата конца:</p>
|
||||||
|
<input id="date-to-input" class="form-control" type="date" />
|
||||||
|
</div>
|
||||||
|
<button id="generate-button" class="btn btn-primary mb-2">
|
||||||
|
Показать
|
||||||
|
</button>
|
||||||
|
<button id="send-by-mail-button" class="btn btn-primary mb-2">
|
||||||
|
На почту
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<p class="mb-0">
|
||||||
|
<span>За период с </span>
|
||||||
|
<span id="date-from-span" class="fw-bold">...</span>
|
||||||
|
<span> по </span>
|
||||||
|
<span id="date-to-span" class="fw-bold">...</span>
|
||||||
|
</p>
|
||||||
|
<div class="table-shell mb-2 border">
|
||||||
|
<table class="table mb-0">
|
||||||
|
<thead class="table-head">
|
||||||
|
<tr>
|
||||||
|
<th>Номер слушания</th>
|
||||||
|
<th>Дело</th>
|
||||||
|
<th>Дата проведения</th>
|
||||||
|
<th>Специализация</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody id="tbody">
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="table"></div>
|
||||||
|
|
||||||
|
<script src="~/js/Report/reportpdf.js" asp-append-version="true"></script>
|
@ -0,0 +1 @@
|
|||||||
|
|
@ -18,8 +18,8 @@ namespace CaseAccountingDataBaseImplement
|
|||||||
Host=localhost;
|
Host=localhost;
|
||||||
Port=5432;
|
Port=5432;
|
||||||
Database=CaseAccountingDatabase;
|
Database=CaseAccountingDatabase;
|
||||||
Username=courseuser;
|
Username=postgres;
|
||||||
Password=courseuser");
|
Password=postgres");
|
||||||
}
|
}
|
||||||
base.OnConfiguring(optionsBuilder);
|
base.OnConfiguring(optionsBuilder);
|
||||||
}
|
}
|
||||||
|
@ -8,17 +8,17 @@ namespace CaseAccountingRestApi.Controllers
|
|||||||
[ApiController]
|
[ApiController]
|
||||||
public class ReportCustomerController : Controller
|
public class ReportCustomerController : Controller
|
||||||
{
|
{
|
||||||
private readonly IReportCustomerLogic _reportCustomerLogic;
|
private readonly IReportCustomerLogic reportLogic;
|
||||||
|
|
||||||
public ReportCustomerController(IReportCustomerLogic reportLogic)
|
public ReportCustomerController(IReportCustomerLogic reportLogic)
|
||||||
{
|
{
|
||||||
_reportCustomerLogic = reportLogic;
|
this.reportLogic = reportLogic;
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
public byte[] LawyerHearinglist(LawyerHearingListBindingModel listModel)
|
public byte[] LawyerHearinglist(LawyerHearingListBindingModel listModel)
|
||||||
{
|
{
|
||||||
byte[] file = _reportCustomerLogic.SaveListFile(listModel);
|
byte[] file = reportLogic.SaveListFile(listModel);
|
||||||
return file;
|
return file;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,6 +1,7 @@
|
|||||||
using CaseAccountingBusinessLogic.BusinessLogic.OfficePackage;
|
using CaseAccountingBusinessLogic.BusinessLogic.OfficePackage;
|
||||||
using CaseAccountingBusinessLogic.BusinessLogics;
|
using CaseAccountingBusinessLogic.BusinessLogics;
|
||||||
using CaseAccountingBusinessLogic.OfficePackage;
|
using CaseAccountingBusinessLogic.OfficePackage;
|
||||||
|
using CaseAccountingBusinessLogic.OfficePackage.HelperModels;
|
||||||
using CaseAccountingContracts.BindingModels;
|
using CaseAccountingContracts.BindingModels;
|
||||||
using CaseAccountingContracts.BusinessLogicContracts;
|
using CaseAccountingContracts.BusinessLogicContracts;
|
||||||
using CaseAccountingContracts.StoragesContracts;
|
using CaseAccountingContracts.StoragesContracts;
|
||||||
@ -30,6 +31,11 @@ builder.Services.AddTransient<ISpecializationLogic, SpecializationLogic>();
|
|||||||
builder.Services.AddTransient<IUserLogic, UserLogic>();
|
builder.Services.AddTransient<IUserLogic, UserLogic>();
|
||||||
|
|
||||||
builder.Services.AddTransient<IReportProviderLogic, ReportProviderLogic>();
|
builder.Services.AddTransient<IReportProviderLogic, ReportProviderLogic>();
|
||||||
|
builder.Services.AddTransient<IReportCustomerLogic, ReportCustomerLogic>();
|
||||||
|
|
||||||
|
builder.Services.AddTransient<WordBuilderCustomer>();
|
||||||
|
builder.Services.AddTransient<ExcelBuilderCustomer>();
|
||||||
|
builder.Services.AddTransient<PdfBuilderCustomer>();
|
||||||
|
|
||||||
builder.Services.AddTransient<WordBuilderProvider>();
|
builder.Services.AddTransient<WordBuilderProvider>();
|
||||||
builder.Services.AddTransient<ExcelBuilderProvider>();
|
builder.Services.AddTransient<ExcelBuilderProvider>();
|
||||||
|
Loading…
Reference in New Issue
Block a user