Compare commits

..

2 Commits

Author SHA1 Message Date
3e3dc0cf2d Сдана Lab6Base 2023-04-10 09:58:11 +04:00
e5e0cddc9b fix 2023-04-10 08:55:05 +04:00
7 changed files with 211 additions and 287 deletions

View File

@ -28,198 +28,174 @@
/// </summary> /// </summary>
private void InitializeComponent() private void InitializeComponent()
{ {
this.menuStrip = new System.Windows.Forms.MenuStrip(); this.menuStrip = new System.Windows.Forms.MenuStrip();
this.справочникиToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.справочникиToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.бланкиToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.бланкиToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.документыToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.документыToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.клиентыToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.клиентыToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.исполнителиToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.исполнителиToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.отчетыToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.отчетыToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.списокДокументовToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.списокДокументовToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.бланкиПоДокументамToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.бланкиПоДокументамToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.списокЗаказовToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.списокЗаказовToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.dataGridView = new System.Windows.Forms.DataGridView(); this.запускРаботToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.buttonCreateOrder = new System.Windows.Forms.Button(); this.dataGridView = new System.Windows.Forms.DataGridView();
this.buttonSetToWork = new System.Windows.Forms.Button(); this.buttonCreateOrder = new System.Windows.Forms.Button();
this.buttonSetToDone = new System.Windows.Forms.Button(); this.buttonSetToFinish = new System.Windows.Forms.Button();
this.buttonSetToFinish = new System.Windows.Forms.Button(); this.buttonUpdate = new System.Windows.Forms.Button();
this.buttonUpdate = new System.Windows.Forms.Button(); this.menuStrip.SuspendLayout();
this.запускРаботToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
this.menuStrip.SuspendLayout(); this.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit(); //
this.SuspendLayout(); // menuStrip
// //
// menuStrip this.menuStrip.ImageScalingSize = new System.Drawing.Size(20, 20);
// this.menuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.menuStrip.ImageScalingSize = new System.Drawing.Size(20, 20);
this.menuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.справочникиToolStripMenuItem, this.справочникиToolStripMenuItem,
this.отчетыToolStripMenuItem, this.отчетыToolStripMenuItem,
this.запускРаботToolStripMenuItem}); this.запускРаботToolStripMenuItem});
this.menuStrip.Location = new System.Drawing.Point(0, 0); this.menuStrip.Location = new System.Drawing.Point(0, 0);
this.menuStrip.Name = "menuStrip"; this.menuStrip.Name = "menuStrip";
this.menuStrip.Size = new System.Drawing.Size(1139, 28); this.menuStrip.Size = new System.Drawing.Size(1139, 28);
this.menuStrip.TabIndex = 0; this.menuStrip.TabIndex = 0;
this.menuStrip.Text = "Справочники"; this.menuStrip.Text = "Справочники";
// //
// справочникиToolStripMenuItem // справочникиToolStripMenuItem
// //
this.справочникиToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { this.справочникиToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.бланкиToolStripMenuItem, this.бланкиToolStripMenuItem,
this.документыToolStripMenuItem, this.документыToolStripMenuItem,
this.клиентыToolStripMenuItem, this.клиентыToolStripMenuItem,
this.исполнителиToolStripMenuItem}); this.исполнителиToolStripMenuItem});
this.справочникиToolStripMenuItem.Name = "справочникиToolStripMenuItem"; this.справочникиToolStripMenuItem.Name = "справочникиToolStripMenuItem";
this.справочникиToolStripMenuItem.Size = new System.Drawing.Size(117, 24); this.справочникиToolStripMenuItem.Size = new System.Drawing.Size(117, 24);
this.справочникиToolStripMenuItem.Text = "Справочники"; this.справочникиToolStripMenuItem.Text = "Справочники";
// //
// бланкиToolStripMenuItem // бланкиToolStripMenuItem
// //
this.бланкиToolStripMenuItem.Name = "бланкиToolStripMenuItem"; this.бланкиToolStripMenuItem.Name = "бланкиToolStripMenuItem";
this.бланкиToolStripMenuItem.Size = new System.Drawing.Size(185, 26); this.бланкиToolStripMenuItem.Size = new System.Drawing.Size(185, 26);
this.бланкиToolStripMenuItem.Text = "Бланки"; this.бланкиToolStripMenuItem.Text = "Бланки";
this.бланкиToolStripMenuItem.Click += new System.EventHandler(this.бланкиToolStripMenuItem_Click); this.бланкиToolStripMenuItem.Click += new System.EventHandler(this.бланкиToolStripMenuItem_Click);
// //
// документыToolStripMenuItem // документыToolStripMenuItem
// //
this.документыToolStripMenuItem.Name = окументыToolStripMenuItem"; this.документыToolStripMenuItem.Name = окументыToolStripMenuItem";
this.документыToolStripMenuItem.Size = new System.Drawing.Size(185, 26); this.документыToolStripMenuItem.Size = new System.Drawing.Size(185, 26);
this.документыToolStripMenuItem.Text = "Документы"; this.документыToolStripMenuItem.Text = "Документы";
this.документыToolStripMenuItem.Click += new System.EventHandler(this.документыToolStripMenuItem_Click); this.документыToolStripMenuItem.Click += new System.EventHandler(this.документыToolStripMenuItem_Click);
// //
// клиентыToolStripMenuItem // клиентыToolStripMenuItem
// //
this.клиентыToolStripMenuItem.Name = "клиентыToolStripMenuItem"; this.клиентыToolStripMenuItem.Name = "клиентыToolStripMenuItem";
this.клиентыToolStripMenuItem.Size = new System.Drawing.Size(185, 26); this.клиентыToolStripMenuItem.Size = new System.Drawing.Size(185, 26);
this.клиентыToolStripMenuItem.Text = "Клиенты"; this.клиентыToolStripMenuItem.Text = "Клиенты";
this.клиентыToolStripMenuItem.Click += new System.EventHandler(this.клиентыToolStripMenuItem_Click); this.клиентыToolStripMenuItem.Click += new System.EventHandler(this.клиентыToolStripMenuItem_Click);
// //
// исполнителиToolStripMenuItem // исполнителиToolStripMenuItem
// //
this.исполнителиToolStripMenuItem.Name = сполнителиToolStripMenuItem"; this.исполнителиToolStripMenuItem.Name = сполнителиToolStripMenuItem";
this.исполнителиToolStripMenuItem.Size = new System.Drawing.Size(185, 26); this.исполнителиToolStripMenuItem.Size = new System.Drawing.Size(185, 26);
this.исполнителиToolStripMenuItem.Text = "Исполнители"; this.исполнителиToolStripMenuItem.Text = "Исполнители";
this.исполнителиToolStripMenuItem.Click += new System.EventHandler(this.исполнителиToolStripMenuItem_Click); this.исполнителиToolStripMenuItem.Click += new System.EventHandler(this.исполнителиToolStripMenuItem_Click);
// //
// отчетыToolStripMenuItem // отчетыToolStripMenuItem
// //
this.отчетыToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { this.отчетыToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.списокДокументовToolStripMenuItem, this.списокДокументовToolStripMenuItem,
this.бланкиПоДокументамToolStripMenuItem, this.бланкиПоДокументамToolStripMenuItem,
this.списокЗаказовToolStripMenuItem}); this.списокЗаказовToolStripMenuItem});
this.отчетыToolStripMenuItem.Name = "отчетыToolStripMenuItem"; this.отчетыToolStripMenuItem.Name = "отчетыToolStripMenuItem";
this.отчетыToolStripMenuItem.Size = new System.Drawing.Size(73, 24); this.отчетыToolStripMenuItem.Size = new System.Drawing.Size(73, 24);
this.отчетыToolStripMenuItem.Text = "Отчеты"; this.отчетыToolStripMenuItem.Text = "Отчеты";
// //
// списокДокументовToolStripMenuItem // списокДокументовToolStripMenuItem
// //
this.списокДокументовToolStripMenuItem.Name = "списокДокументовToolStripMenuItem"; this.списокДокументовToolStripMenuItem.Name = "списокДокументовToolStripMenuItem";
this.списокДокументовToolStripMenuItem.Size = new System.Drawing.Size(252, 26); this.списокДокументовToolStripMenuItem.Size = new System.Drawing.Size(252, 26);
this.списокДокументовToolStripMenuItem.Text = "Список документов"; this.списокДокументовToolStripMenuItem.Text = "Список документов";
this.списокДокументовToolStripMenuItem.Click += new System.EventHandler(this.списокДокументовToolStripMenuItem_Click); this.списокДокументовToolStripMenuItem.Click += new System.EventHandler(this.списокДокументовToolStripMenuItem_Click);
// //
// бланкиПоДокументамToolStripMenuItem // бланкиПоДокументамToolStripMenuItem
// //
this.бланкиПоДокументамToolStripMenuItem.Name = "бланкиПоДокументамToolStripMenuItem"; this.бланкиПоДокументамToolStripMenuItem.Name = "бланкиПоДокументамToolStripMenuItem";
this.бланкиПоДокументамToolStripMenuItem.Size = new System.Drawing.Size(252, 26); this.бланкиПоДокументамToolStripMenuItem.Size = new System.Drawing.Size(252, 26);
this.бланкиПоДокументамToolStripMenuItem.Text = "Бланки по документам"; this.бланкиПоДокументамToolStripMenuItem.Text = "Бланки по документам";
this.бланкиПоДокументамToolStripMenuItem.Click += new System.EventHandler(this.бланкиПоДокументамToolStripMenuItem_Click); this.бланкиПоДокументамToolStripMenuItem.Click += new System.EventHandler(this.бланкиПоДокументамToolStripMenuItem_Click);
// //
// списокЗаказовToolStripMenuItem // списокЗаказовToolStripMenuItem
// //
this.списокЗаказовToolStripMenuItem.Name = "списокЗаказовToolStripMenuItem"; this.списокЗаказовToolStripMenuItem.Name = "списокЗаказовToolStripMenuItem";
this.списокЗаказовToolStripMenuItem.Size = new System.Drawing.Size(252, 26); this.списокЗаказовToolStripMenuItem.Size = new System.Drawing.Size(252, 26);
this.списокЗаказовToolStripMenuItem.Text = "Список заказов"; this.списокЗаказовToolStripMenuItem.Text = "Список заказов";
this.списокЗаказовToolStripMenuItem.Click += new System.EventHandler(this.списокЗаказовToolStripMenuItem_Click); this.списокЗаказовToolStripMenuItem.Click += new System.EventHandler(this.списокЗаказовToolStripMenuItem_Click);
// //
// dataGridView // запускРаботToolStripMenuItem
// //
this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; this.запускРаботToolStripMenuItem.Name = апускРаботToolStripMenuItem";
this.dataGridView.Location = new System.Drawing.Point(12, 31); this.запускРаботToolStripMenuItem.Size = new System.Drawing.Size(114, 24);
this.dataGridView.Name = "dataGridView"; this.запускРаботToolStripMenuItem.Text = "Запуск работ";
this.dataGridView.RowHeadersWidth = 51; this.запускРаботToolStripMenuItem.Click += new System.EventHandler(this.запускРаботToolStripMenuItem_Click);
this.dataGridView.RowTemplate.Height = 29; //
this.dataGridView.Size = new System.Drawing.Size(915, 407); // dataGridView
this.dataGridView.TabIndex = 1; //
// this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
// buttonCreateOrder this.dataGridView.Location = new System.Drawing.Point(12, 31);
// this.dataGridView.Name = "dataGridView";
this.buttonCreateOrder.Location = new System.Drawing.Point(933, 45); this.dataGridView.RowHeadersWidth = 51;
this.buttonCreateOrder.Name = "buttonCreateOrder"; this.dataGridView.RowTemplate.Height = 29;
this.buttonCreateOrder.Size = new System.Drawing.Size(194, 29); this.dataGridView.Size = new System.Drawing.Size(915, 407);
this.buttonCreateOrder.TabIndex = 2; this.dataGridView.TabIndex = 1;
this.buttonCreateOrder.Text = "Создать заказ"; //
this.buttonCreateOrder.UseVisualStyleBackColor = true; // buttonCreateOrder
this.buttonCreateOrder.Click += new System.EventHandler(this.buttonCreateOrder_Click); //
// this.buttonCreateOrder.Location = new System.Drawing.Point(933, 45);
// buttonSetToWork this.buttonCreateOrder.Name = "buttonCreateOrder";
// this.buttonCreateOrder.Size = new System.Drawing.Size(194, 29);
this.buttonSetToWork.Location = new System.Drawing.Point(933, 80); this.buttonCreateOrder.TabIndex = 2;
this.buttonSetToWork.Name = "buttonSetToWork"; this.buttonCreateOrder.Text = "Создать заказ";
this.buttonSetToWork.Size = new System.Drawing.Size(194, 29); this.buttonCreateOrder.UseVisualStyleBackColor = true;
this.buttonSetToWork.TabIndex = 3; this.buttonCreateOrder.Click += new System.EventHandler(this.buttonCreateOrder_Click);
this.buttonSetToWork.Text = "Отдать на выполнение"; //
this.buttonSetToWork.UseVisualStyleBackColor = true; // buttonSetToFinish
this.buttonSetToWork.Click += new System.EventHandler(this.buttonSetToWork_Click); //
// this.buttonSetToFinish.Location = new System.Drawing.Point(933, 80);
// buttonSetToDone this.buttonSetToFinish.Name = "buttonSetToFinish";
// this.buttonSetToFinish.Size = new System.Drawing.Size(194, 29);
this.buttonSetToDone.Location = new System.Drawing.Point(933, 115); this.buttonSetToFinish.TabIndex = 5;
this.buttonSetToDone.Name = "buttonSetToDone"; this.buttonSetToFinish.Text = "Заказ выдан";
this.buttonSetToDone.Size = new System.Drawing.Size(194, 29); this.buttonSetToFinish.UseVisualStyleBackColor = true;
this.buttonSetToDone.TabIndex = 4; this.buttonSetToFinish.Click += new System.EventHandler(this.buttonSetToFinish_Click);
this.buttonSetToDone.Text = "Заказ готов"; //
this.buttonSetToDone.UseVisualStyleBackColor = true; // buttonUpdate
this.buttonSetToDone.Click += new System.EventHandler(this.buttonSetToDone_Click); //
// this.buttonUpdate.Location = new System.Drawing.Point(933, 410);
// buttonSetToFinish this.buttonUpdate.Name = "buttonUpdate";
// this.buttonUpdate.Size = new System.Drawing.Size(194, 29);
this.buttonSetToFinish.Location = new System.Drawing.Point(933, 150); this.buttonUpdate.TabIndex = 6;
this.buttonSetToFinish.Name = "buttonSetToFinish"; this.buttonUpdate.Text = "Обновить";
this.buttonSetToFinish.Size = new System.Drawing.Size(194, 29); this.buttonUpdate.UseVisualStyleBackColor = true;
this.buttonSetToFinish.TabIndex = 5; this.buttonUpdate.Click += new System.EventHandler(this.buttonUpdate_Click);
this.buttonSetToFinish.Text = "Заказ выдан"; //
this.buttonSetToFinish.UseVisualStyleBackColor = true; // FormMain
this.buttonSetToFinish.Click += new System.EventHandler(this.buttonSetToFinish_Click); //
// this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
// buttonUpdate this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
// this.ClientSize = new System.Drawing.Size(1139, 450);
this.buttonUpdate.Location = new System.Drawing.Point(933, 410); this.Controls.Add(this.buttonUpdate);
this.buttonUpdate.Name = "buttonUpdate"; this.Controls.Add(this.buttonSetToFinish);
this.buttonUpdate.Size = new System.Drawing.Size(194, 29); this.Controls.Add(this.buttonCreateOrder);
this.buttonUpdate.TabIndex = 6; this.Controls.Add(this.dataGridView);
this.buttonUpdate.Text = "Обновить"; this.Controls.Add(this.menuStrip);
this.buttonUpdate.UseVisualStyleBackColor = true; this.MainMenuStrip = this.menuStrip;
this.buttonUpdate.Click += new System.EventHandler(this.buttonUpdate_Click); this.Name = "FormMain";
// this.Text = "Юридическая компания";
// запускРаботToolStripMenuItem this.Load += new System.EventHandler(this.FormMain_Load);
// this.menuStrip.ResumeLayout(false);
this.запускРаботToolStripMenuItem.Name = апускРаботToolStripMenuItem"; this.menuStrip.PerformLayout();
this.запускРаботToolStripMenuItem.Size = new System.Drawing.Size(114, 24); ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
this.запускРаботToolStripMenuItem.Text = "Запуск работ"; this.ResumeLayout(false);
this.запускРаботToolStripMenuItem.Click += new System.EventHandler(this.запускРаботToolStripMenuItem_Click); this.PerformLayout();
//
// FormMain
//
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(1139, 450);
this.Controls.Add(this.buttonUpdate);
this.Controls.Add(this.buttonSetToFinish);
this.Controls.Add(this.buttonSetToDone);
this.Controls.Add(this.buttonSetToWork);
this.Controls.Add(this.buttonCreateOrder);
this.Controls.Add(this.dataGridView);
this.Controls.Add(this.menuStrip);
this.MainMenuStrip = this.menuStrip;
this.Name = "FormMain";
this.Text = "Юридическая компания";
this.Load += new System.EventHandler(this.FormMain_Load);
this.menuStrip.ResumeLayout(false);
this.menuStrip.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();
} }
@ -231,8 +207,6 @@
private ToolStripMenuItem документыToolStripMenuItem; private ToolStripMenuItem документыToolStripMenuItem;
private DataGridView dataGridView; private DataGridView dataGridView;
private Button buttonCreateOrder; private Button buttonCreateOrder;
private Button buttonSetToWork;
private Button buttonSetToDone;
private Button buttonSetToFinish; private Button buttonSetToFinish;
private Button buttonUpdate; private Button buttonUpdate;
private ToolStripMenuItem отчетыToolStripMenuItem; private ToolStripMenuItem отчетыToolStripMenuItem;

