Compare commits
4 Commits
c8741b8e51
...
7d7be6231f
Author | SHA1 | Date | |
---|---|---|---|
7d7be6231f | |||
5a541e540b | |||
bb689ff63b | |||
dc680a0e1a |
1
LawFirm/LawFirm/FormMain.Designer.cs
generated
1
LawFirm/LawFirm/FormMain.Designer.cs
generated
@ -266,7 +266,6 @@
|
||||
private ToolStripMenuItem списокЗаказовПоДатеToolStripMenuItem;
|
||||
private ToolStripMenuItem клиентыToolStripMenuItem;
|
||||
private ToolStripMenuItem исполнителиToolStripMenuItem;
|
||||
private ToolStripMenuItem запускРаботToolStripMenuItem;
|
||||
private ToolStripMenuItem запускРаботыToolStripMenuItem;
|
||||
}
|
||||
}
|
@ -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)
|
||||
@ -96,6 +96,8 @@ namespace LawFirmBusinessLogic.BusinessLogics
|
||||
if (CheckThenSupplyMany(document, model.Count) == false)
|
||||
{
|
||||
_logger.LogWarning("Status update to " + newStatus.ToString() + " operation failed. Shop supply error.");
|
||||
model.Status = OrderStatus.Ожидание;
|
||||
_orderStorage.Update(model);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -35,7 +35,12 @@ namespace LawFirmBusinessLogic.BusinessLogics
|
||||
_logger.LogWarning("DoWork. Implementers is null");
|
||||
return;
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
_logger.LogWarning("DoWork. Orders is null or empty");
|
||||
@ -54,6 +59,9 @@ namespace LawFirmBusinessLogic.BusinessLogics
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
await RunWaitingOrder(implementer);
|
||||
|
||||
await RunOrderInWork(implementer, orders);
|
||||
|
||||
await Task.Run(() =>
|
||||
@ -136,5 +144,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
|
||||
}
|
||||
}
|
||||
|
@ -48,7 +48,7 @@ namespace LawFirmRestApi.Controllers
|
||||
{
|
||||
return _order.ReadList(new OrderSearchModel
|
||||
{
|
||||
Statuses = new() { OrderStatus.Принят }
|
||||
Status = OrderStatus.Принят
|
||||
}) ;
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
Loading…
Reference in New Issue
Block a user