From c9460bcb996e7e4abf3f7b03da62bf023928cf73 Mon Sep 17 00:00:00 2001 From: "a.puchkina" Date: Thu, 30 May 2024 04:37:12 +0400 Subject: [PATCH] =?UTF-8?q?=D1=8F=20=D0=B2=20=D1=88=D0=BE=D0=BA=D0=B5=20?= =?UTF-8?q?=D0=B4=D0=BE=D0=BA=D1=83=D0=BC=D0=B5=D0=BD=D1=82=D1=8B=20=D0=B4?= =?UTF-8?q?=D0=B5=D0=BB=D0=B0=D1=8E=D1=82=D1=81=D1=8F=20=D0=B8=20=D1=81?= =?UTF-8?q?=D0=BE=D1=85=D1=80=D0=B0=D0=BD=D1=8F=D1=8E=D1=82=D1=81=D1=8F!?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../AbstractSaveToExcelVisitsLawyer.cs | 1 + .../Controllers/LawyerController.cs | 63 +++++++++- .../Controllers/ReportController.cs | 110 ++++++++++++++++++ .../Views/Home/Lawyers.cshtml | 8 ++ .../Views/Home/Report.cshtml | 65 +++++++++++ .../Views/Lawyer/GetFile.cshtml | 31 +++++ .../Views/Shared/_Layout.cshtml | 3 + 7 files changed, 279 insertions(+), 2 deletions(-) create mode 100644 LawFim/LawFirmGuarantorApp/Controllers/ReportController.cs create mode 100644 LawFim/LawFirmGuarantorApp/Views/Home/Report.cshtml create mode 100644 LawFim/LawFirmGuarantorApp/Views/Lawyer/GetFile.cshtml diff --git a/LawFim/LawFirmBusinessLogic/OfficePackages/AbstractSaveToExcelVisitsLawyer.cs b/LawFim/LawFirmBusinessLogic/OfficePackages/AbstractSaveToExcelVisitsLawyer.cs index 3eeac85..9cd5941 100644 --- a/LawFim/LawFirmBusinessLogic/OfficePackages/AbstractSaveToExcelVisitsLawyer.cs +++ b/LawFim/LawFirmBusinessLogic/OfficePackages/AbstractSaveToExcelVisitsLawyer.cs @@ -75,6 +75,7 @@ namespace LawFirmBusinessLogic.OfficePackages StyleInfo = ExcelStyleInfoType.Text }); + rowIndex++; } } diff --git a/LawFim/LawFirmGuarantorApp/Controllers/LawyerController.cs b/LawFim/LawFirmGuarantorApp/Controllers/LawyerController.cs index e5162af..91776e0 100644 --- a/LawFim/LawFirmGuarantorApp/Controllers/LawyerController.cs +++ b/LawFim/LawFirmGuarantorApp/Controllers/LawyerController.cs @@ -51,7 +51,7 @@ namespace LawFirmGuarantorApp.Controllers [HttpGet] public IActionResult UpdateLawyer() { - ViewBag.Medicines = APIClient.GetRequest>($"api/lawyer/getlawyerlist?guarantorid={APIClient.Guarantor.Id}"); + ViewBag.Lawyers = APIClient.GetRequest>($"api/lawyer/getlawyerlist?guarantorid={APIClient.Guarantor.Id}"); return View(); } [HttpPost] @@ -73,5 +73,64 @@ namespace LawFirmGuarantorApp.Controllers }); Response.Redirect("/Home/Lawyers"); } - } + + [HttpGet] + public IActionResult GetFile() + { + ViewBag.Lawyers = APIClient.GetRequest>($"api/lawyer/getlawyerlist?guarantorid={APIClient.Guarantor.Id}"); + + return View(); + } + + [HttpPost] + public void GetFile(int lawyerId, string type) + { + if (APIClient.Guarantor == null) + { + throw new Exception("Вы как суда попали? Суда вход только авторизованным"); + } + + if (lawyerId == 0) + { + throw new Exception("Выберите юриста"); + } + + if (string.IsNullOrEmpty(type)) + { + throw new Exception("Неверный тип отчета"); + } + + if (type == "docx") + { + APIClient.PostRequest("api/reportguarantor/savevisitlawyertowordfile", new ReportVisitLawyerBindingModel + { + LawyerId = lawyerId, + //FileName = "D:\\CourseWork\\wordfileTest.docx", + GuarantorId= APIClient.Guarantor.Id + }); + Response.Redirect("GetWordFile"); + } + else + { + APIClient.PostRequest("api/reportguarantor/savevisitlawyertoexcelfile", new ReportVisitLawyerBindingModel + { + LawyerId = lawyerId, + GuarantorId = APIClient.Guarantor.Id + //FileName = "D:\\CourseWork\\excelfileTest.xlsx" + }); + Response.Redirect("GetExcelFile"); + } + } + + [HttpGet] + public IActionResult GetWordFile() + { + return new PhysicalFileResult("D:\\CourseWork\\wordVisitLawyerReport.docx", "application/vnd.openxmlformats-officedocument.wordprocessingml.document"); + } + + public IActionResult GetExcelFile() + { + return new PhysicalFileResult("D:\\CourseWork\\excelVisitLawyerReport.xlsx", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); + } + } } diff --git a/LawFim/LawFirmGuarantorApp/Controllers/ReportController.cs b/LawFim/LawFirmGuarantorApp/Controllers/ReportController.cs new file mode 100644 index 0000000..f9dad88 --- /dev/null +++ b/LawFim/LawFirmGuarantorApp/Controllers/ReportController.cs @@ -0,0 +1,110 @@ +using LawFirmContracts.BindingModels; +using LawFirmContracts.ViewModels; +using Microsoft.AspNetCore.Mvc; +using System.Globalization; + +namespace LawFirmGuarantorApp.Controllers +{ + public class ReportController : Controller + { + private readonly ILogger _logger; + + public ReportController(ILogger logger) + { + _logger = logger; + } + [HttpGet] + public IActionResult Report() + { + ViewBag.Report = new List(); + return View(); + } + + [HttpGet] + public string GetReport(DateTime dateFrom, DateTime dateTo) + { + if (APIClient.Guarantor == null) + { + throw new Exception("Вы как суда попали? Суда вход только авторизованным"); + } + List result; + try + { + string dateFromS = dateFrom.ToString("s", CultureInfo.InvariantCulture); + string dateToS = dateTo.ToString("s", CultureInfo.InvariantCulture); + result = APIClient.GetRequest> + ($"api/reportguarantor/getconsultationhearingreport?datefrom={dateFromS}&dateto={dateToS}&guarantorid={APIClient.Guarantor.Id}")!; + + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка создания отчета"); + throw; + } + string table = ""; + table += "

Предварительный отчет

"; + table += "
"; + table += ""; + table += ""; + table += ""; + table += ""; + table += ""; + table += ""; + table += ""; + table += ""; + table += ""; + foreach (var medicine in result) + { + table += ""; + table += ""; + table += $""; + table += $""; + table += $""; + table += $""; + table += ""; + foreach (var guidance in medicine.Hearing) + { + table += ""; + table += $""; + table += $""; + table += $""; + table += $""; + table += ""; + } + foreach (var visit in medicine.Case) + { + table += ""; + table += $""; + table += $""; + table += $""; + table += $""; + table += ""; + } + table += ""; + } + table += "
ДатаНазвание медикаментаУслуга рекомендацииНазвание визита
{medicine.LawyerName}
{guidance.HearingDate}{guidance.HearingDate}
{visit.CaseName}{visit.CaseType}
"; + table += "
"; + return table; + } + + [HttpPost] + public void Report(DateTime dateFrom, DateTime dateTo) + { + if (APIClient.Guarantor == null) + { + throw new Exception("Вы как суда попали? Суда вход только авторизованным"); + } + APIClient.PostRequest("api/reportguarantor/mailsend", new ReportCaseHearingBindingModel + { + FileName = "D:\\CourseWork\\pdffiletest.pdf", + GuarantorId = APIClient.Guarantor.Id, + DateFrom = dateFrom, + DateTo = dateTo, + Email = APIClient.Guarantor.Email + + }); + Response.Redirect("Report"); + + } + } +} diff --git a/LawFim/LawFirmGuarantorApp/Views/Home/Lawyers.cshtml b/LawFim/LawFirmGuarantorApp/Views/Home/Lawyers.cshtml index a9a4e70..d6b78ef 100644 --- a/LawFim/LawFirmGuarantorApp/Views/Home/Lawyers.cshtml +++ b/LawFim/LawFirmGuarantorApp/Views/Home/Lawyers.cshtml @@ -69,5 +69,13 @@ } + + +
+ +
+ + + } \ No newline at end of file diff --git a/LawFim/LawFirmGuarantorApp/Views/Home/Report.cshtml b/LawFim/LawFirmGuarantorApp/Views/Home/Report.cshtml new file mode 100644 index 0000000..240a9a4 --- /dev/null +++ b/LawFim/LawFirmGuarantorApp/Views/Home/Report.cshtml @@ -0,0 +1,65 @@ +@{ + ViewData["Title"] = "Report"; +} + +
+
+

Отчет по консультациям и слушаниям за период

+
+ +
+
+
+
+ + +
+
+
+
+ + +
+
+
+ +
+
+
+ +
+
+ +
+
+
+ +
+
+ +
+
+
+ +@section Scripts { + +} \ No newline at end of file diff --git a/LawFim/LawFirmGuarantorApp/Views/Lawyer/GetFile.cshtml b/LawFim/LawFirmGuarantorApp/Views/Lawyer/GetFile.cshtml new file mode 100644 index 0000000..67dea2a --- /dev/null +++ b/LawFim/LawFirmGuarantorApp/Views/Lawyer/GetFile.cshtml @@ -0,0 +1,31 @@ +@using LawFirmContracts.ViewModels; + +@{ + ViewData["Title"] = "Визиты по юристам"; +} + +
+

Создать списки визитов по юристам

+
+
+
+
Юрист:
+
+ +
+
+
+ +
+ + +
+
+ + +
+
+
+ +
+
diff --git a/LawFim/LawFirmGuarantorApp/Views/Shared/_Layout.cshtml b/LawFim/LawFirmGuarantorApp/Views/Shared/_Layout.cshtml index f16ed2c..03338cd 100644 --- a/LawFim/LawFirmGuarantorApp/Views/Shared/_Layout.cshtml +++ b/LawFim/LawFirmGuarantorApp/Views/Shared/_Layout.cshtml @@ -31,6 +31,9 @@ +