View File

@ -136,59 +136,6 @@ namespace LawFirmView
} }
} }
private void buttonSetToWork_Click(object sender, EventArgs e)
{
if (dataGridView.SelectedRows.Count == 1)
{
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
_logger.LogInformation("Заказ №{id}. Меняется статус на 'В работе'", id);
try
{
var operationResult = _orderLogic.TakeOrderInWork(new OrderBindingModel
{
Id = id
});
if (!operationResult)
{
throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
}
LoadData();
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка передачи заказа в работу");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
MessageBoxIcon.Error);
}
}
}
private void buttonSetToDone_Click(object sender, EventArgs e)
{
if (dataGridView.SelectedRows.Count == 1)
{
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
_logger.LogInformation("Заказ №{id}. Меняется статус на 'Готов'", id);
try
{
var operationResult = _orderLogic.DeliveryOrder(new OrderBindingModel
{
Id = id
});
if (!operationResult)
{
throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
}
LoadData();
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка отметки о готовности заказа");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
private void buttonSetToFinish_Click(object sender, EventArgs e) private void buttonSetToFinish_Click(object sender, EventArgs e)
{ {
if (dataGridView.SelectedRows.Count == 1) if (dataGridView.SelectedRows.Count == 1)

View File

@ -35,7 +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 { Statuses = new() { OrderStatus.Принят, OrderStatus.Выполняется } }); var orders = _orderLogic.ReadList(new OrderSearchModel { Status = OrderStatus.Принят });
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");
@ -56,43 +56,46 @@ namespace LawFirmBusinessLogic.BusinessLogics
} }
await RunOrderInWork(implementer, orders); await RunOrderInWork(implementer, orders);
await Task.Run(() => await Task.Run(() =>
{ {
foreach (var order in orders) foreach (var order in orders)
{ {
try try
{ {
_logger.LogDebug("DoWork. Worker {Id} try get order {Order}", implementer.Id, order.Id); _logger.LogDebug("DoWork. Worker {Id} try get order {Order}", implementer.Id, order.Id);
// пытаемся назначить заказ на исполнителя // пытаемся назначить заказ на исполнителя
_orderLogic.TakeOrderInWork(new OrderBindingModel if (_orderLogic.TakeOrderInWork(new OrderBindingModel
{ {
Id = order.Id, Id = order.Id,
ImplementerId = implementer.Id ImplementerId = implementer.Id
}); }))
// делаем работу {
Thread.Sleep(implementer.WorkExperience * _rnd.Next(100, 1000) * order.Count); // делаем работу
_logger.LogDebug("DoWork. Worker {Id} finish order {Order}", implementer.Id, order.Id); Thread.Sleep(implementer.WorkExperience * _rnd.Next(100, 1000) * order.Count);
_orderLogic.DeliveryOrder(new OrderBindingModel _logger.LogDebug("DoWork. Worker {Id} finish order {Order}", implementer.Id, order.Id);
{ _orderLogic.DeliveryOrder(new OrderBindingModel
Id = order.Id, {
ImplementerId = implementer.Id Id = order.Id,
}); ImplementerId = implementer.Id
// отдыхаем });
Thread.Sleep(implementer.Qualification * _rnd.Next(10, 100)); // отдыхаем
} Thread.Sleep(implementer.Qualification * _rnd.Next(10, 100));
// кто-то мог уже перехватить заказ, игнорируем ошибку }
catch (InvalidOperationException ex)
{ }
_logger.LogWarning(ex, "Error try get work"); // кто-то мог уже перехватить заказ, игнорируем ошибку
} catch (InvalidOperationException ex)
// заканчиваем выполнение имитации в случае иной ошибки {
catch (Exception ex) _logger.LogWarning(ex, "Error try get work");
{ }
_logger.LogError(ex, "Error while do work"); // заканчиваем выполнение имитации в случае иной ошибки
throw; catch (Exception ex)
} {
} _logger.LogError(ex, "Error while do work");
}); throw;
}
}
});
} }
private async Task RunOrderInWork(ImplementerViewModel implementer, List<OrderViewModel> allOrders) private async Task RunOrderInWork(ImplementerViewModel implementer, List<OrderViewModel> allOrders)

View File

@ -14,6 +14,6 @@ namespace LawFirmContracts.SearchModels
public DateTime? DateTo { get; set; } public DateTime? DateTo { get; set; }
public int? ClientId { get; set; } public int? ClientId { get; set; }
public int? ImplementerId { get; set; } public int? ImplementerId { get; set; }
public List<OrderStatus>? Statuses { get; set; } public OrderStatus? Status { get; set; }
} }
} }

