Merge branch 'lab6' into lab7
This commit is contained in:
commit
dbcbacaa05
@ -10,9 +10,7 @@ namespace FlowerShopBusinessLogic.BusinessLogics
|
||||
public class WorkModeling : IWorkProcess
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
|
||||
private readonly Random _rnd;
|
||||
|
||||
private IOrderLogic? _orderLogic;
|
||||
|
||||
public WorkModeling(ILogger<WorkModeling> Logger)
|
||||
@ -35,7 +33,6 @@ namespace FlowerShopBusinessLogic.BusinessLogics
|
||||
|
||||
var Orders = _orderLogic.ReadList(new OrderSearchModel { Status = OrderStatus.Принят });
|
||||
var BeingProcessedOrders = _orderLogic.ReadList(new OrderSearchModel { Status = OrderStatus.Выполняется });
|
||||
// in case there are BeingProcessed orders but no Accepted orders
|
||||
|
||||
if (Orders == null || BeingProcessedOrders == null || (Orders.Count == 0 && BeingProcessedOrders.Count == 0))
|
||||
{
|
||||
@ -68,8 +65,6 @@ namespace FlowerShopBusinessLogic.BusinessLogics
|
||||
{
|
||||
_logger.LogDebug("WorkerWorkAsync. Worker {Id} try get order {Order}", Implementer.Id, Order.Id);
|
||||
|
||||
// TakeOrderInWork will fail when the worker tries to change status to BeingProcessed when the order is already BeingProcessed
|
||||
// which would happen when other worker already acquired that order
|
||||
bool AcquireResult = _orderLogic.TakeOrderInWork(new OrderBindingModel
|
||||
{
|
||||
Id = Order.Id,
|
||||
@ -89,7 +84,8 @@ namespace FlowerShopBusinessLogic.BusinessLogics
|
||||
{
|
||||
Id = Order.Id
|
||||
});
|
||||
}
|
||||
Thread.Sleep(Implementer.Qualification * _rnd.Next(10, 100));
|
||||
}
|
||||
|
||||
catch (InvalidOperationException ex)
|
||||
{
|
||||
@ -101,8 +97,6 @@ namespace FlowerShopBusinessLogic.BusinessLogics
|
||||
_logger.LogError(ex, "Error while do work");
|
||||
throw;
|
||||
}
|
||||
|
||||
Thread.Sleep(Implementer.Qualification * _rnd.Next(10, 100));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user