Compare commits

..

No commits in common. "6fef69e06d78f7d747944fd3a15205cc9b28879a" and "ccf551cc4a618669fe09c158d657b8266e22ec27" have entirely different histories.

7 changed files with 1 additions and 313 deletions

View File

@ -26,8 +26,6 @@ namespace LawFirmBusinessLogic.BusinessLogics
private readonly AbstractSaveToPdfConsultationHearing _saveToPdfConsultationHearing;
private readonly AbstractSaveToPdfCaseHearing _saveToPdfCaseHearing;
private readonly AbstractSaveToPdfClientCaseHearing _saveToPdfClientCaseHearing;
public ReportLogic(IClientStorage clientStorage, IHearingStorage hearingStorage,
IVisitStorage visitStorage, ICaseStorage caseStorage,
ILawyerStorage lawyerStorage, IConsultationStorage consultationStorage,
@ -256,45 +254,6 @@ namespace LawFirmBusinessLogic.BusinessLogics
return list;
}
public List<ReportClientCaseHearingViewModel> GetCaseHearing(ReportClientCaseHearingBindingModel model)
{
var list = new List<ReportClientCaseHearingViewModel>();
var clients = _clientStorage.GetFilteredList(new ClientSearchModel { ExecutorId = model.ExecutorId });
var cases = _caseStorage.GetFilteredList(new CaseSearchModel { ExecutorId = model.ExecutorId, DateFrom = model.DateFrom });
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)
{
var record = new ReportClientCaseHearingViewModel
{
ClientName = client.FIO
};
foreach (var cas in cases)
{
if (cas.CaseClients.ContainsKey(client.Id))
{
record.Case.Add(new(cas.DateCreate, cas.Name));
}
}
foreach (var visit in visits)
{
if (visit.VisitClients.ContainsKey(client.Id))
{
foreach (var hear in hearings)
{
if (visit.HearingId.Equals(hear.Id))
{
record.Hearing.Add(new(hear.HearingDate, hear.Judge));
}
}
}
}
list.Add(record);
}
return list;
}
public void SaveClientsConsultationToExcelFile(ReportBindingModel model)
{
_saveToExcelClientsConsultation.CreateReport(new ExcelClientsConsultationInfo
@ -360,18 +319,6 @@ namespace LawFirmBusinessLogic.BusinessLogics
});
}
public void SaveClientCaseHearingToPdfFile(ReportClientCaseHearingBindingModel model)
{
_saveToPdfClientCaseHearing.CreateDoc(new PDFClientCaseHearingInfo
{
FileName = model.FileName,
Title = "Отчёт по клиентам по делам и консультациям",
DateFrom = model.DateFrom,
DateTo = model.DateTo,
ClientCaseHearing = GetCaseHearing(model)
});
}
public void SaveCaseHearingToPdfFile(ReportCaseHearingBindingModel model)
{
_saveToPdfCaseHearing.CreateDoc(new PDFCaseHearingInfo

View File

@ -25,7 +25,7 @@ namespace LawFirmBusinessLogic.MailWorker
objMailMessage.Body = info.Text;
objMailMessage.SubjectEncoding = Encoding.UTF8;
objMailMessage.BodyEncoding = Encoding.UTF8;
Attachment attachment = new Attachment("E:\\reports\\pdffile.pdf", new ContentType(MediaTypeNames.Application.Pdf));
Attachment attachment = new Attachment("C:\\ReportsCourseWork\\pdffile.pdf", new ContentType(MediaTypeNames.Application.Pdf));
objMailMessage.Attachments.Add(attachment);
objSmtpClient.UseDefaultCredentials = false;

View File

@ -1,120 +0,0 @@
using LawFirmBusinessLogic.OfficePackages.HelperEnums;
using LawFirmBusinessLogic.OfficePackages.HelperModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace LawFirmBusinessLogic.OfficePackages
{
public abstract class AbstractSaveToPdfClientCaseHearing
{
public void CreateDoc(PDFClientCaseHearingInfo 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.ClientCaseHearing)
{
CreateRow(new PdfRowParameters
{
Texts = new List<string> { ch.ClientName, " ", " " },
Style = "Normal",
ParagraphAlignment = PdfParagraphAlignmentType.Center
});
foreach (var cas in ch.Case)
CreateRow(new PdfRowParameters
{
Texts = new List<string> { " ", cas.CaseName, cas.CaseDate.ToShortDateString() },
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.ClientCaseHearing)
{
CreateRow(new PdfRowParameters
{
Texts = new List<string> { ch.ClientName, " ", " " },
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(PDFClientCaseHearingInfo 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(PDFClientCaseHearingInfo info);
}
}

View File

@ -1,18 +0,0 @@
using LawFirmContracts.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace LawFirmBusinessLogic.OfficePackages.HelperModels
{
public class PDFClientCaseHearingInfo
{
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<ReportClientCaseHearingViewModel> ClientCaseHearing { get; set; } = new();
}
}

View File

@ -1,101 +0,0 @@
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 SaveToPdfClientCaseHearing : AbstractSaveToPdfClientCaseHearing
{
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(PDFClientCaseHearingInfo 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(PDFClientCaseHearingInfo info)
{
var renderer = new PdfDocumentRenderer(true)
{
Document = _document
};
renderer.RenderDocument();
renderer.PdfDocument.Save(info.FileName);
}
}
}

View File

@ -1,11 +0,0 @@
namespace LawFirmContracts.BindingModels
{
public class ReportClientCaseHearingBindingModel
{
public string FileName { get; set; } = string.Empty;
public DateTime DateFrom { get; set; } = DateTime.Now;
public DateTime DateTo { get; set; } = DateTime.Now;
public int? ExecutorId { get; set; }
public string? Email { get; set; }
}
}

View File

@ -1,9 +0,0 @@
namespace LawFirmContracts.ViewModels
{
public class ReportClientCaseHearingViewModel
{
public string ClientName { get; set; } = string.Empty;
public List<(DateTime CaseDate, string CaseName)> Case { get; set; } = new();
public List<(DateTime HearingDate, string Judge)> Hearing { get; set; } = new();
}
}