From 4e4d3ff5e17be451c8ef15878546685b33bad7ac Mon Sep 17 00:00:00 2001 From: DyCTaTOR <125912249+DyCTaTOR@users.noreply.github.com> Date: Tue, 28 May 2024 21:40:18 +0400 Subject: [PATCH] =?UTF-8?q?=D0=9F=D1=80=D0=BE=D0=BC=D0=B5=D0=B6=D1=83?= =?UTF-8?q?=D1=82=D0=BE=D1=87=D0=BD=D0=BE=D0=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BusinessLogics/ReportLogic.cs | 20 ++++++-- .../AbstractSaveToExcelWorker.cs | 8 +-- .../OfficePackage/AbstractSaveToPdfWorker.cs | 8 +-- .../AbstractSaveToWordStorekeeper.cs | 2 +- .../{ExcelInfo.cs => ExcelInfoWorker.cs} | 2 +- .../{PdfInfo.cs => PdfInfoWorker.cs} | 2 +- .../Implements/SaveToExcelWorker.cs | 4 +- .../Implements/SaveToPdfWorker.cs | 4 +- .../Controllers/HomeController.cs | 21 ++++---- .../ReportPlanOfStudyAndDisciplines.cshtml | 49 +++++++++++++++++++ .../Views/Shared/_Layout.cshtml | 4 ++ .../BusinessLogicsContracts/IReportLogic.cs | 14 ++++-- .../Controllers/PlanOfStudysController.cs | 33 +++++++------ University/UniversityRestApi/Program.cs | 8 +++ 14 files changed, 130 insertions(+), 49 deletions(-) rename University/UniversityBusinessLogic/OfficePackage/HelperModels/{ExcelInfo.cs => ExcelInfoWorker.cs} (92%) rename University/UniversityBusinessLogic/OfficePackage/HelperModels/{PdfInfo.cs => PdfInfoWorker.cs} (92%) create mode 100644 University/UniversityClientAppWorker/Views/Home/ReportPlanOfStudyAndDisciplines.cshtml diff --git a/University/UniversityBusinessLogic/BusinessLogics/ReportLogic.cs b/University/UniversityBusinessLogic/BusinessLogics/ReportLogic.cs index 158565f..e333bfd 100644 --- a/University/UniversityBusinessLogic/BusinessLogics/ReportLogic.cs +++ b/University/UniversityBusinessLogic/BusinessLogics/ReportLogic.cs @@ -5,6 +5,7 @@ using UniversityContracts.BusinessLogicContracts; using UniversityContracts.SearchModels; using UniversityContracts.StorageContracts; using UniversityContracts.ViewModels; +using UniversityBusinessLogic.OfficePackage.HelperModels; namespace UniversityBusinessLogics.BusinessLogics; @@ -206,17 +207,25 @@ public class ReportLogic : IReportLogic } public void SavePlanOfStudyToExcel(ReportBindingModel option) { - throw new NotImplementedException(); + /*_saveToExcelWorker.CreateReport(new ExcelInfoWorker + { + + });*/ } public void SavePlanOfStudyToWord(ReportBindingModel option) { - throw new NotImplementedException(); + _saveToWordWorker.CreateDoc(new WordInfoWorker + { + FileName = option.FileName, + Title = "Список планов обучения", + PlanOfStudys = GetPlanOfStudyAndDisciplines() + }); } public void SaveTeachersToWord(ReportBindingModel option) { - throw new NotImplementedException(); + } public void SendDisciplinesToEmail(ReportDateRangeBindingModel option, string email) @@ -226,6 +235,9 @@ public class ReportLogic : IReportLogic public void SendPlanOfStudyToEmail(ReportDateRangeBindingModel option, string email) { - throw new NotImplementedException(); + /*_saveToPdfWorker.CreateDoc(new PdfInfoWorker + { + + });*/ } } \ No newline at end of file diff --git a/University/UniversityBusinessLogic/OfficePackage/AbstractSaveToExcelWorker.cs b/University/UniversityBusinessLogic/OfficePackage/AbstractSaveToExcelWorker.cs index 3c05794..e1edd8c 100644 --- a/University/UniversityBusinessLogic/OfficePackage/AbstractSaveToExcelWorker.cs +++ b/University/UniversityBusinessLogic/OfficePackage/AbstractSaveToExcelWorker.cs @@ -10,7 +10,7 @@ namespace UniversityBusinessLogic.OfficePackage { public abstract class AbstractSaveToExcelWorker { - public void CreateReport(ExcelInfo info) + /*public void CreateReport(ExcelInfoWorker info) { CreateExcel(info); InsertCellInWorksheet(new ExcelCellParameters @@ -73,10 +73,10 @@ namespace UniversityBusinessLogic.OfficePackage rowIndex++; } SaveExcel(info); - } - protected abstract void CreateExcel(ExcelInfo info); + }*/ + protected abstract void CreateExcel(ExcelInfoWorker info); protected abstract void InsertCellInWorksheet(ExcelCellParameters excelParams); protected abstract void MergeCells(ExcelMergeParameters excelParams); - protected abstract void SaveExcel(ExcelInfo info); + protected abstract void SaveExcel(ExcelInfoWorker info); } } diff --git a/University/UniversityBusinessLogic/OfficePackage/AbstractSaveToPdfWorker.cs b/University/UniversityBusinessLogic/OfficePackage/AbstractSaveToPdfWorker.cs index 7096b57..d01ffee 100644 --- a/University/UniversityBusinessLogic/OfficePackage/AbstractSaveToPdfWorker.cs +++ b/University/UniversityBusinessLogic/OfficePackage/AbstractSaveToPdfWorker.cs @@ -5,7 +5,7 @@ namespace UniversityBusinessLogic.OfficePackage { public abstract class AbstractSaveToPdfWorker { - public void CreateDoc(PdfInfo info) + /*public void CreateDoc(PdfInfoWorker info) { CreatePdf(info); CreateParagraph(new PdfParagraph { Text = info.Title, Style = "NormalTitle", ParagraphAlignment = PdfParagraphAlignmentType.Center }); @@ -32,13 +32,13 @@ namespace UniversityBusinessLogic.OfficePackage CreateParagraph(new PdfParagraph { Text = $"Итого: {info.Orders.Sum(x => x.Sum)}\t", Style = "Normal", ParagraphAlignment = PdfParagraphAlignmentType.Right }); SavePdf(info); - } + }*/ /// /// Создание doc-файла /// /// - protected abstract void CreatePdf(PdfInfo info); + protected abstract void CreatePdf(PdfInfoWorker info); /// /// Создание параграфа с текстом @@ -64,6 +64,6 @@ namespace UniversityBusinessLogic.OfficePackage /// Сохранение файла /// /// - protected abstract void SavePdf(PdfInfo info); + protected abstract void SavePdf(PdfInfoWorker info); } } diff --git a/University/UniversityBusinessLogic/OfficePackage/AbstractSaveToWordStorekeeper.cs b/University/UniversityBusinessLogic/OfficePackage/AbstractSaveToWordStorekeeper.cs index d3d74f0..2ea932f 100644 --- a/University/UniversityBusinessLogic/OfficePackage/AbstractSaveToWordStorekeeper.cs +++ b/University/UniversityBusinessLogic/OfficePackage/AbstractSaveToWordStorekeeper.cs @@ -4,7 +4,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; using UniversityBusinessLogic.OfficePackage.HelperModels; -using UniversityBusinessLogics.OfficePackage.HelperEnums; +using UniversityBusinessLogic.OfficePackage.HelperEnums; namespace UniversityBusinessLogic.OfficePackage { diff --git a/University/UniversityBusinessLogic/OfficePackage/HelperModels/ExcelInfo.cs b/University/UniversityBusinessLogic/OfficePackage/HelperModels/ExcelInfoWorker.cs similarity index 92% rename from University/UniversityBusinessLogic/OfficePackage/HelperModels/ExcelInfo.cs rename to University/UniversityBusinessLogic/OfficePackage/HelperModels/ExcelInfoWorker.cs index 8c01fab..804afb4 100644 --- a/University/UniversityBusinessLogic/OfficePackage/HelperModels/ExcelInfo.cs +++ b/University/UniversityBusinessLogic/OfficePackage/HelperModels/ExcelInfoWorker.cs @@ -1,6 +1,6 @@ namespace UniversityBusinessLogic.OfficePackage.HelperModels { - public class ExcelInfo + public class ExcelInfoWorker { public string? FileName { get; set; } diff --git a/University/UniversityBusinessLogic/OfficePackage/HelperModels/PdfInfo.cs b/University/UniversityBusinessLogic/OfficePackage/HelperModels/PdfInfoWorker.cs similarity index 92% rename from University/UniversityBusinessLogic/OfficePackage/HelperModels/PdfInfo.cs rename to University/UniversityBusinessLogic/OfficePackage/HelperModels/PdfInfoWorker.cs index 59f9ea4..dba7672 100644 --- a/University/UniversityBusinessLogic/OfficePackage/HelperModels/PdfInfo.cs +++ b/University/UniversityBusinessLogic/OfficePackage/HelperModels/PdfInfoWorker.cs @@ -1,6 +1,6 @@ namespace UniversityBusinessLogic.OfficePackage.HelperModels { - public class PdfInfo + public class PdfInfoWorker { public string? FileName { get; set; } public Stream? Stream { get; set; } diff --git a/University/UniversityBusinessLogic/OfficePackage/Implements/SaveToExcelWorker.cs b/University/UniversityBusinessLogic/OfficePackage/Implements/SaveToExcelWorker.cs index c65b09c..f9253c2 100644 --- a/University/UniversityBusinessLogic/OfficePackage/Implements/SaveToExcelWorker.cs +++ b/University/UniversityBusinessLogic/OfficePackage/Implements/SaveToExcelWorker.cs @@ -211,7 +211,7 @@ namespace UniversityBusinessLogic.OfficePackage.Implements _ => 0U, }; } - protected override void CreateExcel(ExcelInfo info) + protected override void CreateExcel(ExcelInfoWorker info) { _spreadsheetDocument = SpreadsheetDocument.Create(info.FileName, SpreadsheetDocumentType.Workbook); @@ -343,7 +343,7 @@ namespace UniversityBusinessLogic.OfficePackage.Implements }; mergeCells.Append(mergeCell); } - protected override void SaveExcel(ExcelInfo info) + protected override void SaveExcel(ExcelInfoWorker info) { if (_spreadsheetDocument == null) { diff --git a/University/UniversityBusinessLogic/OfficePackage/Implements/SaveToPdfWorker.cs b/University/UniversityBusinessLogic/OfficePackage/Implements/SaveToPdfWorker.cs index 26d0154..2f574e1 100644 --- a/University/UniversityBusinessLogic/OfficePackage/Implements/SaveToPdfWorker.cs +++ b/University/UniversityBusinessLogic/OfficePackage/Implements/SaveToPdfWorker.cs @@ -39,7 +39,7 @@ namespace UniversityBusinessLogic.OfficePackage.Implements style.Font.Bold = true; } - protected override void CreatePdf(PdfInfo info) + protected override void CreatePdf(PdfInfoWorker info) { _document = new Document(); DefineStyles(_document); @@ -101,7 +101,7 @@ namespace UniversityBusinessLogic.OfficePackage.Implements } } - protected override void SavePdf(PdfInfo info) + protected override void SavePdf(PdfInfoWorker info) { var renderer = new PdfDocumentRenderer(true) { diff --git a/University/UniversityClientAppWorker/Controllers/HomeController.cs b/University/UniversityClientAppWorker/Controllers/HomeController.cs index 373f516..f3e6244 100644 --- a/University/UniversityClientAppWorker/Controllers/HomeController.cs +++ b/University/UniversityClientAppWorker/Controllers/HomeController.cs @@ -17,16 +17,6 @@ namespace UniversityClientAppWorker.Controllers { _logger = logger; } - /*[HttpGet] - public IActionResult Index() - { - if (APIClient.User == null) - { - return Redirect("~/Home/Enter"); - } - ViewBag.Teachers = APIClient.GetRequest>($"api/teacher/getallteachers"); - return View(APIClient.GetRequest>($"api/planofstudys/getplanofstudys?userId={APIClient.User.Id}")); - }*/ [HttpGet] public async Task Index() { @@ -243,5 +233,14 @@ namespace UniversityClientAppWorker.Controllers Response.Redirect("Enter"); return; } - } + [HttpGet] + public IActionResult ReportPlanOfStudyViewModel() + { + if (APIClient.User == null) + { + return Redirect("~/Home/Enter"); + } + return View(APIClient.GetRequest>($"api/planofstudys/GetPlanOfStudyAndDisciplines")); + } + } } diff --git a/University/UniversityClientAppWorker/Views/Home/ReportPlanOfStudyAndDisciplines.cshtml b/University/UniversityClientAppWorker/Views/Home/ReportPlanOfStudyAndDisciplines.cshtml new file mode 100644 index 0000000..516892f --- /dev/null +++ b/University/UniversityClientAppWorker/Views/Home/ReportPlanOfStudyAndDisciplines.cshtml @@ -0,0 +1,49 @@ +@using UniversityContracts.ViewModels +@model List +@{ + ViewData["Title"] = "Отчёт по планам обучения"; +} + +
+

@ViewData["Title"]

+
+ +
+
+
+
+ +
+
+
+ + + + + + + + + + + @foreach (var item in Model) + { + + + + + + } + +
План обученияФорма обученияДисциплины
+ @Html.DisplayFor(modelItem => item.PlanOfStudyName) + + @Html.DisplayFor(modelItem => item.FormOfStudy) + + @foreach (var discipline in item.Disciplines) + { + @Html.DisplayFor(modelItem => discipline) + } +
+ + diff --git a/University/UniversityClientAppWorker/Views/Shared/_Layout.cshtml b/University/UniversityClientAppWorker/Views/Shared/_Layout.cshtml index a3f5281..e957baf 100644 --- a/University/UniversityClientAppWorker/Views/Shared/_Layout.cshtml +++ b/University/UniversityClientAppWorker/Views/Shared/_Layout.cshtml @@ -37,6 +37,10 @@ + diff --git a/University/UniversityContracts/BusinessLogicsContracts/IReportLogic.cs b/University/UniversityContracts/BusinessLogicsContracts/IReportLogic.cs index 6c17041..1c93372 100644 --- a/University/UniversityContracts/BusinessLogicsContracts/IReportLogic.cs +++ b/University/UniversityContracts/BusinessLogicsContracts/IReportLogic.cs @@ -5,6 +5,7 @@ using System.Text; using System.Threading.Tasks; using University.ViewModels; using UniversityContracts.BindingModels; +using UniversityContracts.ViewModels; namespace UniversityContracts.BusinessLogicContracts { @@ -17,10 +18,15 @@ namespace UniversityContracts.BusinessLogicContracts /// List GetTeachers(); List GetDisciplines(ReportBindingModel model); - void SaveTeachersToWord(ReportBindingModel option); + List GetPlanOfStudyAndDisciplines(); + List GetPlanOfStudyAndStudents(ReportDateRangeBindingModel model); - void SaveTeachersToExcel(ReportBindingModel option); + void SaveTeachersToWord(ReportBindingModel option); + void SavePlanOfStudyToWord(ReportBindingModel option); + void SaveTeachersToExcel(ReportBindingModel option); + void SavePlanOfStudyToExcel(ReportBindingModel option); + void SendDisciplinesToEmail(ReportDateRangeBindingModel option, string email); + public void SendPlanOfStudyToEmail(ReportDateRangeBindingModel option, string email); - void SendDisciplinesToEmail(ReportDateRangeBindingModel option, string email); - } + } } diff --git a/University/UniversityRestApi/Controllers/PlanOfStudysController.cs b/University/UniversityRestApi/Controllers/PlanOfStudysController.cs index d35fe24..b2ab712 100644 --- a/University/UniversityRestApi/Controllers/PlanOfStudysController.cs +++ b/University/UniversityRestApi/Controllers/PlanOfStudysController.cs @@ -1,5 +1,6 @@ using Microsoft.AspNetCore.Mvc; using UniversityContracts.BindingModels; +using UniversityContracts.BusinessLogicContracts; using UniversityContracts.BusinessLogicsContracts; using UniversityContracts.SearchModels; using UniversityContracts.ViewModels; @@ -13,10 +14,12 @@ namespace UniversityRestApi.Controllers { private readonly ILogger _logger; private readonly IPlanOfStudyLogic _logic; - public PlanOfStudysController(IPlanOfStudyLogic logic, ILogger logger) + private readonly IReportLogic _reportLogic; + public PlanOfStudysController(IPlanOfStudyLogic logic, ILogger logger, IReportLogic reportLogic) { _logic = logic; _logger = logger; + _reportLogic = reportLogic; } [HttpGet] public List? GetPlanOfStudys(int userId) @@ -44,7 +47,20 @@ namespace UniversityRestApi.Controllers throw; } } - [HttpPost] + [HttpGet] + public List? GetPlanOfStudyAndDisciplines() + { + try + { + return _reportLogic.GetPlanOfStudyAndDisciplines(); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка получения списка планов обучения"); + throw; + } + } + [HttpPost] public void CreatePlanOfStudy(PlanOfStudyBindingModel model) { try @@ -83,18 +99,5 @@ namespace UniversityRestApi.Controllers throw; } } - [HttpPost] - public void LinkTeacherToPlanOfStudy(int planOfStudyId, int teacherId) - { - try - { - - } - catch (Exception ex) - { - _logger.LogError(ex, "Ошибка при связывании преподавателя с планом обучения"); - throw; - } - } } } diff --git a/University/UniversityRestApi/Program.cs b/University/UniversityRestApi/Program.cs index b2a7c6e..5edf8c1 100644 --- a/University/UniversityRestApi/Program.cs +++ b/University/UniversityRestApi/Program.cs @@ -1,6 +1,10 @@ using Microsoft.OpenApi.Models; using UniversityBusinessLogic.BusinessLogics; +using UniversityBusinessLogic.OfficePackage; +using UniversityBusinessLogic.OfficePackage.Implements; +using UniversityBusinessLogics.BusinessLogics; +using UniversityContracts.BusinessLogicContracts; using UniversityContracts.BusinessLogicsContracts; using UniversityContracts.StorageContracts; using UniversityDatabaseImplement.Implements; @@ -19,6 +23,10 @@ builder.Services.AddTransient(); builder.Services.AddTransient(); builder.Services.AddTransient(); +builder.Services.AddTransient(); +builder.Services.AddTransient(); +builder.Services.AddTransient(); +builder.Services.AddTransient(); builder.Services.AddTransient(); builder.Services.AddTransient(); builder.Services.AddTransient();