View File

@ -26,14 +26,14 @@ namespace LawFirmDatabaseImplement.Implements
.Include(x => x.Client) .Include(x => x.Client)
.Include(x => x.Implementer) .Include(x => x.Implementer)
.FirstOrDefault(x => .FirstOrDefault(x =>
(model.Statuses == null || model.Statuses != null && model.Statuses.Contains(x.Status)) && (model.Status == null || model.Status != null && model.Status.Equals(x.Status)) &&
model.ImplementerId.HasValue && x.ImplementerId == model.ImplementerId || model.ImplementerId.HasValue && x.ImplementerId == model.ImplementerId ||
model.Id.HasValue && x.Id == model.Id)?.GetViewModel; model.Id.HasValue && x.Id == model.Id)?.GetViewModel;
} }
public List<OrderViewModel> GetFilteredList(OrderSearchModel model) public List<OrderViewModel> GetFilteredList(OrderSearchModel model)
{ {
if (!model.Id.HasValue && !model.DateFrom.HasValue && !model.DateTo.HasValue && !model.ClientId.HasValue && model.Statuses == null) if (!model.Id.HasValue && !model.DateFrom.HasValue && !model.DateTo.HasValue && !model.ClientId.HasValue && model.Status == null)
{ {
return new(); return new();
} }
@ -47,12 +47,12 @@ namespace LawFirmDatabaseImplement.Implements
.Select(x => x.GetViewModel) .Select(x => x.GetViewModel)
.ToList(); .ToList();
} }
if (model.Statuses!= null) if (model.Status!= null)
{ {
return context.Orders return context.Orders
.Include(x => x.Client) .Include(x => x.Client)
.Include(x => x.Implementer) .Include(x => x.Implementer)
.Where(x => model.Statuses.Contains(x.Status)) .Where(x => model.Status.Equals(x.Status))
.Select(x => x.GetViewModel) .Select(x => x.GetViewModel)
.ToList(); .ToList();
} }

