From ae9d5eb54ceea5120b05752c6e30b2ef0f1896e7 Mon Sep 17 00:00:00 2001 From: Zyzf Date: Thu, 18 May 2023 11:06:34 -0700 Subject: [PATCH] done base part, added order report page with mail support, added check for role of user --- .../BusinessLogics/ReportWorkerLogic.cs | 36 +++++- .../MailWorker/MailWorker.cs | 70 ++++++++++ .../OfficePackage/AbstractWorkerSaveToPdf.cs | 16 ++- .../OfficePackage/HelperModels/PdfInfo.cs | 2 +- .../OfficePackage/Implements/SaveToPdf.cs | 3 +- .../BindingModels/MailSendInfoBindingModel.cs | 15 +++ .../BindingModels/ReportWorkerBindingModel.cs | 3 +- .../IReportWorkerLogic.cs | 12 +- .../ViewModels/ReportOrdersWorkerViewModel.cs | 4 +- .../Implements/OrderInfoStorage.cs | 2 +- .../Controllers/ReportController.cs | 34 ++++- .../FurnitureAssemblyRestApi/Program.cs | 2 + .../APIClient.cs | 19 +++ .../Controllers/HomeController.cs | 122 +++++++++++++++++- .../FurnitureAssemblyWorkerClientApp.csproj | 3 + .../Models/ErrorViewModel.cs | 2 +- .../Program.cs | 20 ++- .../Views/Home/Enter.cshtml | 6 +- .../Views/Home/Error.cshtml | 13 ++ .../Views/Home/OrdersReport.cshtml | 60 +++++++++ .../Views/Shared/_Layout.cshtml | 22 ++-- 21 files changed, 415 insertions(+), 51 deletions(-) create mode 100644 FurnitureAssembly/FurnitureAssemblyBusinessLogic/MailWorker/MailWorker.cs create mode 100644 FurnitureAssembly/FurnitureAssemblyContracts/BindingModels/MailSendInfoBindingModel.cs create mode 100644 FurnitureAssembly/FurnitureAssemblyWorkerClientApp/Views/Home/Error.cshtml create mode 100644 FurnitureAssembly/FurnitureAssemblyWorkerClientApp/Views/Home/OrdersReport.cshtml diff --git a/FurnitureAssembly/FurnitureAssemblyBusinessLogic/BusinessLogics/ReportWorkerLogic.cs b/FurnitureAssembly/FurnitureAssemblyBusinessLogic/BusinessLogics/ReportWorkerLogic.cs index c3e826c..ab32418 100644 --- a/FurnitureAssembly/FurnitureAssemblyBusinessLogic/BusinessLogics/ReportWorkerLogic.cs +++ b/FurnitureAssembly/FurnitureAssemblyBusinessLogic/BusinessLogics/ReportWorkerLogic.cs @@ -81,17 +81,28 @@ namespace FurnitureAssemblyBusinessLogic.BusinessLogics /// /// /// - public List GetOrders(ReportWorkerBindingModel model) + public Tuple, double> GetOrders(ReportWorkerBindingModel model) { var orderInfos = _orderInfoStorage - .GetFilteredList(new OrderInfoSearchModel { DateFrom = model.DateFrom, DateTo = model.DateTo }); + .GetFilteredList(new OrderInfoSearchModel { DateFrom = model.DateFrom, DateTo = model.DateTo, UserId = model.UserId }); List orderInfoIds = new List(); foreach (var orderInfo in orderInfos) { orderInfoIds.Add(orderInfo.Id); } - var orders = _orderStorage.GetFilteredList(new OrderSearchModel { OrderInfoId = orderInfoIds }); - var sets = _setStorage.GetFullList(); + var orders = _orderStorage.GetFilteredList(new OrderSearchModel + { + OrderInfoId = orderInfoIds + }); + List sets = new List(); + foreach (var order in orders) + { + sets.Add(_setStorage.GetElement(new SetSearchModel + { + Id = order.SetId + })); + } + var furnitureModules = _furnitureModuleStorage.GetFullList(); var list = new List(); @@ -108,13 +119,23 @@ namespace FurnitureAssemblyBusinessLogic.BusinessLogics { if (orderInfo.Id == order.OrderInfoId) { + var currentSet = _setStorage.GetElement(new SetSearchModel { Id = order.SetId }); + string setName = ""; + if (order.Count > 1) + { + setName = order.SetName + " X" + order.Count; + } else + { + setName = order.SetName; + } record = new ReportOrdersWorkerViewModel { Id = order.Id, - SetName = order.SetName, + SetName = setName, DateCreate = orderInfo.DateCreate, FurnitureModules = new List<(string, double)>(), - TotalCount = 0 + TotalCount = order.Count, + Sum = currentSet.Cost.ToString() + "x" + order.Count.ToString() }; } } @@ -134,8 +155,9 @@ namespace FurnitureAssemblyBusinessLogic.BusinessLogics } list.Add(record); } + double fullSum = orderInfos.Sum(x => x.Sum); - return list; + return Tuple.Create(list, fullSum); } /// /// Сохранение компонент в файл-Word diff --git a/FurnitureAssembly/FurnitureAssemblyBusinessLogic/MailWorker/MailWorker.cs b/FurnitureAssembly/FurnitureAssemblyBusinessLogic/MailWorker/MailWorker.cs new file mode 100644 index 0000000..20a1331 --- /dev/null +++ b/FurnitureAssembly/FurnitureAssemblyBusinessLogic/MailWorker/MailWorker.cs @@ -0,0 +1,70 @@ +using Microsoft.Extensions.Logging; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Net.Mail; +using System.Net; +using System.Text; +using System.Threading.Tasks; +using FurnitureAssemblyContracts.BindingModels; +using System.Net.Mime; + +namespace FurnitureAssemblyBusinessLogic.MailWorker +{ + public class MailWorker + { + protected string _mailLogin = "yankalyshev@outlook.com"; + protected string _mailPassword = "250303zyzf"; + protected string _smtpClientHost = "smtp-mail.outlook.com"; + protected int _smtpClientPort = 587; + private readonly ILogger _logger; + public MailWorker(ILogger logger) + { + _logger = logger; + } + public async void MailSendAsync(MailSendInfoBindingModel info) + { + if (string.IsNullOrEmpty(_mailLogin) || string.IsNullOrEmpty(_mailPassword)) + { + return; + } + if (string.IsNullOrEmpty(_smtpClientHost) || _smtpClientPort == 0) + { + return; + } + if (string.IsNullOrEmpty(info.MailAddress) || string.IsNullOrEmpty(info.Subject) || string.IsNullOrEmpty(info.Text)) + { + return; + } + _logger.LogDebug("Send Mail: {To}, {Subject}", info.MailAddress, info.Subject); + await SendMailAsync(info); + } + protected async Task SendMailAsync(MailSendInfoBindingModel info) + { + using var objMailMessage = new MailMessage(); + using var objSmtpClient = new SmtpClient(_smtpClientHost, _smtpClientPort); + try + { + objMailMessage.From = new MailAddress(_mailLogin); + objMailMessage.To.Add(new MailAddress(info.MailAddress)); + objMailMessage.Subject = info.Subject; + objMailMessage.Body = info.Text; + objMailMessage.SubjectEncoding = Encoding.UTF8; + objMailMessage.BodyEncoding = Encoding.UTF8; + Attachment attachment = new Attachment("C:\\temp\\pdf_worker.pdf", new ContentType(MediaTypeNames.Application.Pdf)); + objMailMessage.Attachments.Add(attachment); + + objSmtpClient.UseDefaultCredentials = false; + objSmtpClient.EnableSsl = true; + objSmtpClient.DeliveryMethod = SmtpDeliveryMethod.Network; + objSmtpClient.Credentials = new NetworkCredential(_mailLogin, _mailPassword); + + await Task.Run(() => objSmtpClient.Send(objMailMessage)); + } + catch (Exception) + { + throw; + } + } + } +} diff --git a/FurnitureAssembly/FurnitureAssemblyBusinessLogic/OfficePackage/AbstractWorkerSaveToPdf.cs b/FurnitureAssembly/FurnitureAssemblyBusinessLogic/OfficePackage/AbstractWorkerSaveToPdf.cs index 19b9597..d2e00c1 100644 --- a/FurnitureAssembly/FurnitureAssemblyBusinessLogic/OfficePackage/AbstractWorkerSaveToPdf.cs +++ b/FurnitureAssembly/FurnitureAssemblyBusinessLogic/OfficePackage/AbstractWorkerSaveToPdf.cs @@ -27,7 +27,7 @@ namespace FurnitureAssemblyBusinessLogic.OfficePackage Style = "Normal", ParagraphAlignment = PdfParagraphAlignmentType.Center }); - foreach (var order in info.Orders) + foreach (var order in info.Orders.Item1) { CreateParagraph(new PdfParagraph { @@ -35,29 +35,37 @@ namespace FurnitureAssemblyBusinessLogic.OfficePackage Style = "Normal", ParagraphAlignment = PdfParagraphAlignmentType.Left }); - CreateTable(new List { "2cm", "3cm", "3cm", "3cm" }); + CreateTable(new List { "2cm", "3cm", "7cm", "3cm" }); CreateRow(new PdfRowParameters { Texts = new List { "Номер", "Дата заказа", "Мебельный модуль", "Сумма" }, Style = "NormalTitle", ParagraphAlignment = PdfParagraphAlignmentType.Center }); + int i = 1; foreach (var furnitureModule in order.FurnitureModules) { CreateRow(new PdfRowParameters { - Texts = new List { order.Id.ToString(), order.DateCreate.ToShortDateString(), furnitureModule.Name, furnitureModule.Cost.ToString() }, + Texts = new List { i.ToString(), order.DateCreate.ToShortDateString(), furnitureModule.Name, furnitureModule.Cost.ToString() }, Style = "Normal", ParagraphAlignment = PdfParagraphAlignmentType.Left }); + i++; } CreateParagraph(new PdfParagraph { - Text = $"Итого: {info.Orders.Sum(x => x.Sum)}\t", + Text = $"Итого: {order.Sum}\t", Style = "Normal", ParagraphAlignment = PdfParagraphAlignmentType.Rigth }); } + CreateParagraph(new PdfParagraph + { + Text = $"Итого: {info.Orders.Item2}\t", + Style = "Normal", + ParagraphAlignment = PdfParagraphAlignmentType.Left + }); SavePdf(info); } /// diff --git a/FurnitureAssembly/FurnitureAssemblyBusinessLogic/OfficePackage/HelperModels/PdfInfo.cs b/FurnitureAssembly/FurnitureAssemblyBusinessLogic/OfficePackage/HelperModels/PdfInfo.cs index 3f5211d..92885cd 100644 --- a/FurnitureAssembly/FurnitureAssemblyBusinessLogic/OfficePackage/HelperModels/PdfInfo.cs +++ b/FurnitureAssembly/FurnitureAssemblyBusinessLogic/OfficePackage/HelperModels/PdfInfo.cs @@ -13,6 +13,6 @@ namespace FurnitureAssemblyBusinessLogic.OfficePackage.HelperModels public string Title { get; set; } = string.Empty; public DateTime DateFrom { get; set; } public DateTime DateTo { get; set; } - public List Orders { get; set; } = new(); + public Tuple, double> Orders { get; set; } } } diff --git a/FurnitureAssembly/FurnitureAssemblyBusinessLogic/OfficePackage/Implements/SaveToPdf.cs b/FurnitureAssembly/FurnitureAssemblyBusinessLogic/OfficePackage/Implements/SaveToPdf.cs index 67f9825..ae24e8e 100644 --- a/FurnitureAssembly/FurnitureAssemblyBusinessLogic/OfficePackage/Implements/SaveToPdf.cs +++ b/FurnitureAssembly/FurnitureAssemblyBusinessLogic/OfficePackage/Implements/SaveToPdf.cs @@ -99,7 +99,8 @@ namespace FurnitureAssemblyBusinessLogic.OfficePackage.Implements { Document = _document }; - renderer.RenderDocument(); + System.Text.Encoding.RegisterProvider(System.Text.CodePagesEncodingProvider.Instance); + renderer.RenderDocument(); renderer.PdfDocument.Save(info.FileName); } } diff --git a/FurnitureAssembly/FurnitureAssemblyContracts/BindingModels/MailSendInfoBindingModel.cs b/FurnitureAssembly/FurnitureAssemblyContracts/BindingModels/MailSendInfoBindingModel.cs new file mode 100644 index 0000000..94acb13 --- /dev/null +++ b/FurnitureAssembly/FurnitureAssemblyContracts/BindingModels/MailSendInfoBindingModel.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace FurnitureAssemblyContracts.BindingModels +{ + public class MailSendInfoBindingModel + { + public string MailAddress { get; set; } = string.Empty; + public string Subject { get; set; } = string.Empty; + public string Text { get; set; } = string.Empty; + } +} diff --git a/FurnitureAssembly/FurnitureAssemblyContracts/BindingModels/ReportWorkerBindingModel.cs b/FurnitureAssembly/FurnitureAssemblyContracts/BindingModels/ReportWorkerBindingModel.cs index fbe0878..bcc70ce 100644 --- a/FurnitureAssembly/FurnitureAssemblyContracts/BindingModels/ReportWorkerBindingModel.cs +++ b/FurnitureAssembly/FurnitureAssemblyContracts/BindingModels/ReportWorkerBindingModel.cs @@ -12,5 +12,6 @@ namespace FurnitureAssemblyContracts.BindingModels public DateTime? DateFrom { get; set; } public DateTime? DateTo { get; set; } public List? SetIds { get; set; } - } + public int UserId { get; set; } + } } diff --git a/FurnitureAssembly/FurnitureAssemblyContracts/BusinessLogicContracts/IReportWorkerLogic.cs b/FurnitureAssembly/FurnitureAssemblyContracts/BusinessLogicContracts/IReportWorkerLogic.cs index 642aaf8..3f64471 100644 --- a/FurnitureAssembly/FurnitureAssemblyContracts/BusinessLogicContracts/IReportWorkerLogic.cs +++ b/FurnitureAssembly/FurnitureAssemblyContracts/BusinessLogicContracts/IReportWorkerLogic.cs @@ -15,12 +15,12 @@ namespace FurnitureAssemblyContracts.BusinessLogicContracts /// /// List GetSetFurnitureModule(List setIds); - /// - /// Получение списка заказов за определенный период - /// - /// - /// - List GetOrders(ReportWorkerBindingModel model); + /// + /// Получение списка заказов за определенный период + /// + /// + /// + Tuple, double> GetOrders(ReportWorkerBindingModel model); /// /// Сохранение материалов в файл-Word /// diff --git a/FurnitureAssembly/FurnitureAssemblyContracts/ViewModels/ReportOrdersWorkerViewModel.cs b/FurnitureAssembly/FurnitureAssemblyContracts/ViewModels/ReportOrdersWorkerViewModel.cs index 771c8c9..80bd089 100644 --- a/FurnitureAssembly/FurnitureAssemblyContracts/ViewModels/ReportOrdersWorkerViewModel.cs +++ b/FurnitureAssembly/FurnitureAssemblyContracts/ViewModels/ReportOrdersWorkerViewModel.cs @@ -14,6 +14,6 @@ namespace FurnitureAssemblyContracts.ViewModels public string SetName { get; set; } = string.Empty; public List<(string Name, double Cost)> FurnitureModules { get; set; } = new(); public int TotalCount { get; set; } - public double Sum { get; set; } - } + public string Sum { get; set; } = string.Empty; + } } diff --git a/FurnitureAssembly/FurnitureAssemblyDatabaseImplement/Implements/OrderInfoStorage.cs b/FurnitureAssembly/FurnitureAssemblyDatabaseImplement/Implements/OrderInfoStorage.cs index 3b3d15a..36d84ff 100644 --- a/FurnitureAssembly/FurnitureAssemblyDatabaseImplement/Implements/OrderInfoStorage.cs +++ b/FurnitureAssembly/FurnitureAssemblyDatabaseImplement/Implements/OrderInfoStorage.cs @@ -58,7 +58,7 @@ namespace FurnitureAssemblyDatabaseImplement.Implements { return context.OrderInfos .Include(x => x.User) - .Where(x => x.DateCreate >= model.DateFrom && x.DateCreate <= model.DateTo) + .Where(x => x.DateCreate >= model.DateFrom.Value.ToUniversalTime() && x.DateCreate <= model.DateTo.Value.ToUniversalTime() && model.UserId == x.UserId) .Select(x => x.GetViewModel) .ToList(); } diff --git a/FurnitureAssembly/FurnitureAssemblyRestApi/Controllers/ReportController.cs b/FurnitureAssembly/FurnitureAssemblyRestApi/Controllers/ReportController.cs index 3c95540..4f4dd5f 100644 --- a/FurnitureAssembly/FurnitureAssemblyRestApi/Controllers/ReportController.cs +++ b/FurnitureAssembly/FurnitureAssemblyRestApi/Controllers/ReportController.cs @@ -1,4 +1,6 @@ -using DocumentFormat.OpenXml.Spreadsheet; +using DocumentFormat.OpenXml.Presentation; +using DocumentFormat.OpenXml.Spreadsheet; +using FurnitureAssemblyBusinessLogic.MailWorker; using FurnitureAssemblyContracts.BindingModels; using FurnitureAssemblyContracts.BusinessLogicContracts; using FurnitureAssemblyContracts.SearchModels; @@ -15,10 +17,12 @@ namespace FurnitureAssemblyRestApi.Controllers { private readonly ILogger _logger; private readonly IReportWorkerLogic _reportWorkerLogic; - public ReportController(ILogger logger, IReportWorkerLogic reportWorkerLogic) + private readonly MailWorker _mail; + public ReportController(ILogger logger, IReportWorkerLogic reportWorkerLogic, MailWorker mailWorker) { _logger = logger; _reportWorkerLogic = reportWorkerLogic; + _mail = mailWorker; } @@ -48,5 +52,31 @@ namespace FurnitureAssemblyRestApi.Controllers throw; } } + [HttpPost] + public void CreateReportOrdersToPdf(ReportWorkerBindingModel model) + { + try + { + _reportWorkerLogic.SaveOrdersToPdfFile(model); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка создания отчета"); + throw; + } + } + [HttpPost] + public void SendPdfToMail(MailSendInfoBindingModel model) + { + try + { + _mail.MailSendAsync(model); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка отправки письма"); + throw; + } + } } } diff --git a/FurnitureAssembly/FurnitureAssemblyRestApi/Program.cs b/FurnitureAssembly/FurnitureAssemblyRestApi/Program.cs index e08d03d..4297a7b 100644 --- a/FurnitureAssembly/FurnitureAssemblyRestApi/Program.cs +++ b/FurnitureAssembly/FurnitureAssemblyRestApi/Program.cs @@ -5,6 +5,7 @@ using FurnitureAssemblyContracts.BusinessLogicContracts; using FurnitureAssemblyContracts.StorageContracts; using FurnitureAssemblyDatabaseImplement.Implements; using Microsoft.OpenApi.Models; +using FurnitureAssemblyBusinessLogic.MailWorker; var builder = WebApplication.CreateBuilder(args); @@ -32,6 +33,7 @@ builder.Services.AddTransient(); builder.Services.AddTransient(); builder.Services.AddTransient(); builder.Services.AddTransient(); +builder.Services.AddTransient(); builder.Services.AddTransient(); builder.Services.AddTransient(); diff --git a/FurnitureAssembly/FurnitureAssemblyWorkerClientApp/APIClient.cs b/FurnitureAssembly/FurnitureAssemblyWorkerClientApp/APIClient.cs index 1fc3e84..1a716b9 100644 --- a/FurnitureAssembly/FurnitureAssemblyWorkerClientApp/APIClient.cs +++ b/FurnitureAssembly/FurnitureAssemblyWorkerClientApp/APIClient.cs @@ -42,6 +42,25 @@ namespace FurnitureAssemblyWorkerClientApp return JsonConvert.DeserializeObject(result); } else { + + throw new Exception(result); + } + } + public static List? PostRequestReportOrders(string requestUrl, T model) + { + var json = JsonConvert.SerializeObject(model); + var data = new StringContent(json, Encoding.UTF8, "application/json"); + + var response = _client.PostAsync(requestUrl, data); + + var result = response.Result.Content.ReadAsStringAsync().Result; + if (response.Result.IsSuccessStatusCode) + { + return JsonConvert.DeserializeObject>(result); + } + else + { + throw new Exception(result); } } diff --git a/FurnitureAssembly/FurnitureAssemblyWorkerClientApp/Controllers/HomeController.cs b/FurnitureAssembly/FurnitureAssemblyWorkerClientApp/Controllers/HomeController.cs index 4b084b3..9a1f1fd 100644 --- a/FurnitureAssembly/FurnitureAssemblyWorkerClientApp/Controllers/HomeController.cs +++ b/FurnitureAssembly/FurnitureAssemblyWorkerClientApp/Controllers/HomeController.cs @@ -7,16 +7,23 @@ using FurnitureAssemblyDataModels.Models; using System; using FurnitureAssemblyContracts.SearchModels; using FurnitureAssemblyDataModels.Enums; +using System.Web.Helpers; +using System.Reflection; +using FurnitureAssemblyBusinessLogic.BusinessLogics; +using FurnitureAssemblyContracts.BusinessLogicContracts; namespace FurnitureAssemblyWorkerClientApp.Controllers { public class HomeController : Controller { private readonly ILogger _logger; - public HomeController(ILogger logger) - { - _logger = logger; - } + private readonly IReportWorkerLogic _report; + public HomeController(ILogger logger, IReportWorkerLogic report) + { + _logger = logger; + _report = report; + } + [HttpGet] public IActionResult Index() { @@ -79,10 +86,16 @@ namespace FurnitureAssemblyWorkerClientApp.Controllers throw new Exception("Введите логин и пароль"); } APIClient.User = APIClient.GetRequest($"api/user/login?login={login}&password={password}"); + if (APIClient.User == null) { throw new Exception("Неверный логин/пароль"); } + if (APIClient.User.RoleName != "Работник") + { + APIClient.User = null; + throw new Exception("Данному сотруднику вход запрещен"); + } Response.Redirect("Index"); } [HttpGet] @@ -307,6 +320,10 @@ namespace FurnitureAssemblyWorkerClientApp.Controllers { return new PhysicalFileResult("C:\\temp\\excel_worker.xlsx", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); } + public IActionResult GetPdfFile() + { + return new PhysicalFileResult("C:\\temp\\pdf_worker.pdf", "application/pdf"); + } [HttpGet] public IActionResult FurnitureModules() { @@ -438,7 +455,7 @@ namespace FurnitureAssemblyWorkerClientApp.Controllers counts[i] )); } - Response.Redirect("Index"); + Response.Redirect("Index"); } [HttpGet] public IActionResult Orders() @@ -600,8 +617,99 @@ namespace FurnitureAssemblyWorkerClientApp.Controllers )); } } - Response.Redirect("Orders"); } - } + [HttpGet] + public IActionResult OrdersReport() + { + if (APIClient.User == null) + { + return Redirect("~/Home/Enter"); + } + return View("OrdersReport"); + } + [HttpPost] + public void OrdersReport(DateTime dateFrom, DateTime dateTo, string customerEmail) + { + if (APIClient.User == null) + { + throw new Exception("Вы как суда попали? Суда вход только авторизованным"); + } + if (string.IsNullOrEmpty(customerEmail)) + { + throw new Exception("Email пуст"); + } + APIClient.PostRequest("api/report/createreportorderstopdf", new ReportWorkerBindingModel + { + DateFrom = dateFrom, + DateTo = dateTo, + UserId = APIClient.User.Id + }); + APIClient.PostRequest("api/report/sendpdftomail", new MailSendInfoBindingModel + { + MailAddress = customerEmail, + Subject = "Отчет по заказам", + Text = "Отчет по заказам с " + dateFrom.ToShortDateString() + " до " + dateTo.ToShortDateString() + }); + Response.Redirect("OrdersReport"); + } + [HttpGet] + public string GetOrdersReport(DateTime dateFrom, DateTime dateTo) + { + if (APIClient.User == null) + { + throw new Exception("Вы как суда попали? Суда вход только авторизованным"); + } + Tuple,double> result; + try + { + result = _report.GetOrders(new ReportWorkerBindingModel + { + UserId = APIClient.User.Id, + DateFrom = dateFrom, + DateTo = dateTo + }); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка создания отчета"); + throw; + } + if (result == null) + { + return "error"; + } + string html = ""; + foreach (var report in result.Item1) + { + html += $"

