From 34004cd13f970e0301bf1bb2f64620816259e8cc Mon Sep 17 00:00:00 2001 From: dex_moth Date: Fri, 21 Jun 2024 20:59:30 +0400 Subject: [PATCH] =?UTF-8?q?=D1=80=D0=B0=D0=B1=D0=BE=D1=82=D0=B0=D0=B5?= =?UTF-8?q?=D1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- FishFactory/FishFactory.csproj | 3 +++ FishFactoryBusinessLogic/BusinessLogic/WorkModeling.cs | 10 +++++----- .../SearchModels/ImplementerSearchModel.cs | 2 +- FishFactoryDatabaseImplement/Models/Order.cs | 6 ------ 4 files changed, 9 insertions(+), 12 deletions(-) diff --git a/FishFactory/FishFactory.csproj b/FishFactory/FishFactory.csproj index d2c10da..f36cb40 100644 --- a/FishFactory/FishFactory.csproj +++ b/FishFactory/FishFactory.csproj @@ -42,6 +42,9 @@ + + Always + Always diff --git a/FishFactoryBusinessLogic/BusinessLogic/WorkModeling.cs b/FishFactoryBusinessLogic/BusinessLogic/WorkModeling.cs index 73eada3..1a59259 100644 --- a/FishFactoryBusinessLogic/BusinessLogic/WorkModeling.cs +++ b/FishFactoryBusinessLogic/BusinessLogic/WorkModeling.cs @@ -31,9 +31,8 @@ namespace FishFactoryBusinessLogic.BusinessLogic return; } var orders = _orderLogic.ReadList(new OrderSearchModel { Status = OrderStatus.Принят }); - var processingOrders = _orderLogic.ReadList(new OrderSearchModel { Status = OrderStatus.Выполняется }); - if (orders == null || processingOrders == null || (orders.Count == 0 && processingOrders.Count == 0)) + if (orders == null || orders.Count == 0) { _logger.LogWarning("DoWork. Orders is null or empty"); return; @@ -78,7 +77,8 @@ namespace FishFactoryBusinessLogic.BusinessLogic { Id = order.Id }); - } + Thread.Sleep(implementer.Qualification * _rnd.Next(10, 100)); + } // кто-то мог уже перехватить заказ, игнорируем ошибку catch (InvalidOperationException ex) { @@ -91,7 +91,7 @@ namespace FishFactoryBusinessLogic.BusinessLogic throw; } // отдыхаем - Thread.Sleep(implementer.Qualification * _rnd.Next(10, 100)); + } }); } @@ -104,7 +104,7 @@ namespace FishFactoryBusinessLogic.BusinessLogic } try { - var runOrder = await Task.Run(() => _orderLogic.ReadElement(new OrderSearchModel + var runOrder = await Task.Run(() => _orderLogic.ReadElement(new() { ImplementerId = implementer.Id, Status = OrderStatus.Выполняется diff --git a/FishFactoryContracts/SearchModels/ImplementerSearchModel.cs b/FishFactoryContracts/SearchModels/ImplementerSearchModel.cs index 2420ab5..ec31f76 100644 --- a/FishFactoryContracts/SearchModels/ImplementerSearchModel.cs +++ b/FishFactoryContracts/SearchModels/ImplementerSearchModel.cs @@ -4,7 +4,7 @@ namespace FishFactoryContracts.SearchModels public class ImplementerSearchModel { public int? Id { get; set; } - public string? ImplementerFIO { get; set; } = string.Empty; + public string? ImplementerFIO { get; set; } = string.Empty; public string? Password { get; set; } = string.Empty; } } diff --git a/FishFactoryDatabaseImplement/Models/Order.cs b/FishFactoryDatabaseImplement/Models/Order.cs index a079ca2..10d329b 100644 --- a/FishFactoryDatabaseImplement/Models/Order.cs +++ b/FishFactoryDatabaseImplement/Models/Order.cs @@ -56,14 +56,8 @@ namespace FishFactoryDatabaseImplement.Models } using var context = new FishFactoryDatabase(); - Id = model.Id; - CannedId = model.CannedId; - ClientId = model.ClientId; ImplementerId = model.ImplementerId; - Implementer = model.ImplementerId.HasValue ? context.Implementers.First(x => x.Id == model.ImplementerId) : null; - Sum = model.Sum; Status = model.Status; - DateCreate = model.DateCreate; DateImplement = model.DateImplement; } public OrderViewModel GetViewModel => new()