diff --git a/AircraftPlant/AircraftPlantBusinessLogic/BusinessLogics/OrderLogic.cs b/AircraftPlant/AircraftPlantBusinessLogic/BusinessLogics/OrderLogic.cs index ab91015..704e5fd 100644 --- a/AircraftPlant/AircraftPlantBusinessLogic/BusinessLogics/OrderLogic.cs +++ b/AircraftPlant/AircraftPlantBusinessLogic/BusinessLogics/OrderLogic.cs @@ -28,6 +28,8 @@ namespace AircraftPlantBusinessLogic.BusinessLogics /// private readonly IOrderStorage _orderStorage; + static readonly object locker = new(); + /// /// Конструктор /// @@ -109,9 +111,13 @@ namespace AircraftPlantBusinessLogic.BusinessLogics /// /// /// + public bool TakeOrderInWork(OrderBindingModel model) { - return StatusUpdate(model, OrderStatus.Выполняется); + lock (locker) + { + return StatusUpdate(model, OrderStatus.Выполняется); + } } /// /// Смена статуса заказа (Выдан) diff --git a/AircraftPlant/AircraftPlantBusinessLogic/BusinessLogics/WorkModeling.cs b/AircraftPlant/AircraftPlantBusinessLogic/BusinessLogics/WorkModeling.cs index bd3b364..21c947c 100644 --- a/AircraftPlant/AircraftPlantBusinessLogic/BusinessLogics/WorkModeling.cs +++ b/AircraftPlant/AircraftPlantBusinessLogic/BusinessLogics/WorkModeling.cs @@ -78,12 +78,15 @@ namespace AircraftPlantBusinessLogic.BusinessLogics } // делаем работу - Thread.Sleep(implementer.WorkExperience * _rnd.Next(100, 1000) * order.Count); + Thread.Sleep(implementer.WorkExperience * _rnd.Next(500, 1000) * order.Count); _logger.LogDebug("DoWork. Worker {Id} finish order {Order}", implementer.Id, order.Id); _orderLogic.DeliveryOrder(new OrderBindingModel { Id = order.Id }); + + // отдыхаем + Thread.Sleep(implementer.Qualification * _rnd.Next(10, 20)); } // кто-то мог уже перехватить заказ, игнорируем ошибку catch (InvalidOperationException ex) @@ -97,8 +100,6 @@ namespace AircraftPlantBusinessLogic.BusinessLogics throw; } - // отдыхаем - Thread.Sleep(implementer.Qualification * _rnd.Next(10, 100)); } }); }