{report.SetName}

"; + html += $""; + html += ""; + html += ""; + html += $""; + html += $""; + html += $""; + html += $""; + html += ""; + html += ""; + int i = 1; + html += ""; + foreach (var furnitureModule in report.FurnitureModules) + { + html += ""; + html += $""; + html += $""; + html += $""; + html += $""; + html += ""; + i++; + } + html += ""; + html += "
НомерДата заказаМебельный модульСумма
{i}{report.DateCreate}{furnitureModule.Name}{furnitureModule.Cost}
"; + html += $"

Итого: {report.Sum}

"; + } + html += $"

Итого: {result.Item2}

"; + return html; + } + } } \ No newline at end of file diff --git a/FurnitureAssembly/FurnitureAssemblyWorkerClientApp/FurnitureAssemblyWorkerClientApp.csproj b/FurnitureAssembly/FurnitureAssemblyWorkerClientApp/FurnitureAssemblyWorkerClientApp.csproj index 308321f..0a322b3 100644 --- a/FurnitureAssembly/FurnitureAssemblyWorkerClientApp/FurnitureAssemblyWorkerClientApp.csproj +++ b/FurnitureAssembly/FurnitureAssemblyWorkerClientApp/FurnitureAssemblyWorkerClientApp.csproj @@ -7,11 +7,14 @@ + + + diff --git a/FurnitureAssembly/FurnitureAssemblyWorkerClientApp/Models/ErrorViewModel.cs b/FurnitureAssembly/FurnitureAssemblyWorkerClientApp/Models/ErrorViewModel.cs index 65578a0..1bce34f 100644 --- a/FurnitureAssembly/FurnitureAssemblyWorkerClientApp/Models/ErrorViewModel.cs +++ b/FurnitureAssembly/FurnitureAssemblyWorkerClientApp/Models/ErrorViewModel.cs @@ -3,7 +3,7 @@ namespace FurnitureAssemblyWorkerClientApp.Models public class ErrorViewModel { public string? RequestId { get; set; } - + public int? Code { get; set; } public bool ShowRequestId => !string.IsNullOrEmpty(RequestId); } } \ No newline at end of file diff --git a/FurnitureAssembly/FurnitureAssemblyWorkerClientApp/Program.cs b/FurnitureAssembly/FurnitureAssemblyWorkerClientApp/Program.cs index 8a27ec2..6d28932 100644 --- a/FurnitureAssembly/FurnitureAssemblyWorkerClientApp/Program.cs +++ b/FurnitureAssembly/FurnitureAssemblyWorkerClientApp/Program.cs @@ -1,6 +1,20 @@ +using FurnitureAssemblyBusinessLogic.BusinessLogics; +using FurnitureAssemblyBusinessLogic.OfficePackage; +using FurnitureAssemblyBusinessLogic.OfficePackage.Implements; +using FurnitureAssemblyContracts.BusinessLogicContracts; +using FurnitureAssemblyContracts.StorageContracts; +using FurnitureAssemblyDatabaseImplement.Implements; using FurnitureAssemblyWorkerClientApp; var builder = WebApplication.CreateBuilder(args); +builder.Services.AddTransient(); +builder.Services.AddTransient(); +builder.Services.AddTransient(); +builder.Services.AddTransient(); +builder.Services.AddTransient(); +builder.Services.AddTransient(); +builder.Services.AddTransient(); +builder.Services.AddTransient(); // Add services to the container. builder.Services.AddControllersWithViews(); @@ -8,12 +22,12 @@ builder.Services.AddControllersWithViews(); var app = builder.Build(); APIClient.Connect(builder.Configuration); // Configure the HTTP request pipeline. -if (!app.Environment.IsDevelopment()) -{ +//if (app.Environment.IsDevelopment()) +//{ app.UseExceptionHandler("/Home/Error"); // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. app.UseHsts(); -} +//} app.UseHttpsRedirection(); app.UseStaticFiles(); diff --git a/FurnitureAssembly/FurnitureAssemblyWorkerClientApp/Views/Home/Enter.cshtml b/FurnitureAssembly/FurnitureAssemblyWorkerClientApp/Views/Home/Enter.cshtml index 53ca16d..917dac5 100644 --- a/FurnitureAssembly/FurnitureAssemblyWorkerClientApp/Views/Home/Enter.cshtml +++ b/FurnitureAssembly/FurnitureAssemblyWorkerClientApp/Views/Home/Enter.cshtml @@ -1,5 +1,5 @@ @{ - ViewData["Title"] = "Enter"; + ViewData["Title"] = "Вход"; }

