Готовая лабораторная работа 7
This commit is contained in:
parent
a0d56f19cb
commit
4c766eb80b
@ -12,7 +12,7 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace FurnitureAssemblyBusinessLogic.BussinessLogic
|
namespace FurnitureAssemblyBusinessLogic.BussinessLogic
|
||||||
{
|
{
|
||||||
// Класс, реализующий логику для исполнителя
|
// Класс, реализующий логику для исполнителей
|
||||||
public class ImplementerLogic : IImplementerLogic
|
public class ImplementerLogic : IImplementerLogic
|
||||||
{
|
{
|
||||||
private readonly ILogger _logger;
|
private readonly ILogger _logger;
|
||||||
|
@ -25,6 +25,8 @@ namespace FurnitureAssemblyBusinessLogic.BussinessLogic
|
|||||||
|
|
||||||
private readonly IClientLogic _clientLogic;
|
private readonly IClientLogic _clientLogic;
|
||||||
|
|
||||||
|
private readonly object locker = new object();
|
||||||
|
|
||||||
// Конструктор
|
// Конструктор
|
||||||
public OrderLogic(ILogger<OrderLogic> logger, IOrderStorage orderStorage, AbstractMailWorker mailWorker, IClientLogic clientLogic)
|
public OrderLogic(ILogger<OrderLogic> logger, IOrderStorage orderStorage, AbstractMailWorker mailWorker, IClientLogic clientLogic)
|
||||||
{
|
{
|
||||||
@ -108,7 +110,10 @@ namespace FurnitureAssemblyBusinessLogic.BussinessLogic
|
|||||||
|
|
||||||
public bool TakeOrderInWork(OrderBindingModel model)
|
public bool TakeOrderInWork(OrderBindingModel model)
|
||||||
{
|
{
|
||||||
return StatusUpdate(model, OrderStatus.Выполняется);
|
lock (locker)
|
||||||
|
{
|
||||||
|
return StatusUpdate(model, OrderStatus.Выполняется);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool FinishOrder(OrderBindingModel model)
|
public bool FinishOrder(OrderBindingModel model)
|
||||||
|
@ -1,20 +1,20 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>net6.0</TargetFramework>
|
<TargetFramework>net6.0</TargetFramework>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="DocumentFormat.OpenXml" Version="3.0.2" />
|
<PackageReference Include="DocumentFormat.OpenXml" Version="3.0.2" />
|
||||||
<PackageReference Include="MailKit" Version="4.0.0" />
|
<PackageReference Include="MailKit" Version="4.0.0" />
|
||||||
<PackageReference Include="Microsoft.Extensions.Logging" Version="8.0.0" />
|
<PackageReference Include="Microsoft.Extensions.Logging" Version="8.0.0" />
|
||||||
<PackageReference Include="PdfSharp.MigraDoc.Standard" Version="1.51.15" />
|
<PackageReference Include="PDFsharp-MigraDoc-GDI" Version="1.50.5147" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\FurnitureAssemblyContracts\FurnitureAssemblyContracts.csproj" />
|
<ProjectReference Include="..\FurnitureAssemblyContracts\FurnitureAssemblyContracts.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
@ -14,7 +14,7 @@ namespace FurnitureAssemblyBusinessLogic.OfficePackage.HelperModels
|
|||||||
|
|
||||||
public string Title { get; set; } = string.Empty;
|
public string Title { get; set; } = string.Empty;
|
||||||
|
|
||||||
// Список заготовок для вывода и сохранения
|
//список заготовок для вывода и сохранения
|
||||||
public List<FurnitureViewModel> Furnitures { get; set; } = new();
|
public List<FurnitureViewModel> Furnitures { get; set; } = new();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,7 +12,7 @@ namespace FurnitureAssemblyBusinessLogic.OfficePackage.HelperModels
|
|||||||
// Набор текстов в абзаце (для случая, если в абзаце текст разных стилей)
|
// Набор текстов в абзаце (для случая, если в абзаце текст разных стилей)
|
||||||
public List<(string, WordTextProperties)> Texts { get; set; } = new();
|
public List<(string, WordTextProperties)> Texts { get; set; } = new();
|
||||||
|
|
||||||
// Свойства параграфа, если они есть
|
//свойства параграфа, если они есть
|
||||||
public WordTextProperties? TextProperties { get; set; }
|
public WordTextProperties? TextProperties { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,17 +7,17 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace FurnitureAssemblyContracts.BindingModels
|
namespace FurnitureAssemblyContracts.BindingModels
|
||||||
{
|
{
|
||||||
// Реализация сущности "Исполнитель"
|
// Реализация сущности "Исполнитель"
|
||||||
public class ImplementerBindingModel : IImplementerModel
|
public class ImplementerBindingModel : IImplementerModel
|
||||||
{
|
{
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
|
|
||||||
public string ImplementerFIO { get; set; } = string.Empty;
|
public string ImplementerFIO { get; set; } = string.Empty;
|
||||||
|
|
||||||
public string Password { get; set; } = string.Empty;
|
public string Password { get; set; } = string.Empty;
|
||||||
|
|
||||||
public int WorkExperience { get; set; }
|
public int WorkExperience { get; set; }
|
||||||
|
|
||||||
public int Qualification { get; set; }
|
public int Qualification { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,7 +14,7 @@ namespace FurnitureAssemblyContracts.BindingModels
|
|||||||
|
|
||||||
public int ClientId { get; set; }
|
public int ClientId { get; set; }
|
||||||
|
|
||||||
public int? ImplementerId { get; set; }
|
public int? ImplementerId { get; set; }
|
||||||
|
|
||||||
public int FurnitureId { get; set; }
|
public int FurnitureId { get; set; }
|
||||||
|
|
||||||
|
@ -9,17 +9,17 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace FurnitureAssemblyContracts.BusinessLogicsContracts
|
namespace FurnitureAssemblyContracts.BusinessLogicsContracts
|
||||||
{
|
{
|
||||||
// Бизнес-логика для исполнителя
|
// Бизнес-логика для исполнителя
|
||||||
public interface IImplementerLogic
|
public interface IImplementerLogic
|
||||||
{
|
{
|
||||||
List<ImplementerViewModel>? ReadList(ImplementerSearchModel? model);
|
List<ImplementerViewModel>? ReadList(ImplementerSearchModel? model);
|
||||||
|
|
||||||
ImplementerViewModel? ReadElement(ImplementerSearchModel model);
|
ImplementerViewModel? ReadElement(ImplementerSearchModel model);
|
||||||
|
|
||||||
bool Create(ImplementerBindingModel model);
|
bool Create(ImplementerBindingModel model);
|
||||||
|
|
||||||
bool Update(ImplementerBindingModel model);
|
bool Update(ImplementerBindingModel model);
|
||||||
|
|
||||||
bool Delete(ImplementerBindingModel model);
|
bool Delete(ImplementerBindingModel model);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,10 +22,10 @@ namespace FurnitureAssemblyContracts.ViewModels
|
|||||||
|
|
||||||
public int? ImplementerId { get; set; }
|
public int? ImplementerId { get; set; }
|
||||||
|
|
||||||
[DisplayName("ФИО исполнителя")]
|
[DisplayName("ФИО исполнителя")]
|
||||||
public string ImplementerFIO { get; set; } = string.Empty;
|
public string ImplementerFIO { get; set; } = string.Empty;
|
||||||
|
|
||||||
public int FurnitureId { get; set; }
|
public int FurnitureId { get; set; }
|
||||||
|
|
||||||
[DisplayName("Изделие")]
|
[DisplayName("Изделие")]
|
||||||
public string FurnitureName { get; set; } = string.Empty;
|
public string FurnitureName { get; set; } = string.Empty;
|
||||||
|
@ -81,7 +81,7 @@ namespace FurnitureAssemblyFileImplement
|
|||||||
|
|
||||||
private static void SaveData<T>(List<T> data, string filename, string xmlNodeName, Func<T, XElement> selectFunction)
|
private static void SaveData<T>(List<T> data, string filename, string xmlNodeName, Func<T, XElement> selectFunction)
|
||||||
{
|
{
|
||||||
if(data != null)
|
if (data != null)
|
||||||
{
|
{
|
||||||
new XDocument(new XElement(xmlNodeName, data.Select(selectFunction).ToArray())).Save(filename);
|
new XDocument(new XElement(xmlNodeName, data.Select(selectFunction).ToArray())).Save(filename);
|
||||||
}
|
}
|
||||||
|
@ -20,9 +20,9 @@ namespace FurnitureAssemblyFileImplement.Models
|
|||||||
|
|
||||||
public int ClientId { get; private set; }
|
public int ClientId { get; private set; }
|
||||||
|
|
||||||
public int? ImplementerId { get; private set; }
|
public int? ImplementerId { get; private set; }
|
||||||
|
|
||||||
public int Count { get; private set; }
|
public int Count { get; private set; }
|
||||||
|
|
||||||
public double Sum { get; private set; }
|
public double Sum { get; private set; }
|
||||||
|
|
||||||
@ -44,8 +44,8 @@ namespace FurnitureAssemblyFileImplement.Models
|
|||||||
Id = model.Id,
|
Id = model.Id,
|
||||||
FurnitureId = model.FurnitureId,
|
FurnitureId = model.FurnitureId,
|
||||||
ClientId = model.ClientId,
|
ClientId = model.ClientId,
|
||||||
ImplementerId = model.ImplementerId,
|
ImplementerId = model.ImplementerId,
|
||||||
Count = model.Count,
|
Count = model.Count,
|
||||||
Sum = model.Sum,
|
Sum = model.Sum,
|
||||||
Status = model.Status,
|
Status = model.Status,
|
||||||
DateCreate = model.DateCreate,
|
DateCreate = model.DateCreate,
|
||||||
@ -65,8 +65,8 @@ namespace FurnitureAssemblyFileImplement.Models
|
|||||||
Id = Convert.ToInt32(element.Attribute("Id")!.Value),
|
Id = Convert.ToInt32(element.Attribute("Id")!.Value),
|
||||||
FurnitureId = Convert.ToInt32(element.Element("FurnitureId")!.Value),
|
FurnitureId = Convert.ToInt32(element.Element("FurnitureId")!.Value),
|
||||||
ClientId = Convert.ToInt32(element.Attribute("Id")!.Value),
|
ClientId = Convert.ToInt32(element.Attribute("Id")!.Value),
|
||||||
ImplementerId = Convert.ToInt32(element.Attribute("ImplementerId")!.Value),
|
ImplementerId = Convert.ToInt32(element.Attribute("ImplementerId")!.Value),
|
||||||
Count = Convert.ToInt32(element.Element("Count")!.Value),
|
Count = Convert.ToInt32(element.Element("Count")!.Value),
|
||||||
Sum = Convert.ToDouble(element.Element("Sum")!.Value),
|
Sum = Convert.ToDouble(element.Element("Sum")!.Value),
|
||||||
Status = (OrderStatus)Enum.Parse(typeof(OrderStatus), element.Element("Status")!.Value),
|
Status = (OrderStatus)Enum.Parse(typeof(OrderStatus), element.Element("Status")!.Value),
|
||||||
DateCreate = Convert.ToDateTime(element.Element("DateCreate")!.Value),
|
DateCreate = Convert.ToDateTime(element.Element("DateCreate")!.Value),
|
||||||
@ -91,8 +91,8 @@ namespace FurnitureAssemblyFileImplement.Models
|
|||||||
Id = Id,
|
Id = Id,
|
||||||
FurnitureId = FurnitureId,
|
FurnitureId = FurnitureId,
|
||||||
ClientId = ClientId,
|
ClientId = ClientId,
|
||||||
ImplementerId = ImplementerId,
|
ImplementerId = ImplementerId,
|
||||||
Count = Count,
|
Count = Count,
|
||||||
Sum = Sum,
|
Sum = Sum,
|
||||||
Status = Status,
|
Status = Status,
|
||||||
DateCreate = DateCreate,
|
DateCreate = DateCreate,
|
||||||
@ -103,8 +103,8 @@ namespace FurnitureAssemblyFileImplement.Models
|
|||||||
new XAttribute("Id", Id),
|
new XAttribute("Id", Id),
|
||||||
new XElement("FurnitureId", FurnitureId.ToString()),
|
new XElement("FurnitureId", FurnitureId.ToString()),
|
||||||
new XElement("ClientId", ClientId.ToString()),
|
new XElement("ClientId", ClientId.ToString()),
|
||||||
new XElement("ImplementerId", ImplementerId.ToString()),
|
new XElement("ImplementerId", ImplementerId.ToString()),
|
||||||
new XElement("Count", Count.ToString()),
|
new XElement("Count", Count.ToString()),
|
||||||
new XElement("Sum", Sum.ToString()),
|
new XElement("Sum", Sum.ToString()),
|
||||||
new XElement("Status", Status.ToString()),
|
new XElement("Status", Status.ToString()),
|
||||||
new XElement("DateCreate", DateCreate.ToString()),
|
new XElement("DateCreate", DateCreate.ToString()),
|
||||||
|
@ -42,7 +42,7 @@ namespace FurnitureAssemblyListImplement
|
|||||||
|
|
||||||
public static DataListSingleton GetInstance()
|
public static DataListSingleton GetInstance()
|
||||||
{
|
{
|
||||||
if(_instance == null)
|
if (_instance == null)
|
||||||
{
|
{
|
||||||
_instance = new DataListSingleton();
|
_instance = new DataListSingleton();
|
||||||
}
|
}
|
||||||
|
@ -35,7 +35,7 @@ namespace FurnitureAssemblyListImplement.Models
|
|||||||
|
|
||||||
public static Order? Create(OrderBindingModel? model)
|
public static Order? Create(OrderBindingModel? model)
|
||||||
{
|
{
|
||||||
if(model == null)
|
if (model == null)
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -45,8 +45,8 @@ namespace FurnitureAssemblyListImplement.Models
|
|||||||
Id = model.Id,
|
Id = model.Id,
|
||||||
FurnitureId = model.FurnitureId,
|
FurnitureId = model.FurnitureId,
|
||||||
ClientId = model.ClientId,
|
ClientId = model.ClientId,
|
||||||
ImplementerId = model.ImplementerId,
|
ImplementerId = model.ImplementerId,
|
||||||
Count = model.Count,
|
Count = model.Count,
|
||||||
Sum = model.Sum,
|
Sum = model.Sum,
|
||||||
Status = model.Status,
|
Status = model.Status,
|
||||||
DateCreate = model.DateCreate,
|
DateCreate = model.DateCreate,
|
||||||
@ -57,7 +57,7 @@ namespace FurnitureAssemblyListImplement.Models
|
|||||||
// Метод изменения существующего объекта
|
// Метод изменения существующего объекта
|
||||||
public void Update(OrderBindingModel? model)
|
public void Update(OrderBindingModel? model)
|
||||||
{
|
{
|
||||||
if(model == null)
|
if (model == null)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -72,8 +72,8 @@ namespace FurnitureAssemblyListImplement.Models
|
|||||||
Id = Id,
|
Id = Id,
|
||||||
FurnitureId = FurnitureId,
|
FurnitureId = FurnitureId,
|
||||||
ClientId = ClientId,
|
ClientId = ClientId,
|
||||||
ImplementerId = ImplementerId,
|
ImplementerId = ImplementerId,
|
||||||
Count = Count,
|
Count = Count,
|
||||||
Sum = Sum,
|
Sum = Sum,
|
||||||
Status = Status,
|
Status = Status,
|
||||||
DateCreate = DateCreate,
|
DateCreate = DateCreate,
|
||||||
|
@ -46,7 +46,7 @@ namespace FurnitureAssemblyView
|
|||||||
{
|
{
|
||||||
var view = _logic.ReadElement(new FurnitureSearchModel { Id = _id.Value });
|
var view = _logic.ReadElement(new FurnitureSearchModel { Id = _id.Value });
|
||||||
|
|
||||||
if (view != null)
|
if(view != null)
|
||||||
{
|
{
|
||||||
textBoxName.Text = view.FurnitureName;
|
textBoxName.Text = view.FurnitureName;
|
||||||
textBoxPrice.Text = view.Price.ToString();
|
textBoxPrice.Text = view.Price.ToString();
|
||||||
@ -54,7 +54,7 @@ namespace FurnitureAssemblyView
|
|||||||
LoadData();
|
LoadData();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch(Exception ex)
|
||||||
{
|
{
|
||||||
_logger.LogError(ex, "Ошибка загрузки изделия");
|
_logger.LogError(ex, "Ошибка загрузки изделия");
|
||||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
@ -52,8 +52,8 @@ namespace FurnitureAssemblyView
|
|||||||
dataGridView.DataSource = list;
|
dataGridView.DataSource = list;
|
||||||
dataGridView.Columns["FurnitureId"].Visible = false;
|
dataGridView.Columns["FurnitureId"].Visible = false;
|
||||||
dataGridView.Columns["ClientId"].Visible = false;
|
dataGridView.Columns["ClientId"].Visible = false;
|
||||||
dataGridView.Columns["ImplementerId"].Visible = false;
|
dataGridView.Columns["ImplementerId"].Visible = false;
|
||||||
dataGridView.Columns["FurnitureName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
dataGridView.Columns["FurnitureName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||||
dataGridView.Columns["ClientFIO"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
dataGridView.Columns["ClientFIO"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||||
dataGridView.Columns["ImplementerFIO"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
dataGridView.Columns["ImplementerFIO"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user