слияние

This commit is contained in:
AnnZhimol 2023-05-05 09:58:49 +04:00
commit 63f11d87c2
57 changed files with 943 additions and 984 deletions

3
.gitignore vendored
View File

@ -14,6 +14,9 @@
# User-specific files (MonoDevelop/Xamarin Studio) # User-specific files (MonoDevelop/Xamarin Studio)
*.userprefs *.userprefs
# dll файлы
*.dll
# Mono auto generated files # Mono auto generated files
mono_crash.* mono_crash.*

View File

@ -0,0 +1,22 @@
using System;
namespace SofrwareInstallationContracts.Attributes
{
[AttributeUsage(AttributeTargets.Property)]
public class ColumnAttribute : Attribute
{
public ColumnAttribute(string title = "", bool visible = true, int width = 0, GridViewAutoSize gridViewAutoSize = GridViewAutoSize.None, bool isUseAutoSize = false)
{
Title = title;
Visible = visible;
Width = width;
GridViewAutoSize = gridViewAutoSize;
IsUseAutoSize = isUseAutoSize;
}
public string Title { get; private set; }
public bool Visible { get; private set; }
public int Width { get; private set; }
public GridViewAutoSize GridViewAutoSize { get; private set; }
public bool IsUseAutoSize { get; private set; }
}
}

View File

@ -0,0 +1,14 @@
namespace SofrwareInstallationContracts.Attributes
{
public enum GridViewAutoSize
{
NotSet = 0,
None = 1,
ColumnHeader = 2,
AllCellsExceptHeader = 4,
AllCells = 6,
DisplayedCellsExceptHeader = 8,
DisplayedCells = 10,
Fill = 16
}
}

View File

@ -0,0 +1,7 @@
namespace SofrwareInstallationContracts.BindingModels
{
public class BackUpSaveBinidngModel
{
public string FolderName { get; set; } = string.Empty;
}
}

View File

@ -15,6 +15,8 @@ namespace SofrwareInstallationContracts.BindingModels
public string Subject { get; set; } = string.Empty; public string Subject { get; set; } = string.Empty;
public string Body { get; set; } = string.Empty; public string Body { get; set; } = string.Empty;
public DateTime DateDelivery { get; set; } public DateTime DateDelivery { get; set; }
public int Id => throw new NotImplementedException();
public bool HasRead { get; set; } public bool HasRead { get; set; }
public string? Reply { get; set; } public string? Reply { get; set; }
} }

View File

@ -0,0 +1,9 @@
using SofrwareInstallationContracts.BindingModels;
namespace SofrwareInstallationContracts.BusinessLogicsContracts
{
public interface IBackUpLogic
{
void CreateBackUp(BackUpSaveBinidngModel model);
}
}

View File

@ -0,0 +1,38 @@
using Microsoft.Extensions.Logging;
namespace SofrwareInstallationContracts.DI
{
public class DependencyManager
{
private readonly IDependencyContainer _dependencyManager;
private static DependencyManager? _manager;
private static readonly object _locjObject = new();
private DependencyManager()
{
_dependencyManager = new ServiceDependencyContainer();
}
public static DependencyManager Instance { get { if (_manager == null) { lock (_locjObject) { _manager = new DependencyManager(); } } return _manager; } }
public static void InitDependency()
{
var ext = ServiceProviderLoader.GetImplementationExtensions();
if (ext == null)
{
throw new ArgumentNullException("Отсутствуют компоненты для загрузки зависимостей по модулям");
}
// регистрируем зависимости
ext.RegisterServices();
}
public void AddLogging(Action<ILoggingBuilder> configure) => _dependencyManager.AddLogging(configure);
public void RegisterType<T, U>(bool isSingle = false) where U : class, T where T : class => _dependencyManager.RegisterType<T, U>(isSingle);
public void RegisterType<T>(bool isSingle = false) where T : class => _dependencyManager.RegisterType<T>(isSingle);
public T Resolve<T>() => _dependencyManager.Resolve<T>();
}
}

View File

@ -0,0 +1,13 @@
using Microsoft.Extensions.Logging;
namespace SofrwareInstallationContracts.DI
{
public interface IDependencyContainer
{
void AddLogging(Action<ILoggingBuilder> configure);
void RegisterType<T, U>(bool isSingle) where U : class, T where T : class;
void RegisterType<T>(bool isSingle) where T : class;
T Resolve<T>();
}
}

View File

@ -0,0 +1,8 @@
namespace SofrwareInstallationContracts.DI
{
public interface IImplementationExtension
{
public int Priority { get; }
public void RegisterServices();
}
}

View File

@ -0,0 +1,59 @@
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
namespace SofrwareInstallationContracts.DI
{
public class ServiceDependencyContainer : IDependencyContainer
{
private ServiceProvider? _serviceProvider;
private readonly ServiceCollection _serviceCollection;
public ServiceDependencyContainer()
{
_serviceCollection = new ServiceCollection();
}
public void AddLogging(Action<ILoggingBuilder> configure)
{
_serviceCollection.AddLogging(configure);
}
public void RegisterType<T, U>(bool isSingle) where U : class, T where T : class
{
if (isSingle)
{
_serviceCollection.AddSingleton<T, U>();
}
else
{
_serviceCollection.AddTransient<T, U>();
}
_serviceProvider = null;
}
public void RegisterType<T>(bool isSingle) where T : class
{
if (isSingle)
{
_serviceCollection.AddSingleton<T>();
}
else
{
_serviceCollection.AddTransient<T>();
}
_serviceProvider = null;
}
public T Resolve<T>()
{
if (_serviceProvider == null)
{
_serviceProvider = _serviceCollection.BuildServiceProvider();
}
return _serviceProvider.GetService<T>()!;
}
}
}

View File

@ -0,0 +1,52 @@
using System.Reflection;
namespace SofrwareInstallationContracts.DI
{
public class ServiceProviderLoader
{
public static IImplementationExtension? GetImplementationExtensions()
{
IImplementationExtension? source = null;
var files = Directory.GetFiles(TryGetImplementationExtensionsFolder(), "*.dll", SearchOption.AllDirectories);
foreach (var file in files.Distinct())
{
Assembly asm = Assembly.LoadFrom(file);
foreach (var t in asm.GetExportedTypes())
{
if (t.IsClass && typeof(IImplementationExtension).IsAssignableFrom(t))
{
if (source == null)
{
source = (IImplementationExtension)Activator.CreateInstance(t)!;
}
else
{
var newSource = (IImplementationExtension)Activator.CreateInstance(t)!;
if (newSource.Priority > source.Priority)
{
source = newSource;
}
}
}
}
}
return source;
}
private static string TryGetImplementationExtensionsFolder()
{
var directory = new DirectoryInfo(Directory.GetCurrentDirectory());
while (directory != null && !directory.GetDirectories("ImplementationExtensions", SearchOption.AllDirectories).Any(x => x.Name == "ImplementationExtensions"))
{
directory = directory.Parent;
}
return $"{directory?.FullName}\\ImplementationExtensions";
}
}
}

View File

@ -0,0 +1,40 @@
using Microsoft.Extensions.Logging;
using System.ComponentModel;
using Unity;
using Unity.Lifetime;
using Unity.Microsoft.Logging;
namespace SofrwareInstallationContracts.DI
{
public class UnityDependencyContainer : IDependencyContainer
{
private readonly IUnityContainer _container;
public UnityDependencyContainer()
{
_container = new UnityContainer();
}
public void AddLogging(Action<ILoggingBuilder> configure)
{
var factory = LoggerFactory.Create(configure);
_container.AddExtension(new LoggingExtension(factory));
}
public void RegisterType<T>(bool isSingle) where T : class
{
_container.RegisterType<T>(isSingle ? TypeLifetime.Singleton : TypeLifetime.Transient);
}
public T Resolve<T>()
{
return _container.Resolve<T>();
}
void IDependencyContainer.RegisterType<T, U>(bool isSingle)
{
_container.RegisterType<T, U>(isSingle ? TypeLifetime.Singleton : TypeLifetime.Transient);
}
}
}

View File

@ -38,6 +38,8 @@
<PackageReference Include="System.Runtime.CompilerServices.Unsafe" Version="6.0.0" /> <PackageReference Include="System.Runtime.CompilerServices.Unsafe" Version="6.0.0" />
<PackageReference Include="System.Text.Encodings.Web" Version="7.0.0" /> <PackageReference Include="System.Text.Encodings.Web" Version="7.0.0" />
<PackageReference Include="System.Text.Json" Version="7.0.1" /> <PackageReference Include="System.Text.Json" Version="7.0.1" />
<PackageReference Include="Unity" Version="5.11.10" />
<PackageReference Include="Unity.Microsoft.Logging" Version="5.11.1" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

View File

@ -0,0 +1,8 @@
namespace SofrwareInstallationContracts.StoragesContracts
{
public interface IBackUpInfo
{
List<T>? GetList<T>() where T : class, new();
Type? GetTypeByModelInterface(string modelInterfaceName);
}
}

View File

