Compare commits
4 Commits
5528cd9ab8
...
48db7fbf05
Author | SHA1 | Date | |
---|---|---|---|
48db7fbf05 | |||
23f2fbf3eb | |||
c0aa47fd2e | |||
dc680a0e1a |
@ -54,7 +54,7 @@ namespace LawFirmBusinessLogic.BusinessLogics
|
||||
{
|
||||
return;
|
||||
}
|
||||
await RunOrderInWork(implementer, orders);
|
||||
await RunOrderInWork(implementer);
|
||||
|
||||
await Task.Run(() =>
|
||||
{
|
||||
@ -98,26 +98,28 @@ namespace LawFirmBusinessLogic.BusinessLogics
|
||||
});
|
||||
}
|
||||
|
||||
private async Task RunOrderInWork(ImplementerViewModel implementer, List<OrderViewModel> allOrders)
|
||||
private async Task RunOrderInWork(ImplementerViewModel implementer)
|
||||
{
|
||||
if (_orderLogic == null || implementer == null || allOrders == null || allOrders.Count == 0)
|
||||
if (_orderLogic == null || implementer == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
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);
|
||||
// доделываем работу
|
||||
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 +138,6 @@ namespace LawFirmBusinessLogic.BusinessLogics
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -16,10 +16,6 @@ namespace LawFirmDatabaseImplement.Implements
|
||||
{
|
||||
public OrderViewModel? GetElement(OrderSearchModel model)
|
||||
{
|
||||
if (!model.Id.HasValue)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
using var context = new LawFirmDatabase();
|
||||
return context.Orders
|
||||
.Include(x => x.Document)
|
||||
|
Loading…
Reference in New Issue
Block a user