Знаю как починить, но мб это неправильно

This commit is contained in:
DyCTaTOR 2024-05-04 18:55:34 +04:00
parent 7d890d2294
commit ea538ac02c
4 changed files with 15 additions and 41 deletions

View File

@ -1,38 +0,0 @@
namespace PlumbingRepairView
{
partial class nlog
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
} base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(800, 450);
this.Text = "nlog";
}
#endregion
}
}

View File

@ -85,11 +85,13 @@ namespace PlumbingRepairBusinessLogic.BusinessLogics
return false;
}
model.Status = newStatus;
model.DateCreate = viewModel.DateCreate;
model.Sum = viewModel.Sum;
model.Count = viewModel.Count;
model.DateImplement = viewModel.DateImplement;
model.WorkId = viewModel.WorkId;
if (viewModel.ImplementerId.HasValue)
{
model.ImplementerId = viewModel.ImplementerId;

View File

@ -15,13 +15,17 @@ namespace PlumbingRepairBusinessLogic.BusinessLogics
public class WorkModeling : IWorkProcess
{
private readonly ILogger _logger;
private readonly Random _rnd;
private IOrderLogic? _orderLogic;
public WorkModeling(ILogger<WorkModeling> logger)
{
_logger = logger;
_rnd = new Random(1000);
}
public void DoWork(IImplementerLogic implementerLogic, IOrderLogic orderLogic)
{
_orderLogic = orderLogic;
@ -43,6 +47,7 @@ namespace PlumbingRepairBusinessLogic.BusinessLogics
Task.Run(() => WorkerWorkAsync(implementer, orders));
}
}
/// <summary>
/// Иммитация работы исполнителя
/// </summary>
@ -55,6 +60,7 @@ namespace PlumbingRepairBusinessLogic.BusinessLogics
return;
}
await RunOrderInWork(implementer);
await Task.Run(() =>
{
foreach (var order in orders)
@ -89,9 +95,11 @@ namespace PlumbingRepairBusinessLogic.BusinessLogics
_logger.LogError(ex, "Error while do work");
throw;
}
}
});
}
/// <summary>
/// Ищем заказ, которые уже в работе (вдруг исполнителя прервали)
/// </summary>
@ -114,6 +122,7 @@ namespace PlumbingRepairBusinessLogic.BusinessLogics
{
return;
}
_logger.LogDebug("DoWork. Worker {Id} back to order {Order}", implementer.Id, runOrder.Id);
// доделываем работу
Thread.Sleep(implementer.WorkExperience * _rnd.Next(100, 300) * runOrder.Count);

View File

@ -90,8 +90,9 @@ namespace PlumbingRepairDataBaseImplement.Implements
.Include(x => x.Work)
.Include(x => x.Client)
.Include(x => x.Implementer)
.FirstOrDefault(x => model.Id.HasValue && x.Id == model.Id)
?.GetViewModel;
.FirstOrDefault(x => (!model.ImplementerId.HasValue || x.ImplementerId == model.ImplementerId) &&
(!model.Status.HasValue || x.Status == model.Status) &&
(!model.Id.HasValue || x.Id == model.Id))?.GetViewModel;
}
public OrderViewModel? Insert(OrderBindingModel model)