From 1f4b43dd00b80fbfaf96b9c75b75cf09d79f19ee Mon Sep 17 00:00:00 2001 From: goblinrf Date: Mon, 6 May 2024 21:19:40 +0400 Subject: [PATCH] Finaly --- .../BusinessLogics/WorkModeling.cs | 26 ++++++++++++------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/AbstractShopBusinessLogic/BusinessLogics/WorkModeling.cs b/AbstractShopBusinessLogic/BusinessLogics/WorkModeling.cs index b47b7d1..565993f 100644 --- a/AbstractShopBusinessLogic/BusinessLogics/WorkModeling.cs +++ b/AbstractShopBusinessLogic/BusinessLogics/WorkModeling.cs @@ -103,24 +103,30 @@ namespace DinerBusinessLogic.BusinessLogics try { - var runOrder = await Task.Run(() => allOrders.FirstOrDefault(x => x.ImplementerId == implementer.Id && x.Status == OrderStatus.Выполняется)); + + var runOrder = await Task.Run(() => _orderLogic.ReadElement(new + OrderSearchModel + { + ImplementerId = implementer.Id, + Status = OrderStatus.Выполняется + })); if (runOrder == null) { return; } - - _logger.LogDebug("DoWork. Worker {Id} back to order {Order}", implementer.Id, runOrder.Id); - - await Task.Delay(implementer.WorkExperience * _rnd.Next(100, 300) * runOrder.Count); - - _logger.LogDebug("DoWork. Worker {Id} finish order {Order}", implementer.Id, runOrder.Id); - + _logger.LogDebug("DoWork. Worker {Id} back to order {Order}", + implementer.Id, runOrder.Id); + // доделываем работу + Thread.Sleep(implementer.WorkExperience * _rnd.Next(100, 300) * + runOrder.Count); + _logger.LogDebug("DoWork. Worker {Id} finish order {Order}", + implementer.Id, runOrder.Id); _orderLogic.FinishOrder(new OrderBindingModel { Id = runOrder.Id }); - - await Task.Delay(implementer.Qualification * _rnd.Next(10, 100)); + // отдыхаем + Thread.Sleep(implementer.Qualification * _rnd.Next(10, 100)); } catch (InvalidOperationException ex) {