Compare commits

..

No commits in common. "7d7be6231f28c3b9ed654b35ae06176a7182d346" and "c8741b8e51ff0d2ea154979e86203514189f57f1" have entirely different histories.

5 changed files with 7 additions and 52 deletions

View File

@ -266,6 +266,7 @@
private ToolStripMenuItem списокЗаказовПоДатеToolStripMenuItem; private ToolStripMenuItem списокЗаказовПоДатеToolStripMenuItem;
private ToolStripMenuItem клиентыToolStripMenuItem; private ToolStripMenuItem клиентыToolStripMenuItem;
private ToolStripMenuItem исполнителиToolStripMenuItem; private ToolStripMenuItem исполнителиToolStripMenuItem;
private ToolStripMenuItem запускРаботToolStripMenuItem;
private ToolStripMenuItem запускРаботыToolStripMenuItem; private ToolStripMenuItem запускРаботыToolStripMenuItem;
} }
} }

View File

@ -79,13 +79,13 @@ namespace LawFirmBusinessLogic.BusinessLogics
} }
CheckModel(model, false); CheckModel(model, false);
if (model.Status + 1 != newStatus && model.Status!=OrderStatus.Ожидание) if (model.Status + 1 != newStatus)
{ {
_logger.LogWarning("Status update to " + newStatus.ToString() +" operation failed. Order status incorrect."); _logger.LogWarning("Status update to " + newStatus.ToString() +" operation failed. Order status incorrect.");
return false; return false;
} }
if (newStatus == OrderStatus.Готов || newStatus == OrderStatus.Ожидание) if (newStatus == OrderStatus.Готов)
{ {
var document = _documentStorage.GetElement(new DocumentSearchModel() { Id = model.DocumentId}); var document = _documentStorage.GetElement(new DocumentSearchModel() { Id = model.DocumentId});
if (document == null) if (document == null)
@ -96,9 +96,7 @@ namespace LawFirmBusinessLogic.BusinessLogics
if (CheckThenSupplyMany(document, model.Count) == false) if (CheckThenSupplyMany(document, model.Count) == false)
{ {
_logger.LogWarning("Status update to " + newStatus.ToString() + " operation failed. Shop supply error."); _logger.LogWarning("Status update to " + newStatus.ToString() + " operation failed. Shop supply error.");
model.Status = OrderStatus.Ожидание; return false;
_orderStorage.Update(model);
return false;
} }
} }

View File

@ -35,12 +35,7 @@ namespace LawFirmBusinessLogic.BusinessLogics
_logger.LogWarning("DoWork. Implementers is null"); _logger.LogWarning("DoWork. Implementers is null");
return; return;
} }
var orders = _orderLogic.ReadList(new OrderSearchModel { Status = OrderStatus.Принят });
var orders = _orderLogic.ReadList(new OrderSearchModel { Status = OrderStatus.Принят });
if (orders != null) {
orders.AddRange(_orderLogic.ReadList(new OrderSearchModel { Status = OrderStatus.Выполняется }) ?? new());
orders.AddRange(_orderLogic.ReadList(new OrderSearchModel { Status = OrderStatus.Ожидание }) ?? new());
}
if (orders == null || orders.Count == 0) if (orders == null || orders.Count == 0)
{ {
_logger.LogWarning("DoWork. Orders is null or empty"); _logger.LogWarning("DoWork. Orders is null or empty");
@ -59,9 +54,6 @@ namespace LawFirmBusinessLogic.BusinessLogics
{ {
return; return;
} }
await RunWaitingOrder(implementer);
await RunOrderInWork(implementer, orders); await RunOrderInWork(implementer, orders);
await Task.Run(() => await Task.Run(() =>
@ -144,40 +136,5 @@ namespace LawFirmBusinessLogic.BusinessLogics
throw; 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;
}
}
}
} }

View File

@ -13,6 +13,5 @@ namespace LawFirmDataModels.Enums
Выполняется = 1, Выполняется = 1,
Готов = 2, Готов = 2,
Выдан = 3, Выдан = 3,
Ожидание = 4
} }
} }

View File

@ -48,7 +48,7 @@ namespace LawFirmRestApi.Controllers
{ {
return _order.ReadList(new OrderSearchModel return _order.ReadList(new OrderSearchModel
{ {
Status = OrderStatus.Принят Statuses = new() { OrderStatus.Принят }
}) ; }) ;
} }
catch (Exception ex) catch (Exception ex)