вроде готово

This commit is contained in:
sardq 2024-05-16 18:30:57 +04:00
parent ecf2e10885
commit 8f1bcf00fc
16 changed files with 148 additions and 54 deletions

View File

@ -0,0 +1,34 @@
using PlumbingRepairBusinessLogic.BusinessLogics;
using PlumbingRepairBusinessLogic.MailWorker;
using PlumbingRepairBusinessLogic.OfficePackage.Implements;
using PlumbingRepairBusinessLogic.OfficePackage;
using PlumbingRepairContracts.BusinessLogicsContracts;
using PlumbingRepairContracts.DI;
namespace PlumbingRepairBusinessLogic
{
public class ImplementationBusinessLogicExtension : IImplementationBusinessLogicExtension
{
public int Priority => 0;
public void RegisterServices()
{
DependencyManager.Instance.RegisterType<IComponentLogic, ComponentLogic>();
DependencyManager.Instance.RegisterType<IOrderLogic, OrderLogic>();
DependencyManager.Instance.RegisterType<IWorkLogic, WorkLogic>();
DependencyManager.Instance.RegisterType<IReportLogic, ReportLogic>();
DependencyManager.Instance.RegisterType<IClientLogic, ClientLogic>();
DependencyManager.Instance.RegisterType<IImplementerLogic, ImplementerLogic>();
DependencyManager.Instance.RegisterType<IMessageInfoLogic, MessageInfoLogic>();
DependencyManager.Instance.RegisterType<IWorkProcess, WorkModeling>();
DependencyManager.Instance.RegisterType<IBackUpLogic, BackUpLogic>();
DependencyManager.Instance.RegisterType<IShopLogic, ShopLogic>();
DependencyManager.Instance.RegisterType<AbstractMailWorker, MailKitWorker>(true);
DependencyManager.Instance.RegisterType<AbstractSaveToExcel, SaveToExcel>();
DependencyManager.Instance.RegisterType<AbstractSaveToWord, SaveToWord>();
DependencyManager.Instance.RegisterType<AbstractSaveToPdf, SaveToPdf>();
}
}
}

View File

@ -20,4 +20,8 @@
<ProjectReference Include="..\PlumbingRepairContracts\PlumbingRepairContracts.csproj" />
</ItemGroup>
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
<Exec Command="copy /Y &quot;$(TargetDir)*.dll&quot; &quot;$(SolutionDir)BusinessLogicImplementationExtensions\*.dll&quot;" />
</Target>
</Project>

View File

@ -12,14 +12,16 @@
public GridViewAutoSize GridViewAutoSize { get; private set; }
public bool IsUseAutoSize { get; private set; }
public string Format { get; private set; }
public ColumnAttribute(string title = "", bool visible = true, int width = 0, GridViewAutoSize gridViewAutoSize = GridViewAutoSize.None, bool isUseAutoSize = false)
public ColumnAttribute(string title = "", bool visible = true, int width = 0, GridViewAutoSize gridViewAutoSize = GridViewAutoSize.None, bool isUseAutoSize = false, string format = "")
{
Title = title;
Visible = visible;
Width = width;
GridViewAutoSize = gridViewAutoSize;
IsUseAutoSize = isUseAutoSize;
Format = format;
}
}
}

View File

@ -29,6 +29,14 @@ namespace PlumbingRepairContracts.DI
}
// регистрируем зависимости
ext.RegisterServices();
var bsExtensions = ServiceProviderLoader.GetBusinessLogicImplementationExtensions();
if (bsExtensions == null)
{
throw new ArgumentNullException("Отсутствуют компоненты для загрузки зависимостей бизнес-логики");
}
// регистрируем зависимости
bsExtensions.RegisterServices();
}
/// <summary>

View File

@ -0,0 +1,7 @@
namespace PlumbingRepairContracts.DI
{
public interface IImplementationBusinessLogicExtension
{
public void RegisterServices();
}
}

View File

