Готовая лабораторная работа 7

This commit is contained in:
nikbel2004@outlook.com 2024-05-12 04:06:11 +04:00
parent a0d56f19cb
commit 4c766eb80b
15 changed files with 68 additions and 63 deletions

View File

@ -12,7 +12,7 @@ using System.Threading.Tasks;
namespace FurnitureAssemblyBusinessLogic.BussinessLogic
{
// Класс, реализующий логику для исполнителя
// Класс, реализующий логику для исполнителей
public class ImplementerLogic : IImplementerLogic
{
private readonly ILogger _logger;

View File

@ -25,6 +25,8 @@ namespace FurnitureAssemblyBusinessLogic.BussinessLogic
private readonly IClientLogic _clientLogic;
private readonly object locker = new object();
// Конструктор
public OrderLogic(ILogger<OrderLogic> logger, IOrderStorage orderStorage, AbstractMailWorker mailWorker, IClientLogic clientLogic)
{
@ -108,7 +110,10 @@ namespace FurnitureAssemblyBusinessLogic.BussinessLogic
public bool TakeOrderInWork(OrderBindingModel model)
{
return StatusUpdate(model, OrderStatus.Выполняется);
lock (locker)
{
return StatusUpdate(model, OrderStatus.Выполняется);
}
}
public bool FinishOrder(OrderBindingModel model)

View File

@ -1,20 +1,20 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="DocumentFormat.OpenXml" Version="3.0.2" />
<PackageReference Include="MailKit" Version="4.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="8.0.0" />
<PackageReference Include="PdfSharp.MigraDoc.Standard" Version="1.51.15" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="DocumentFormat.OpenXml" Version="3.0.2" />
<PackageReference Include="MailKit" Version="4.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="8.0.0" />
<PackageReference Include="PDFsharp-MigraDoc-GDI" Version="1.50.5147" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\FurnitureAssemblyContracts\FurnitureAssemblyContracts.csproj" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\FurnitureAssemblyContracts\FurnitureAssemblyContracts.csproj" />
</ItemGroup>
</Project>

View File

@ -14,7 +14,7 @@ namespace FurnitureAssemblyBusinessLogic.OfficePackage.HelperModels
public string Title { get; set; } = string.Empty;
// Список заготовок для вывода и сохранения
//список заготовок для вывода и сохранения
public List<FurnitureViewModel> Furnitures { get; set; } = new();
}
}

View File

@ -12,7 +12,7 @@ namespace FurnitureAssemblyBusinessLogic.OfficePackage.HelperModels
// Набор текстов в абзаце (для случая, если в абзаце текст разных стилей)
public List<(string, WordTextProperties)> Texts { get; set; } = new();
// Свойства параграфа, если они есть
//свойства параграфа, если они есть
public WordTextProperties? TextProperties { get; set; }
}
}

View File

@ -7,17 +7,17 @@ using System.Threading.Tasks;
namespace FurnitureAssemblyContracts.BindingModels
{
// Реализация сущности "Исполнитель"
public class ImplementerBindingModel : IImplementerModel
{
public int Id { get; set; }
// Реализация сущности "Исполнитель"
public class ImplementerBindingModel : IImplementerModel
{
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; }
}
}

View File

@ -14,8 +14,8 @@ namespace FurnitureAssemblyContracts.BindingModels
public int ClientId { get; set; }
public int? ImplementerId { get; set; }
public int? ImplementerId { get; set; }
public int FurnitureId { get; set; }
public int Count { get; set; }

View File

@ -9,17 +9,17 @@ using System.Threading.Tasks;
namespace FurnitureAssemblyContracts.BusinessLogicsContracts
{
// Бизнес-логика для исполнителя
public interface IImplementerLogic
{
List<ImplementerViewModel>? ReadList(ImplementerSearchModel? model);
// Бизнес-логика для исполнителя
public interface IImplementerLogic
{
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);
}
}

View File

@ -22,10 +22,10 @@ namespace FurnitureAssemblyContracts.ViewModels
public int? ImplementerId { get; set; }
[DisplayName("ФИО исполнителя")]
public string ImplementerFIO { get; set; } = string.Empty;
[DisplayName("ФИО исполнителя")]
public string ImplementerFIO { get; set; } = string.Empty;
public int FurnitureId { get; set; }
public int FurnitureId { get; set; }
[DisplayName("Изделие")]
public string FurnitureName { get; set; } = string.Empty;

View File

@ -81,7 +81,7 @@ namespace FurnitureAssemblyFileImplement
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);
}

View File