@ -1,16 +1,18 @@
using SoftwareInstallationDataModels.Models; using SoftwareInstallationDataModels.Models;
using System.ComponentModel; using System.ComponentModel;
using SofrwareInstallationContracts.Attributes;
namespace SofrwareInstallationContracts.ViewModels namespace SofrwareInstallationContracts.ViewModels
{ {
public class ClientViewModel : IClientModel public class ClientViewModel : IClientModel
{ {
[Column(visible: false)]
public int Id { get; set; } public int Id { get; set; }
[DisplayName("ФИО клиента")] [Column("ФИО клиента", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)]
public string ClientFIO { get; set; } = string.Empty; public string ClientFIO { get; set; } = string.Empty;
[DisplayName("Логин (эл. почта)")] [Column("Логин (эл. почта)", width: 150)]
public string Email { get; set; } = string.Empty; public string Email { get; set; } = string.Empty;
[DisplayName("Пароль")] [Column("Пароль", width: 150)]
public string Password { get; set; } = string.Empty; public string Password { get; set; } = string.Empty;
} }

View File

@ -1,16 +1,18 @@
using SoftwareInstallationDataModels.Models; using SofrwareInstallationContracts.Attributes;
using SoftwareInstallationDataModels.Models;
using System.ComponentModel; using System.ComponentModel;
namespace SofrwareInstallationContracts.ViewModels namespace SofrwareInstallationContracts.ViewModels
{ {
public class ComponentViewModel : IComponentModel public class ComponentViewModel : IComponentModel
{ {
[Column(visible: false)]
public int Id { get; set; } public int Id { get; set; }
[DisplayName("Название компонента")] [Column("Название компонента", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)]
public string ComponentName { get; set; } = string.Empty; public string ComponentName { get; set; } = string.Empty;
[DisplayName("Цена")] [Column("Цена", width: 80)]
public double Cost { get; set; } public double Cost { get; set; }
} }
} }

View File

@ -1,22 +1,24 @@
using SoftwareInstallationDataModels.Models; using SofrwareInstallationContracts.Attributes;
using SoftwareInstallationDataModels.Models;
using System.ComponentModel; using System.ComponentModel;
namespace SofrwareInstallationContracts.ViewModels namespace SofrwareInstallationContracts.ViewModels
{ {
public class ImplementerViewModel : IImplementerModel public class ImplementerViewModel : IImplementerModel
{ {
[Column(visible: false)]
public int Id { get; set; } public int Id { get; set; }
[DisplayName("ФИО исполнителя")] [Column("ФИО исполнителя", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)]
public string ImplementerFIO { get; set; } = string.Empty; public string ImplementerFIO { get; set; } = string.Empty;
[DisplayName("Пароль")] [Column("Пароль", width: 150)]
public string Password { get; set; } = string.Empty; public string Password { get; set; } = string.Empty;
[DisplayName("Стаж работы")] [Column("Стаж работы", gridViewAutoSize: GridViewAutoSize.AllCells, isUseAutoSize: true)]
public int WorkExperience { get; set; } public int WorkExperience { get; set; }
[DisplayName("Квалификация")] [Column("Квалификация", gridViewAutoSize: GridViewAutoSize.AllCells, isUseAutoSize: true)]
public int Qualification { get; set; } public int Qualification { get; set; }
} }
} }

View File

@ -1,25 +1,30 @@
using SoftwareInstallationDataModels.Models; using SofrwareInstallationContracts.Attributes;
using SoftwareInstallationDataModels.Models;
using System.ComponentModel; using System.ComponentModel;
namespace SofrwareInstallationContracts.ViewModels namespace SofrwareInstallationContracts.ViewModels
{ {
public class MessageInfoViewModel : IMessageInfoModel public class MessageInfoViewModel : IMessageInfoModel
{ {
[Column(visible: false)]
public string MessageId { get; set; } = string.Empty; public string MessageId { get; set; } = string.Empty;
[Column(visible: false)]
public int? ClientId { get; set; } public int? ClientId { get; set; }
[DisplayName("Имя отправителя")] [Column("Имя отправителя", gridViewAutoSize: GridViewAutoSize.DisplayedCells, isUseAutoSize: true)]
public string SenderName { get; set; } = string.Empty; public string SenderName { get; set; } = string.Empty;
[DisplayName("Дата отправления")] [Column("Дата отправления", width: 100)]
public DateTime DateDelivery { get; set; } public DateTime DateDelivery { get; set; }
[DisplayName("Тема")] [Column("Тема", width: 150)]
public string Subject { get; set; } = string.Empty; public string Subject { get; set; } = string.Empty;
[DisplayName("Содержание")] [Column("Содержание", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)]
public string Body { get; set; } = string.Empty; public string Body { get; set; } = string.Empty;
[Column(visible: false)]
public int Id => throw new NotImplementedException();
[DisplayName("Прочитано")] [DisplayName("Прочитано")]
public bool HasRead { get; set; } public bool HasRead { get; set; }

View File

@ -1,4 +1,5 @@
using SoftwareInstallationDataModels.Enums; using SofrwareInstallationContracts.Attributes;
using SoftwareInstallationDataModels.Enums;
using SoftwareInstallationDataModels.Models; using SoftwareInstallationDataModels.Models;
using System.ComponentModel; using System.ComponentModel;
@ -6,37 +7,40 @@ namespace SofrwareInstallationContracts.ViewModels
{ {
public class OrderViewModel : IOrderModel public class OrderViewModel : IOrderModel
{ {
[Column(visible: false)]
public int PackageId { get; set; } public int PackageId { get; set; }
[Column(visible: false)]
public int ClientId { get; set; } public int ClientId { get; set; }
[Column(visible: false)]
public int? ImplementerId { get; set; } public int? ImplementerId { get; set; }
[DisplayName("Номер")] [Column("Номер", gridViewAutoSize: GridViewAutoSize.AllCells, isUseAutoSize: true)]
public int Id { get; set; } public int Id { get; set; }
[DisplayName("ФИО исполнителя")] [Column("ФИО исполнителя", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)]
public string ImplementerFIO { get; set; } = string.Empty; public string ImplementerFIO { get; set; } = string.Empty;
[DisplayName("Название изделия")] [Column("Название изделия", gridViewAutoSize: GridViewAutoSize.AllCells, isUseAutoSize: true)]
public string PackageName { get; set; } = string.Empty; public string PackageName { get; set; } = string.Empty;
[DisplayName("Клиент")] [Column("ФИО клиента", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)]
public string ClientFIO { get; set; } = string.Empty; public string ClientFIO { get; set; } = string.Empty;
[DisplayName("Количество")] [Column("Количество", gridViewAutoSize: GridViewAutoSize.AllCells, isUseAutoSize: true)]
public int Count { get; set; } public int Count { get; set; }
[DisplayName("Сумма")] [Column("Сумма", gridViewAutoSize: GridViewAutoSize.AllCells, isUseAutoSize: true)]
public double Sum { get; set; } public double Sum { get; set; }
[DisplayName("Статус")] [Column("Статус", gridViewAutoSize: GridViewAutoSize.AllCells, isUseAutoSize: true)]
public OrderStatus Status { get; set; } = OrderStatus.Неизвестен; public OrderStatus Status { get; set; } = OrderStatus.Неизвестен;
[DisplayName("Дата создания")] [Column("Дата создания", width: 100)]
public DateTime DateCreate { get; set; } = DateTime.Now; public DateTime DateCreate { get; set; } = DateTime.Now;
[DisplayName("Дата выполнения")] [Column("Дата выполнения", width: 100)]
public DateTime? DateImplement { get; set; } public DateTime? DateImplement { get; set; }
} }
} }

View File

@ -1,18 +1,21 @@
using SoftwareInstallationDataModels.Models; using SofrwareInstallationContracts.Attributes;
using SoftwareInstallationDataModels.Models;
using System.ComponentModel; using System.ComponentModel;
namespace SofrwareInstallationContracts.ViewModels namespace SofrwareInstallationContracts.ViewModels
{ {
public class PackageViewModel : IPackageModel public class PackageViewModel : IPackageModel
{ {
[Column(visible: false)]
public int Id { get; set; } public int Id { get; set; }
[DisplayName("Название изделия")] [Column("Название изделия", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)]
public string PackageName { get; set; }=string.Empty; public string PackageName { get; set; }=string.Empty;
[DisplayName("Цена")] [Column("Цена", width: 100)]
public double Price { get; set; } public double Price { get; set; }
[Column(visible: false)]
public Dictionary<int, (IComponentModel, int)> PackageComponents { get; set; } = new(); public Dictionary<int, (IComponentModel, int)> PackageComponents { get; set; } = new();
} }
} }

View File

@ -0,0 +1,53 @@
using SofrwareInstallationContracts.Attributes;
namespace SoftwareInstallationView
{
public static class DataGridViewExtension
{
public static void FillandConfigGrid<T>(this DataGridView grid, List<T>? data)
{
if (data == null)
{
return;
}
grid.DataSource = data;
var type = typeof(T);
var properties = type.GetProperties();
foreach (DataGridViewColumn column in grid.Columns)
{
var property = properties.FirstOrDefault(x => x.Name == column.Name);
if (property == null)
{
throw new InvalidOperationException($"В типе {type.Name} не найдено свойство с именем { column.Name }");
}
var attribute = property.GetCustomAttributes(typeof(ColumnAttribute), true)?.SingleOrDefault();
if (attribute == null)
{
throw new InvalidOperationException($"Не найден атрибут типа ColumnAttribute для свойства { property.Name }");
}
// ищем нужный нам атрибут
if (attribute is ColumnAttribute columnAttr)
{
column.HeaderText = columnAttr.Title;
column.Visible = columnAttr.Visible;
if (columnAttr.IsUseAutoSize)
{
column.AutoSizeMode = (DataGridViewAutoSizeColumnMode)Enum.Parse(typeof(DataGridViewAutoSizeColumnMode), columnAttr.GridViewAutoSize.ToString());
}
else
{
column.Width = columnAttr.Width;
}
}
}
}
}
}

View File

@ -55,13 +55,7 @@ namespace SoftwareInstallationView
{ {
try try
{ {
var list = _logic.ReadList(null); DataGridView.FillandConfigGrid(_logic.ReadList(null));
if (list != null)
{
DataGridView.DataSource = list;
DataGridView.Columns["Id"].Visible = false;
DataGridView.Columns["ClientFIO"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
}
_logger.LogInformation("Загрузка клиентов"); _logger.LogInformation("Загрузка клиентов");
} }
catch (Exception ex) catch (Exception ex)

View File

@ -1,6 +1,8 @@
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using SofrwareInstallationContracts.BindingModels; using SofrwareInstallationContracts.BindingModels;
using SofrwareInstallationContracts.BusinessLogicsContracts; using SofrwareInstallationContracts.BusinessLogicsContracts;
using SofrwareInstallationContracts.DI;
using System.Windows.Forms;
namespace SoftwareInstallationView namespace SoftwareInstallationView
{ {
@ -26,15 +28,7 @@ namespace SoftwareInstallationView
{ {
try try
{ {
var list = _logic.ReadList(null); DataGridView.FillandConfigGrid(_logic.ReadList(null));
if (list != null)
{
DataGridView.DataSource = list;
DataGridView.Columns["Id"].Visible = false;
DataGridView.Columns["ComponentName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
}
_logger.LogInformation("Загрузка компонентов"); _logger.LogInformation("Загрузка компонентов");
} }
@ -47,33 +41,26 @@ namespace SoftwareInstallationView
private void AddButton_Click(object sender, EventArgs e) private void AddButton_Click(object sender, EventArgs e)
{ {
var service = Program.ServiceProvider?.GetService(typeof(FormComponent)); var form = DependencyManager.Instance.Resolve<FormComponent>();
if (service is FormComponent form)
{
if (form.ShowDialog() == DialogResult.OK) if (form.ShowDialog() == DialogResult.OK)
{ {
LoadData(); LoadData();
} }
} }
}
private void ChangeButton_Click(object sender, EventArgs e) private void ChangeButton_Click(object sender, EventArgs e)
{ {
if (DataGridView.SelectedRows.Count == 1) if (DataGridView.SelectedRows.Count == 1)
{ {
var service = Program.ServiceProvider?.GetService(typeof(FormComponent)); var form = DependencyManager.Instance.Resolve<FormComponent>();
if (service is FormComponent form)
{
form.Id = Convert.ToInt32(DataGridView.SelectedRows[0].Cells["Id"].Value); form.Id = Convert.ToInt32(DataGridView.SelectedRows[0].Cells["Id"].Value);
if (form.ShowDialog() == DialogResult.OK) if (form.ShowDialog() == DialogResult.OK)
{ {
LoadData(); LoadData();
} }
} }
} }
}
private void DeleteButton_Click(object sender, EventArgs e) private void DeleteButton_Click(object sender, EventArgs e)
{ {
if (DataGridView.SelectedRows.Count == 1) if (DataGridView.SelectedRows.Count == 1)

View File

@ -1,6 +1,7 @@
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using SofrwareInstallationContracts.BindingModels; using SofrwareInstallationContracts.BindingModels;
using SofrwareInstallationContracts.BusinessLogicsContracts; using SofrwareInstallationContracts.BusinessLogicsContracts;
using SofrwareInstallationContracts.DI;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel; using System.ComponentModel;
@ -26,32 +27,28 @@ namespace SoftwareInstallationView
private void AddButton_Click(object sender, EventArgs e) private void AddButton_Click(object sender, EventArgs e)
{ {
var service = Program.ServiceProvider?.GetService(typeof(FormImplementer)); var form = DependencyManager.Instance.Resolve<FormImplementer>();
if (service is FormImplementer form)
{
if (form.ShowDialog() == DialogResult.OK) if (form.ShowDialog() == DialogResult.OK)
{ {
LoadData(); LoadData();
} }
} }
}
private void ChangeButton_Click(object sender, EventArgs e) private void ChangeButton_Click(object sender, EventArgs e)
{ {
if (DataGridView.SelectedRows.Count == 1) if (DataGridView.SelectedRows.Count == 1)
{ {
var service = Program.ServiceProvider?.GetService(typeof(FormImplementer)); var form = DependencyManager.Instance.Resolve<FormImplementer>();
if (service is FormImplementer form)
{
form.Id = Convert.ToInt32(DataGridView.SelectedRows[0].Cells["Id"].Value); form.Id = Convert.ToInt32(DataGridView.SelectedRows[0].Cells["Id"].Value);
if (form.ShowDialog() == DialogResult.OK) if (form.ShowDialog() == DialogResult.OK)
{ {
LoadData(); LoadData();
} }
} }
} }
}
private void DeleteButton_Click(object sender, EventArgs e) private void DeleteButton_Click(object sender, EventArgs e)
{ {
@ -98,15 +95,7 @@ namespace SoftwareInstallationView
{ {
try try
{ {
var list = _logic.ReadList(null); DataGridView.FillandConfigGrid(_logic.ReadList(null));
if (list != null)
{
DataGridView.DataSource = list;
DataGridView.Columns["Id"].Visible = false;
DataGridView.Columns["ImplementerFIO"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
}
_logger.LogInformation("Загрузка исполнителей"); _logger.LogInformation("Загрузка исполнителей");
} }

View File

@ -25,18 +25,11 @@ namespace SoftwareInstallationView
{ {
try try
{ {
var list = _logic.ReadList(new() DataGridView.FillandConfigGrid(_logic.ReadList(new()
{ {
Page = currentPage, Page = currentPage,
PageSize = pageSize, PageSize = pageSize,
}); }));
if (list != null)
{
DataGridView.DataSource = list;
DataGridView.Columns["ClientId"].Visible = false;
DataGridView.Columns["MessageId"].Visible = false;
DataGridView.Columns["Body"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
}
_logger.LogInformation("Загрузка писем"); _logger.LogInformation("Загрузка писем");
labelInfoPages.Text = $"{currentPage} страница"; labelInfoPages.Text = $"{currentPage} страница";
return true; return true;

View File

@ -40,12 +40,14 @@
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.запускРабот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.DataGridView = new System.Windows.Forms.DataGridView();
this.CreateOrderButton = new System.Windows.Forms.Button(); this.CreateOrderButton = new System.Windows.Forms.Button();
this.TakeOrderInWorkButton = new System.Windows.Forms.Button(); this.TakeOrderInWorkButton = new System.Windows.Forms.Button();
this.OrderReadyButton = new System.Windows.Forms.Button(); this.OrderReadyButton = new System.Windows.Forms.Button();
this.IssuedOrderButton = new System.Windows.Forms.Button(); this.IssuedOrderButton = new System.Windows.Forms.Button();
this.UpdateListButton = new System.Windows.Forms.Button(); this.UpdateListButton = new System.Windows.Forms.Button();
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.исполнителиToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.клиентыToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.клиентыToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
@ -64,7 +66,8 @@
this.СправочникиToolStripMenuItem, this.СправочникиToolStripMenuItem,
this.отчетыToolStripMenuItem, this.отчетыToolStripMenuItem,
this.запускРаботToolStripMenuItem, this.запускРаботToolStripMenuItem,
this.элПисьмаToolStripMenuItem}); this.элПисьмаToolStripMenuItem,
this.создатьБекапToolStripMenuItem});
this.MenuStrip.Location = new System.Drawing.Point(0, 0); this.MenuStrip.Location = new System.Drawing.Point(0, 0);
this.MenuStrip.Name = "MenuStrip"; this.MenuStrip.Name = "MenuStrip";
this.MenuStrip.Size = new System.Drawing.Size(865, 24); this.MenuStrip.Size = new System.Drawing.Size(865, 24);
@ -160,6 +163,13 @@
this.запускРаботToolStripMenuItem.Text = "Запуск работ"; this.запускРаботToolStripMenuItem.Text = "Запуск работ";
this.запускРаботToolStripMenuItem.Click += new System.EventHandler(this.запускРаботToolStripMenuItem_Click); this.запускРаботToolStripMenuItem.Click += new System.EventHandler(this.запускРаботToolStripMenuItem_Click);
// //
// элПисьмаToolStripMenuItem
//
this.элПисьмаToolStripMenuItem.Name = "элПисьмаToolStripMenuItem";
this.элПисьмаToolStripMenuItem.Size = new System.Drawing.Size(82, 20);
this.элПисьмаToolStripMenuItem.Text = "Эл. Письма";
this.элПисьмаToolStripMenuItem.Click += new System.EventHandler(this.элПисьмаToolStripMenuItem_Click);
//
// DataGridView // DataGridView
// //
this.DataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; this.DataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
@ -219,12 +229,12 @@
this.UpdateListButton.UseVisualStyleBackColor = true; this.UpdateListButton.UseVisualStyleBackColor = true;
this.UpdateListButton.Click += new System.EventHandler(this.UpdateListButton_Click); this.UpdateListButton.Click += new System.EventHandler(this.UpdateListButton_Click);
// //
// элПисьмаToolStripMenuItem // создатьБекапToolStripMenuItem
// //
this.элПисьмаToolStripMenuItem.Name = "элПисьмаToolStripMenuItem"; this.создатьБекапToolStripMenuItem.Name = "создатьБекапToolStripMenuItem";
this.элПисьмаToolStripMenuItem.Size = new System.Drawing.Size(82, 20); this.создатьБекапToolStripMenuItem.Size = new System.Drawing.Size(97, 20);
this.элПисьмаToolStripMenuItem.Text = "Эл. Письма"; this.создатьБекапToolStripMenuItem.Text = "Создать Бекап";
this.элПисьмаToolStripMenuItem.Click += new System.EventHandler(this.элПисьмаToolStripMenuItem_Click); this.создатьБекапToolStripMenuItem.Click += new System.EventHandler(this.создатьБекапToolStripMenuItem_Click);
// //
// StoreReplenishment // StoreReplenishment
// //
@ -315,6 +325,7 @@
private ToolStripMenuItem запускРаботToolStripMenuItem; private ToolStripMenuItem запускРаботToolStripMenuItem;
private ToolStripMenuItem исполнителиToolStripMenuItem; private ToolStripMenuItem исполнителиToolStripMenuItem;
private ToolStripMenuItem элПисьмаToolStripMenuItem; private ToolStripMenuItem элПисьмаToolStripMenuItem;
private ToolStripMenuItem создатьБекапToolStripMenuItem;
private ToolStripMenuItem списокМагазиновToolStripMenuItem; private ToolStripMenuItem списокМагазиновToolStripMenuItem;
private ToolStripMenuItem изделияПоМагазинамToolStripMenuItem; private ToolStripMenuItem изделияПоМагазинамToolStripMenuItem;
private ToolStripMenuItem списокЗаказовгруппировкаПоДатеToolStripMenuItem; private ToolStripMenuItem списокЗаказовгруппировкаПоДатеToolStripMenuItem;

View File

@ -1,9 +1,7 @@
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using SofrwareInstallationContracts.BindingModels; using SofrwareInstallationContracts.BindingModels;
using SofrwareInstallationContracts.BusinessLogicsContracts; using SofrwareInstallationContracts.BusinessLogicsContracts;
using SoftwareInstallationBusinessLogic.BusinessLogic; using SofrwareInstallationContracts.DI;
using SoftwareInstallationDataModels.Enums;
using System.Windows.Forms;
namespace SoftwareInstallationView namespace SoftwareInstallationView
{ {
@ -14,14 +12,16 @@ namespace SoftwareInstallationView
private readonly IOrderLogic _orderLogic; private readonly IOrderLogic _orderLogic;
private readonly IReportLogic _reportLogic; private readonly IReportLogic _reportLogic;
private readonly IWorkProcess _workProcess; private readonly IWorkProcess _workProcess;
private readonly IBackUpLogic _backUpLogic;
public FormMain(ILogger<FormMain> logger, IWorkProcess workProcess, IOrderLogic orderLogic, IReportLogic reportLogic) public FormMain(ILogger<FormMain> logger, IBackUpLogic backUpLogic, IWorkProcess workProcess, IOrderLogic orderLogic, IReportLogic reportLogic)
{ {
InitializeComponent(); InitializeComponent();
_logger = logger; _logger = logger;
_orderLogic = orderLogic; _orderLogic = orderLogic;
_reportLogic = reportLogic; _reportLogic = reportLogic;
_workProcess = workProcess; _workProcess = workProcess;
_backUpLogic = backUpLogic;
LoadData(); LoadData();
} }
@ -36,16 +36,7 @@ namespace SoftwareInstallationView
try try
{ {
var list = _orderLogic.ReadList(null); DataGridView.FillandConfigGrid(_orderLogic.ReadList(null));
if (list != null)
{
DataGridView.DataSource = list;
DataGridView.Columns["PackageId"].Visible = false;
DataGridView.Columns["ClientId"].Visible = false;
DataGridView.Columns["ImplementerId"].Visible = false;
}
_logger.LogInformation("Загрузка заказов"); _logger.LogInformation("Загрузка заказов");
} }
catch (Exception ex) catch (Exception ex)
@ -57,34 +48,22 @@ namespace SoftwareInstallationView
private void КомпонентыToolStripMenuItem_Click(object sender, EventArgs e) private void КомпонентыToolStripMenuItem_Click(object sender, EventArgs e)
{ {
var service = Program.ServiceProvider?.GetService(typeof(FormComponents)); var form = DependencyManager.Instance.Resolve<FormComponents>();
if (service is FormComponents form)
{
form.ShowDialog(); form.ShowDialog();
} }
}
private void ИзделияToolStripMenuItem_Click(object sender, EventArgs e) private void ИзделияToolStripMenuItem_Click(object sender, EventArgs e)
{ {
var service = Program.ServiceProvider?.GetService(typeof(FormPackages)); var form = DependencyManager.Instance.Resolve<FormPackages>();
if (service is FormPackages form)
{
form.ShowDialog(); form.ShowDialog();
} }
}
private void CreateOrderButton_Click(object sender, EventArgs e) private void CreateOrderButton_Click(object sender, EventArgs e)
{ {
var service = Program.ServiceProvider?.GetService(typeof(FormCreateOrder)); var form = DependencyManager.Instance.Resolve<FormCreateOrder>();
if (service is FormCreateOrder form)
{
form.ShowDialog(); form.ShowDialog();
LoadData(); LoadData();
} }
}
private void TakeOrderInWorkButton_Click(object sender, EventArgs e) private void TakeOrderInWorkButton_Click(object sender, EventArgs e)
{ {
@ -225,55 +204,64 @@ namespace SoftwareInstallationView
private void компонентыПоИзделиямToolStripMenuItem_Click(object sender, EventArgs e) private void компонентыПоИзделиямToolStripMenuItem_Click(object sender, EventArgs e)
{ {
var service = Program.ServiceProvider?.GetService(typeof(FormReportPackageComponents)); var form = DependencyManager.Instance.Resolve<FormReportPackageComponents>();
if (service is FormReportPackageComponents form)
{
form.ShowDialog(); form.ShowDialog();
} }
}
private void списокЗаказовToolStripMenuItem_Click(object sender, EventArgs e) private void списокЗаказовToolStripMenuItem_Click(object sender, EventArgs e)
{ {
var service = Program.ServiceProvider?.GetService(typeof(FormReportOrders)); var form = DependencyManager.Instance.Resolve<FormReportOrders>();
if (service is FormReportOrders form)
{
form.ShowDialog(); form.ShowDialog();
} }
}
private void клиентыToolStripMenuItem_Click(object sender, EventArgs e) private void клиентыToolStripMenuItem_Click(object sender, EventArgs e)
{ {
var service = Program.ServiceProvider?.GetService(typeof(FormClients)); var form = DependencyManager.Instance.Resolve<FormClients>();
if (service is FormClients form)
{
form.ShowDialog(); form.ShowDialog();
} }
}
private void запускРаботToolStripMenuItem_Click(object sender, EventArgs e) private void запускРаботToolStripMenuItem_Click(object sender, EventArgs e)
{ {
_workProcess.DoWork((Program.ServiceProvider?.GetService(typeof(IImplementerLogic)) as IImplementerLogic)!, _orderLogic); _workProcess.DoWork(DependencyManager.Instance.Resolve<IImplementerLogic>(), _orderLogic);
MessageBox.Show("Процесс обработки запущен", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information); MessageBox.Show("Процесс обработки запущен", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
} }
private void исполнителиToolStripMenuItem_Click(object sender, EventArgs e) private void исполнителиToolStripMenuItem_Click(object sender, EventArgs e)
{ {
var service = Program.ServiceProvider?.GetService(typeof(FormImplementers)); var form = DependencyManager.Instance.Resolve<FormImplementers>();
if (service is FormImplementers form)
{
form.ShowDialog(); form.ShowDialog();
} }
}
private void элПисьмаToolStripMenuItem_Click(object sender, EventArgs e) private void элПисьмаToolStripMenuItem_Click(object sender, EventArgs e)
{ {
var service = Program.ServiceProvider?.GetService(typeof(FormMails)); var form = DependencyManager.Instance.Resolve<FormMails>();
if (service is FormMails form)
{
form.ShowDialog(); form.ShowDialog();
} }
private void создатьБекапToolStripMenuItem_Click(object sender, EventArgs e)
{
try
{
if (_backUpLogic != null)
{
var fbd = new FolderBrowserDialog();
if (fbd.ShowDialog() == DialogResult.OK)
{
_backUpLogic.CreateBackUp(new BackUpSaveBinidngModel
{
FolderName = fbd.SelectedPath
});
MessageBox.Show("Бекап создан", "Сообщение",
MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
MessageBoxIcon.Error);
}
} }
private void списокМагазиновToolStripMenuItem_Click(object sender, EventArgs e) private void списокМагазиновToolStripMenuItem_Click(object sender, EventArgs e)

View File

@ -3,7 +3,8 @@ using SofrwareInstallationContracts.BusinessLogicsContracts;
using SofrwareInstallationContracts.SearchModels; using SofrwareInstallationContracts.SearchModels;
using SoftwareInstallationDataModels.Models; using SoftwareInstallationDataModels.Models;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using SofrwareInstallationContracts.DI;
using System.Windows.Forms;
namespace SoftwareInstallationView namespace SoftwareInstallationView
{ {
@ -77,10 +78,8 @@ namespace SoftwareInstallationView
} }
private void AddButton_Click(object sender, EventArgs e) private void AddButton_Click(object sender, EventArgs e)
{ {
var service = Program.ServiceProvider?.GetService(typeof(FormPackageComponent)); var form = DependencyManager.Instance.Resolve<FormPackageComponent>();
if (service is FormPackageComponent form)
{
if (form.ShowDialog() == DialogResult.OK) if (form.ShowDialog() == DialogResult.OK)
{ {
if (form.ComponentModel == null) if (form.ComponentModel == null)
@ -88,13 +87,12 @@ namespace SoftwareInstallationView
return; return;
} }
_logger.LogInformation("Добавление нового компонента: { ComponentName} - { Count}", form.ComponentModel.ComponentName, form.Count); _logger.LogInformation("Добавление нового компонента: { ComponentName}- { Count}", form.ComponentModel.ComponentName, form.Count);
if (_packageComponents.ContainsKey(form.Id)) if (_packageComponents.ContainsKey(form.Id))
{ {
_packageComponents[form.Id] = (form.ComponentModel, form.Count); _packageComponents[form.Id] = (form.ComponentModel, form.Count);
} }
else else
{ {
_packageComponents.Add(form.Id, (form.ComponentModel, form.Count)); _packageComponents.Add(form.Id, (form.ComponentModel, form.Count));
@ -103,17 +101,14 @@ namespace SoftwareInstallationView
LoadData(); LoadData();
} }
} }
}
private void ChangeButton_Click(object sender, EventArgs e) private void ChangeButton_Click(object sender, EventArgs e)
{ {
if (DataGridView.SelectedRows.Count == 1) if (DataGridView.SelectedRows.Count == 1)
{ {
var service = Program.ServiceProvider?.GetService(typeof(FormPackageComponent)); var form = DependencyManager.Instance.Resolve<FormPackageComponent>();
if (service is FormPackageComponent form)
{
int id = Convert.ToInt32(DataGridView.SelectedRows[0].Cells[0].Value); int id = Convert.ToInt32(DataGridView.SelectedRows[0].Cells[0].Value);
form.Id = id; form.Id = id;
form.Count = _packageComponents[id].Item2; form.Count = _packageComponents[id].Item2;
@ -124,13 +119,13 @@ namespace SoftwareInstallationView
return; return;
} }
_logger.LogInformation("Изменение компонента: { ComponentName} - { Count}", form.ComponentModel.ComponentName, form.Count); _logger.LogInformation("Изменение компонента: { ComponentName} - { Count} ", form.ComponentModel.ComponentName, form.Count);
_packageComponents[form.Id] = (form.ComponentModel, form.Count); _packageComponents[id] = (form.ComponentModel, form.Count);
LoadData(); LoadData();
} }
} }
} }
}
private void DeleteButton_Click(object sender, EventArgs e) private void DeleteButton_Click(object sender, EventArgs e)
{ {

View File

@ -1,6 +1,8 @@
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using SofrwareInstallationContracts.BindingModels; using SofrwareInstallationContracts.BindingModels;
using SofrwareInstallationContracts.BusinessLogicsContracts; using SofrwareInstallationContracts.BusinessLogicsContracts;
using SofrwareInstallationContracts.DI;
using System.Windows.Forms;
namespace SoftwareInstallationView namespace SoftwareInstallationView
{ {
@ -26,16 +28,7 @@ namespace SoftwareInstallationView
{ {
try try
{ {
var list = _logic.ReadList(null); DataGridView.FillandConfigGrid(_logic.ReadList(null));
if (list != null)
{
DataGridView.DataSource = list;
DataGridView.Columns["Id"].Visible = false;
DataGridView.Columns["PackageName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
DataGridView.Columns["PackageComponents"].Visible = false;
}
_logger.LogInformation("Загрузка изделий"); _logger.LogInformation("Загрузка изделий");
} }
@ -48,24 +41,19 @@ namespace SoftwareInstallationView
private void AddButton_Click(object sender, EventArgs e) private void AddButton_Click(object sender, EventArgs e)
{ {
var service = Program.ServiceProvider?.GetService(typeof(FormPackage)); var form = DependencyManager.Instance.Resolve<FormPackage>();
if (service is FormPackage form)
{
if (form.ShowDialog() == DialogResult.OK) if (form.ShowDialog() == DialogResult.OK)
{ {
LoadData(); LoadData();
} }
} }
}
private void ChangeButton_Click(object sender, EventArgs e) private void ChangeButton_Click(object sender, EventArgs e)
{ {
if (DataGridView.SelectedRows.Count == 1) if (DataGridView.SelectedRows.Count == 1)
{ {
var service = Program.ServiceProvider?.GetService(typeof(FormPackage)); var form = DependencyManager.Instance.Resolve<FormPackage>();
if (service is FormPackage form)
{
form.Id = Convert.ToInt32(DataGridView.SelectedRows[0].Cells["Id"].Value); form.Id = Convert.ToInt32(DataGridView.SelectedRows[0].Cells["Id"].Value);
if (form.ShowDialog() == DialogResult.OK) if (form.ShowDialog() == DialogResult.OK)
@ -74,7 +62,6 @@ namespace SoftwareInstallationView
} }
} }
} }
}
private void DeleteButton_Click(object sender, EventArgs e) private void DeleteButton_Click(object sender, EventArgs e)
{ {
if (DataGridView.SelectedRows.Count == 1) if (DataGridView.SelectedRows.Count == 1)

View File

@ -1,32 +1,26 @@
using SoftwareInstallationBusinessLogic.BusinessLogic; using SoftwareInstallationBusinessLogic.BusinessLogic;
using Microsoft.Extensions.DependencyInjection;
using SofrwareInstallationContracts.BusinessLogicsContracts; using SofrwareInstallationContracts.BusinessLogicsContracts;
using SofrwareInstallationContracts.StoragesContracts;
using SoftwareInstallationDataBaseImplement.Implements;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using NLog.Extensions.Logging; using NLog.Extensions.Logging;
using SoftwareInstallationBusinessLogic.OfficePackage; using SoftwareInstallationBusinessLogic.OfficePackage;
using SoftwareInstallationBusinessLogic.OfficePackage.Implements; using SoftwareInstallationBusinessLogic.OfficePackage.Implements;
using SofrwareInstallationContracts.BindingModels; using SofrwareInstallationContracts.BindingModels;
using SoftwareInstallationBusinessLogic.MailWorker; using SoftwareInstallationBusinessLogic.MailWorker;
using SofrwareInstallationContracts.DI;
namespace SoftwareInstallationView namespace SoftwareInstallationView
{ {
internal static class Program internal static class Program
{ {
private static ServiceProvider? _serviceProvider;
public static ServiceProvider? ServiceProvider => _serviceProvider;
[STAThread] [STAThread]
static void Main() static void Main()
{ {
ApplicationConfiguration.Initialize(); ApplicationConfiguration.Initialize();
var services = new ServiceCollection(); InitDependency();
ConfigureServices(services);
_serviceProvider = services.BuildServiceProvider();
try try
{ {
var mailSender = _serviceProvider.GetService<AbstractMailWorker>(); var mailSender = DependencyManager.Instance.Resolve<AbstractMailWorker>();
mailSender?.MailConfig(new MailConfigBindingModel mailSender?.MailConfig(new MailConfigBindingModel
{ {
MailLogin = System.Configuration.ConfigurationManager.AppSettings["MailLogin"] ?? string.Empty, MailLogin = System.Configuration.ConfigurationManager.AppSettings["MailLogin"] ?? string.Empty,
@ -41,64 +35,62 @@ namespace SoftwareInstallationView
} }
catch (Exception ex) catch (Exception ex)
{ {
var logger = _serviceProvider.GetService<ILogger>(); var logger = DependencyManager.Instance.Resolve<ILogger>();
logger?.LogError(ex, "Error"); logger?.LogError(ex, "Îøèáêà");
}
Application.Run(_serviceProvider.GetRequiredService<FormMain>());
} }
private static void ConfigureServices(ServiceCollection services) Application.Run(DependencyManager.Instance.Resolve<FormMain>());
}
private static void InitDependency()
{ {
services.AddLogging(option => DependencyManager.InitDependency();
DependencyManager.Instance.AddLogging(option =>
{ {
option.SetMinimumLevel(LogLevel.Information); option.SetMinimumLevel(LogLevel.Information);
option.AddNLog("nlog.config"); option.AddNLog("nlog.config");
}); });
services.AddTransient<IClientStorage, ClientStorage>();
services.AddTransient<IMessageInfoStorage, MessageInfoStorage>();
services.AddTransient<IComponentStorage, ComponentStorage>();
services.AddTransient<IOrderStorage, OrderStorage>();
services.AddTransient<IPackageStorage, PackageStorage>();
services.AddTransient<IImplementerStorage, ImplementerStorage>();
services.AddTransient<IClientLogic, ClientLogic>();
services.AddTransient<IMessageInfoLogic, MessageInfoLogic>();
services.AddTransient<IWorkProcess, WorkModeling>();
services.AddSingleton<AbstractMailWorker, MailKitWorker>();
services.AddTransient<IImplementerLogic, ImplementerLogic>();
services.AddTransient<IStoreStorage, StoreStorage>();
services.AddTransient<IComponentLogic, ComponentLogic>(); DependencyManager.Instance.RegisterType<IComponentLogic, ComponentLogic>();
services.AddTransient<IOrderLogic, OrderLogic>(); DependencyManager.Instance.RegisterType<IOrderLogic, OrderLogic>();
services.AddTransient<IPackageLogic, PackageLogic>(); DependencyManager.Instance.RegisterType<IPackageLogic, PackageLogic>();
services.AddTransient<IReportLogic, ReportLogic>(); DependencyManager.Instance.RegisterType<IReportLogic, ReportLogic>();
services.AddTransient<IStoreLogic, StoreLogic>(); DependencyManager.Instance.RegisterType<IClientLogic, ClientLogic>();
DependencyManager.Instance.RegisterType<IImplementerLogic, ImplementerLogic>();
DependencyManager.Instance.RegisterType<IMessageInfoLogic, MessageInfoLogic>();
DependencyManager.Instance.RegisterType<IStoreLogic, StoreLogic>();
DependencyManager.Instance.RegisterType<IWorkProcess, WorkModeling>();
DependencyManager.Instance.RegisterType<IBackUpLogic, BackUpLogic>();
services.AddTransient<AbstractSaveToPdf, SaveToPdf>(); DependencyManager.Instance.RegisterType<AbstractMailWorker, MailKitWorker>(true);
services.AddTransient<AbstractSaveToWord, SaveToWord>();
services.AddTransient<AbstractSaveToExcel, SaveToExcel>();
services.AddTransient<FormMain>(); DependencyManager.Instance.RegisterType<AbstractSaveToExcel, SaveToExcel>();
services.AddTransient<FormComponent>(); DependencyManager.Instance.RegisterType<AbstractSaveToWord, SaveToWord>();
services.AddTransient<FormComponents>(); DependencyManager.Instance.RegisterType<AbstractSaveToPdf, SaveToPdf>();
services.AddTransient<FormCreateOrder>();
services.AddTransient<FormPackage>(); DependencyManager.Instance.RegisterType<FormMain>();
services.AddTransient<FormPackageComponent>(); DependencyManager.Instance.RegisterType<FormComponent>();
services.AddTransient<FormPackages>(); DependencyManager.Instance.RegisterType<FormComponents>();
services.AddTransient<FormReportOrders>(); DependencyManager.Instance.RegisterType<FormCreateOrder>();
services.AddTransient<FormReportOrdersGroupByDate>(); DependencyManager.Instance.RegisterType<FormPackage>();
services.AddTransient<FormReportPackageComponents>(); DependencyManager.Instance.RegisterType<FormPackageComponent>();
services.AddTransient<FormClients>(); DependencyManager.Instance.RegisterType<FormPackages>();
services.AddTransient<FormImplementer>(); DependencyManager.Instance.RegisterType<FormReportPackageComponents>();
services.AddTransient<FormImplementers>(); DependencyManager.Instance.RegisterType<FormReportOrders>();
services.AddTransient<FormMails>(); DependencyManager.Instance.RegisterType<FormClients>();
services.AddTransient<FormReplyMail>(); DependencyManager.Instance.RegisterType<FormImplementers>();
services.AddTransient<FormReportStorePackages>(); DependencyManager.Instance.RegisterType<FormImplementer>();
services.AddTransient<FormStores>(); DependencyManager.Instance.RegisterType<FormReportOrdersGroupByDate>();
services.AddTransient<FormStore>(); DependencyManager.Instance.RegisterType<FormMails>();
services.AddTransient<FormStoreReplenishment>(); DependencyManager.Instance.RegisterType<FormReplyMail>();
services.AddTransient<FormSellPackage>(); DependencyManager.Instance.RegisterType<FormReportStorePackages>();
DependencyManager.Instance.RegisterType<FormStores>();
DependencyManager.Instance.RegisterType<FormStore>();
DependencyManager.Instance.RegisterType<FormStoreReplenishment>();
DependencyManager.Instance.RegisterType<FormSellPackage>();
} }
private static void MailCheck(object obj) => ServiceProvider?.GetService<AbstractMailWorker>()?.MailCheck(); private static void MailCheck(object obj) => DependencyManager.Instance.Resolve<AbstractMailWorker>()?.MailCheck();
} }
} }

View File

@ -0,0 +1,113 @@
using Microsoft.Extensions.Logging;
using SofrwareInstallationContracts.BindingModels;
using SofrwareInstallationContracts.BusinessLogicsContracts;
using SofrwareInstallationContracts.StoragesContracts;
using SoftwareInstallationDataModels;
using System.IO.Compression;
using System.Reflection;
using System.Runtime.Serialization.Json;
namespace SoftwareInstallationBusinessLogic.BusinessLogic
{
public class BackUpLogic : IBackUpLogic
{
private readonly ILogger _logger;
private readonly IBackUpInfo _backUpInfo;
public BackUpLogic(ILogger<BackUpLogic> logger, IBackUpInfo backUpInfo)
{
_logger = logger;
_backUpInfo = backUpInfo;
}
public void CreateBackUp(BackUpSaveBinidngModel model)
{
if (_backUpInfo == null)
{
return;
}
try
{
_logger.LogDebug("Clear folder");
// зачистка папки и удаление старого архива
var dirInfo = new DirectoryInfo(model.FolderName);
if (dirInfo.Exists)
{
foreach (var file in dirInfo.GetFiles())
{
file.Delete();
}
}
_logger.LogDebug("Delete archive");
string fileName = $"{model.FolderName}.zip";
if (File.Exists(fileName))
{
File.Delete(fileName);
}
// берем метод для сохранения
_logger.LogDebug("Get assembly");
var typeIId = typeof(IId);
var assembly = typeIId.Assembly;
if (assembly == null)
{
throw new ArgumentNullException("Сборка не найдена", nameof(assembly));
}
var types = assembly.GetTypes();
var method = GetType().GetMethod("SaveToFile", BindingFlags.NonPublic | BindingFlags.Instance);
_logger.LogDebug("Find {count} types", types.Length);
foreach (var type in types)
{
if (type.IsInterface && type.GetInterface(typeIId.Name) != null)
{
var modelType = _backUpInfo.GetTypeByModelInterface(type.Name);
if (modelType == null)
{
throw new InvalidOperationException($"Не найден класс-модель для {type.Name}");
}
_logger.LogDebug("Call SaveToFile method for {name} type", type.Name);
// вызываем метод на выполнение
method?.MakeGenericMethod(modelType).Invoke(this, new object[] { model.FolderName });
}
}
_logger.LogDebug("Create zip and remove folder");
ZipFile.CreateFromDirectory(model.FolderName, fileName);
dirInfo.Delete(true);
}
catch (Exception)
{
throw;
}
}
private void SaveToFile<T>(string folderName) where T : class, new()
{
var records = _backUpInfo.GetList<T>();
if (records == null)
{
_logger.LogWarning("{type} type get null list", typeof(T).Name);
return;
}
var jsonFormatter = new DataContractJsonSerializer(typeof(List<T>));
using var fs = new FileStream(string.Format("{0}/{1}.json", folderName, typeof(T).Name), FileMode.OpenOrCreate);
jsonFormatter.WriteObject(fs, records);
}
}
}

View File

@ -0,0 +1,23 @@
using SofrwareInstallationContracts.DI;
using SofrwareInstallationContracts.StoragesContracts;
using SoftwareInstallationDataBaseImplement.Implements;
namespace SoftwareInstallationDataBaseImplement
{
public class DatabaseImplementationExtension : IImplementationExtension
{
public int Priority => 2;
public void RegisterServices()
{
DependencyManager.Instance.RegisterType<IClientStorage, ClientStorage>();
DependencyManager.Instance.RegisterType<IComponentStorage, ComponentStorage>();
DependencyManager.Instance.RegisterType<IImplementerStorage, ImplementerStorage>();
DependencyManager.Instance.RegisterType<IMessageInfoStorage, MessageInfoStorage>();
DependencyManager.Instance.RegisterType<IOrderStorage, OrderStorage>();
DependencyManager.Instance.RegisterType<IPackageStorage, PackageStorage>();
DependencyManager.Instance.RegisterType<IBackUpInfo, BackUpInfo>();
}
}
}

View File

@ -0,0 +1,29 @@
using SofrwareInstallationContracts.StoragesContracts;
namespace SoftwareInstallationDataBaseImplement.Implements
{
public class BackUpInfo : IBackUpInfo
{
public List<T>? GetList<T>() where T : class, new()
{
using var context = new SoftwareInstallationDataBase();
return context.Set<T>().ToList();
}
public Type? GetTypeByModelInterface(string modelInterfaceName)
{
var assembly = typeof(BackUpInfo).Assembly;
var types = assembly.GetTypes();
foreach (var type in types)
{
if (type.IsClass && type.GetInterface(modelInterfaceName) != null)
{
return type;
}
}
return null;
}
}
}

View File

@ -1,390 +0,0 @@
// <auto-generated />
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using SoftwareInstallationDataBaseImplement;
#nullable disable
namespace SoftwareInstallationDataBaseImplement.Migrations
{
[DbContext(typeof(SoftwareInstallationDataBase))]
[Migration("20230504171714_InitDb")]
partial class InitDb
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "7.0.3")
.HasAnnotation("Relational:MaxIdentifierLength", 128);
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
modelBuilder.Entity("SoftwareInstallationDataBaseImplement.Models.Client", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("ClientFIO")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Email")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Password")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("Clients");
});
modelBuilder.Entity("SoftwareInstallationDataBaseImplement.Models.Component", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("ComponentName")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<double>("Cost")
.HasColumnType("float");
b.HasKey("Id");
b.ToTable("Components");
});
modelBuilder.Entity("SoftwareInstallationDataBaseImplement.Models.Implementer", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("ImplementerFIO")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Password")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<int>("Qualification")
.HasColumnType("int");
b.Property<int>("WorkExperience")
.HasColumnType("int");
b.HasKey("Id");
b.ToTable("Implementers");
});
modelBuilder.Entity("SoftwareInstallationDataBaseImplement.Models.Message", b =>
{
b.Property<string>("MessageId")
.HasColumnType("nvarchar(450)");
b.Property<string>("Body")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<int?>("ClientId")
.IsRequired()
.HasColumnType("int");
b.Property<DateTime>("DateDelivery")
.HasColumnType("datetime2");
b.Property<bool>("HasRead")
.HasColumnType("bit");
b.Property<string>("Reply")
.HasColumnType("nvarchar(max)");
b.Property<string>("SenderName")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Subject")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("MessageId");
b.HasIndex("ClientId");
b.ToTable("Messages");
});
modelBuilder.Entity("SoftwareInstallationDataBaseImplement.Models.Order", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("ClientId")
.HasColumnType("int");
b.Property<int>("Count")
.HasColumnType("int");
b.Property<DateTime>("DateCreate")
.HasColumnType("datetime2");
b.Property<DateTime?>("DateImplement")
.HasColumnType("datetime2");
b.Property<int?>("ImplementerId")
.HasColumnType("int");
b.Property<int>("PackageId")
.HasColumnType("int");
b.Property<string>("PackageName")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<int>("Status")
.HasColumnType("int");
b.Property<double>("Sum")
.HasColumnType("float");
b.HasKey("Id");
b.HasIndex("ClientId");
b.HasIndex("ImplementerId");
b.HasIndex("PackageId");
b.ToTable("Orders");
});
modelBuilder.Entity("SoftwareInstallationDataBaseImplement.Models.Package", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("PackageName")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<double>("Price")
.HasColumnType("float");
b.HasKey("Id");
b.ToTable("Packages");
});
modelBuilder.Entity("SoftwareInstallationDataBaseImplement.Models.PackageComponent", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("ComponentId")
.HasColumnType("int");
b.Property<int>("Count")
.HasColumnType("int");
b.Property<int>("PackageId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("ComponentId");
b.HasIndex("PackageId");
b.ToTable("PackageComponents");
});
modelBuilder.Entity("SoftwareInstallationDataBaseImplement.Models.Store", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<DateTime>("OpeningDate")
.HasColumnType("datetime2");
b.Property<int>("PackageMaxCount")
.HasColumnType("int");
b.Property<string>("StoreAdress")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("StoreName")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("Stores");
});
modelBuilder.Entity("SoftwareInstallationDataBaseImplement.Models.StorePackage", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("Count")
.HasColumnType("int");
b.Property<int>("PackageId")
.HasColumnType("int");
b.Property<int>("StoreId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("PackageId");
b.HasIndex("StoreId");
b.ToTable("StorePackages");
});
modelBuilder.Entity("SoftwareInstallationDataBaseImplement.Models.Message", b =>
{
b.HasOne("SoftwareInstallationDataBaseImplement.Models.Client", "Client")
.WithMany("Messages")
.HasForeignKey("ClientId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Client");
});
modelBuilder.Entity("SoftwareInstallationDataBaseImplement.Models.Order", b =>
{
b.HasOne("SoftwareInstallationDataBaseImplement.Models.Client", "Client")
.WithMany("Orders")
.HasForeignKey("ClientId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("SoftwareInstallationDataBaseImplement.Models.Implementer", "Implementer")
.WithMany("Orders")
.HasForeignKey("ImplementerId");
b.HasOne("SoftwareInstallationDataBaseImplement.Models.Package", "Package")
.WithMany("Orders")
.HasForeignKey("PackageId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Client");
b.Navigation("Implementer");
b.Navigation("Package");
});
modelBuilder.Entity("SoftwareInstallationDataBaseImplement.Models.PackageComponent", b =>
{
b.HasOne("SoftwareInstallationDataBaseImplement.Models.Component", "Component")
.WithMany("PackageComponents")
.HasForeignKey("ComponentId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("SoftwareInstallationDataBaseImplement.Models.Package", "Package")
.WithMany("Components")
.HasForeignKey("PackageId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Component");
b.Navigation("Package");
});
modelBuilder.Entity("SoftwareInstallationDataBaseImplement.Models.StorePackage", b =>
{
b.HasOne("SoftwareInstallationDataBaseImplement.Models.Package", "Package")
.WithMany("StorePackages")
.HasForeignKey("PackageId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("SoftwareInstallationDataBaseImplement.Models.Store", "Store")
.WithMany("Packages")
.HasForeignKey("StoreId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Package");
b.Navigation("Store");
});
modelBuilder.Entity("SoftwareInstallationDataBaseImplement.Models.Client", b =>
{
b.Navigation("Messages");
b.Navigation("Orders");
});
modelBuilder.Entity("SoftwareInstallationDataBaseImplement.Models.Component", b =>
{
b.Navigation("PackageComponents");
});
modelBuilder.Entity("SoftwareInstallationDataBaseImplement.Models.Implementer", b =>
{
b.Navigation("Orders");
});
modelBuilder.Entity("SoftwareInstallationDataBaseImplement.Models.Package", b =>
{
b.Navigation("Components");
b.Navigation("Orders");
b.Navigation("StorePackages");
});
modelBuilder.Entity("SoftwareInstallationDataBaseImplement.Models.Store", b =>
{
b.Navigation("Packages");
});
#pragma warning restore 612, 618
}
}
}

View File

@ -1,277 +0,0 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace SoftwareInstallationDataBaseImplement.Migrations
{
/// <inheritdoc />
public partial class InitDb : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Clients",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
ClientFIO = table.Column<string>(type: "nvarchar(max)", nullable: false),
Email = table.Column<string>(type: "nvarchar(max)", nullable: false),
Password = table.Column<string>(type: "nvarchar(max)", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Clients", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Components",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
ComponentName = table.Column<string>(type: "nvarchar(max)", nullable: false),
Cost = table.Column<double>(type: "float", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Components", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Implementers",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
ImplementerFIO = table.Column<string>(type: "nvarchar(max)", nullable: false),
Password = table.Column<string>(type: "nvarchar(max)", nullable: false),
WorkExperience = table.Column<int>(type: "int", nullable: false),
Qualification = table.Column<int>(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Implementers", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Packages",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
PackageName = table.Column<string>(type: "nvarchar(max)", nullable: false),
Price = table.Column<double>(type: "float", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Packages", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Stores",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
StoreName = table.Column<string>(type: "nvarchar(max)", nullable: false),
StoreAdress = table.Column<string>(type: "nvarchar(max)", nullable: false),
OpeningDate = table.Column<DateTime>(type: "datetime2", nullable: false),
PackageMaxCount = table.Column<int>(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Stores", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Messages",
columns: table => new
{
MessageId = table.Column<string>(type: "nvarchar(450)", nullable: false),
ClientId = table.Column<int>(type: "int", nullable: false),
SenderName = table.Column<string>(type: "nvarchar(max)", nullable: false),
DateDelivery = table.Column<DateTime>(type: "datetime2", nullable: false),
Subject = table.Column<string>(type: "nvarchar(max)", nullable: false),
Body = table.Column<string>(type: "nvarchar(max)", nullable: false),
HasRead = table.Column<bool>(type: "bit", nullable: false),
Reply = table.Column<string>(type: "nvarchar(max)", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Messages", x => x.MessageId);
table.ForeignKey(
name: "FK_Messages_Clients_ClientId",
column: x => x.ClientId,
principalTable: "Clients",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "Orders",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
PackageId = table.Column<int>(type: "int", nullable: false),
ImplementerId = table.Column<int>(type: "int", nullable: true),
ClientId = table.Column<int>(type: "int", nullable: false),
PackageName = table.Column<string>(type: "nvarchar(max)", nullable: false),
Count = table.Column<int>(type: "int", nullable: false),
Sum = table.Column<double>(type: "float", nullable: false),
Status = table.Column<int>(type: "int", nullable: false),
DateCreate = table.Column<DateTime>(type: "datetime2", nullable: false),
DateImplement = table.Column<DateTime>(type: "datetime2", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Orders", x => x.Id);
table.ForeignKey(
name: "FK_Orders_Clients_ClientId",
column: x => x.ClientId,
principalTable: "Clients",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_Orders_Implementers_ImplementerId",
column: x => x.ImplementerId,
principalTable: "Implementers",
principalColumn: "Id");
table.ForeignKey(
name: "FK_Orders_Packages_PackageId",
column: x => x.PackageId,
principalTable: "Packages",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "PackageComponents",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
PackageId = table.Column<int>(type: "int", nullable: false),
ComponentId = table.Column<int>(type: "int", nullable: false),
Count = table.Column<int>(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_PackageComponents", x => x.Id);
table.ForeignKey(
name: "FK_PackageComponents_Components_ComponentId",
column: x => x.ComponentId,
principalTable: "Components",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_PackageComponents_Packages_PackageId",
column: x => x.PackageId,
principalTable: "Packages",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "StorePackages",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
PackageId = table.Column<int>(type: "int", nullable: false),
StoreId = table.Column<int>(type: "int", nullable: false),
Count = table.Column<int>(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_StorePackages", x => x.Id);
table.ForeignKey(
name: "FK_StorePackages_Packages_PackageId",
column: x => x.PackageId,
principalTable: "Packages",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_StorePackages_Stores_StoreId",
column: x => x.StoreId,
principalTable: "Stores",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_Messages_ClientId",
table: "Messages",
column: "ClientId");
migrationBuilder.CreateIndex(
name: "IX_Orders_ClientId",
table: "Orders",
column: "ClientId");
migrationBuilder.CreateIndex(
name: "IX_Orders_ImplementerId",
table: "Orders",
column: "ImplementerId");
migrationBuilder.CreateIndex(
name: "IX_Orders_PackageId",
table: "Orders",
column: "PackageId");
migrationBuilder.CreateIndex(
name: "IX_PackageComponents_ComponentId",
table: "PackageComponents",
column: "ComponentId");
migrationBuilder.CreateIndex(
name: "IX_PackageComponents_PackageId",
table: "PackageComponents",
column: "PackageId");
migrationBuilder.CreateIndex(
name: "IX_StorePackages_PackageId",
table: "StorePackages",
column: "PackageId");
migrationBuilder.CreateIndex(
name: "IX_StorePackages_StoreId",
table: "StorePackages",
column: "StoreId");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "Messages");
migrationBuilder.DropTable(
name: "Orders");
migrationBuilder.DropTable(
name: "PackageComponents");
migrationBuilder.DropTable(
name: "StorePackages");
migrationBuilder.DropTable(
name: "Clients");
migrationBuilder.DropTable(
name: "Implementers");
migrationBuilder.DropTable(
name: "Components");
migrationBuilder.DropTable(
name: "Packages");
migrationBuilder.DropTable(
name: "Stores");
}
}
}

View File

@ -3,17 +3,23 @@ using SofrwareInstallationContracts.ViewModels;
using SoftwareInstallationDataModels.Models; using SoftwareInstallationDataModels.Models;
using System.ComponentModel.DataAnnotations.Schema; using System.ComponentModel.DataAnnotations.Schema;
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using System.Runtime.Serialization;
namespace SoftwareInstallationDataBaseImplement.Models namespace SoftwareInstallationDataBaseImplement.Models
{ {
[DataContract]
public class Client : IClientModel public class Client : IClientModel
{ {
[DataMember]
public int Id { get; private set; } public int Id { get; private set; }
[Required] [Required]
[DataMember]
public string ClientFIO { get; set; } = string.Empty; public string ClientFIO { get; set; } = string.Empty;
[Required] [Required]
[DataMember]
public string Email { get; set; } = string.Empty; public string Email { get; set; } = string.Empty;
[Required] [Required]
[DataMember]
public string Password { get; set; } = string.Empty; public string Password { get; set; } = string.Empty;
[ForeignKey("ClientId")] [ForeignKey("ClientId")]

View File

@ -3,17 +3,22 @@ using SofrwareInstallationContracts.ViewModels;
using SoftwareInstallationDataModels.Models; using SoftwareInstallationDataModels.Models;
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema; using System.ComponentModel.DataAnnotations.Schema;
using System.Runtime.Serialization;
namespace SoftwareInstallationDataBaseImplement.Models namespace SoftwareInstallationDataBaseImplement.Models
{ {
[DataContract]
public class Component : IComponentModel public class Component : IComponentModel
{ {
[DataMember]
public int Id { get; private set; } public int Id { get; private set; }
[Required] [Required]
[DataMember]
public string ComponentName { get; private set; } = string.Empty; public string ComponentName { get; private set; } = string.Empty;
[Required] [Required]
[DataMember]
public double Cost { get; set; } public double Cost { get; set; }
[ForeignKey("ComponentId")] [ForeignKey("ComponentId")]

View File

@ -3,23 +3,30 @@ using SofrwareInstallationContracts.ViewModels;
using SoftwareInstallationDataModels.Models; using SoftwareInstallationDataModels.Models;
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema; using System.ComponentModel.DataAnnotations.Schema;
using System.Runtime.Serialization;
namespace SoftwareInstallationDataBaseImplement.Models namespace SoftwareInstallationDataBaseImplement.Models
{ {
[DataContract]
public class Implementer : IImplementerModel public class Implementer : IImplementerModel
{ {
[Required] [Required]
[DataMember]
public string ImplementerFIO { get; private set; } = string.Empty; public string ImplementerFIO { get; private set; } = string.Empty;
[Required] [Required]
[DataMember]
public string Password { get; private set; } = string.Empty; public string Password { get; private set; } = string.Empty;
[Required] [Required]
[DataMember]
public int WorkExperience { get; private set; } public int WorkExperience { get; private set; }
[Required] [Required]
[DataMember]
public int Qualification { get; private set; } public int Qualification { get; private set; }
[DataMember]
public int Id { get; private set; } public int Id { get; private set; }
[ForeignKey("ImplementerId")] [ForeignKey("ImplementerId")]

View File

@ -2,21 +2,29 @@
using SofrwareInstallationContracts.ViewModels; using SofrwareInstallationContracts.ViewModels;
using SoftwareInstallationDataModels.Models; using SoftwareInstallationDataModels.Models;
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using System.Runtime.Serialization;
namespace SoftwareInstallationDataBaseImplement.Models namespace SoftwareInstallationDataBaseImplement.Models
{ {
[DataContract]
public class Message : IMessageInfoModel public class Message : IMessageInfoModel
{ {
[Key] [Key]
[DataMember]
public string MessageId { get; private set; } = string.Empty; public string MessageId { get; private set; } = string.Empty;
[DataMember]
public int? ClientId { get; private set; } public int? ClientId { get; private set; }
[Required] [Required]
[DataMember]
public string SenderName { get; private set; } = string.Empty; public string SenderName { get; private set; } = string.Empty;
[Required] [Required]
[DataMember]
public DateTime DateDelivery { get; private set; } = DateTime.Now; public DateTime DateDelivery { get; private set; } = DateTime.Now;
[Required] [Required]
[DataMember]
public string Subject { get; private set; } = string.Empty; public string Subject { get; private set; } = string.Empty;
[Required] [Required]
[DataMember]
public string Body { get; private set; } = string.Empty; public string Body { get; private set; } = string.Empty;
[Required] [Required]
public bool HasRead { get; private set; } public bool HasRead { get; private set; }
@ -65,5 +73,7 @@ namespace SoftwareInstallationDataBaseImplement.Models
SenderName = SenderName, SenderName = SenderName,
DateDelivery = DateDelivery, DateDelivery = DateDelivery,
}; };
public int Id => throw new NotImplementedException();
} }
} }

View File

@ -3,34 +3,46 @@ using SofrwareInstallationContracts.ViewModels;
using SoftwareInstallationDataModels.Enums; using SoftwareInstallationDataModels.Enums;
using SoftwareInstallationDataModels.Models; using SoftwareInstallationDataModels.Models;
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using System.Runtime.Serialization;
namespace SoftwareInstallationDataBaseImplement.Models namespace SoftwareInstallationDataBaseImplement.Models
{ {
[DataContract]
public class Order : IOrderModel public class Order : IOrderModel
{ {
[DataMember]
public int Id { get; private set; } public int Id { get; private set; }
[DataMember]
public int PackageId { get; private set; } public int PackageId { get; private set; }
[DataMember]
public int? ImplementerId { get; private set; } public int? ImplementerId { get; private set; }
[Required] [Required]
[DataMember]
public int ClientId { get; set; } public int ClientId { get; set; }
[DataMember]
public string PackageName { get; private set; } = string.Empty; public string PackageName { get; private set; } = string.Empty;
[Required] [Required]
[DataMember]
public int Count { get; private set; } public int Count { get; private set; }
[Required] [Required]
[DataMember]
public double Sum { get; private set; } public double Sum { get; private set; }
[Required] [Required]
[DataMember]
public OrderStatus Status { get; private set; } = OrderStatus.Неизвестен; public OrderStatus Status { get; private set; } = OrderStatus.Неизвестен;
[Required] [Required]
[DataMember]
public DateTime DateCreate { get; private set; } = DateTime.Now; public DateTime DateCreate { get; private set; } = DateTime.Now;
[DataMember]
public DateTime? DateImplement { get; private set; } public DateTime? DateImplement { get; private set; }
public virtual Package Package { get; set; } public virtual Package Package { get; set; }

View File

@ -3,22 +3,28 @@ using SofrwareInstallationContracts.ViewModels;
using SoftwareInstallationDataModels.Models; using SoftwareInstallationDataModels.Models;
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema; using System.ComponentModel.DataAnnotations.Schema;
using System.Runtime.Serialization;
namespace SoftwareInstallationDataBaseImplement.Models namespace SoftwareInstallationDataBaseImplement.Models
{ {
[DataContract]
public class Package : IPackageModel public class Package : IPackageModel
{ {
[DataMember]
public int Id { get; set; } public int Id { get; set; }
[Required] [Required]
[DataMember]
public string PackageName { get; set; } = string.Empty; public string PackageName { get; set; } = string.Empty;
[Required] [Required]
[DataMember]
public double Price { get; set; } public double Price { get; set; }
private Dictionary<int, (IComponentModel, int)>? _packageComponents = null; private Dictionary<int, (IComponentModel, int)>? _packageComponents = null;
[NotMapped] [NotMapped]
[DataMember]
public Dictionary<int, (IComponentModel, int)> PackageComponents public Dictionary<int, (IComponentModel, int)> PackageComponents
{ {
get get

View File

@ -9,7 +9,7 @@ namespace SoftwareInstallationDataBaseImplement
{ {
if (optionsBuilder.IsConfigured == false) if (optionsBuilder.IsConfigured == false)
{ {
optionsBuilder.UseSqlServer(@"Data Source=COMP-AVZH\SQLEXPRESS;Initial Catalog=SoftwareInstallationDataBaseHardFulllab7;Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True"); optionsBuilder.UseSqlServer(@"Data Source=COMP-AVZH\SQLEXPRESS;Initial Catalog=SoftwareInstallationDataBaseFulllab8;Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True");
} }
base.OnConfiguring(optionsBuilder); base.OnConfiguring(optionsBuilder);
} }

View File

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

View File

@ -1,6 +1,6 @@
namespace SoftwareInstallationDataModels.Models namespace SoftwareInstallationDataModels.Models
{ {
public interface IMessageInfoModel public interface IMessageInfoModel : IId
{ {
string MessageId { get; } string MessageId { get; }
int? ClientId { get; } int? ClientId { get; }

View File

@ -0,0 +1,22 @@
using SofrwareInstallationContracts.DI;
using SofrwareInstallationContracts.StoragesContracts;
using SoftwareInstallationFileImplement.Implements;
namespace SoftwareInstallationFileImplement
{
public class FileImplementationExtension : IImplementationExtension
{
public int Priority => 1;
public void RegisterServices()
{
DependencyManager.Instance.RegisterType<IClientStorage, ClientStorage>();
DependencyManager.Instance.RegisterType<IComponentStorage, ComponentStorage>();
DependencyManager.Instance.RegisterType<IImplementerStorage, ImplementerStorage>();
DependencyManager.Instance.RegisterType<IMessageInfoStorage, MessageInfoStorage>();
DependencyManager.Instance.RegisterType<IOrderStorage, OrderStorage>();
DependencyManager.Instance.RegisterType<IPackageStorage, PackageStorage>();
DependencyManager.Instance.RegisterType<IBackUpInfo, BackUpInfo>();
}
}
}

View File

@ -0,0 +1,32 @@
using SofrwareInstallationContracts.StoragesContracts;
namespace SoftwareInstallationFileImplement.Implements
{
public class BackUpInfo : IBackUpInfo
{
public List<T>? GetList<T>() where T : class, new()
{
var source = DataFileSingleton.GetInstance();
return (List<T>?)source.GetType().GetProperties()
.FirstOrDefault(x => x.PropertyType.IsGenericType && x.PropertyType.GetGenericArguments()[0] == typeof(T))
?.GetValue(source);
}
public Type? GetTypeByModelInterface(string modelInterfaceName)
{
var assembly = typeof(BackUpInfo).Assembly;
var types = assembly.GetTypes();
foreach (var type in types)
{
if (type.IsClass && type.GetInterface(modelInterfaceName) != null)
{
return type;
}
}
return null;
}
}
}

View File

@ -1,15 +1,21 @@
using SofrwareInstallationContracts.BindingModels; using SofrwareInstallationContracts.BindingModels;
using SofrwareInstallationContracts.ViewModels; using SofrwareInstallationContracts.ViewModels;
using SoftwareInstallationDataModels.Models; using SoftwareInstallationDataModels.Models;
using System.Runtime.Serialization;
using System.Xml.Linq; using System.Xml.Linq;
namespace SoftwareInstallationFileImplement.Models namespace SoftwareInstallationFileImplement.Models
{ {
[DataContract]
public class Client : IClientModel public class Client : IClientModel
{ {
[DataMember]
public int Id { get; private set; } public int Id { get; private set; }
[DataMember]
public string ClientFIO { get; private set; } = string.Empty; public string ClientFIO { get; private set; } = string.Empty;
[DataMember]
public string Email { get; set; } = string.Empty; public string Email { get; set; } = string.Empty;
[DataMember]
public string Password { get; set; } = string.Empty; public string Password { get; set; } = string.Empty;
public static Client? Create(ClientBindingModel model) public static Client? Create(ClientBindingModel model)
{ {

View File

@ -1,16 +1,19 @@
using System.Xml.Linq; using System.Runtime.Serialization;
using System.Xml.Linq;
using SofrwareInstallationContracts.BindingModels; using SofrwareInstallationContracts.BindingModels;
using SofrwareInstallationContracts.ViewModels; using SofrwareInstallationContracts.ViewModels;
using SoftwareInstallationDataModels.Models; using SoftwareInstallationDataModels.Models;
namespace SoftwareInstallationFileImplement.Models namespace SoftwareInstallationFileImplement.Models
{ {
[DataContract]
public class Component : IComponentModel public class Component : IComponentModel
{ {
[DataMember]
public string ComponentName { get; private set; } = string.Empty; public string ComponentName { get; private set; } = string.Empty;
[DataMember]
public double Cost { get; set; } public double Cost { get; set; }
[DataMember]
public int Id { get; private set; } public int Id { get; private set; }
public static Component? Create(ComponentBindingModel model) public static Component? Create(ComponentBindingModel model)

View File

@ -1,20 +1,23 @@
using SofrwareInstallationContracts.BindingModels; using SofrwareInstallationContracts.BindingModels;
using SofrwareInstallationContracts.ViewModels; using SofrwareInstallationContracts.ViewModels;
using SoftwareInstallationDataModels.Models; using SoftwareInstallationDataModels.Models;
using System.Runtime.Serialization;
using System.Xml.Linq; using System.Xml.Linq;
namespace SoftwareInstallationFileImplement.Models namespace SoftwareInstallationFileImplement.Models
{ {
[DataContract]
public class Implementer : IImplementerModel public class Implementer : IImplementerModel
{ {
[DataMember]
public string ImplementerFIO { get; private set; } = string.Empty; public string ImplementerFIO { get; private set; } = string.Empty;
[DataMember]
public string Password { get; private set; } = string.Empty; public string Password { get; private set; } = string.Empty;
[DataMember]
public int WorkExperience { get; private set; } public int WorkExperience { get; private set; }
[DataMember]
public int Qualification { get; private set; } public int Qualification { get; private set; }
[DataMember]
public int Id { get; private set; } public int Id { get; private set; }
public static Implementer? Create(XElement element) public static Implementer? Create(XElement element)

View File

@ -1,22 +1,25 @@
using SofrwareInstallationContracts.BindingModels; using SofrwareInstallationContracts.BindingModels;
using SofrwareInstallationContracts.ViewModels; using SofrwareInstallationContracts.ViewModels;
using SoftwareInstallationDataModels.Models; using SoftwareInstallationDataModels.Models;
using System.Runtime.Serialization;
using System.Xml.Linq; using System.Xml.Linq;
namespace SoftwareInstallationFileImplement.Models namespace SoftwareInstallationFileImplement.Models
{ {
[DataContract]
public class Message : IMessageInfoModel public class Message : IMessageInfoModel
{ {
[DataMember]
public string MessageId { get; private set; } = string.Empty; public string MessageId { get; private set; } = string.Empty;
[DataMember]
public int? ClientId { get; private set; } public int? ClientId { get; private set; }
[DataMember]
public string SenderName { get; private set; } = string.Empty; public string SenderName { get; private set; } = string.Empty;
[DataMember]
public DateTime DateDelivery { get; private set; } = DateTime.Now; public DateTime DateDelivery { get; private set; } = DateTime.Now;
[DataMember]
public string Subject { get; private set; } = string.Empty; public string Subject { get; private set; } = string.Empty;
[DataMember]
public string Body { get; private set; } = string.Empty; public string Body { get; private set; } = string.Empty;
public bool HasRead { get; private set; } public bool HasRead { get; private set; }
@ -93,5 +96,7 @@ namespace SoftwareInstallationFileImplement.Models
new XAttribute("SenderName", SenderName), new XAttribute("SenderName", SenderName),
new XAttribute("DateDelivery", DateDelivery) new XAttribute("DateDelivery", DateDelivery)
); );
public int Id => throw new NotImplementedException();
} }
} }

View File

@ -2,30 +2,33 @@
using SofrwareInstallationContracts.ViewModels; using SofrwareInstallationContracts.ViewModels;
using SoftwareInstallationDataModels.Enums; using SoftwareInstallationDataModels.Enums;
using SoftwareInstallationDataModels.Models; using SoftwareInstallationDataModels.Models;
using System.Runtime.Serialization;
using System.Xml.Linq; using System.Xml.Linq;
namespace SoftwareInstallationFileImplement.Models namespace SoftwareInstallationFileImplement.Models
{ {
[DataContract]
public class Order : IOrderModel public class Order : IOrderModel
{ {
[DataMember]
public int PackageId { get; private set; } public int PackageId { get; private set; }
[DataMember]
public int? ImplementerId { get; set; } public int? ImplementerId { get; set; }
[DataMember]
public int ClientId { get; private set; } public int ClientId { get; private set; }
[DataMember]
public string PackageName { get; private set; } = string.Empty; public string PackageName { get; private set; } = string.Empty;
[DataMember]
public int Count { get; private set; } public int Count { get; private set; }
[DataMember]
public double Sum { get; private set; } public double Sum { get; private set; }
[DataMember]
public OrderStatus Status { get; private set; } = OrderStatus.Неизвестен; public OrderStatus Status { get; private set; } = OrderStatus.Неизвестен;
[DataMember]
public DateTime DateCreate { get; private set; } = DateTime.Now; public DateTime DateCreate { get; private set; } = DateTime.Now;
[DataMember]
public DateTime? DateImplement { get; private set; } public DateTime? DateImplement { get; private set; }
[DataMember]
public int Id { get; private set; } public int Id { get; private set; }
public static Order? Create(OrderBindingModel model) public static Order? Create(OrderBindingModel model)
@ -56,22 +59,22 @@ namespace SoftwareInstallationFileImplement.Models
return null; return null;
} }
DateTime.TryParse(element.Element("DateImplement")!.Value, out DateTime dateImpl);
var order = new Order() var order = new Order()
{ {
PackageName = element.Element("PackageName")!.Value,
Id = Convert.ToInt32(element.Attribute("Id")!.Value), Id = Convert.ToInt32(element.Attribute("Id")!.Value),
ImplementerId = Convert.ToInt32(element.Element("ImplementerId")!.Value), ImplementerId = Convert.ToInt32(element.Element("ImplementerId")!.Value),
PackageId = Convert.ToInt32(element.Element("PackageId")!.Value), PackageId = Convert.ToInt32(element.Element("PackageId")!.Value),
ClientId = Convert.ToInt32(element.Element("ClientId")!.Value), ClientId = Convert.ToInt32(element.Element("ClientId")!.Value),
PackageName = element.Element("PackageName")!.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)Convert.ToInt32(element.Element("Status")!.Value),
DateCreate = DateTime.ParseExact(element.Element("DateCreate")!.Value, "G", null) DateCreate = DateTime.ParseExact(element.Element("DateCreate")!.Value, "G", null),
DateImplement = dateImpl
}; };
DateTime.TryParse(element.Element("DateImplement")!.Value, out DateTime dateImpl);
order.DateImplement = dateImpl;
return order; return order;
} }

View File

@ -1,20 +1,23 @@
using SofrwareInstallationContracts.BindingModels; using SofrwareInstallationContracts.BindingModels;
using SofrwareInstallationContracts.ViewModels; using SofrwareInstallationContracts.ViewModels;
using SoftwareInstallationDataModels.Models; using SoftwareInstallationDataModels.Models;
using System.Runtime.Serialization;
using System.Xml.Linq; using System.Xml.Linq;
namespace SoftwareInstallationFileImplement.Models namespace SoftwareInstallationFileImplement.Models
{ {
[DataContract]
public class Package : IPackageModel public class Package : IPackageModel
{ {
[DataMember]
public string PackageName { get; private set; } = string.Empty; public string PackageName { get; private set; } = string.Empty;
[DataMember]
public double Price { get; private set; } public double Price { get; private set; }
public Dictionary<int, int> Components { get; private set; } = new(); public Dictionary<int, int> Components { get; private set; } = new();
public Dictionary<int, (IComponentModel, int)> _packageComponents = null; public Dictionary<int, (IComponentModel, int)> _packageComponents = null;
[DataMember]
public Dictionary<int, (IComponentModel, int)> PackageComponents public Dictionary<int, (IComponentModel, int)> PackageComponents
{ {
get get
@ -27,7 +30,7 @@ namespace SoftwareInstallationFileImplement.Models
return _packageComponents; return _packageComponents;
} }
} }
[DataMember]
public int Id { get; private set; } public int Id { get; private set; }
public static Package? Create(PackageBindingModel model) public static Package? Create(PackageBindingModel model)

View File

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

View File

@ -0,0 +1,17 @@
using SofrwareInstallationContracts.StoragesContracts;
namespace SoftwareInstallationListImplement.Implements
{
public class BackUpInfo : IBackUpInfo
{
public List<T>? GetList<T>() where T : class, new()
{
throw new NotImplementedException();
}
public Type? GetTypeByModelInterface(string modelInterfaceName)
{
throw new NotImplementedException();
}
}
}

View File

@ -0,0 +1,23 @@
using SofrwareInstallationContracts.DI;
using SofrwareInstallationContracts.StoragesContracts;
using SoftwareInstallationListImplement.Implements;
namespace SoftwareInstallationListImplement
{
public class ListImplementationExtension : IImplementationExtension
{
public int Priority => 0;
public void RegisterServices()
{
DependencyManager.Instance.RegisterType<IClientStorage, ClientStorage>();
DependencyManager.Instance.RegisterType<IComponentStorage, ComponentStorage>();
DependencyManager.Instance.RegisterType<IImplementerStorage, ImplementerStorage>();
DependencyManager.Instance.RegisterType<IMessageInfoStorage, MessageInfoStorage>();
DependencyManager.Instance.RegisterType<IOrderStorage, OrderStorage>();
DependencyManager.Instance.RegisterType<IPackageStorage, PackageStorage>();
DependencyManager.Instance.RegisterType<IBackUpInfo, BackUpInfo>();
}
}
}

View File

@ -67,5 +67,7 @@ namespace SoftwareInstallationListImplement.Models
ClientId = ClientId, ClientId = ClientId,
MessageId = MessageId MessageId = MessageId
}; };
public int Id => throw new NotImplementedException();
} }
} }

View File

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