@ -36,7 +36,34 @@ namespace PlumbingRepairContracts.DI
}
return source;
}
public static IImplementationBusinessLogicExtension? GetBusinessLogicImplementationExtensions()
{
IImplementationBusinessLogicExtension? source = null;
var files = Directory.GetFiles(TryGetBusinessLogicImplementationExtensionsFolder(), "*.dll", SearchOption.AllDirectories);
foreach (var file in files.Distinct())
{
Assembly asm = Assembly.LoadFrom(file);
foreach (var t in asm.GetExportedTypes())
{
if (t.IsClass && typeof(IImplementationBusinessLogicExtension).IsAssignableFrom(t))
{
source = (IImplementationBusinessLogicExtension)Activator.CreateInstance(t)!;
break;
}
}
}
return source;
}
private static string TryGetBusinessLogicImplementationExtensionsFolder()
{
var directory = new DirectoryInfo(Directory.GetCurrentDirectory());
while (directory != null && !directory.GetDirectories("BusinessLogicImplementationExtensions", SearchOption.AllDirectories).Any(x => x.Name == "BusinessLogicImplementationExtensions"))
{
directory = directory.Parent;
}
return $"{directory?.FullName}\\BusinessLogicImplementationExtensions";
}
private static string TryGetImplementationExtensionsFolder()
{
var directory = new DirectoryInfo(Directory.GetCurrentDirectory());

View File

@ -12,7 +12,7 @@ namespace PlumbingRepairContracts.ViewModels
public int? ClientId { get; set; }
[Column(title: "Отправитель", width: 150)]
public string SenderName { get; set; } = string.Empty;
[Column(title: "Дата отправления", width: 150)]
[Column(title: "Дата отправления", width: 150, format: "Date: dd/MM/yyyy")]
public DateTime DateDelivery { get; set; }
[Column(title: "Заголовок", width: 150)]
public string Subject { get; set; } = string.Empty;

View File

@ -36,10 +36,10 @@ namespace PlumbingRepairContracts.ViewModels
[Column(title: "Статус", width: 150)]
public OrderStatus Status { get; set; } = OrderStatus.Неизвестен;
[Column(title: "Дата создания", width: 150)]
[Column(title: "Дата создания", width: 150, format: "Date: dd/MM/yyyy")]
public DateTime DateCreate { get; set; } = DateTime.Now;
[Column(title: "Дата выполнения", width: 150)]
[Column(title: "Дата выполнения", width: 150, format: "Date: dd/MM/yyyy")]
public DateTime? DateImplement { get; set; }
}
}

View File