Вход в приложение

@@ -17,4 +17,8 @@
+ \ No newline at end of file diff --git a/FurnitureAssembly/FurnitureAssemblyWorkerClientApp/Views/Home/Error.cshtml b/FurnitureAssembly/FurnitureAssemblyWorkerClientApp/Views/Home/Error.cshtml new file mode 100644 index 0000000..c846dba --- /dev/null +++ b/FurnitureAssembly/FurnitureAssemblyWorkerClientApp/Views/Home/Error.cshtml @@ -0,0 +1,13 @@ +@page "{code?}" +@model ErrorViewModel +@{ + ViewData["Title"] = "Ошибка"; +} + +

Произошла ошибка

+@if (Model.ShowRequestId) +{ +

+ Request ID: @Model.RequestId +

+} \ No newline at end of file diff --git a/FurnitureAssembly/FurnitureAssemblyWorkerClientApp/Views/Home/OrdersReport.cshtml b/FurnitureAssembly/FurnitureAssemblyWorkerClientApp/Views/Home/OrdersReport.cshtml new file mode 100644 index 0000000..a98024e --- /dev/null +++ b/FurnitureAssembly/FurnitureAssemblyWorkerClientApp/Views/Home/OrdersReport.cshtml @@ -0,0 +1,60 @@ +@using FurnitureAssemblyContracts.ViewModels + +@{ + ViewData["Title"] = "Отчет по заказам"; +} +
+

Отчет по заказам

+
+ +
+ @{ +
+
+
+ + +
+
+ + +
+
+
+ Ваш email + + +
+
+
+
+ + } +
+ +@section Scripts { + +} \ No newline at end of file diff --git a/FurnitureAssembly/FurnitureAssemblyWorkerClientApp/Views/Shared/_Layout.cshtml b/FurnitureAssembly/FurnitureAssemblyWorkerClientApp/Views/Shared/_Layout.cshtml index 2e1f308..4eae554 100644 --- a/FurnitureAssembly/FurnitureAssemblyWorkerClientApp/Views/Shared/_Layout.cshtml +++ b/FurnitureAssembly/FurnitureAssemblyWorkerClientApp/Views/Shared/_Layout.cshtml @@ -3,7 +3,7 @@ - @ViewData["Title"] - FurnitureAssemblyWorkerClientApp + @ViewData["Title"] - Приложение сотрудника мебельной компании @@ -20,16 +20,10 @@ @@ -59,7 +53,7 @@
- © 2023 - FurnitureAssemblyWorkerClientApp - Privacy + © 2023 - Приложение сотрудника мебельной компании - Privacy