Compare commits
2 Commits
4092fa7a9c
...
3e3dc0cf2d
Author | SHA1 | Date | |
---|---|---|---|
3e3dc0cf2d | |||
e5e0cddc9b |
44
LawFirm/LawFirm/FormMain.Designer.cs
generated
44
LawFirm/LawFirm/FormMain.Designer.cs
generated
@ -38,13 +38,11 @@
|
||||
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.buttonCreateOrder = new System.Windows.Forms.Button();
|
||||
this.buttonSetToWork = new System.Windows.Forms.Button();
|
||||
this.buttonSetToDone = new System.Windows.Forms.Button();
|
||||
this.buttonSetToFinish = new System.Windows.Forms.Button();
|
||||
this.buttonUpdate = new System.Windows.Forms.Button();
|
||||
this.запускРаботToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.menuStrip.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
|
||||
this.SuspendLayout();
|
||||
@ -132,6 +130,13 @@
|
||||
this.списокЗаказовToolStripMenuItem.Text = "Список заказов";
|
||||
this.списокЗаказовToolStripMenuItem.Click += new System.EventHandler(this.списокЗаказовToolStripMenuItem_Click);
|
||||
//
|
||||
// запускРаботToolStripMenuItem
|
||||
//
|
||||
this.запускРаботToolStripMenuItem.Name = "запускРаботToolStripMenuItem";
|
||||
this.запускРаботToolStripMenuItem.Size = new System.Drawing.Size(114, 24);
|
||||
this.запускРаботToolStripMenuItem.Text = "Запуск работ";
|
||||
this.запускРаботToolStripMenuItem.Click += new System.EventHandler(this.запускРаботToolStripMenuItem_Click);
|
||||
//
|
||||
// dataGridView
|
||||
//
|
||||
this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
@ -152,29 +157,9 @@
|
||||
this.buttonCreateOrder.UseVisualStyleBackColor = true;
|
||||
this.buttonCreateOrder.Click += new System.EventHandler(this.buttonCreateOrder_Click);
|
||||
//
|
||||
// buttonSetToWork
|
||||
//
|
||||
this.buttonSetToWork.Location = new System.Drawing.Point(933, 80);
|
||||
this.buttonSetToWork.Name = "buttonSetToWork";
|
||||
this.buttonSetToWork.Size = new System.Drawing.Size(194, 29);
|
||||
this.buttonSetToWork.TabIndex = 3;
|
||||
this.buttonSetToWork.Text = "Отдать на выполнение";
|
||||
this.buttonSetToWork.UseVisualStyleBackColor = true;
|
||||
this.buttonSetToWork.Click += new System.EventHandler(this.buttonSetToWork_Click);
|
||||
//
|
||||
// buttonSetToDone
|
||||
//
|
||||
this.buttonSetToDone.Location = new System.Drawing.Point(933, 115);
|
||||
this.buttonSetToDone.Name = "buttonSetToDone";
|
||||
this.buttonSetToDone.Size = new System.Drawing.Size(194, 29);
|
||||
this.buttonSetToDone.TabIndex = 4;
|
||||
this.buttonSetToDone.Text = "Заказ готов";
|
||||
this.buttonSetToDone.UseVisualStyleBackColor = true;
|
||||
this.buttonSetToDone.Click += new System.EventHandler(this.buttonSetToDone_Click);
|
||||
//
|
||||
// buttonSetToFinish
|
||||
//
|
||||
this.buttonSetToFinish.Location = new System.Drawing.Point(933, 150);
|
||||
this.buttonSetToFinish.Location = new System.Drawing.Point(933, 80);
|
||||
this.buttonSetToFinish.Name = "buttonSetToFinish";
|
||||
this.buttonSetToFinish.Size = new System.Drawing.Size(194, 29);
|
||||
this.buttonSetToFinish.TabIndex = 5;
|
||||
@ -192,13 +177,6 @@
|
||||
this.buttonUpdate.UseVisualStyleBackColor = true;
|
||||
this.buttonUpdate.Click += new System.EventHandler(this.buttonUpdate_Click);
|
||||
//
|
||||
// запускРаботToolStripMenuItem
|
||||
//
|
||||
this.запускРаботToolStripMenuItem.Name = "запускРаботToolStripMenuItem";
|
||||
this.запускРаботToolStripMenuItem.Size = new System.Drawing.Size(114, 24);
|
||||
this.запускРаботToolStripMenuItem.Text = "Запуск работ";
|
||||
this.запускРаботToolStripMenuItem.Click += new System.EventHandler(this.запускРаботToolStripMenuItem_Click);
|
||||
//
|
||||
// FormMain
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
|
||||
@ -206,8 +184,6 @@
|
||||
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);
|
||||
@ -231,8 +207,6 @@
|
||||
private ToolStripMenuItem документыToolStripMenuItem;
|
||||
private DataGridView dataGridView;
|
||||
private Button buttonCreateOrder;
|
||||
private Button buttonSetToWork;
|
||||
private Button buttonSetToDone;
|
||||
private Button buttonSetToFinish;
|
||||
private Button buttonUpdate;
|
||||
private ToolStripMenuItem отчетыToolStripMenuItem;
|
||||
|
@ -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)
|
||||
{
|
||||
if (dataGridView.SelectedRows.Count == 1)
|
||||
|
@ -35,7 +35,7 @@ namespace LawFirmBusinessLogic.BusinessLogics
|
||||
_logger.LogWarning("DoWork. Implementers is null");
|
||||
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)
|
||||
{
|
||||
_logger.LogWarning("DoWork. Orders is null or empty");
|
||||
@ -64,11 +64,12 @@ namespace LawFirmBusinessLogic.BusinessLogics
|
||||
{
|
||||
_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,
|
||||
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);
|
||||
@ -80,6 +81,8 @@ namespace LawFirmBusinessLogic.BusinessLogics
|
||||
// отдыхаем
|
||||
Thread.Sleep(implementer.Qualification * _rnd.Next(10, 100));
|
||||
}
|
||||
|
||||
}
|
||||
// кто-то мог уже перехватить заказ, игнорируем ошибку
|
||||
catch (InvalidOperationException ex)
|
||||
{
|
||||
|
@ -14,6 +14,6 @@ namespace LawFirmContracts.SearchModels
|
||||
public DateTime? DateTo { get; set; }
|
||||
public int? ClientId { get; set; }
|
||||
public int? ImplementerId { get; set; }
|
||||
public List<OrderStatus>? Statuses { get; set; }
|
||||
public OrderStatus? Status { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -26,14 +26,14 @@ namespace LawFirmDatabaseImplement.Implements
|
||||
.Include(x => x.Client)
|
||||
.Include(x => x.Implementer)
|
||||
.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.Id.HasValue && x.Id == model.Id)?.GetViewModel;
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
@ -47,12 +47,12 @@ namespace LawFirmDatabaseImplement.Implements
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
if (model.Statuses!= null)
|
||||
if (model.Status!= null)
|
||||
{
|
||||
return context.Orders
|
||||
.Include(x => x.Client)
|
||||
.Include(x => x.Implementer)
|
||||
.Where(x => model.Statuses.Contains(x.Status))
|
||||
.Where(x => model.Status.Equals(x.Status))
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
|
@ -22,7 +22,7 @@ namespace LawFirmFileImplement.Implements
|
||||
|
||||
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)
|
||||
{
|
||||
return source.Orders.FirstOrDefault(x => x.ImplementerId == model.ImplementerId)?.GetViewModel;
|
||||
@ -36,7 +36,7 @@ namespace LawFirmFileImplement.Implements
|
||||
|
||||
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();
|
||||
}
|
||||
@ -47,10 +47,10 @@ namespace LawFirmFileImplement.Implements
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
if (model.Statuses != null)
|
||||
if (model.Status != null)
|
||||
{
|
||||
return source.Orders
|
||||
.Where(x => model.Statuses.Contains(x.Status))
|
||||
.Where(x => model.Status.Equals(x.Status))
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
|
@ -32,7 +32,7 @@ namespace LawFirmListImplements.Implements
|
||||
{
|
||||
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);
|
||||
}
|
||||
@ -77,11 +77,11 @@ namespace LawFirmListImplements.Implements
|
||||
}
|
||||
}
|
||||
}
|
||||
if (model.Statuses != null)
|
||||
if (model.Status != null)
|
||||
{
|
||||
foreach (var order in _source.Orders)
|
||||
{
|
||||
if (model.Statuses.Contains(order.Status))
|
||||
if (model.Status.Equals(order.Status))
|
||||
{
|
||||
result.Add(GetViewModel(order));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user