From 520441bd07e140b9e874eb6d88757d798733a7d8 Mon Sep 17 00:00:00 2001 From: DyCTaTOR <125912249+DyCTaTOR@users.noreply.github.com> Date: Thu, 30 May 2024 01:19:26 +0400 Subject: [PATCH] =?UTF-8?q?=D0=93=D0=BE=D1=82=D0=BE=D0=B2=D1=8B=D0=B5=20?= =?UTF-8?q?=D1=80=D0=B5=D0=BF=D0=BE=D1=80=D1=82=D1=8B=20=D0=BF=D0=B4=D1=84?= =?UTF-8?q?=20=D1=83=20=D0=BA=D0=BB=D0=B0=D0=B4=D0=BE=D0=B2=D1=89=D0=B8?= =?UTF-8?q?=D0=BA=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../OfficePackage/AbstractSaveToPdfWorker.cs | 2 +- .../UniversityClientApp/Controllers/HomeController.cs | 10 ++++++---- .../Views/Home/ReportDisciplines.cshtml | 8 ++++++++ .../BindingModels/ReportDateRangeBindingModel.cs | 1 - .../UniversityDatabaseImplement/UniversityDatabase.cs | 2 +- .../Controllers/DisciplineController .cs | 4 +++- 6 files changed, 19 insertions(+), 8 deletions(-) diff --git a/University/UniversityBusinessLogic/OfficePackage/AbstractSaveToPdfWorker.cs b/University/UniversityBusinessLogic/OfficePackage/AbstractSaveToPdfWorker.cs index e16ad15..6d34c7d 100644 --- a/University/UniversityBusinessLogic/OfficePackage/AbstractSaveToPdfWorker.cs +++ b/University/UniversityBusinessLogic/OfficePackage/AbstractSaveToPdfWorker.cs @@ -10,7 +10,7 @@ namespace UniversityBusinessLogic.OfficePackage CreatePdf(info); CreateParagraph(new PdfParagraph { Text = info.Title, Style = "NormalTitle", ParagraphAlignment = PdfParagraphAlignmentType.Center }); - CreateTable(new List { "2cm", "3cm", "6cm", "3cm", "4 cm" }); + CreateTable(new List { "4cm", "5cm", "6cm", "5cm", "5 cm" }); CreateRow(new PdfRowParameters { diff --git a/University/UniversityClientApp/Controllers/HomeController.cs b/University/UniversityClientApp/Controllers/HomeController.cs index 54f2fcf..5aac7b6 100644 --- a/University/UniversityClientApp/Controllers/HomeController.cs +++ b/University/UniversityClientApp/Controllers/HomeController.cs @@ -225,13 +225,15 @@ namespace UniversityClientApp.Controllers Redirect("~/Home/Enter"); throw new Exception(" "); } + if (dateFrom == DateOnly.MinValue || dateTo == DateOnly.MaxValue) + { + throw new Exception(); + } if (type == "pdf") { - APIStorekeeper.PostRequest("api/discipline/createreporttopdffile", new ReportDateRangeBindingModel + APIStorekeeper.PostRequest($"api/discipline/createreporttopdffile?dateFrom={dateFrom:yyyy-MM-dd}&dateTo={dateTo:yyyy-MM-dd}", new ReportDateRangeBindingModel { - FileName = "C:\\\\ .pdf", - DateFrom = dateFrom, - DateTo = dateTo + FileName = "C:\\\\ .pdf" }); APIStorekeeper.PostRequest("api/discipline/sendpdftomail", new MailSendInfoBindingModel { diff --git a/University/UniversityClientApp/Views/Home/ReportDisciplines.cshtml b/University/UniversityClientApp/Views/Home/ReportDisciplines.cshtml index 406cf1e..58e0a9f 100644 --- a/University/UniversityClientApp/Views/Home/ReportDisciplines.cshtml +++ b/University/UniversityClientApp/Views/Home/ReportDisciplines.cshtml @@ -21,6 +21,14 @@
+
+ + +
+
+ + +
diff --git a/University/UniversityContracts/BindingModels/ReportDateRangeBindingModel.cs b/University/UniversityContracts/BindingModels/ReportDateRangeBindingModel.cs index a0d7808..602fa7c 100644 --- a/University/UniversityContracts/BindingModels/ReportDateRangeBindingModel.cs +++ b/University/UniversityContracts/BindingModels/ReportDateRangeBindingModel.cs @@ -10,7 +10,6 @@ namespace UniversityContracts.BindingModels { public string? FileName { get; set; } public Stream? Stream { get; set; } - public DateOnly DateFrom { get; set; } public DateOnly DateTo { get; set; } } diff --git a/University/UniversityDatabaseImplement/UniversityDatabase.cs b/University/UniversityDatabaseImplement/UniversityDatabase.cs index 2b73bad..3eebb86 100644 --- a/University/UniversityDatabaseImplement/UniversityDatabase.cs +++ b/University/UniversityDatabaseImplement/UniversityDatabase.cs @@ -11,7 +11,7 @@ namespace UniversityDatabaseImplement if (optionsBuilder.IsConfigured == false) { //Возможно понадобится писать вместо (localdb) название пк, вот пк Егора: DESKTOP-N8BRIPR; other-name: LAPTOP-DYCTATOR; other-name: DyCTaTOR - optionsBuilder.UseSqlServer(@"Data Source=DyCTaTOR\SQLEXPRESS;Initial Catalog=UniversityDatabaseFull;Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True"); + optionsBuilder.UseSqlServer(@"Data Source=LAPTOP-DYCTATOR\SQLEXPRESS;Initial Catalog=UniversityDatabaseFull;Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True"); } base.OnConfiguring(optionsBuilder); } diff --git a/University/UniversityRestApi/Controllers/DisciplineController .cs b/University/UniversityRestApi/Controllers/DisciplineController .cs index da19bd7..9c3ba42 100644 --- a/University/UniversityRestApi/Controllers/DisciplineController .cs +++ b/University/UniversityRestApi/Controllers/DisciplineController .cs @@ -105,11 +105,13 @@ namespace UniversityRestApi.Controllers [HttpPost] - public void CreateReportToPDFFile(ReportDateRangeBindingModel model) + public void CreateReportToPDFFile(ReportDateRangeBindingModel model, DateOnly dateFrom, DateOnly dateTo) { try { System.Text.Encoding.RegisterProvider(System.Text.CodePagesEncodingProvider.Instance); + model.DateTo = dateTo; + model.DateFrom = dateFrom; _reportLogic.SendDisciplinesToEmail(model); } catch (Exception ex)