временное зафиксирование

This commit is contained in:
dasha 2023-04-25 13:23:53 +04:00
parent a410427c9b
commit 1149a8fe88
2 changed files with 21 additions and 24 deletions

View File

@ -30,24 +30,18 @@ namespace SushiBarBusinessLogic.BusinessLogics
_logger.LogWarning("DoWork. Implementers is null");
return;
}
List<OrderViewModel>? orders = _orderLogic.ReadList(new OrderSearchModel { OrderStatus = OrderStatus.Принят });
List<OrderViewModel>? ordersInWork = _orderLogic.ReadList(new OrderSearchModel { OrderStatus = OrderStatus.Выполняется });
List<OrderViewModel>? ordersInWaiting = _orderLogic.ReadList(new OrderSearchModel { OrderStatus = OrderStatus.Ожидание });
if (orders == null || ordersInWork == null || ordersInWaiting == null)
var orders = _orderLogic.ReadList(new OrderSearchModel
{
_logger.LogWarning("DoWork. Orders are null");
return;
}
else
{
orders.AddRange(ordersInWork);
orders.AddRange(ordersInWaiting);
}
if (orders.Count == 0)
{
_logger.LogWarning("DoWork. Orders are empty");
OrderStatus = OrderStatus.Принят
});
if (orders == null)
{
_logger.LogWarning("DoWork. Orders is null or empty");
return;
}
_logger.LogDebug("DoWork for {Count} orders", orders.Count);
foreach (var implementer in implementers)
{
@ -169,16 +163,18 @@ namespace SushiBarBusinessLogic.BusinessLogics
}
try
{
var order = await Task.Run(() => _orderLogic.ReadElement(new OrderSearchModel
var orders = await Task.Run(() => _orderLogic.ReadList(new OrderSearchModel
{
ImplementerId = implementer.Id,
OrderStatus = OrderStatus.Ожидание
}));
if (order == null)
if (orders == null)
{
return;
}
// доделываем работу
foreach (var order in orders)
{
_logger.LogDebug("DoWork. Worker {Id} finish order {Order}", implementer.Id, order.Id);
_orderLogic.FinishOrder(new OrderBindingModel
{
@ -187,6 +183,7 @@ namespace SushiBarBusinessLogic.BusinessLogics
// отдыхаем
Thread.Sleep(implementer.Qualification * _rnd.Next(10, 100));
}
}
catch (InvalidOperationException ex)
{
_logger.LogWarning(ex, "Error try get work");

View File

@ -10,7 +10,7 @@ namespace SushiBarDatabaseImplement
if (optionsBuilder.IsConfigured == false)
{
// D8KMQQU comp JC256C6 nout
optionsBuilder.UseSqlServer(@"Data Source=DESKTOP-D8KMQQU\SQLEXPRESS;Initial Catalog=SushiBarDatabase;Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True");
optionsBuilder.UseSqlServer(@"Data Source=DESKTOP-JC256C6\SQLEXPRESS;Initial Catalog=SushiBarDatabase;Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True");
}
base.OnConfiguring(optionsBuilder);
}