ниче не понимаю какие конфликты....
This commit is contained in:
commit
6fef69e06d
@ -24,6 +24,7 @@ namespace LawFirmBusinessLogic.BusinessLogics
|
||||
private readonly AbstractSaveToExcelVisitsLawyer _saveToExcelVisitLawyer;
|
||||
private readonly AbstractSaveToWordVisitsLawyer _saveToWordVisitLawyer;
|
||||
private readonly AbstractSaveToPdfConsultationHearing _saveToPdfConsultationHearing;
|
||||
private readonly AbstractSaveToPdfCaseHearing _saveToPdfCaseHearing;
|
||||
|
||||
private readonly AbstractSaveToPdfClientCaseHearing _saveToPdfClientCaseHearing;
|
||||
|
||||
@ -37,7 +38,8 @@ namespace LawFirmBusinessLogic.BusinessLogics
|
||||
|
||||
AbstractSaveToExcelVisitsLawyer saveToExcelVisitLawyer,
|
||||
AbstractSaveToWordVisitsLawyer saveToWordVisitLawyer,
|
||||
AbstractSaveToPdfConsultationHearing saveToPdfConsultationHearing
|
||||
AbstractSaveToPdfConsultationHearing saveToPdfConsultationHearing,
|
||||
AbstractSaveToPdfCaseHearing saveToPdfCaseHearing
|
||||
)
|
||||
{
|
||||
_clientStorage = clientStorage;
|
||||
@ -52,6 +54,7 @@ namespace LawFirmBusinessLogic.BusinessLogics
|
||||
_saveToExcelVisitLawyer = saveToExcelVisitLawyer;
|
||||
_saveToWordVisitLawyer = saveToWordVisitLawyer;
|
||||
_saveToPdfConsultationHearing = saveToPdfConsultationHearing;
|
||||
_saveToPdfCaseHearing = saveToPdfCaseHearing;
|
||||
}
|
||||
public List<ReportClientsConsultationViewModel> GetClientsConsultation(ReportBindingModel model)
|
||||
{
|
||||
@ -135,40 +138,6 @@ namespace LawFirmBusinessLogic.BusinessLogics
|
||||
|
||||
public List<ReportVisitLawyerViewModel> GetVisitLawyer(ReportVisitLawyerBindingModel model)
|
||||
{
|
||||
/*var list = new List<ReportVisitLawyerViewModel>();
|
||||
var lawyers = _lawyerStorage.GetFilteredList(new LawyerSearchModel
|
||||
{
|
||||
Id = model.LawyerId
|
||||
});
|
||||
//getfilteredlist
|
||||
var hearings = _hearingStorage.GetFullList();
|
||||
var visits = _visitStorage.GetFullList();
|
||||
foreach (var lawyer in lawyers)
|
||||
{
|
||||
var record = new ReportVisitLawyerViewModel
|
||||
{
|
||||
LawyerName = lawyer.FIO,
|
||||
Visits = new List<DateTime>()
|
||||
|
||||
};
|
||||
foreach (var hearing in hearings)
|
||||
{
|
||||
if (hearing.HearingLawyers.ContainsKey(lawyer.Id))
|
||||
{
|
||||
foreach (var visit in visits)
|
||||
{
|
||||
if (visit.HearingId.Equals(hearing.Id))
|
||||
{
|
||||
record.Visits.Add(visit.VisitDate);
|
||||
//record.VisitDate = visit.VisitDate;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
list.Add(record);
|
||||
}
|
||||
return list;*/
|
||||
|
||||
var lawyers = _lawyerStorage.GetFilteredList(new LawyerSearchModel { Id = model.LawyerId });
|
||||
var hearings = _hearingStorage.GetFilteredList(new HearingSearchModel { GuarantorId = model.GuarantorId });
|
||||
var visits = _visitStorage.GetFullList();
|
||||
@ -243,6 +212,50 @@ namespace LawFirmBusinessLogic.BusinessLogics
|
||||
return list;
|
||||
}
|
||||
|
||||
public List<ReportCaseHearingViewModel> GetCaseHearing(ReportCaseHearingBindingModel model)
|
||||
{
|
||||
var list = new List<ReportCaseHearingViewModel>();
|
||||
var lawyers = _lawyerStorage.GetFilteredList(new LawyerSearchModel { Id = model.LawyerId });
|
||||
var consulations = _consultationStorage.GetFilteredList(new ConsultationSearchModel { GuarantorId = model.GuarantorId });
|
||||
var cases = _caseStorage.GetFullList();
|
||||
var hearings = _hearingStorage.GetFilteredList(new HearingSearchModel
|
||||
{
|
||||
GuarantorId = model.GuarantorId,
|
||||
DateFrom = model.DateFrom,
|
||||
DateTo = model.DateTo
|
||||
});
|
||||
|
||||
foreach (var lawyer in lawyers)
|
||||
{
|
||||
var record = new ReportCaseHearingViewModel
|
||||
{
|
||||
LawyerName = lawyer.FIO,
|
||||
};
|
||||
foreach (var cons in consulations)
|
||||
{
|
||||
if (cons.ConsultationLawyers.ContainsKey(lawyer.Id))
|
||||
{
|
||||
foreach (var cas in cases)
|
||||
{
|
||||
if (cas.Id.Equals(cons.CaseId))
|
||||
{
|
||||
record.Case.Add(new(cas.Name, cas.CaseType));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
foreach (var hearing in hearings)
|
||||
{
|
||||
if (hearing.HearingLawyers.ContainsKey(lawyer.Id))
|
||||
{
|
||||
record.Hearing.Add(new(hearing.HearingDate, hearing.Judge));
|
||||
}
|
||||
}
|
||||
list.Add(record);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
public List<ReportClientCaseHearingViewModel> GetCaseHearing(ReportClientCaseHearingBindingModel model)
|
||||
{
|
||||
var list = new List<ReportClientCaseHearingViewModel>();
|
||||
@ -358,5 +371,18 @@ namespace LawFirmBusinessLogic.BusinessLogics
|
||||
ClientCaseHearing = GetCaseHearing(model)
|
||||
});
|
||||
}
|
||||
|
||||
public void SaveCaseHearingToPdfFile(ReportCaseHearingBindingModel model)
|
||||
{
|
||||
_saveToPdfCaseHearing.CreateDoc(new PDFCaseHearingInfo
|
||||
{
|
||||
FileName = model.FileName,
|
||||
Title = "Отчёт по делам и слушаниям по выбранным юристам",
|
||||
DateFrom = model.DateFrom,
|
||||
DateTo = model.DateTo,
|
||||
CaseHearing = GetCaseHearing(model)
|
||||
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,115 @@
|
||||
using LawFirmBusinessLogic.OfficePackages.HelperEnums;
|
||||
using LawFirmBusinessLogic.OfficePackages.HelperModels;
|
||||
|
||||
namespace LawFirmBusinessLogic.OfficePackages
|
||||
{
|
||||
public abstract class AbstractSaveToPdfCaseHearing
|
||||
{
|
||||
public void CreateDoc(PDFCaseHearingInfo info)
|
||||
{
|
||||
CreatePdf(info);
|
||||
CreateParagraph(new PdfParagraph
|
||||
{
|
||||
Text = info.Title,
|
||||
Style = "NormalTitle",
|
||||
ParagraphAlignment = PdfParagraphAlignmentType.Center
|
||||
});
|
||||
CreateParagraph(new PdfParagraph
|
||||
{
|
||||
Text = $"с{info.DateFrom.ToShortDateString()} по {info.DateTo.ToShortDateString()}",
|
||||
Style = "Normal",
|
||||
ParagraphAlignment = PdfParagraphAlignmentType.Center
|
||||
});
|
||||
CreateTable(new List<string> { "3cm", "5cm", "5cm" });
|
||||
CreateRow(new PdfRowParameters
|
||||
{
|
||||
Texts = new List<string> { "Юрист", "Название дела", "Тип производства" },
|
||||
Style = "NormalTitle",
|
||||
ParagraphAlignment = PdfParagraphAlignmentType.Center
|
||||
});
|
||||
|
||||
foreach (var ch in info.CaseHearing)
|
||||
{
|
||||
CreateRow(new PdfRowParameters
|
||||
{
|
||||
Texts = new List<string> { ch.LawyerName, " ", " " },
|
||||
Style = "Normal",
|
||||
ParagraphAlignment = PdfParagraphAlignmentType.Center
|
||||
|
||||
});
|
||||
foreach (var @case in ch.Case)
|
||||
CreateRow(new PdfRowParameters
|
||||
{
|
||||
Texts = new List<string> { " ", @case.CaseName, @case.CaseType },
|
||||
Style = "Normal",
|
||||
ParagraphAlignment = PdfParagraphAlignmentType.Center
|
||||
});
|
||||
CreateRow(new PdfRowParameters
|
||||
{
|
||||
Texts = new List<string> { " ", " ", "Итого: " + ch.Case.Count.ToString() },
|
||||
Style = "Normal",
|
||||
ParagraphAlignment = PdfParagraphAlignmentType.Rigth
|
||||
});
|
||||
}
|
||||
|
||||
CreateTable(new List<string> { "3cm", "5cm", "5cm" });
|
||||
CreateRow(new PdfRowParameters
|
||||
{
|
||||
Texts = new List<string> { "Юрист", "Суд", "Дата слушания" },
|
||||
Style = "NormalTitle",
|
||||
ParagraphAlignment = PdfParagraphAlignmentType.Center
|
||||
});
|
||||
foreach (var ch in info.CaseHearing)
|
||||
{
|
||||
CreateRow(new PdfRowParameters
|
||||
{
|
||||
Texts = new List<string> { ch.LawyerName, " ", " " },
|
||||
Style = "Normal",
|
||||
ParagraphAlignment = PdfParagraphAlignmentType.Center
|
||||
|
||||
});
|
||||
foreach (var hear in ch.Hearing)
|
||||
CreateRow(new PdfRowParameters
|
||||
{
|
||||
Texts = new List<string> { " ", hear.Judge, hear.HearingDate.ToShortDateString() },
|
||||
Style = "Normal",
|
||||
ParagraphAlignment = PdfParagraphAlignmentType.Left
|
||||
});
|
||||
CreateRow(new PdfRowParameters
|
||||
{
|
||||
Texts = new List<string> { " ", " ", "Итого: " + ch.Hearing.Count.ToString() },
|
||||
Style = "Normal",
|
||||
ParagraphAlignment = PdfParagraphAlignmentType.Rigth
|
||||
});
|
||||
}
|
||||
SavePdf(info);
|
||||
}
|
||||
/// <summary>
|
||||
/// Создание doc-файла
|
||||
/// </summary>
|
||||
/// <param name="info"></param>
|
||||
protected abstract void CreatePdf(PDFCaseHearingInfo info);
|
||||
/// <summary>
|
||||
/// Создание параграфа с текстом
|
||||
/// </summary>
|
||||
/// <param name="title"></param>
|
||||
/// <param name="style"></param>
|
||||
protected abstract void CreateParagraph(PdfParagraph paragraph);
|
||||
/// <summary>
|
||||
/// Создание таблицы
|
||||
/// </summary>
|
||||
/// <param name="title"></param>
|
||||
/// <param name="style"></param>
|
||||
protected abstract void CreateTable(List<string> columns);
|
||||
/// <summary>
|
||||
/// Создание и заполнение строки
|
||||
/// </summary>
|
||||
/// <param name="rowParameters"></param>
|
||||
protected abstract void CreateRow(PdfRowParameters rowParameters);
|
||||
/// <summary>
|
||||
/// Сохранение файла
|
||||
/// </summary>
|
||||
/// <param name="info"></param>
|
||||
protected abstract void SavePdf(PDFCaseHearingInfo info);
|
||||
}
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
using LawFirmContracts.ViewModels;
|
||||
|
||||
namespace LawFirmBusinessLogic.OfficePackages.HelperModels
|
||||
{
|
||||
public class PDFCaseHearingInfo
|
||||
{
|
||||
public string FileName { get; set; } = string.Empty;
|
||||
public string Title { get; set; } = string.Empty;
|
||||
public DateTime DateFrom { get; set; }
|
||||
public DateTime DateTo { get; set; }
|
||||
public List<ReportCaseHearingViewModel> CaseHearing { get; set; } = new();
|
||||
}
|
||||
}
|
@ -0,0 +1,102 @@
|
||||
|
||||
using LawFirmBusinessLogic.OfficePackages.HelperEnums;
|
||||
using LawFirmBusinessLogic.OfficePackages.HelperModels;
|
||||
using MigraDoc.DocumentObjectModel;
|
||||
using MigraDoc.Rendering;
|
||||
using VerticalAlignment = MigraDoc.DocumentObjectModel.Tables.VerticalAlignment;
|
||||
|
||||
namespace LawFirmBusinessLogic.OfficePackages.Implements
|
||||
{
|
||||
public class SaveToPdfCaseHearing : AbstractSaveToPdfCaseHearing
|
||||
{
|
||||
private Document? _document;
|
||||
private Section? _section;
|
||||
private MigraDoc.DocumentObjectModel.Tables.Table? _table;
|
||||
private static ParagraphAlignment
|
||||
GetParagraphAlignment(PdfParagraphAlignmentType type)
|
||||
{
|
||||
return type switch
|
||||
{
|
||||
PdfParagraphAlignmentType.Center => ParagraphAlignment.Center,
|
||||
PdfParagraphAlignmentType.Left => ParagraphAlignment.Left,
|
||||
PdfParagraphAlignmentType.Rigth => ParagraphAlignment.Right,
|
||||
_ => ParagraphAlignment.Justify,
|
||||
};
|
||||
}
|
||||
/// <summary>
|
||||
/// Создание стилей для документа
|
||||
/// </summary>
|
||||
/// <param name="document"></param>
|
||||
private static 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;
|
||||
}
|
||||
protected override void CreatePdf(PDFCaseHearingInfo info)
|
||||
{
|
||||
_document = new Document();
|
||||
DefineStyles(_document);
|
||||
_section = _document.AddSection();
|
||||
}
|
||||
protected override 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;
|
||||
}
|
||||
protected override void CreateTable(List<string> columns)
|
||||
{
|
||||
if (_document == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_table = _document.LastSection.AddTable();
|
||||
foreach (var elem in columns)
|
||||
{
|
||||
_table.AddColumn(elem);
|
||||
}
|
||||
}
|
||||
protected override 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;
|
||||
}
|
||||
}
|
||||
protected override void SavePdf(PDFCaseHearingInfo info)
|
||||
{
|
||||
var renderer = new PdfDocumentRenderer(true)
|
||||
{
|
||||
Document = _document
|
||||
};
|
||||
renderer.RenderDocument();
|
||||
renderer.PdfDocument.Save(info.FileName);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
using LawFirmContracts.ViewModels;
|
||||
|
||||
namespace LawFirmContracts.BindingModels
|
||||
{
|
||||
public class ReportCaseHearingBindingModel
|
||||
{
|
||||
public string FileName { get; set; } = string.Empty;
|
||||
public DateTime DateFrom { get; set; } = DateTime.Now;
|
||||
public DateTime DateTo { get; set; } = DateTime.Now;
|
||||
public int? GuarantorId { get; set; }
|
||||
public int? LawyerId { get; set; }
|
||||
}
|
||||
}
|
@ -9,12 +9,14 @@ namespace LawFirmContracts.BusinessLogicContracts
|
||||
List<ReportClientsViewModel> GetGetClients(ReportBindingModel model);
|
||||
List<ReportVisitLawyerViewModel> GetVisitLawyer(ReportVisitLawyerBindingModel model);
|
||||
List<ReportConsultationHearingViewModel> GetConsultationHearing(ReportConsultationHearingBindingModel model);
|
||||
List<ReportCaseHearingViewModel> GetCaseHearing(ReportCaseHearingBindingModel model);
|
||||
|
||||
void SaveClientsConsultationToWordFile(ReportBindingModel model);
|
||||
void SaveClientsConsultationToExcelFile(ReportBindingModel model);
|
||||
void SaveVisitLawyerToWordFile(ReportVisitLawyerBindingModel model);
|
||||
void SaveVisitLawyerToExcelFile(ReportVisitLawyerBindingModel model);
|
||||
void SaveConsultationHearingToPdfFile(ReportConsultationHearingBindingModel model);
|
||||
void SaveCaseHearingToPdfFile(ReportCaseHearingBindingModel model);
|
||||
void SaveClientsToPdfFile(ReportBindingModel model);
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,9 @@
|
||||
namespace LawFirmContracts.ViewModels
|
||||
{
|
||||
public class ReportCaseHearingViewModel
|
||||
{
|
||||
public string LawyerName { get; set; } = string.Empty;
|
||||
public List<(string CaseName, string CaseType)> Case { get; set; } = new();
|
||||
public List<(DateTime HearingDate, string Judge)> Hearing { get; set; } = new();
|
||||
}
|
||||
}
|
@ -42,11 +42,36 @@ namespace LawFirmRestApi.Controllers
|
||||
}
|
||||
}
|
||||
[HttpPost]
|
||||
public void SaveCaseHearingToPdfFile(ReportCaseHearingBindingModel report)
|
||||
{
|
||||
try
|
||||
{
|
||||
_reportLogic.SaveCaseHearingToPdfFile(new ReportCaseHearingBindingModel
|
||||
{
|
||||
DateFrom = report.DateFrom,
|
||||
DateTo = report.DateTo,
|
||||
FileName = "D:\\CourseWork\\pdfCaseHearingsReport.pdf",
|
||||
GuarantorId = report.GuarantorId,
|
||||
LawyerId =report.LawyerId,
|
||||
});
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка создания отчета");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
[HttpPost]
|
||||
public void SaveVisitLawyerToWordFile(ReportVisitLawyerBindingModel report)
|
||||
{
|
||||
try
|
||||
{
|
||||
_reportLogic.SaveVisitLawyerToWordFile(new ReportVisitLawyerBindingModel { GuarantorId = report.GuarantorId, FileName = "D:\\CourseWork\\wordVisitLawyerReport.docx", LawyerId = report.LawyerId });
|
||||
_reportLogic.SaveVisitLawyerToWordFile(new ReportVisitLawyerBindingModel
|
||||
{
|
||||
GuarantorId = report.GuarantorId,
|
||||
FileName = "D:\\CourseWork\\wordVisitLawyerReport.docx",
|
||||
LawyerId = report.LawyerId
|
||||
});
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@ -59,7 +84,12 @@ namespace LawFirmRestApi.Controllers
|
||||
{
|
||||
try
|
||||
{
|
||||
_reportLogic.SaveVisitLawyerToExcelFile(new ReportVisitLawyerBindingModel { GuarantorId = report.GuarantorId, FileName = "D:\\CourseWork\\excelVisitLawyerReport.xlsx", LawyerId = report.LawyerId });
|
||||
_reportLogic.SaveVisitLawyerToExcelFile(new ReportVisitLawyerBindingModel
|
||||
{
|
||||
GuarantorId = report.GuarantorId,
|
||||
FileName = "D:\\CourseWork\\excelVisitLawyerReport.xlsx",
|
||||
LawyerId = report.LawyerId
|
||||
});
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
@ -44,6 +44,7 @@ builder.Services.AddTransient<AbstractSaveToExcelVisitsLawyer, SaveToExcelVisits
|
||||
builder.Services.AddTransient<AbstractSaveToWordClientsConsultation, SaveToWordClientsConsultation>();
|
||||
builder.Services.AddTransient<AbstractSaveToWordVisitsLawyer, SaveToWordVisitsLawyer>();
|
||||
builder.Services.AddTransient<AbstractSaveToPdfConsultationHearing, SaveToPdfConsultationHearing>();
|
||||
builder.Services.AddTransient<AbstractSaveToPdfCaseHearing, SaveToPdfCaseHearing>();
|
||||
builder.Services.AddTransient<AbstractSaveToPdfClients, SaveToPdfClients>();
|
||||
builder.Services.AddTransient<AbstractMailWorker, MailKitWorker>();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user