Compare commits

..

4 Commits

Author SHA1 Message Date
48db7fbf05 merge fix 2023-04-22 10:25:15 +04:00
23f2fbf3eb fix 2023-04-21 12:23:35 +04:00
c0aa47fd2e fix 2023-04-21 09:13:38 +04:00
dc680a0e1a fix 2023-04-19 21:19:29 +04:00
2 changed files with 41 additions and 42 deletions

View File

@ -54,7 +54,7 @@ namespace LawFirmBusinessLogic.BusinessLogics
{ {
return; return;
} }
await RunOrderInWork(implementer, orders); await RunOrderInWork(implementer);
await Task.Run(() => 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; return;
} }
try try
{ {
// Выбираем из всех заказов тот, который выполняется данным исполнителем var runOrder = await Task.Run(() => _orderLogic.ReadElement(new OrderSearchModel
var runOrder = await Task.Run(() => allOrders.FirstOrDefault(x => x.ImplementerId == implementer.Id && x.Status == OrderStatus.Выполняется)); {
ImplementerId = implementer.Id,
Status = OrderStatus.Выполняется
}));
if (runOrder == null) if (runOrder == null)
{ {
return; return;
} }
_logger.LogDebug("DoWork. Worker {Id} back to 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); Thread.Sleep(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} finish order {Order}", implementer.Id, runOrder.Id);
_orderLogic.FinishOrder(new OrderBindingModel _orderLogic.DeliveryOrder(new OrderBindingModel
{ {
Id = runOrder.Id Id = runOrder.Id
}); });
@ -136,5 +138,6 @@ namespace LawFirmBusinessLogic.BusinessLogics
throw; throw;
} }
} }
} }
} }

View File

@ -16,10 +16,6 @@ namespace LawFirmDatabaseImplement.Implements
{ {
public OrderViewModel? GetElement(OrderSearchModel model) public OrderViewModel? GetElement(OrderSearchModel model)
{ {
if (!model.Id.HasValue)
{
return null;
}
using var context = new LawFirmDatabase(); using var context = new LawFirmDatabase();
return context.Orders return context.Orders
.Include(x => x.Document) .Include(x => x.Document)