работаем
This commit is contained in:
parent
bb689ff63b
commit
5a541e540b
@ -79,13 +79,13 @@ namespace LawFirmBusinessLogic.BusinessLogics
|
||||
}
|
||||
|
||||
CheckModel(model, false);
|
||||
if (model.Status + 1 != newStatus)
|
||||
if (model.Status + 1 != newStatus && model.Status!=OrderStatus.Ожидание)
|
||||
{
|
||||
_logger.LogWarning("Status update to " + newStatus.ToString() +" operation failed. Order status incorrect.");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (newStatus == OrderStatus.Готов)
|
||||
if (newStatus == OrderStatus.Готов || newStatus == OrderStatus.Ожидание)
|
||||
{
|
||||
var document = _documentStorage.GetElement(new DocumentSearchModel() { Id = model.DocumentId});
|
||||
if (document == null)
|
||||
|
@ -54,6 +54,9 @@ namespace LawFirmBusinessLogic.BusinessLogics
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
await RunWaitingOrder(implementer);
|
||||
|
||||
await RunOrderInWork(implementer, orders);
|
||||
|
||||
await Task.Run(() =>
|
||||
@ -117,7 +120,7 @@ namespace LawFirmBusinessLogic.BusinessLogics
|
||||
// доделываем работу
|
||||
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
|
||||
_orderLogic.DeliveryOrder(new OrderBindingModel
|
||||
{
|
||||
Id = runOrder.Id
|
||||
});
|
||||
@ -136,5 +139,40 @@ namespace LawFirmBusinessLogic.BusinessLogics
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private async Task RunWaitingOrder(ImplementerViewModel implementer)
|
||||
{
|
||||
if (_orderLogic == null || implementer == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
try
|
||||
{
|
||||
var order = await Task.Run(() => _orderLogic.ReadElement(new OrderSearchModel
|
||||
{
|
||||
ImplementerId = implementer.Id,
|
||||
Status = OrderStatus.Ожидание
|
||||
}));
|
||||
if (order == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_logger.LogDebug("DoWork. Worker {Id} finish order {Order}", implementer.Id, order.Id);
|
||||
_orderLogic.FinishOrder(new OrderBindingModel
|
||||
{
|
||||
Id = order.Id
|
||||
});
|
||||
Thread.Sleep(implementer.Qualification * _rnd.Next(10, 100));
|
||||
}
|
||||
catch (InvalidOperationException ex)
|
||||
{
|
||||
_logger.LogWarning(ex, "Error try get work");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Error while do work");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -13,5 +13,6 @@ namespace LawFirmDataModels.Enums
|
||||
Выполняется = 1,
|
||||
Готов = 2,
|
||||
Выдан = 3,
|
||||
Ожидание = 4
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user