@ -1,20 +1,22 @@
using PlumbingRepairDataModels.Models;
using PlumbingRepairContracts.Attributes;
using PlumbingRepairDataModels.Models;
using System.ComponentModel;
namespace PlumbingRepairContracts.ViewModels
{
public class ShopViewModel
{
public int Id { get; set; }
[Column(visible: false)]
public int Id { get; set; }
[DisplayName("Название магазина")]
public string ShopName { get; set; } = string.Empty;
[Column(title: "Название магазина", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)]
public string ShopName { get; set; } = string.Empty;
[DisplayName("Адрес")]
public string Address { get; set; } = string.Empty;
[DisplayName("Максимальное количество работ")]
public int maxCountWorks { get; set; }
[DisplayName("Дата открытия")]
[Column(title: "Адрес", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)]
public string Address { get; set; } = string.Empty;
[Column(title: "Максимальное количество работ", width: 150)]
public int maxCountWorks { get; set; }
[Column(title: "Дата открытия", width: 150, format: "Date: dd/MM/yyyy")]
public DateTime DateOpening { get; set; }
public Dictionary<int, (IWorkModel, int)> ShopWorks { get; set; } = new();

View File

@ -4,26 +4,34 @@ using PlumbingRepairContracts.ViewModels;
using PlumbingRepairDataModels.Models;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Runtime.Serialization;
namespace PlumbingRepairDatabaseImplement.Models
{
public class Shop
[DataContract]
public class Shop
{
public int Id { get; set; }
[DataMember]
public int Id { get; set; }
[Required]
public string ShopName { get; set; } = string.Empty;
[DataMember]
public string ShopName { get; set; } = string.Empty;
[Required]
public string Address { get; set; } = string.Empty;
[DataMember]
public string Address { get; set; } = string.Empty;
[Required]
public DateTime DateOpening { get; set; }
[DataMember]
public DateTime DateOpening { get; set; }
[Required]
public int maxCountWorks { get; set; }
[DataMember]
public int maxCountWorks { get; set; }
private Dictionary<int, (IWorkModel, int)>? _shopWorks = null;
[NotMapped]
public Dictionary<int, (IWorkModel, int)> ShopWorks
[DataMember]
public Dictionary<int, (IWorkModel, int)> ShopWorks
{
get
{

View File

@ -24,7 +24,8 @@ namespace PlumbingRepairDatabaseImplement.Models
private Dictionary<int, (IComponentModel, int)>? _workComponents = null;
[NotMapped]
public Dictionary<int, (IComponentModel, int)> WorkComponents
[DataMember]
public Dictionary<int, (IComponentModel, int)> WorkComponents
{
get
{

View File

@ -1,23 +1,28 @@
using PlumbingRepairContracts.BindingModels;
using PlumbingRepairContracts.ViewModels;
using PlumbingRepairDataModels.Models;
using System.Runtime.Serialization;
using System.Xml.Linq;
namespace PlumbingRepairFileImplement.Models
{
[DataContract]
public class Shop : IShopModel
{
public int Id { get; private set; }
public string ShopName { get; private set; } = string.Empty;
public string Address { get; private set; } = string.Empty;
public DateTime DateOpening { get; private set; }
[DataMember]
public int Id { get; private set; }
[DataMember]
public string ShopName { get; private set; } = string.Empty;
[DataMember]
public string Address { get; private set; } = string.Empty;
[DataMember]
public DateTime DateOpening { get; private set; }
public Dictionary<int, int> Works { get; private set; } = new();
private Dictionary<int, (IWorkModel, int)>? _shopWorks = null;
public Dictionary<int, (IWorkModel, int)> ShopWorks
[DataMember]
public Dictionary<int, (IWorkModel, int)> ShopWorks
{
get
{

View File

@ -19,8 +19,8 @@ namespace PlumbingRepairFileImplement.Models
public Dictionary<int, int> Components { get; private set; } = new();
private Dictionary<int, (IComponentModel, int)>? _workComponents = null;
public Dictionary<int, (IComponentModel, int)> WorkComponents
[DataMember]
public Dictionary<int, (IComponentModel, int)> WorkComponents
{
get
{

View File

@ -1,21 +1,25 @@
using PlumbingRepairContracts.BindingModels;
using PlumbingRepairContracts.ViewModels;
using PlumbingRepairDataModels.Models;
using System.Runtime.Serialization;
namespace PlumbingRepairListImplement.Models
{
public class Shop
[DataContract]
public class Shop
{
[DataMember]
public int Id { get; private set; }
public string ShopName { get; private set; } = string.Empty;
public string Address { get; private set; } = string.Empty;
public DateTime DateOpening { get; private set; }
public Dictionary<int, (IWorkModel, int)> ShopWorks { get; private set; } = new Dictionary<int, (IWorkModel, int)>();
public int maxCountWorks { get; private set; }
[DataMember]
public string ShopName { get; private set; } = string.Empty;
[DataMember]
public string Address { get; private set; } = string.Empty;
[DataMember]
public DateTime DateOpening { get; private set; }
[DataMember]
public Dictionary<int, (IWorkModel, int)> ShopWorks { get; private set; } = new Dictionary<int, (IWorkModel, int)>();
[DataMember]
public int maxCountWorks { get; private set; }
public static Shop? Create(ShopBindingModel? model)
{

View File

@ -14,8 +14,8 @@ namespace PlumbingRepairListImplement.Models
public string WorkName { get; private set; } = string.Empty;
[DataMember]
public double Price { get; private set; }
public Dictionary<int, (IComponentModel, int)> WorkComponents { get; private set; } = new Dictionary<int, (IComponentModel, int)>();
[DataMember]
public Dictionary<int, (IComponentModel, int)> WorkComponents { get; private set; } = new Dictionary<int, (IComponentModel, int)>();
public static Work? Create(WorkBindingModel? model)
{

View File

@ -57,16 +57,6 @@ namespace PlumbingRepairView
option.SetMinimumLevel(LogLevel.Information);
option.AddNLog("nlog.config");
});
DependencyManager.Instance.RegisterType<IComponentLogic, ComponentLogic>();
DependencyManager.Instance.RegisterType<IOrderLogic, OrderLogic>();
DependencyManager.Instance.RegisterType<IWorkLogic, WorkLogic>();
DependencyManager.Instance.RegisterType<IReportLogic, ReportLogic>();
DependencyManager.Instance.RegisterType<IClientLogic, ClientLogic>();
DependencyManager.Instance.RegisterType<IShopLogic, ShopLogic>();
DependencyManager.Instance.RegisterType<IImplementerLogic, ImplementerLogic>();
DependencyManager.Instance.RegisterType<IMessageInfoLogic, MessageInfoLogic>();
DependencyManager.Instance.RegisterType<AbstractSaveToExcel, SaveToExcel>();
DependencyManager.Instance.RegisterType<AbstractSaveToWord, SaveToWord>();
DependencyManager.Instance.RegisterType<AbstractSaveToPdf, SaveToPdf>();
@ -80,13 +70,15 @@ namespace PlumbingRepairView
DependencyManager.Instance.RegisterType<FormCreateOrder>();
DependencyManager.Instance.RegisterType<FormWork>();
DependencyManager.Instance.RegisterType<FormWorks>();
DependencyManager.Instance.RegisterType<FormWorkComponent>();
DependencyManager.Instance.RegisterType<FormReportShopWorks>();
DependencyManager.Instance.RegisterType<FormReportWorkComponents>();
DependencyManager.Instance.RegisterType<FormReportOrders>();
DependencyManager.Instance.RegisterType<FormClients>();
DependencyManager.Instance.RegisterType<FormImplementers>();
DependencyManager.Instance.RegisterType<FormImplementer>();
DependencyManager.Instance.RegisterType<FormMail>();
DependencyManager.Instance.RegisterType<FormMails>();
}
private static void MailCheck(object obj) => DependencyManager.Instance.Resolve<AbstractMailWorker>()?.MailCheck();
}