View File

@ -22,7 +22,7 @@ namespace LawFirmFileImplement.Implements
public OrderViewModel? GetElement(OrderSearchModel model) public OrderViewModel? GetElement(OrderSearchModel model)
{ {
if (model.ImplementerId.HasValue && model.Statuses != null) return source.Orders.FirstOrDefault(x => x.ImplementerId == model.ImplementerId && model.Statuses.Contains(x.Status))?.GetViewModel; if (model.ImplementerId.HasValue && model.Status != null) return source.Orders.FirstOrDefault(x => x.ImplementerId == model.ImplementerId && model.Status.Equals(x.Status))?.GetViewModel;
if (model.ImplementerId.HasValue) if (model.ImplementerId.HasValue)
{ {
return source.Orders.FirstOrDefault(x => x.ImplementerId == model.ImplementerId)?.GetViewModel; return source.Orders.FirstOrDefault(x => x.ImplementerId == model.ImplementerId)?.GetViewModel;
@ -36,7 +36,7 @@ namespace LawFirmFileImplement.Implements
public List<OrderViewModel> GetFilteredList(OrderSearchModel model) public List<OrderViewModel> GetFilteredList(OrderSearchModel model)
{ {
if (!model.Id.HasValue && !model.DateFrom.HasValue && !model.DateTo.HasValue && !model.ClientId.HasValue && model.Statuses == null) if (!model.Id.HasValue && !model.DateFrom.HasValue && !model.DateTo.HasValue && !model.ClientId.HasValue && model.Status == null)
{ {
return new(); return new();
} }
@ -47,10 +47,10 @@ namespace LawFirmFileImplement.Implements
.Select(x => x.GetViewModel) .Select(x => x.GetViewModel)
.ToList(); .ToList();
} }
if (model.Statuses != null) if (model.Status != null)
{ {
return source.Orders return source.Orders
.Where(x => model.Statuses.Contains(x.Status)) .Where(x => model.Status.Equals(x.Status))
.Select(x => x.GetViewModel) .Select(x => x.GetViewModel)
.ToList(); .ToList();
} }

View File

@ -32,7 +32,7 @@ namespace LawFirmListImplements.Implements
{ {
return GetViewModel(order); return GetViewModel(order);
} }
else if (model.ImplementerId.HasValue && model.Statuses != null && order.ImplementerId == model.ImplementerId && model.Statuses.Contains(order.Status)) else if (model.ImplementerId.HasValue && model.Status != null && order.ImplementerId == model.ImplementerId && model.Status.Equals(order.Status))
{ {
return GetViewModel(order); return GetViewModel(order);
} }
@ -77,11 +77,11 @@ namespace LawFirmListImplements.Implements
} }
} }
} }
if (model.Statuses != null) if (model.Status != null)
{ {
foreach (var order in _source.Orders) foreach (var order in _source.Orders)
{ {
if (model.Statuses.Contains(order.Status)) if (model.Status.Equals(order.Status))
{ {
result.Add(GetViewModel(order)); result.Add(GetViewModel(order));
} }