From 8eb81803217e9fe38cc4032db5b7b16479f0a339 Mon Sep 17 00:00:00 2001 From: "nikbel2004@outlook.com" Date: Wed, 15 May 2024 20:12:33 +0400 Subject: [PATCH] =?UTF-8?q?=D0=9F=D1=80=D0=B0=D0=B2=D0=BA=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BussinessLogic/OrderLogic.cs | 30 +++++++++++------ .../FurnitureAssemblyBusinessLogic.csproj | 32 +++++++++---------- .../OfficePackage/Implements/SaveToWord.cs | 3 +- .../BindingModels/ClientBindingModel.cs | 2 +- .../IMessageInfoLogic.cs | 2 +- .../SearchModels/ClientSearchModel.cs | 4 +-- .../Models/ShopFurniture.cs | 3 +- 7 files changed, 43 insertions(+), 33 deletions(-) diff --git a/FurnitureAssembly/FurnitureAssemblyBusinessLogic/BussinessLogic/OrderLogic.cs b/FurnitureAssembly/FurnitureAssemblyBusinessLogic/BussinessLogic/OrderLogic.cs index 81014c6..37ed7a8 100644 --- a/FurnitureAssembly/FurnitureAssemblyBusinessLogic/BussinessLogic/OrderLogic.cs +++ b/FurnitureAssembly/FurnitureAssemblyBusinessLogic/BussinessLogic/OrderLogic.cs @@ -23,11 +23,13 @@ namespace FurnitureAssemblyBusinessLogic.BussinessLogic private readonly IShopLogic _shopLogic; + private readonly AbstractMailWorker _mailWorker; + private readonly IFurnitureStorage _furnitureStorage; private readonly IClientLogic _clientLogic; - private readonly AbstractMailWorker _mailWorker; + private readonly object locker = new object(); // Конструктор public OrderLogic(ILogger logger, IOrderStorage orderStorage, IShopLogic shopLogic, IFurnitureStorage furnitureStorage, IClientLogic clientLogic, AbstractMailWorker mailWorker) @@ -60,6 +62,7 @@ namespace FurnitureAssemblyBusinessLogic.BussinessLogic return list; } + // Вывод конкретного чека public OrderViewModel? ReadElement(OrderSearchModel model) { if (model == null) @@ -112,7 +115,10 @@ namespace FurnitureAssemblyBusinessLogic.BussinessLogic public bool TakeOrderInWork(OrderBindingModel model) { - return StatusUpdate(model, OrderStatus.Выполняется); + lock (locker) + { + return StatusUpdate(model, OrderStatus.Выполняется); + } } public bool FinishOrder(OrderBindingModel model) @@ -157,18 +163,18 @@ namespace FurnitureAssemblyBusinessLogic.BussinessLogic throw new ArgumentNullException("Некорректный id у изделия", nameof(model.FurnitureId)); } - // Проверка на клиента - if (model.ClientId < 0) - { - throw new ArgumentNullException("Некорректный идентификатор у клиента", nameof(model.ClientId)); - } - // Проверка корректности дат if (model.DateCreate > model.DateImplement) { throw new InvalidOperationException("Дата создания должна быть более ранней, нежели дата завершения"); } + // Проверка на клиента + if (model.ClientId < 0) + { + throw new ArgumentNullException("Некорректный идентификатор у клиента", nameof(model.ClientId)); + } + _logger.LogInformation("Order. OrderId:{Id}, Sum:{Sum}. FurnitureId:{Id}. Sum:{Sum}", model.Id, model.Sum, model.FurnitureId, model.Sum); } @@ -192,6 +198,12 @@ namespace FurnitureAssemblyBusinessLogic.BussinessLogic model.Status = newOrderStatus; + // Помещаем id работника, не забываем про него... + if (viewModel.ImplementerId.HasValue) + { + model.ImplementerId = viewModel.ImplementerId; + } + // Проверка на выдачу if (model.Status == OrderStatus.Готов || viewModel.Status == OrderStatus.Ожидание) { @@ -231,7 +243,7 @@ namespace FurnitureAssemblyBusinessLogic.BussinessLogic return false; } - SendOrderMessage(result.ClientId, $"Сборка мебели Заказ №{result.Id}", $"Заказ №{model.Id} изменен статус на {result.Status}"); + SendOrderMessage(result.ClientId, $"Сборка мебели, Заказ №{result.Id}", $"Заказ №{model.Id} изменен статус на {result.Status}"); return true; } diff --git a/FurnitureAssembly/FurnitureAssemblyBusinessLogic/FurnitureAssemblyBusinessLogic.csproj b/FurnitureAssembly/FurnitureAssemblyBusinessLogic/FurnitureAssemblyBusinessLogic.csproj index d9b2055..933d142 100644 --- a/FurnitureAssembly/FurnitureAssemblyBusinessLogic/FurnitureAssemblyBusinessLogic.csproj +++ b/FurnitureAssembly/FurnitureAssemblyBusinessLogic/FurnitureAssemblyBusinessLogic.csproj @@ -1,23 +1,21 @@  - - net6.0 - enable - enable - + + net6.0 + enable + enable + - - - - - - - - - + + + + + - - - + + + + + diff --git a/FurnitureAssembly/FurnitureAssemblyBusinessLogic/OfficePackage/Implements/SaveToWord.cs b/FurnitureAssembly/FurnitureAssemblyBusinessLogic/OfficePackage/Implements/SaveToWord.cs index 38b8f58..652ad5c 100644 --- a/FurnitureAssembly/FurnitureAssemblyBusinessLogic/OfficePackage/Implements/SaveToWord.cs +++ b/FurnitureAssembly/FurnitureAssemblyBusinessLogic/OfficePackage/Implements/SaveToWord.cs @@ -114,6 +114,7 @@ namespace FurnitureAssemblyBusinessLogic.OfficePackage.Implements var docRun = new Run(); var properties = new RunProperties(); + // Задание свойств текста - размер и жирность properties.AppendChild(new FontSize { Val = run.Item2.Size }); if (run.Item2.Bold) @@ -145,7 +146,7 @@ namespace FurnitureAssemblyBusinessLogic.OfficePackage.Implements // Сохраняем документ _wordDocument.MainDocumentPart!.Document.Save(); - _wordDocument.Close(); + _wordDocument.Dispose(); } protected override void CreateTable(WordParagraph paragraph) diff --git a/FurnitureAssembly/FurnitureAssemblyContracts/BindingModels/ClientBindingModel.cs b/FurnitureAssembly/FurnitureAssemblyContracts/BindingModels/ClientBindingModel.cs index e083983..882d915 100644 --- a/FurnitureAssembly/FurnitureAssemblyContracts/BindingModels/ClientBindingModel.cs +++ b/FurnitureAssembly/FurnitureAssemblyContracts/BindingModels/ClientBindingModel.cs @@ -16,6 +16,6 @@ namespace FurnitureAssemblyContracts.BindingModels public string Email { get; set; } = string.Empty; - public string Password { get; set; } = string.Empty; + public string Password { get; set; } = string.Empty; } } diff --git a/FurnitureAssembly/FurnitureAssemblyContracts/BusinessLogicsContracts/IMessageInfoLogic.cs b/FurnitureAssembly/FurnitureAssemblyContracts/BusinessLogicsContracts/IMessageInfoLogic.cs index f21c518..5781243 100644 --- a/FurnitureAssembly/FurnitureAssemblyContracts/BusinessLogicsContracts/IMessageInfoLogic.cs +++ b/FurnitureAssembly/FurnitureAssemblyContracts/BusinessLogicsContracts/IMessageInfoLogic.cs @@ -9,7 +9,7 @@ using System.Threading.Tasks; namespace FurnitureAssemblyContracts.BusinessLogicsContracts { - // Бизнес-логика для сообщений + // Бизнес-логика сообщений public interface IMessageInfoLogic { List? ReadList(MessageInfoSearchModel? model); diff --git a/FurnitureAssembly/FurnitureAssemblyContracts/SearchModels/ClientSearchModel.cs b/FurnitureAssembly/FurnitureAssemblyContracts/SearchModels/ClientSearchModel.cs index 2fddaab..99617a7 100644 --- a/FurnitureAssembly/FurnitureAssemblyContracts/SearchModels/ClientSearchModel.cs +++ b/FurnitureAssembly/FurnitureAssemblyContracts/SearchModels/ClientSearchModel.cs @@ -11,9 +11,9 @@ namespace FurnitureAssemblyContracts.SearchModels { public int? Id { get; set; } - public string? Email { get; set; } + public string? Email { get; set; } - public string? ClientFIO { get; set; } + public string? ClientFIO { get; set; } public string? Password { get; set; } } diff --git a/FurnitureAssembly/FurnitureAssemblyDatabaseImplement/Models/ShopFurniture.cs b/FurnitureAssembly/FurnitureAssemblyDatabaseImplement/Models/ShopFurniture.cs index 8d83e90..3245bd7 100644 --- a/FurnitureAssembly/FurnitureAssemblyDatabaseImplement/Models/ShopFurniture.cs +++ b/FurnitureAssembly/FurnitureAssemblyDatabaseImplement/Models/ShopFurniture.cs @@ -1,5 +1,4 @@ -using BlacksmithWorkshopDatabaseImplement.Models; -using System; +using System; using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using System.Linq;