@ -20,9 +20,9 @@ namespace FurnitureAssemblyFileImplement.Models
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; }
@ -44,8 +44,8 @@ namespace FurnitureAssemblyFileImplement.Models
Id = model.Id,
FurnitureId = model.FurnitureId,
ClientId = model.ClientId,
ImplementerId = model.ImplementerId,
Count = model.Count,
ImplementerId = model.ImplementerId,
Count = model.Count,
Sum = model.Sum,
Status = model.Status,
DateCreate = model.DateCreate,
@ -65,8 +65,8 @@ namespace FurnitureAssemblyFileImplement.Models
Id = Convert.ToInt32(element.Attribute("Id")!.Value),
FurnitureId = Convert.ToInt32(element.Element("FurnitureId")!.Value),
ClientId = Convert.ToInt32(element.Attribute("Id")!.Value),
ImplementerId = Convert.ToInt32(element.Attribute("ImplementerId")!.Value),
Count = Convert.ToInt32(element.Element("Count")!.Value),
ImplementerId = Convert.ToInt32(element.Attribute("ImplementerId")!.Value),
Count = Convert.ToInt32(element.Element("Count")!.Value),
Sum = Convert.ToDouble(element.Element("Sum")!.Value),
Status = (OrderStatus)Enum.Parse(typeof(OrderStatus), element.Element("Status")!.Value),
DateCreate = Convert.ToDateTime(element.Element("DateCreate")!.Value),
@ -91,8 +91,8 @@ namespace FurnitureAssemblyFileImplement.Models
Id = Id,
FurnitureId = FurnitureId,
ClientId = ClientId,
ImplementerId = ImplementerId,
Count = Count,
ImplementerId = ImplementerId,
Count = Count,
Sum = Sum,
Status = Status,
DateCreate = DateCreate,
@ -103,8 +103,8 @@ namespace FurnitureAssemblyFileImplement.Models
new XAttribute("Id", Id),
new XElement("FurnitureId", FurnitureId.ToString()),
new XElement("ClientId", ClientId.ToString()),
new XElement("ImplementerId", ImplementerId.ToString()),
new XElement("Count", Count.ToString()),
new XElement("ImplementerId", ImplementerId.ToString()),
new XElement("Count", Count.ToString()),
new XElement("Sum", Sum.ToString()),
new XElement("Status", Status.ToString()),
new XElement("DateCreate", DateCreate.ToString()),

View File

@ -42,7 +42,7 @@ namespace FurnitureAssemblyListImplement
public static DataListSingleton GetInstance()
{
if(_instance == null)
if (_instance == null)
{
_instance = new DataListSingleton();
}

View File

@ -35,7 +35,7 @@ namespace FurnitureAssemblyListImplement.Models
public static Order? Create(OrderBindingModel? model)
{
if(model == null)
if (model == null)
{
return null;
}
@ -45,8 +45,8 @@ namespace FurnitureAssemblyListImplement.Models
Id = model.Id,
FurnitureId = model.FurnitureId,
ClientId = model.ClientId,
ImplementerId = model.ImplementerId,
Count = model.Count,
ImplementerId = model.ImplementerId,
Count = model.Count,
Sum = model.Sum,
Status = model.Status,
DateCreate = model.DateCreate,
@ -57,7 +57,7 @@ namespace FurnitureAssemblyListImplement.Models
// Метод изменения существующего объекта
public void Update(OrderBindingModel? model)
{
if(model == null)
if (model == null)
{
return;
}
@ -72,8 +72,8 @@ namespace FurnitureAssemblyListImplement.Models
Id = Id,
FurnitureId = FurnitureId,
ClientId = ClientId,
ImplementerId = ImplementerId,
Count = Count,
ImplementerId = ImplementerId,
Count = Count,
Sum = Sum,
Status = Status,
DateCreate = DateCreate,

View File

@ -46,7 +46,7 @@ namespace FurnitureAssemblyView
{
var view = _logic.ReadElement(new FurnitureSearchModel { Id = _id.Value });
if (view != null)
if(view != null)
{
textBoxName.Text = view.FurnitureName;
textBoxPrice.Text = view.Price.ToString();
@ -54,7 +54,7 @@ namespace FurnitureAssemblyView
LoadData();
}
}
catch (Exception ex)
catch(Exception ex)
{
_logger.LogError(ex, "Ошибка загрузки изделия");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);

View File

@ -52,8 +52,8 @@ namespace FurnitureAssemblyView
dataGridView.DataSource = list;
dataGridView.Columns["FurnitureId"].Visible = false;
dataGridView.Columns["ClientId"].Visible = false;
dataGridView.Columns["ImplementerId"].Visible = false;
dataGridView.Columns["FurnitureName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
dataGridView.Columns["ImplementerId"].Visible = false;
dataGridView.Columns["FurnitureName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
dataGridView.Columns["ClientFIO"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
dataGridView.Columns["ImplementerFIO"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
}