Правки

This commit is contained in:
nikbel2004@outlook.com 2024-05-15 20:12:33 +04:00
parent b36a85234c
commit 8eb8180321
7 changed files with 43 additions and 33 deletions

View File

@ -23,11 +23,13 @@ namespace FurnitureAssemblyBusinessLogic.BussinessLogic
private readonly IShopLogic _shopLogic;
private readonly AbstractMailWorker _mailWorker;
private readonly IFurnitureStorage _furnitureStorage;
private readonly IClientLogic _clientLogic;
private readonly AbstractMailWorker _mailWorker;
private readonly object locker = new object();
// Конструктор
public OrderLogic(ILogger<OrderLogic> logger, IOrderStorage orderStorage, IShopLogic shopLogic, IFurnitureStorage furnitureStorage, IClientLogic clientLogic, AbstractMailWorker mailWorker)
@ -60,6 +62,7 @@ namespace FurnitureAssemblyBusinessLogic.BussinessLogic
return list;
}
// Вывод конкретного чека
public OrderViewModel? ReadElement(OrderSearchModel model)
{
if (model == null)
@ -112,7 +115,10 @@ namespace FurnitureAssemblyBusinessLogic.BussinessLogic
public bool TakeOrderInWork(OrderBindingModel model)
{
return StatusUpdate(model, OrderStatus.Выполняется);
lock (locker)
{
return StatusUpdate(model, OrderStatus.Выполняется);
}
}
public bool FinishOrder(OrderBindingModel model)
@ -157,18 +163,18 @@ namespace FurnitureAssemblyBusinessLogic.BussinessLogic
throw new ArgumentNullException("Некорректный id у изделия", nameof(model.FurnitureId));
}
// Проверка на клиента
if (model.ClientId < 0)
{
throw new ArgumentNullException("Некорректный идентификатор у клиента", nameof(model.ClientId));
}
// Проверка корректности дат
if (model.DateCreate > model.DateImplement)
{
throw new InvalidOperationException("Дата создания должна быть более ранней, нежели дата завершения");
}
// Проверка на клиента
if (model.ClientId < 0)
{
throw new ArgumentNullException("Некорректный идентификатор у клиента", nameof(model.ClientId));
}
_logger.LogInformation("Order. OrderId:{Id}, Sum:{Sum}. FurnitureId:{Id}. Sum:{Sum}", model.Id, model.Sum, model.FurnitureId, model.Sum);
}
@ -192,6 +198,12 @@ namespace FurnitureAssemblyBusinessLogic.BussinessLogic
model.Status = newOrderStatus;
// Помещаем id работника, не забываем про него...
if (viewModel.ImplementerId.HasValue)
{
model.ImplementerId = viewModel.ImplementerId;
}
// Проверка на выдачу
if (model.Status == OrderStatus.Готов || viewModel.Status == OrderStatus.Ожидание)
{
@ -231,7 +243,7 @@ namespace FurnitureAssemblyBusinessLogic.BussinessLogic
return false;
}
SendOrderMessage(result.ClientId, $"Сборка мебели Заказ №{result.Id}", $"Заказ №{model.Id} изменен статус на {result.Status}");
SendOrderMessage(result.ClientId, $"Сборка мебели, Заказ №{result.Id}", $"Заказ №{model.Id} изменен статус на {result.Status}");
return true;
}

View File

@ -1,23 +1,21 @@
<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="2.20.0" />
<PackageReference Include="MailKit" Version="4.5.0" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="8.0.0" />
<PackageReference Include="MigraDocCore.DocumentObjectModel" Version="1.3.63" />
<PackageReference Include="MigraDocCore.Rendering" Version="1.3.63" />
<PackageReference Include="PdfSharp.MigraDoc.Standard" Version="1.51.15" />
<PackageReference Include="PdfSharp.MigraDoc.Standard.DocumentObjectModel" Version="1.51.15" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="DocumentFormat.OpenXml" Version="2.20.0" />
<PackageReference Include="MailKit" Version="4.5.0" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="8.0.0" />
<PackageReference Include="PDFsharp-MigraDoc-GDI" Version="1.50.5147" />
<ItemGroup>
<ProjectReference Include="..\FurnitureAssemblyContracts\FurnitureAssemblyContracts.csproj" />
</ItemGroup>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\FurnitureAssemblyContracts\FurnitureAssemblyContracts.csproj" />
</ItemGroup>
</Project>

View File

@ -114,6 +114,7 @@ namespace FurnitureAssemblyBusinessLogic.OfficePackage.Implements
var docRun = new Run();
var properties = new RunProperties();
// Задание свойств текста - размер и жирность
properties.AppendChild(new FontSize { Val = run.Item2.Size });
if (run.Item2.Bold)
@ -145,7 +146,7 @@ namespace FurnitureAssemblyBusinessLogic.OfficePackage.Implements
// Сохраняем документ
_wordDocument.MainDocumentPart!.Document.Save();
_wordDocument.Close();
_wordDocument.Dispose();
}
protected override void CreateTable(WordParagraph paragraph)

View File

@ -16,6 +16,6 @@ namespace FurnitureAssemblyContracts.BindingModels
public string Email { get; set; } = string.Empty;
public string Password { get; set; } = string.Empty;
public string Password { get; set; } = string.Empty;
}
}

View File

@ -9,7 +9,7 @@ using System.Threading.Tasks;
namespace FurnitureAssemblyContracts.BusinessLogicsContracts
{
// Бизнес-логика для сообщений
// Бизнес-логика сообщений
public interface IMessageInfoLogic
{
List<MessageInfoViewModel>? ReadList(MessageInfoSearchModel? model);

View File

@ -11,9 +11,9 @@ namespace FurnitureAssemblyContracts.SearchModels
{
public int? Id { get; set; }
public string? Email { get; set; }
public string? Email { get; set; }
public string? ClientFIO { get; set; }
public string? ClientFIO { get; set; }
public string? Password { get; set; }
}

View File

@ -1,5 +1,4 @@
using BlacksmithWorkshopDatabaseImplement.Models;
using System;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;