diff --git a/.gitignore b/.gitignore index ca1c7a3..52737dc 100644 --- a/.gitignore +++ b/.gitignore @@ -14,6 +14,9 @@ # User-specific files (MonoDevelop/Xamarin Studio) *.userprefs +# dll файлы +*.dll + # Mono auto generated files mono_crash.* diff --git a/SoftwareInstallation/SofrwareInstallationContracts/Attributes/ColumnAttribute.cs b/SoftwareInstallation/SofrwareInstallationContracts/Attributes/ColumnAttribute.cs new file mode 100644 index 0000000..ce3f82c --- /dev/null +++ b/SoftwareInstallation/SofrwareInstallationContracts/Attributes/ColumnAttribute.cs @@ -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; } + } +} diff --git a/SoftwareInstallation/SofrwareInstallationContracts/Attributes/GridViewAutoSize.cs b/SoftwareInstallation/SofrwareInstallationContracts/Attributes/GridViewAutoSize.cs new file mode 100644 index 0000000..5b151b5 --- /dev/null +++ b/SoftwareInstallation/SofrwareInstallationContracts/Attributes/GridViewAutoSize.cs @@ -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 + } +} diff --git a/SoftwareInstallation/SofrwareInstallationContracts/BindingModels/BackUpSaveBinidngModel.cs b/SoftwareInstallation/SofrwareInstallationContracts/BindingModels/BackUpSaveBinidngModel.cs new file mode 100644 index 0000000..9eadf79 --- /dev/null +++ b/SoftwareInstallation/SofrwareInstallationContracts/BindingModels/BackUpSaveBinidngModel.cs @@ -0,0 +1,7 @@ +namespace SofrwareInstallationContracts.BindingModels +{ + public class BackUpSaveBinidngModel + { + public string FolderName { get; set; } = string.Empty; + } +} diff --git a/SoftwareInstallation/SofrwareInstallationContracts/BindingModels/MessageInfoBindingModel.cs b/SoftwareInstallation/SofrwareInstallationContracts/BindingModels/MessageInfoBindingModel.cs index ad14e2e..7362008 100644 --- a/SoftwareInstallation/SofrwareInstallationContracts/BindingModels/MessageInfoBindingModel.cs +++ b/SoftwareInstallation/SofrwareInstallationContracts/BindingModels/MessageInfoBindingModel.cs @@ -15,6 +15,8 @@ namespace SofrwareInstallationContracts.BindingModels public string Subject { get; set; } = string.Empty; public string Body { get; set; } = string.Empty; public DateTime DateDelivery { get; set; } + + public int Id => throw new NotImplementedException(); public bool HasRead { get; set; } public string? Reply { get; set; } } diff --git a/SoftwareInstallation/SofrwareInstallationContracts/BusinessLogicsContracts/IBackUpLogic.cs b/SoftwareInstallation/SofrwareInstallationContracts/BusinessLogicsContracts/IBackUpLogic.cs new file mode 100644 index 0000000..cd4d69e --- /dev/null +++ b/SoftwareInstallation/SofrwareInstallationContracts/BusinessLogicsContracts/IBackUpLogic.cs @@ -0,0 +1,9 @@ +using SofrwareInstallationContracts.BindingModels; + +namespace SofrwareInstallationContracts.BusinessLogicsContracts +{ + public interface IBackUpLogic + { + void CreateBackUp(BackUpSaveBinidngModel model); + } +} diff --git a/SoftwareInstallation/SofrwareInstallationContracts/DI/DependencyManager.cs b/SoftwareInstallation/SofrwareInstallationContracts/DI/DependencyManager.cs new file mode 100644 index 0000000..b81576e --- /dev/null +++ b/SoftwareInstallation/SofrwareInstallationContracts/DI/DependencyManager.cs @@ -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 configure) => _dependencyManager.AddLogging(configure); + + public void RegisterType(bool isSingle = false) where U : class, T where T : class => _dependencyManager.RegisterType(isSingle); + + public void RegisterType(bool isSingle = false) where T : class => _dependencyManager.RegisterType(isSingle); + + public T Resolve() => _dependencyManager.Resolve(); + } +} diff --git a/SoftwareInstallation/SofrwareInstallationContracts/DI/IDependencyContainer.cs b/SoftwareInstallation/SofrwareInstallationContracts/DI/IDependencyContainer.cs new file mode 100644 index 0000000..505ebf2 --- /dev/null +++ b/SoftwareInstallation/SofrwareInstallationContracts/DI/IDependencyContainer.cs @@ -0,0 +1,13 @@ +using Microsoft.Extensions.Logging; + +namespace SofrwareInstallationContracts.DI +{ + public interface IDependencyContainer + { + void AddLogging(Action configure); + void RegisterType(bool isSingle) where U : class, T where T : class; + void RegisterType(bool isSingle) where T : class; + T Resolve(); + + } +} diff --git a/SoftwareInstallation/SofrwareInstallationContracts/DI/IImplementationExtension.cs b/SoftwareInstallation/SofrwareInstallationContracts/DI/IImplementationExtension.cs new file mode 100644 index 0000000..eaf62cf --- /dev/null +++ b/SoftwareInstallation/SofrwareInstallationContracts/DI/IImplementationExtension.cs @@ -0,0 +1,8 @@ +namespace SofrwareInstallationContracts.DI +{ + public interface IImplementationExtension + { + public int Priority { get; } + public void RegisterServices(); + } +} diff --git a/SoftwareInstallation/SofrwareInstallationContracts/DI/ServiceDependencyContainer.cs b/SoftwareInstallation/SofrwareInstallationContracts/DI/ServiceDependencyContainer.cs new file mode 100644 index 0000000..2f169d0 --- /dev/null +++ b/SoftwareInstallation/SofrwareInstallationContracts/DI/ServiceDependencyContainer.cs @@ -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 configure) + { + _serviceCollection.AddLogging(configure); + } + + public void RegisterType(bool isSingle) where U : class, T where T : class + { + if (isSingle) + { + _serviceCollection.AddSingleton(); + } + else + { + _serviceCollection.AddTransient(); + } + + _serviceProvider = null; + } + + public void RegisterType(bool isSingle) where T : class + { + if (isSingle) + { + _serviceCollection.AddSingleton(); + } + else + { + _serviceCollection.AddTransient(); + } + + _serviceProvider = null; + } + + public T Resolve() + { + if (_serviceProvider == null) + { + _serviceProvider = _serviceCollection.BuildServiceProvider(); + } + + return _serviceProvider.GetService()!; + } + } +} diff --git a/SoftwareInstallation/SofrwareInstallationContracts/DI/ServiceProviderLoader.cs b/SoftwareInstallation/SofrwareInstallationContracts/DI/ServiceProviderLoader.cs new file mode 100644 index 0000000..15156bb --- /dev/null +++ b/SoftwareInstallation/SofrwareInstallationContracts/DI/ServiceProviderLoader.cs @@ -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"; + } + } +} diff --git a/SoftwareInstallation/SofrwareInstallationContracts/DI/UnityDependencyContainer .cs b/SoftwareInstallation/SofrwareInstallationContracts/DI/UnityDependencyContainer .cs new file mode 100644 index 0000000..ae8e591 --- /dev/null +++ b/SoftwareInstallation/SofrwareInstallationContracts/DI/UnityDependencyContainer .cs @@ -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 configure) + { + var factory = LoggerFactory.Create(configure); + _container.AddExtension(new LoggingExtension(factory)); + } + + public void RegisterType(bool isSingle) where T : class + { + _container.RegisterType(isSingle ? TypeLifetime.Singleton : TypeLifetime.Transient); + + } + + public T Resolve() + { + return _container.Resolve(); + } + + void IDependencyContainer.RegisterType(bool isSingle) + { + _container.RegisterType(isSingle ? TypeLifetime.Singleton : TypeLifetime.Transient); + } + } +} diff --git a/SoftwareInstallation/SofrwareInstallationContracts/SofrwareInstallationContracts.csproj b/SoftwareInstallation/SofrwareInstallationContracts/SofrwareInstallationContracts.csproj index 0c8e243..9ef1d66 100644 --- a/SoftwareInstallation/SofrwareInstallationContracts/SofrwareInstallationContracts.csproj +++ b/SoftwareInstallation/SofrwareInstallationContracts/SofrwareInstallationContracts.csproj @@ -38,6 +38,8 @@ + + diff --git a/SoftwareInstallation/SofrwareInstallationContracts/StoragesContracts/IBackUpInfo.cs b/SoftwareInstallation/SofrwareInstallationContracts/StoragesContracts/IBackUpInfo.cs new file mode 100644 index 0000000..2c85067 --- /dev/null +++ b/SoftwareInstallation/SofrwareInstallationContracts/StoragesContracts/IBackUpInfo.cs @@ -0,0 +1,8 @@ +namespace SofrwareInstallationContracts.StoragesContracts +{ + public interface IBackUpInfo + { + List? GetList() where T : class, new(); + Type? GetTypeByModelInterface(string modelInterfaceName); + } +} diff --git a/SoftwareInstallation/SofrwareInstallationContracts/ViewModels/ClientViewModel.cs b/SoftwareInstallation/SofrwareInstallationContracts/ViewModels/ClientViewModel.cs index ea7c455..7727563 100644 --- a/SoftwareInstallation/SofrwareInstallationContracts/ViewModels/ClientViewModel.cs +++ b/SoftwareInstallation/SofrwareInstallationContracts/ViewModels/ClientViewModel.cs @@ -1,16 +1,18 @@ using SoftwareInstallationDataModels.Models; using System.ComponentModel; +using SofrwareInstallationContracts.Attributes; namespace SofrwareInstallationContracts.ViewModels { public class ClientViewModel : IClientModel { + [Column(visible: false)] public int Id { get; set; } - [DisplayName("ФИО клиента")] + [Column("ФИО клиента", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)] public string ClientFIO { get; set; } = string.Empty; - [DisplayName("Логин (эл. почта)")] + [Column("Логин (эл. почта)", width: 150)] public string Email { get; set; } = string.Empty; - [DisplayName("Пароль")] + [Column("Пароль", width: 150)] public string Password { get; set; } = string.Empty; } diff --git a/SoftwareInstallation/SofrwareInstallationContracts/ViewModels/ComponentViewModel.cs b/SoftwareInstallation/SofrwareInstallationContracts/ViewModels/ComponentViewModel.cs index ee989bc..c153f5b 100644 --- a/SoftwareInstallation/SofrwareInstallationContracts/ViewModels/ComponentViewModel.cs +++ b/SoftwareInstallation/SofrwareInstallationContracts/ViewModels/ComponentViewModel.cs @@ -1,16 +1,18 @@ -using SoftwareInstallationDataModels.Models; +using SofrwareInstallationContracts.Attributes; +using SoftwareInstallationDataModels.Models; using System.ComponentModel; namespace SofrwareInstallationContracts.ViewModels { public class ComponentViewModel : IComponentModel { + [Column(visible: false)] public int Id { get; set; } - [DisplayName("Название компонента")] + [Column("Название компонента", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)] public string ComponentName { get; set; } = string.Empty; - [DisplayName("Цена")] + [Column("Цена", width: 80)] public double Cost { get; set; } } } diff --git a/SoftwareInstallation/SofrwareInstallationContracts/ViewModels/ImplementerViewModel.cs b/SoftwareInstallation/SofrwareInstallationContracts/ViewModels/ImplementerViewModel.cs index 0c5edac..8d44aae 100644 --- a/SoftwareInstallation/SofrwareInstallationContracts/ViewModels/ImplementerViewModel.cs +++ b/SoftwareInstallation/SofrwareInstallationContracts/ViewModels/ImplementerViewModel.cs @@ -1,22 +1,24 @@ -using SoftwareInstallationDataModels.Models; +using SofrwareInstallationContracts.Attributes; +using SoftwareInstallationDataModels.Models; using System.ComponentModel; namespace SofrwareInstallationContracts.ViewModels { public class ImplementerViewModel : IImplementerModel { + [Column(visible: false)] public int Id { get; set; } - [DisplayName("ФИО исполнителя")] + [Column("ФИО исполнителя", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)] public string ImplementerFIO { get; set; } = string.Empty; - [DisplayName("Пароль")] + [Column("Пароль", width: 150)] public string Password { get; set; } = string.Empty; - [DisplayName("Стаж работы")] + [Column("Стаж работы", gridViewAutoSize: GridViewAutoSize.AllCells, isUseAutoSize: true)] public int WorkExperience { get; set; } - [DisplayName("Квалификация")] + [Column("Квалификация", gridViewAutoSize: GridViewAutoSize.AllCells, isUseAutoSize: true)] public int Qualification { get; set; } } } diff --git a/SoftwareInstallation/SofrwareInstallationContracts/ViewModels/MessageInfoViewModel.cs b/SoftwareInstallation/SofrwareInstallationContracts/ViewModels/MessageInfoViewModel.cs index a8a4e5d..b92b28e 100644 --- a/SoftwareInstallation/SofrwareInstallationContracts/ViewModels/MessageInfoViewModel.cs +++ b/SoftwareInstallation/SofrwareInstallationContracts/ViewModels/MessageInfoViewModel.cs @@ -1,25 +1,30 @@ -using SoftwareInstallationDataModels.Models; +using SofrwareInstallationContracts.Attributes; +using SoftwareInstallationDataModels.Models; using System.ComponentModel; namespace SofrwareInstallationContracts.ViewModels { public class MessageInfoViewModel : IMessageInfoModel { + [Column(visible: false)] public string MessageId { get; set; } = string.Empty; - + + [Column(visible: false)] public int? ClientId { get; set; } - [DisplayName("Имя отправителя")] + [Column("Имя отправителя", gridViewAutoSize: GridViewAutoSize.DisplayedCells, isUseAutoSize: true)] public string SenderName { get; set; } = string.Empty; - - [DisplayName("Дата отправления")] + + [Column("Дата отправления", width: 100)] public DateTime DateDelivery { get; set; } - [DisplayName("Тема")] + [Column("Тема", width: 150)] public string Subject { get; set; } = string.Empty; - [DisplayName("Содержание")] + [Column("Содержание", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)] public string Body { get; set; } = string.Empty; + [Column(visible: false)] + public int Id => throw new NotImplementedException(); [DisplayName("Прочитано")] public bool HasRead { get; set; } diff --git a/SoftwareInstallation/SofrwareInstallationContracts/ViewModels/OrderViewModel.cs b/SoftwareInstallation/SofrwareInstallationContracts/ViewModels/OrderViewModel.cs index 93a1887..62f9d1b 100644 --- a/SoftwareInstallation/SofrwareInstallationContracts/ViewModels/OrderViewModel.cs +++ b/SoftwareInstallation/SofrwareInstallationContracts/ViewModels/OrderViewModel.cs @@ -1,4 +1,5 @@ -using SoftwareInstallationDataModels.Enums; +using SofrwareInstallationContracts.Attributes; +using SoftwareInstallationDataModels.Enums; using SoftwareInstallationDataModels.Models; using System.ComponentModel; @@ -6,37 +7,40 @@ namespace SofrwareInstallationContracts.ViewModels { public class OrderViewModel : IOrderModel { + [Column(visible: false)] public int PackageId { get; set; } + [Column(visible: false)] public int ClientId { get; set; } + [Column(visible: false)] public int? ImplementerId { get; set; } - [DisplayName("Номер")] + [Column("Номер", gridViewAutoSize: GridViewAutoSize.AllCells, isUseAutoSize: true)] public int Id { get; set; } - [DisplayName("ФИО исполнителя")] + [Column("ФИО исполнителя", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)] public string ImplementerFIO { get; set; } = string.Empty; - [DisplayName("Название изделия")] + [Column("Название изделия", gridViewAutoSize: GridViewAutoSize.AllCells, isUseAutoSize: true)] public string PackageName { get; set; } = string.Empty; - [DisplayName("Клиент")] + [Column("ФИО клиента", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)] public string ClientFIO { get; set; } = string.Empty; - [DisplayName("Количество")] - public int Count { get; set; } + [Column("Количество", gridViewAutoSize: GridViewAutoSize.AllCells, isUseAutoSize: true)] + public int Count { get; set; } - [DisplayName("Сумма")] + [Column("Сумма", gridViewAutoSize: GridViewAutoSize.AllCells, isUseAutoSize: true)] public double Sum { get; set; } - [DisplayName("Статус")] + [Column("Статус", gridViewAutoSize: GridViewAutoSize.AllCells, isUseAutoSize: true)] public OrderStatus Status { get; set; } = OrderStatus.Неизвестен; - [DisplayName("Дата создания")] + [Column("Дата создания", width: 100)] public DateTime DateCreate { get; set; } = DateTime.Now; - [DisplayName("Дата выполнения")] + [Column("Дата выполнения", width: 100)] public DateTime? DateImplement { get; set; } } } diff --git a/SoftwareInstallation/SofrwareInstallationContracts/ViewModels/PackageViewModel.cs b/SoftwareInstallation/SofrwareInstallationContracts/ViewModels/PackageViewModel.cs index e43c8e2..8b4761a 100644 --- a/SoftwareInstallation/SofrwareInstallationContracts/ViewModels/PackageViewModel.cs +++ b/SoftwareInstallation/SofrwareInstallationContracts/ViewModels/PackageViewModel.cs @@ -1,18 +1,21 @@ -using SoftwareInstallationDataModels.Models; +using SofrwareInstallationContracts.Attributes; +using SoftwareInstallationDataModels.Models; using System.ComponentModel; namespace SofrwareInstallationContracts.ViewModels { public class PackageViewModel : IPackageModel { + [Column(visible: false)] public int Id { get; set; } - [DisplayName("Название изделия")] + [Column("Название изделия", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)] public string PackageName { get; set; }=string.Empty; - [DisplayName("Цена")] + [Column("Цена", width: 100)] public double Price { get; set; } + [Column(visible: false)] public Dictionary PackageComponents { get; set; } = new(); } } diff --git a/SoftwareInstallation/SoftwareInstallation/DataGridViewExtension.cs b/SoftwareInstallation/SoftwareInstallation/DataGridViewExtension.cs new file mode 100644 index 0000000..b2526ba --- /dev/null +++ b/SoftwareInstallation/SoftwareInstallation/DataGridViewExtension.cs @@ -0,0 +1,53 @@ +using SofrwareInstallationContracts.Attributes; + +namespace SoftwareInstallationView +{ + public static class DataGridViewExtension + { + public static void FillandConfigGrid(this DataGridView grid, List? 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; + } + } + } + } + } +} diff --git a/SoftwareInstallation/SoftwareInstallation/FormClients.cs b/SoftwareInstallation/SoftwareInstallation/FormClients.cs index 807d1be..3700977 100644 --- a/SoftwareInstallation/SoftwareInstallation/FormClients.cs +++ b/SoftwareInstallation/SoftwareInstallation/FormClients.cs @@ -55,13 +55,7 @@ namespace SoftwareInstallationView { try { - var list = _logic.ReadList(null); - if (list != null) - { - DataGridView.DataSource = list; - DataGridView.Columns["Id"].Visible = false; - DataGridView.Columns["ClientFIO"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; - } + DataGridView.FillandConfigGrid(_logic.ReadList(null)); _logger.LogInformation("Загрузка клиентов"); } catch (Exception ex) diff --git a/SoftwareInstallation/SoftwareInstallation/FormComponents.cs b/SoftwareInstallation/SoftwareInstallation/FormComponents.cs index 01f514e..8ef1187 100644 --- a/SoftwareInstallation/SoftwareInstallation/FormComponents.cs +++ b/SoftwareInstallation/SoftwareInstallation/FormComponents.cs @@ -1,6 +1,8 @@ using Microsoft.Extensions.Logging; using SofrwareInstallationContracts.BindingModels; using SofrwareInstallationContracts.BusinessLogicsContracts; +using SofrwareInstallationContracts.DI; +using System.Windows.Forms; namespace SoftwareInstallationView { @@ -26,15 +28,7 @@ namespace SoftwareInstallationView { try { - var list = _logic.ReadList(null); - - if (list != null) - { - DataGridView.DataSource = list; - DataGridView.Columns["Id"].Visible = false; - DataGridView.Columns["ComponentName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; - } - + DataGridView.FillandConfigGrid(_logic.ReadList(null)); _logger.LogInformation("Загрузка компонентов"); } @@ -47,33 +41,26 @@ namespace SoftwareInstallationView private void AddButton_Click(object sender, EventArgs e) { - var service = Program.ServiceProvider?.GetService(typeof(FormComponent)); - - if (service is FormComponent form) + var form = DependencyManager.Instance.Resolve(); + if (form.ShowDialog() == DialogResult.OK) { + LoadData(); + } + } + + private void ChangeButton_Click(object sender, EventArgs e) + { + if (DataGridView.SelectedRows.Count == 1) + { + var form = DependencyManager.Instance.Resolve(); + form.Id = Convert.ToInt32(DataGridView.SelectedRows[0].Cells["Id"].Value); if (form.ShowDialog() == DialogResult.OK) { LoadData(); } } } - private void ChangeButton_Click(object sender, EventArgs e) - { - if (DataGridView.SelectedRows.Count == 1) - { - var service = Program.ServiceProvider?.GetService(typeof(FormComponent)); - if (service is FormComponent form) - { - form.Id = Convert.ToInt32(DataGridView.SelectedRows[0].Cells["Id"].Value); - - if (form.ShowDialog() == DialogResult.OK) - { - LoadData(); - } - } - } - } private void DeleteButton_Click(object sender, EventArgs e) { if (DataGridView.SelectedRows.Count == 1) diff --git a/SoftwareInstallation/SoftwareInstallation/FormImplementers.cs b/SoftwareInstallation/SoftwareInstallation/FormImplementers.cs index b4a4305..202ac32 100644 --- a/SoftwareInstallation/SoftwareInstallation/FormImplementers.cs +++ b/SoftwareInstallation/SoftwareInstallation/FormImplementers.cs @@ -1,6 +1,7 @@ using Microsoft.Extensions.Logging; using SofrwareInstallationContracts.BindingModels; using SofrwareInstallationContracts.BusinessLogicsContracts; +using SofrwareInstallationContracts.DI; using System; using System.Collections.Generic; using System.ComponentModel; @@ -26,14 +27,11 @@ namespace SoftwareInstallationView private void AddButton_Click(object sender, EventArgs e) { - var service = Program.ServiceProvider?.GetService(typeof(FormImplementer)); - - if (service is FormImplementer form) + var form = DependencyManager.Instance.Resolve(); + + if (form.ShowDialog() == DialogResult.OK) { - if (form.ShowDialog() == DialogResult.OK) - { - LoadData(); - } + LoadData(); } } @@ -41,14 +39,13 @@ namespace SoftwareInstallationView { if (DataGridView.SelectedRows.Count == 1) { - var service = Program.ServiceProvider?.GetService(typeof(FormImplementer)); - if (service is FormImplementer form) + var form = DependencyManager.Instance.Resolve(); + + form.Id = Convert.ToInt32(DataGridView.SelectedRows[0].Cells["Id"].Value); + + if (form.ShowDialog() == DialogResult.OK) { - form.Id = Convert.ToInt32(DataGridView.SelectedRows[0].Cells["Id"].Value); - if (form.ShowDialog() == DialogResult.OK) - { - LoadData(); - } + LoadData(); } } } @@ -98,15 +95,7 @@ namespace SoftwareInstallationView { try { - var list = _logic.ReadList(null); - - if (list != null) - { - DataGridView.DataSource = list; - DataGridView.Columns["Id"].Visible = false; - DataGridView.Columns["ImplementerFIO"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; - } - + DataGridView.FillandConfigGrid(_logic.ReadList(null)); _logger.LogInformation("Загрузка исполнителей"); } diff --git a/SoftwareInstallation/SoftwareInstallation/FormMails.cs b/SoftwareInstallation/SoftwareInstallation/FormMails.cs index 153d2ba..179cf5c 100644 --- a/SoftwareInstallation/SoftwareInstallation/FormMails.cs +++ b/SoftwareInstallation/SoftwareInstallation/FormMails.cs @@ -25,18 +25,11 @@ namespace SoftwareInstallationView { try { - var list = _logic.ReadList(new() + DataGridView.FillandConfigGrid(_logic.ReadList(new() { Page = currentPage, 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("Загрузка писем"); labelInfoPages.Text = $"{currentPage} страница"; return true; diff --git a/SoftwareInstallation/SoftwareInstallation/FormMain.Designer.cs b/SoftwareInstallation/SoftwareInstallation/FormMain.Designer.cs index 3a385ac..d5c870d 100644 --- a/SoftwareInstallation/SoftwareInstallation/FormMain.Designer.cs +++ b/SoftwareInstallation/SoftwareInstallation/FormMain.Designer.cs @@ -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.DataGridView = new System.Windows.Forms.DataGridView(); this.CreateOrderButton = new System.Windows.Forms.Button(); this.TakeOrderInWorkButton = new System.Windows.Forms.Button(); this.OrderReadyButton = new System.Windows.Forms.Button(); this.IssuedOrderButton = 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(); @@ -64,7 +66,8 @@ this.СправочникиToolStripMenuItem, this.отчетыToolStripMenuItem, this.запускРаботToolStripMenuItem, - this.элПисьмаToolStripMenuItem}); + this.элПисьмаToolStripMenuItem, + this.создатьБекапToolStripMenuItem}); this.MenuStrip.Location = new System.Drawing.Point(0, 0); this.MenuStrip.Name = "MenuStrip"; this.MenuStrip.Size = new System.Drawing.Size(865, 24); @@ -160,6 +163,13 @@ this.запускРаботToolStripMenuItem.Text = "Запуск работ"; 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 // this.DataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; @@ -219,12 +229,12 @@ this.UpdateListButton.UseVisualStyleBackColor = true; this.UpdateListButton.Click += new System.EventHandler(this.UpdateListButton_Click); // - // элПисьмаToolStripMenuItem + // создатьБекап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); + this.создатьБекапToolStripMenuItem.Name = "создатьБекапToolStripMenuItem"; + this.создатьБекапToolStripMenuItem.Size = new System.Drawing.Size(97, 20); + this.создатьБекапToolStripMenuItem.Text = "Создать Бекап"; + this.создатьБекапToolStripMenuItem.Click += new System.EventHandler(this.создатьБекапToolStripMenuItem_Click); // // 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; diff --git a/SoftwareInstallation/SoftwareInstallation/FormMain.cs b/SoftwareInstallation/SoftwareInstallation/FormMain.cs index e033cf9..d26edd6 100644 --- a/SoftwareInstallation/SoftwareInstallation/FormMain.cs +++ b/SoftwareInstallation/SoftwareInstallation/FormMain.cs @@ -1,9 +1,7 @@ using Microsoft.Extensions.Logging; using SofrwareInstallationContracts.BindingModels; using SofrwareInstallationContracts.BusinessLogicsContracts; -using SoftwareInstallationBusinessLogic.BusinessLogic; -using SoftwareInstallationDataModels.Enums; -using System.Windows.Forms; +using SofrwareInstallationContracts.DI; namespace SoftwareInstallationView { @@ -14,14 +12,16 @@ namespace SoftwareInstallationView private readonly IOrderLogic _orderLogic; private readonly IReportLogic _reportLogic; private readonly IWorkProcess _workProcess; + private readonly IBackUpLogic _backUpLogic; - public FormMain(ILogger logger, IWorkProcess workProcess, IOrderLogic orderLogic, IReportLogic reportLogic) + public FormMain(ILogger logger, IBackUpLogic backUpLogic, IWorkProcess workProcess, IOrderLogic orderLogic, IReportLogic reportLogic) { InitializeComponent(); _logger = logger; _orderLogic = orderLogic; _reportLogic = reportLogic; _workProcess = workProcess; + _backUpLogic = backUpLogic; LoadData(); } @@ -36,16 +36,7 @@ namespace SoftwareInstallationView try { - var list = _orderLogic.ReadList(null); - - if (list != null) - { - DataGridView.DataSource = list; - DataGridView.Columns["PackageId"].Visible = false; - DataGridView.Columns["ClientId"].Visible = false; - DataGridView.Columns["ImplementerId"].Visible = false; - } - + DataGridView.FillandConfigGrid(_orderLogic.ReadList(null)); _logger.LogInformation("Загрузка заказов"); } catch (Exception ex) @@ -57,33 +48,21 @@ namespace SoftwareInstallationView private void КомпонентыToolStripMenuItem_Click(object sender, EventArgs e) { - var service = Program.ServiceProvider?.GetService(typeof(FormComponents)); - - if (service is FormComponents form) - { - form.ShowDialog(); - } + var form = DependencyManager.Instance.Resolve(); + form.ShowDialog(); } private void ИзделияToolStripMenuItem_Click(object sender, EventArgs e) { - var service = Program.ServiceProvider?.GetService(typeof(FormPackages)); - - if (service is FormPackages form) - { - form.ShowDialog(); - } + var form = DependencyManager.Instance.Resolve(); + form.ShowDialog(); } private void CreateOrderButton_Click(object sender, EventArgs e) { - var service = Program.ServiceProvider?.GetService(typeof(FormCreateOrder)); - - if (service is FormCreateOrder form) - { - form.ShowDialog(); - LoadData(); - } + var form = DependencyManager.Instance.Resolve(); + form.ShowDialog(); + LoadData(); } private void TakeOrderInWorkButton_Click(object sender, EventArgs e) @@ -225,55 +204,64 @@ namespace SoftwareInstallationView private void компонентыПоИзделиямToolStripMenuItem_Click(object sender, EventArgs e) { - var service = Program.ServiceProvider?.GetService(typeof(FormReportPackageComponents)); - if (service is FormReportPackageComponents form) - { - form.ShowDialog(); - } - + var form = DependencyManager.Instance.Resolve(); + form.ShowDialog(); } private void списокЗаказовToolStripMenuItem_Click(object sender, EventArgs e) { - var service = Program.ServiceProvider?.GetService(typeof(FormReportOrders)); - if (service is FormReportOrders form) - { - form.ShowDialog(); - } + var form = DependencyManager.Instance.Resolve(); + form.ShowDialog(); } private void клиентыToolStripMenuItem_Click(object sender, EventArgs e) { - var service = Program.ServiceProvider?.GetService(typeof(FormClients)); - if (service is FormClients form) - { - form.ShowDialog(); - } + var form = DependencyManager.Instance.Resolve(); + form.ShowDialog(); } private void запускРаботToolStripMenuItem_Click(object sender, EventArgs e) { - _workProcess.DoWork((Program.ServiceProvider?.GetService(typeof(IImplementerLogic)) as IImplementerLogic)!, _orderLogic); + _workProcess.DoWork(DependencyManager.Instance.Resolve(), _orderLogic); MessageBox.Show("Процесс обработки запущен", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information); } private void исполнителиToolStripMenuItem_Click(object sender, EventArgs e) { - var service = Program.ServiceProvider?.GetService(typeof(FormImplementers)); - - if (service is FormImplementers form) - { - form.ShowDialog(); - } + var form = DependencyManager.Instance.Resolve(); + form.ShowDialog(); } private void элПисьмаToolStripMenuItem_Click(object sender, EventArgs e) { - var service = Program.ServiceProvider?.GetService(typeof(FormMails)); - if (service is FormMails form) + var form = DependencyManager.Instance.Resolve(); + form.ShowDialog(); + } + + private void создатьБекапToolStripMenuItem_Click(object sender, EventArgs e) + { + try { - form.ShowDialog(); + 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) diff --git a/SoftwareInstallation/SoftwareInstallation/FormPackage.cs b/SoftwareInstallation/SoftwareInstallation/FormPackage.cs index 4732133..645cb60 100644 --- a/SoftwareInstallation/SoftwareInstallation/FormPackage.cs +++ b/SoftwareInstallation/SoftwareInstallation/FormPackage.cs @@ -3,7 +3,8 @@ using SofrwareInstallationContracts.BusinessLogicsContracts; using SofrwareInstallationContracts.SearchModels; using SoftwareInstallationDataModels.Models; using Microsoft.Extensions.Logging; - +using SofrwareInstallationContracts.DI; +using System.Windows.Forms; namespace SoftwareInstallationView { @@ -77,31 +78,27 @@ namespace SoftwareInstallationView } private void AddButton_Click(object sender, EventArgs e) { - var service = Program.ServiceProvider?.GetService(typeof(FormPackageComponent)); - - if (service is FormPackageComponent form) + var form = DependencyManager.Instance.Resolve(); + + if (form.ShowDialog() == DialogResult.OK) { - if (form.ShowDialog() == DialogResult.OK) + if (form.ComponentModel == null) { - if (form.ComponentModel == null) - { - return; - } - - _logger.LogInformation("Добавление нового компонента: { ComponentName} - { Count}", form.ComponentModel.ComponentName, form.Count); - - if (_packageComponents.ContainsKey(form.Id)) - { - _packageComponents[form.Id] = (form.ComponentModel, form.Count); - } - - else - { - _packageComponents.Add(form.Id, (form.ComponentModel, form.Count)); - } - - LoadData(); + return; } + + _logger.LogInformation("Добавление нового компонента: { ComponentName}- { Count}", form.ComponentModel.ComponentName, form.Count); + + if (_packageComponents.ContainsKey(form.Id)) + { + _packageComponents[form.Id] = (form.ComponentModel, form.Count); + } + else + { + _packageComponents.Add(form.Id, (form.ComponentModel, form.Count)); + } + + LoadData(); } } @@ -109,25 +106,23 @@ namespace SoftwareInstallationView { if (DataGridView.SelectedRows.Count == 1) { - var service = Program.ServiceProvider?.GetService(typeof(FormPackageComponent)); + var form = DependencyManager.Instance.Resolve(); + int id = Convert.ToInt32(DataGridView.SelectedRows[0].Cells[0].Value); - if (service is FormPackageComponent form) + form.Id = id; + form.Count = _packageComponents[id].Item2; + + if (form.ShowDialog() == DialogResult.OK) { - int id = Convert.ToInt32(DataGridView.SelectedRows[0].Cells[0].Value); - form.Id = id; - form.Count = _packageComponents[id].Item2; - - if (form.ShowDialog() == DialogResult.OK) + if (form.ComponentModel == null) { - if (form.ComponentModel == null) - { - return; - } - - _logger.LogInformation("Изменение компонента: { ComponentName} - { Count}", form.ComponentModel.ComponentName, form.Count); - _packageComponents[form.Id] = (form.ComponentModel, form.Count); - LoadData(); + return; } + + _logger.LogInformation("Изменение компонента: { ComponentName} - { Count} ", form.ComponentModel.ComponentName, form.Count); + _packageComponents[id] = (form.ComponentModel, form.Count); + + LoadData(); } } } diff --git a/SoftwareInstallation/SoftwareInstallation/FormPackages.cs b/SoftwareInstallation/SoftwareInstallation/FormPackages.cs index 9c3b5cc..79891a0 100644 --- a/SoftwareInstallation/SoftwareInstallation/FormPackages.cs +++ b/SoftwareInstallation/SoftwareInstallation/FormPackages.cs @@ -1,6 +1,8 @@ using Microsoft.Extensions.Logging; using SofrwareInstallationContracts.BindingModels; using SofrwareInstallationContracts.BusinessLogicsContracts; +using SofrwareInstallationContracts.DI; +using System.Windows.Forms; namespace SoftwareInstallationView { @@ -26,16 +28,7 @@ namespace SoftwareInstallationView { try { - var list = _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; - } - + DataGridView.FillandConfigGrid(_logic.ReadList(null)); _logger.LogInformation("Загрузка изделий"); } @@ -48,30 +41,24 @@ namespace SoftwareInstallationView private void AddButton_Click(object sender, EventArgs e) { - var service = Program.ServiceProvider?.GetService(typeof(FormPackage)); - - if (service is FormPackage form) + var form = DependencyManager.Instance.Resolve(); + + if (form.ShowDialog() == DialogResult.OK) { - if (form.ShowDialog() == DialogResult.OK) - { - LoadData(); - } + LoadData(); } } private void ChangeButton_Click(object sender, EventArgs e) { if (DataGridView.SelectedRows.Count == 1) { - var service = Program.ServiceProvider?.GetService(typeof(FormPackage)); - - if (service is FormPackage form) + var form = DependencyManager.Instance.Resolve(); + + form.Id = Convert.ToInt32(DataGridView.SelectedRows[0].Cells["Id"].Value); + + if (form.ShowDialog() == DialogResult.OK) { - form.Id = Convert.ToInt32(DataGridView.SelectedRows[0].Cells["Id"].Value); - - if (form.ShowDialog() == DialogResult.OK) - { - LoadData(); - } + LoadData(); } } } diff --git a/SoftwareInstallation/SoftwareInstallation/Program.cs b/SoftwareInstallation/SoftwareInstallation/Program.cs index d9de629..5f9515d 100644 --- a/SoftwareInstallation/SoftwareInstallation/Program.cs +++ b/SoftwareInstallation/SoftwareInstallation/Program.cs @@ -1,32 +1,26 @@ using SoftwareInstallationBusinessLogic.BusinessLogic; -using Microsoft.Extensions.DependencyInjection; using SofrwareInstallationContracts.BusinessLogicsContracts; -using SofrwareInstallationContracts.StoragesContracts; -using SoftwareInstallationDataBaseImplement.Implements; using Microsoft.Extensions.Logging; using NLog.Extensions.Logging; using SoftwareInstallationBusinessLogic.OfficePackage; using SoftwareInstallationBusinessLogic.OfficePackage.Implements; using SofrwareInstallationContracts.BindingModels; using SoftwareInstallationBusinessLogic.MailWorker; +using SofrwareInstallationContracts.DI; namespace SoftwareInstallationView { internal static class Program { - private static ServiceProvider? _serviceProvider; - public static ServiceProvider? ServiceProvider => _serviceProvider; - [STAThread] static void Main() { ApplicationConfiguration.Initialize(); - var services = new ServiceCollection(); - ConfigureServices(services); - _serviceProvider = services.BuildServiceProvider(); + InitDependency(); + try { - var mailSender = _serviceProvider.GetService(); + var mailSender = DependencyManager.Instance.Resolve(); mailSender?.MailConfig(new MailConfigBindingModel { MailLogin = System.Configuration.ConfigurationManager.AppSettings["MailLogin"] ?? string.Empty, @@ -41,64 +35,62 @@ namespace SoftwareInstallationView } catch (Exception ex) { - var logger = _serviceProvider.GetService(); - logger?.LogError(ex, "Error"); + var logger = DependencyManager.Instance.Resolve(); + logger?.LogError(ex, ""); } - Application.Run(_serviceProvider.GetRequiredService()); + + Application.Run(DependencyManager.Instance.Resolve()); } - private static void ConfigureServices(ServiceCollection services) + private static void InitDependency() { - services.AddLogging(option => + DependencyManager.InitDependency(); + + DependencyManager.Instance.AddLogging(option => { option.SetMinimumLevel(LogLevel.Information); option.AddNLog("nlog.config"); }); - services.AddTransient(); - services.AddTransient(); - services.AddTransient(); - services.AddTransient(); - services.AddTransient(); - services.AddTransient(); - services.AddTransient(); - services.AddTransient(); - services.AddTransient(); - services.AddSingleton(); - services.AddTransient(); - services.AddTransient(); - services.AddTransient(); - services.AddTransient(); - services.AddTransient(); - services.AddTransient(); - services.AddTransient(); + DependencyManager.Instance.RegisterType(); + DependencyManager.Instance.RegisterType(); + DependencyManager.Instance.RegisterType(); + DependencyManager.Instance.RegisterType(); + DependencyManager.Instance.RegisterType(); + DependencyManager.Instance.RegisterType(); + DependencyManager.Instance.RegisterType(); + DependencyManager.Instance.RegisterType(); + DependencyManager.Instance.RegisterType(); + DependencyManager.Instance.RegisterType(); - services.AddTransient(); - services.AddTransient(); - services.AddTransient(); - - services.AddTransient(); - services.AddTransient(); - services.AddTransient(); - services.AddTransient(); - services.AddTransient(); - services.AddTransient(); - services.AddTransient(); - services.AddTransient(); - services.AddTransient(); - services.AddTransient(); - services.AddTransient(); - services.AddTransient(); - services.AddTransient(); - services.AddTransient(); - services.AddTransient(); - services.AddTransient(); - services.AddTransient(); - services.AddTransient(); - services.AddTransient(); - services.AddTransient(); + DependencyManager.Instance.RegisterType(true); + + DependencyManager.Instance.RegisterType(); + DependencyManager.Instance.RegisterType(); + DependencyManager.Instance.RegisterType(); + + DependencyManager.Instance.RegisterType(); + DependencyManager.Instance.RegisterType(); + DependencyManager.Instance.RegisterType(); + DependencyManager.Instance.RegisterType(); + DependencyManager.Instance.RegisterType(); + DependencyManager.Instance.RegisterType(); + DependencyManager.Instance.RegisterType(); + DependencyManager.Instance.RegisterType(); + DependencyManager.Instance.RegisterType(); + DependencyManager.Instance.RegisterType(); + DependencyManager.Instance.RegisterType(); + DependencyManager.Instance.RegisterType(); + DependencyManager.Instance.RegisterType(); + DependencyManager.Instance.RegisterType(); + DependencyManager.Instance.RegisterType(); + DependencyManager.Instance.RegisterType(); + DependencyManager.Instance.RegisterType(); + DependencyManager.Instance.RegisterType(); + DependencyManager.Instance.RegisterType(); + DependencyManager.Instance.RegisterType(); } - private static void MailCheck(object obj) => ServiceProvider?.GetService()?.MailCheck(); + private static void MailCheck(object obj) => DependencyManager.Instance.Resolve()?.MailCheck(); } } diff --git a/SoftwareInstallation/SoftwareInstallationBusinessLogic/BusinessLogic/BackUpLogic.cs b/SoftwareInstallation/SoftwareInstallationBusinessLogic/BusinessLogic/BackUpLogic.cs new file mode 100644 index 0000000..930cf8c --- /dev/null +++ b/SoftwareInstallation/SoftwareInstallationBusinessLogic/BusinessLogic/BackUpLogic.cs @@ -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 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(string folderName) where T : class, new() + { + var records = _backUpInfo.GetList(); + + if (records == null) + { + _logger.LogWarning("{type} type get null list", typeof(T).Name); + + return; + } + + var jsonFormatter = new DataContractJsonSerializer(typeof(List)); + using var fs = new FileStream(string.Format("{0}/{1}.json", folderName, typeof(T).Name), FileMode.OpenOrCreate); + jsonFormatter.WriteObject(fs, records); + } + } +} diff --git a/SoftwareInstallation/SoftwareInstallationDataBaseImplement/DatabaseImplementationExtension.cs b/SoftwareInstallation/SoftwareInstallationDataBaseImplement/DatabaseImplementationExtension.cs new file mode 100644 index 0000000..45d2492 --- /dev/null +++ b/SoftwareInstallation/SoftwareInstallationDataBaseImplement/DatabaseImplementationExtension.cs @@ -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(); + DependencyManager.Instance.RegisterType(); + DependencyManager.Instance.RegisterType(); + DependencyManager.Instance.RegisterType(); + DependencyManager.Instance.RegisterType(); + DependencyManager.Instance.RegisterType(); + DependencyManager.Instance.RegisterType(); + } + + } +} diff --git a/SoftwareInstallation/SoftwareInstallationDataBaseImplement/Implements/BackUpInfo.cs b/SoftwareInstallation/SoftwareInstallationDataBaseImplement/Implements/BackUpInfo.cs new file mode 100644 index 0000000..e1c7f02 --- /dev/null +++ b/SoftwareInstallation/SoftwareInstallationDataBaseImplement/Implements/BackUpInfo.cs @@ -0,0 +1,29 @@ +using SofrwareInstallationContracts.StoragesContracts; + +namespace SoftwareInstallationDataBaseImplement.Implements +{ + public class BackUpInfo : IBackUpInfo + { + public List? GetList() where T : class, new() + { + using var context = new SoftwareInstallationDataBase(); + return context.Set().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; + } + } +} diff --git a/SoftwareInstallation/SoftwareInstallationDataBaseImplement/Migrations/20230504171714_InitDb.Designer.cs b/SoftwareInstallation/SoftwareInstallationDataBaseImplement/Migrations/20230504171714_InitDb.Designer.cs deleted file mode 100644 index 11df286..0000000 --- a/SoftwareInstallation/SoftwareInstallationDataBaseImplement/Migrations/20230504171714_InitDb.Designer.cs +++ /dev/null @@ -1,390 +0,0 @@ -// -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 - { - /// - 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("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("ClientFIO") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("Email") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("Password") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.HasKey("Id"); - - b.ToTable("Clients"); - }); - - modelBuilder.Entity("SoftwareInstallationDataBaseImplement.Models.Component", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("ComponentName") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("Cost") - .HasColumnType("float"); - - b.HasKey("Id"); - - b.ToTable("Components"); - }); - - modelBuilder.Entity("SoftwareInstallationDataBaseImplement.Models.Implementer", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("ImplementerFIO") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("Password") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("Qualification") - .HasColumnType("int"); - - b.Property("WorkExperience") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.ToTable("Implementers"); - }); - - modelBuilder.Entity("SoftwareInstallationDataBaseImplement.Models.Message", b => - { - b.Property("MessageId") - .HasColumnType("nvarchar(450)"); - - b.Property("Body") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("ClientId") - .IsRequired() - .HasColumnType("int"); - - b.Property("DateDelivery") - .HasColumnType("datetime2"); - - b.Property("HasRead") - .HasColumnType("bit"); - - b.Property("Reply") - .HasColumnType("nvarchar(max)"); - - b.Property("SenderName") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("Subject") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.HasKey("MessageId"); - - b.HasIndex("ClientId"); - - b.ToTable("Messages"); - }); - - modelBuilder.Entity("SoftwareInstallationDataBaseImplement.Models.Order", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("ClientId") - .HasColumnType("int"); - - b.Property("Count") - .HasColumnType("int"); - - b.Property("DateCreate") - .HasColumnType("datetime2"); - - b.Property("DateImplement") - .HasColumnType("datetime2"); - - b.Property("ImplementerId") - .HasColumnType("int"); - - b.Property("PackageId") - .HasColumnType("int"); - - b.Property("PackageName") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("Status") - .HasColumnType("int"); - - b.Property("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("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("PackageName") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("Price") - .HasColumnType("float"); - - b.HasKey("Id"); - - b.ToTable("Packages"); - }); - - modelBuilder.Entity("SoftwareInstallationDataBaseImplement.Models.PackageComponent", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("ComponentId") - .HasColumnType("int"); - - b.Property("Count") - .HasColumnType("int"); - - b.Property("PackageId") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.HasIndex("ComponentId"); - - b.HasIndex("PackageId"); - - b.ToTable("PackageComponents"); - }); - - modelBuilder.Entity("SoftwareInstallationDataBaseImplement.Models.Store", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("OpeningDate") - .HasColumnType("datetime2"); - - b.Property("PackageMaxCount") - .HasColumnType("int"); - - b.Property("StoreAdress") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("StoreName") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.HasKey("Id"); - - b.ToTable("Stores"); - }); - - modelBuilder.Entity("SoftwareInstallationDataBaseImplement.Models.StorePackage", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("Count") - .HasColumnType("int"); - - b.Property("PackageId") - .HasColumnType("int"); - - b.Property("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 - } - } -} diff --git a/SoftwareInstallation/SoftwareInstallationDataBaseImplement/Migrations/20230504171714_InitDb.cs b/SoftwareInstallation/SoftwareInstallationDataBaseImplement/Migrations/20230504171714_InitDb.cs deleted file mode 100644 index f4e3357..0000000 --- a/SoftwareInstallation/SoftwareInstallationDataBaseImplement/Migrations/20230504171714_InitDb.cs +++ /dev/null @@ -1,277 +0,0 @@ -using System; -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace SoftwareInstallationDataBaseImplement.Migrations -{ - /// - public partial class InitDb : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.CreateTable( - name: "Clients", - columns: table => new - { - Id = table.Column(type: "int", nullable: false) - .Annotation("SqlServer:Identity", "1, 1"), - ClientFIO = table.Column(type: "nvarchar(max)", nullable: false), - Email = table.Column(type: "nvarchar(max)", nullable: false), - Password = table.Column(type: "nvarchar(max)", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_Clients", x => x.Id); - }); - - migrationBuilder.CreateTable( - name: "Components", - columns: table => new - { - Id = table.Column(type: "int", nullable: false) - .Annotation("SqlServer:Identity", "1, 1"), - ComponentName = table.Column(type: "nvarchar(max)", nullable: false), - Cost = table.Column(type: "float", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_Components", x => x.Id); - }); - - migrationBuilder.CreateTable( - name: "Implementers", - columns: table => new - { - Id = table.Column(type: "int", nullable: false) - .Annotation("SqlServer:Identity", "1, 1"), - ImplementerFIO = table.Column(type: "nvarchar(max)", nullable: false), - Password = table.Column(type: "nvarchar(max)", nullable: false), - WorkExperience = table.Column(type: "int", nullable: false), - Qualification = table.Column(type: "int", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_Implementers", x => x.Id); - }); - - migrationBuilder.CreateTable( - name: "Packages", - columns: table => new - { - Id = table.Column(type: "int", nullable: false) - .Annotation("SqlServer:Identity", "1, 1"), - PackageName = table.Column(type: "nvarchar(max)", nullable: false), - Price = table.Column(type: "float", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_Packages", x => x.Id); - }); - - migrationBuilder.CreateTable( - name: "Stores", - columns: table => new - { - Id = table.Column(type: "int", nullable: false) - .Annotation("SqlServer:Identity", "1, 1"), - StoreName = table.Column(type: "nvarchar(max)", nullable: false), - StoreAdress = table.Column(type: "nvarchar(max)", nullable: false), - OpeningDate = table.Column(type: "datetime2", nullable: false), - PackageMaxCount = table.Column(type: "int", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_Stores", x => x.Id); - }); - - migrationBuilder.CreateTable( - name: "Messages", - columns: table => new - { - MessageId = table.Column(type: "nvarchar(450)", nullable: false), - ClientId = table.Column(type: "int", nullable: false), - SenderName = table.Column(type: "nvarchar(max)", nullable: false), - DateDelivery = table.Column(type: "datetime2", nullable: false), - Subject = table.Column(type: "nvarchar(max)", nullable: false), - Body = table.Column(type: "nvarchar(max)", nullable: false), - HasRead = table.Column(type: "bit", nullable: false), - Reply = table.Column(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(type: "int", nullable: false) - .Annotation("SqlServer:Identity", "1, 1"), - PackageId = table.Column(type: "int", nullable: false), - ImplementerId = table.Column(type: "int", nullable: true), - ClientId = table.Column(type: "int", nullable: false), - PackageName = table.Column(type: "nvarchar(max)", nullable: false), - Count = table.Column(type: "int", nullable: false), - Sum = table.Column(type: "float", nullable: false), - Status = table.Column(type: "int", nullable: false), - DateCreate = table.Column(type: "datetime2", nullable: false), - DateImplement = table.Column(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(type: "int", nullable: false) - .Annotation("SqlServer:Identity", "1, 1"), - PackageId = table.Column(type: "int", nullable: false), - ComponentId = table.Column(type: "int", nullable: false), - Count = table.Column(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(type: "int", nullable: false) - .Annotation("SqlServer:Identity", "1, 1"), - PackageId = table.Column(type: "int", nullable: false), - StoreId = table.Column(type: "int", nullable: false), - Count = table.Column(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"); - } - - /// - 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"); - } - } -} diff --git a/SoftwareInstallation/SoftwareInstallationDataBaseImplement/Models/Client.cs b/SoftwareInstallation/SoftwareInstallationDataBaseImplement/Models/Client.cs index f8a7864..27ee80d 100644 --- a/SoftwareInstallation/SoftwareInstallationDataBaseImplement/Models/Client.cs +++ b/SoftwareInstallation/SoftwareInstallationDataBaseImplement/Models/Client.cs @@ -3,17 +3,23 @@ using SofrwareInstallationContracts.ViewModels; using SoftwareInstallationDataModels.Models; using System.ComponentModel.DataAnnotations.Schema; using System.ComponentModel.DataAnnotations; +using System.Runtime.Serialization; namespace SoftwareInstallationDataBaseImplement.Models { + [DataContract] public class Client : IClientModel { + [DataMember] public int Id { get; private set; } [Required] + [DataMember] public string ClientFIO { get; set; } = string.Empty; [Required] + [DataMember] public string Email { get; set; } = string.Empty; [Required] + [DataMember] public string Password { get; set; } = string.Empty; [ForeignKey("ClientId")] diff --git a/SoftwareInstallation/SoftwareInstallationDataBaseImplement/Models/Component.cs b/SoftwareInstallation/SoftwareInstallationDataBaseImplement/Models/Component.cs index fb1c505..cba8f31 100644 --- a/SoftwareInstallation/SoftwareInstallationDataBaseImplement/Models/Component.cs +++ b/SoftwareInstallation/SoftwareInstallationDataBaseImplement/Models/Component.cs @@ -3,17 +3,22 @@ using SofrwareInstallationContracts.ViewModels; using SoftwareInstallationDataModels.Models; using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; +using System.Runtime.Serialization; namespace SoftwareInstallationDataBaseImplement.Models { + [DataContract] public class Component : IComponentModel { + [DataMember] public int Id { get; private set; } [Required] + [DataMember] public string ComponentName { get; private set; } = string.Empty; [Required] + [DataMember] public double Cost { get; set; } [ForeignKey("ComponentId")] diff --git a/SoftwareInstallation/SoftwareInstallationDataBaseImplement/Models/Implementer.cs b/SoftwareInstallation/SoftwareInstallationDataBaseImplement/Models/Implementer.cs index fd6fdd6..b77a8c0 100644 --- a/SoftwareInstallation/SoftwareInstallationDataBaseImplement/Models/Implementer.cs +++ b/SoftwareInstallation/SoftwareInstallationDataBaseImplement/Models/Implementer.cs @@ -3,23 +3,30 @@ using SofrwareInstallationContracts.ViewModels; using SoftwareInstallationDataModels.Models; using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; +using System.Runtime.Serialization; namespace SoftwareInstallationDataBaseImplement.Models { + [DataContract] public class Implementer : IImplementerModel { [Required] + [DataMember] public string ImplementerFIO { get; private set; } = string.Empty; [Required] + [DataMember] public string Password { get; private set; } = string.Empty; [Required] + [DataMember] public int WorkExperience { get; private set; } [Required] + [DataMember] public int Qualification { get; private set; } + [DataMember] public int Id { get; private set; } [ForeignKey("ImplementerId")] diff --git a/SoftwareInstallation/SoftwareInstallationDataBaseImplement/Models/Message.cs b/SoftwareInstallation/SoftwareInstallationDataBaseImplement/Models/Message.cs index 831383e..3049989 100644 --- a/SoftwareInstallation/SoftwareInstallationDataBaseImplement/Models/Message.cs +++ b/SoftwareInstallation/SoftwareInstallationDataBaseImplement/Models/Message.cs @@ -2,21 +2,29 @@ using SofrwareInstallationContracts.ViewModels; using SoftwareInstallationDataModels.Models; using System.ComponentModel.DataAnnotations; +using System.Runtime.Serialization; namespace SoftwareInstallationDataBaseImplement.Models { + [DataContract] public class Message : IMessageInfoModel { [Key] + [DataMember] public string MessageId { get; private set; } = string.Empty; + [DataMember] public int? ClientId { get; private set; } [Required] + [DataMember] public string SenderName { get; private set; } = string.Empty; [Required] + [DataMember] public DateTime DateDelivery { get; private set; } = DateTime.Now; [Required] + [DataMember] public string Subject { get; private set; } = string.Empty; [Required] + [DataMember] public string Body { get; private set; } = string.Empty; [Required] public bool HasRead { get; private set; } @@ -65,5 +73,7 @@ namespace SoftwareInstallationDataBaseImplement.Models SenderName = SenderName, DateDelivery = DateDelivery, }; + + public int Id => throw new NotImplementedException(); } } diff --git a/SoftwareInstallation/SoftwareInstallationDataBaseImplement/Models/Order.cs b/SoftwareInstallation/SoftwareInstallationDataBaseImplement/Models/Order.cs index d0416a2..d2ee276 100644 --- a/SoftwareInstallation/SoftwareInstallationDataBaseImplement/Models/Order.cs +++ b/SoftwareInstallation/SoftwareInstallationDataBaseImplement/Models/Order.cs @@ -3,34 +3,46 @@ using SofrwareInstallationContracts.ViewModels; using SoftwareInstallationDataModels.Enums; using SoftwareInstallationDataModels.Models; using System.ComponentModel.DataAnnotations; +using System.Runtime.Serialization; namespace SoftwareInstallationDataBaseImplement.Models { + [DataContract] public class Order : IOrderModel { + [DataMember] public int Id { get; private set; } + [DataMember] public int PackageId { get; private set; } + [DataMember] public int? ImplementerId { get; private set; } [Required] + [DataMember] public int ClientId { get; set; } + [DataMember] public string PackageName { get; private set; } = string.Empty; [Required] + [DataMember] public int Count { get; private set; } [Required] + [DataMember] public double Sum { get; private set; } [Required] + [DataMember] public OrderStatus Status { get; private set; } = OrderStatus.Неизвестен; [Required] + [DataMember] public DateTime DateCreate { get; private set; } = DateTime.Now; + [DataMember] public DateTime? DateImplement { get; private set; } public virtual Package Package { get; set; } diff --git a/SoftwareInstallation/SoftwareInstallationDataBaseImplement/Models/Package.cs b/SoftwareInstallation/SoftwareInstallationDataBaseImplement/Models/Package.cs index 89d1f05..e958c24 100644 --- a/SoftwareInstallation/SoftwareInstallationDataBaseImplement/Models/Package.cs +++ b/SoftwareInstallation/SoftwareInstallationDataBaseImplement/Models/Package.cs @@ -3,22 +3,28 @@ using SofrwareInstallationContracts.ViewModels; using SoftwareInstallationDataModels.Models; using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; +using System.Runtime.Serialization; namespace SoftwareInstallationDataBaseImplement.Models { + [DataContract] public class Package : IPackageModel { + [DataMember] public int Id { get; set; } [Required] + [DataMember] public string PackageName { get; set; } = string.Empty; [Required] + [DataMember] public double Price { get; set; } private Dictionary? _packageComponents = null; [NotMapped] + [DataMember] public Dictionary PackageComponents { get diff --git a/SoftwareInstallation/SoftwareInstallationDataBaseImplement/SoftwareInstallationDataBase.cs b/SoftwareInstallation/SoftwareInstallationDataBaseImplement/SoftwareInstallationDataBase.cs index 68b25d2..ca69a84 100644 --- a/SoftwareInstallation/SoftwareInstallationDataBaseImplement/SoftwareInstallationDataBase.cs +++ b/SoftwareInstallation/SoftwareInstallationDataBaseImplement/SoftwareInstallationDataBase.cs @@ -9,7 +9,7 @@ namespace SoftwareInstallationDataBaseImplement { 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); } diff --git a/SoftwareInstallation/SoftwareInstallationDataBaseImplement/SoftwareInstallationDataBaseImplement.csproj b/SoftwareInstallation/SoftwareInstallationDataBaseImplement/SoftwareInstallationDataBaseImplement.csproj index 8aec7ec..d5d65ad 100644 --- a/SoftwareInstallation/SoftwareInstallationDataBaseImplement/SoftwareInstallationDataBaseImplement.csproj +++ b/SoftwareInstallation/SoftwareInstallationDataBaseImplement/SoftwareInstallationDataBaseImplement.csproj @@ -15,4 +15,8 @@ + + + + diff --git a/SoftwareInstallation/SoftwareInstallationDataModels/Models/IMessageInfoModel.cs b/SoftwareInstallation/SoftwareInstallationDataModels/Models/IMessageInfoModel.cs index 27dcdbb..fcf62f7 100644 --- a/SoftwareInstallation/SoftwareInstallationDataModels/Models/IMessageInfoModel.cs +++ b/SoftwareInstallation/SoftwareInstallationDataModels/Models/IMessageInfoModel.cs @@ -1,6 +1,6 @@ namespace SoftwareInstallationDataModels.Models { - public interface IMessageInfoModel + public interface IMessageInfoModel : IId { string MessageId { get; } int? ClientId { get; } diff --git a/SoftwareInstallation/SoftwareInstallationFileImplement/FileImplementationExtension.cs b/SoftwareInstallation/SoftwareInstallationFileImplement/FileImplementationExtension.cs new file mode 100644 index 0000000..bae4390 --- /dev/null +++ b/SoftwareInstallation/SoftwareInstallationFileImplement/FileImplementationExtension.cs @@ -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(); + DependencyManager.Instance.RegisterType(); + DependencyManager.Instance.RegisterType(); + DependencyManager.Instance.RegisterType(); + DependencyManager.Instance.RegisterType(); + DependencyManager.Instance.RegisterType(); + DependencyManager.Instance.RegisterType(); + } + } +} diff --git a/SoftwareInstallation/SoftwareInstallationFileImplement/Implements/BackUpInfo.cs b/SoftwareInstallation/SoftwareInstallationFileImplement/Implements/BackUpInfo.cs new file mode 100644 index 0000000..d24b7b2 --- /dev/null +++ b/SoftwareInstallation/SoftwareInstallationFileImplement/Implements/BackUpInfo.cs @@ -0,0 +1,32 @@ +using SofrwareInstallationContracts.StoragesContracts; + +namespace SoftwareInstallationFileImplement.Implements +{ + public class BackUpInfo : IBackUpInfo + { + public List? GetList() where T : class, new() + { + var source = DataFileSingleton.GetInstance(); + + return (List?)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; + } + } +} diff --git a/SoftwareInstallation/SoftwareInstallationFileImplement/Models/Client.cs b/SoftwareInstallation/SoftwareInstallationFileImplement/Models/Client.cs index d5af947..33d611a 100644 --- a/SoftwareInstallation/SoftwareInstallationFileImplement/Models/Client.cs +++ b/SoftwareInstallation/SoftwareInstallationFileImplement/Models/Client.cs @@ -1,15 +1,21 @@ using SofrwareInstallationContracts.BindingModels; using SofrwareInstallationContracts.ViewModels; using SoftwareInstallationDataModels.Models; +using System.Runtime.Serialization; using System.Xml.Linq; namespace SoftwareInstallationFileImplement.Models { + [DataContract] public class Client : IClientModel { + [DataMember] public int Id { get; private set; } + [DataMember] public string ClientFIO { get; private set; } = string.Empty; + [DataMember] public string Email { get; set; } = string.Empty; + [DataMember] public string Password { get; set; } = string.Empty; public static Client? Create(ClientBindingModel model) { diff --git a/SoftwareInstallation/SoftwareInstallationFileImplement/Models/Component.cs b/SoftwareInstallation/SoftwareInstallationFileImplement/Models/Component.cs index f1fe801..07c0839 100644 --- a/SoftwareInstallation/SoftwareInstallationFileImplement/Models/Component.cs +++ b/SoftwareInstallation/SoftwareInstallationFileImplement/Models/Component.cs @@ -1,16 +1,19 @@ -using System.Xml.Linq; +using System.Runtime.Serialization; +using System.Xml.Linq; using SofrwareInstallationContracts.BindingModels; using SofrwareInstallationContracts.ViewModels; using SoftwareInstallationDataModels.Models; namespace SoftwareInstallationFileImplement.Models { + [DataContract] public class Component : IComponentModel { + [DataMember] public string ComponentName { get; private set; } = string.Empty; - + [DataMember] public double Cost { get; set; } - + [DataMember] public int Id { get; private set; } public static Component? Create(ComponentBindingModel model) diff --git a/SoftwareInstallation/SoftwareInstallationFileImplement/Models/Implementer.cs b/SoftwareInstallation/SoftwareInstallationFileImplement/Models/Implementer.cs index 148a310..1fd45aa 100644 --- a/SoftwareInstallation/SoftwareInstallationFileImplement/Models/Implementer.cs +++ b/SoftwareInstallation/SoftwareInstallationFileImplement/Models/Implementer.cs @@ -1,20 +1,23 @@ using SofrwareInstallationContracts.BindingModels; using SofrwareInstallationContracts.ViewModels; using SoftwareInstallationDataModels.Models; +using System.Runtime.Serialization; using System.Xml.Linq; namespace SoftwareInstallationFileImplement.Models { + [DataContract] public class Implementer : IImplementerModel { + [DataMember] public string ImplementerFIO { get; private set; } = string.Empty; - + [DataMember] public string Password { get; private set; } = string.Empty; - + [DataMember] public int WorkExperience { get; private set; } - + [DataMember] public int Qualification { get; private set; } - + [DataMember] public int Id { get; private set; } public static Implementer? Create(XElement element) diff --git a/SoftwareInstallation/SoftwareInstallationFileImplement/Models/Message.cs b/SoftwareInstallation/SoftwareInstallationFileImplement/Models/Message.cs index 7431ba0..b79f7c7 100644 --- a/SoftwareInstallation/SoftwareInstallationFileImplement/Models/Message.cs +++ b/SoftwareInstallation/SoftwareInstallationFileImplement/Models/Message.cs @@ -1,22 +1,25 @@ using SofrwareInstallationContracts.BindingModels; using SofrwareInstallationContracts.ViewModels; using SoftwareInstallationDataModels.Models; +using System.Runtime.Serialization; using System.Xml.Linq; namespace SoftwareInstallationFileImplement.Models { + [DataContract] public class Message : IMessageInfoModel { + [DataMember] public string MessageId { get; private set; } = string.Empty; - + [DataMember] public int? ClientId { get; private set; } - + [DataMember] public string SenderName { get; private set; } = string.Empty; - + [DataMember] public DateTime DateDelivery { get; private set; } = DateTime.Now; - + [DataMember] public string Subject { get; private set; } = string.Empty; - + [DataMember] public string Body { get; private set; } = string.Empty; public bool HasRead { get; private set; } @@ -93,5 +96,7 @@ namespace SoftwareInstallationFileImplement.Models new XAttribute("SenderName", SenderName), new XAttribute("DateDelivery", DateDelivery) ); + + public int Id => throw new NotImplementedException(); } } diff --git a/SoftwareInstallation/SoftwareInstallationFileImplement/Models/Order.cs b/SoftwareInstallation/SoftwareInstallationFileImplement/Models/Order.cs index 2e1e520..6aaaf18 100644 --- a/SoftwareInstallation/SoftwareInstallationFileImplement/Models/Order.cs +++ b/SoftwareInstallation/SoftwareInstallationFileImplement/Models/Order.cs @@ -2,30 +2,33 @@ using SofrwareInstallationContracts.ViewModels; using SoftwareInstallationDataModels.Enums; using SoftwareInstallationDataModels.Models; +using System.Runtime.Serialization; using System.Xml.Linq; namespace SoftwareInstallationFileImplement.Models { + [DataContract] public class Order : IOrderModel { + [DataMember] public int PackageId { get; private set; } - + [DataMember] public int? ImplementerId { get; set; } - + [DataMember] public int ClientId { get; private set; } - + [DataMember] public string PackageName { get; private set; } = string.Empty; - + [DataMember] public int Count { get; private set; } - + [DataMember] public double Sum { get; private set; } - + [DataMember] public OrderStatus Status { get; private set; } = OrderStatus.Неизвестен; - + [DataMember] public DateTime DateCreate { get; private set; } = DateTime.Now; - + [DataMember] public DateTime? DateImplement { get; private set; } - + [DataMember] public int Id { get; private set; } public static Order? Create(OrderBindingModel model) @@ -56,22 +59,22 @@ namespace SoftwareInstallationFileImplement.Models return null; } + DateTime.TryParse(element.Element("DateImplement")!.Value, out DateTime dateImpl); + var order = new Order() { + PackageName = element.Element("PackageName")!.Value, Id = Convert.ToInt32(element.Attribute("Id")!.Value), ImplementerId = Convert.ToInt32(element.Element("ImplementerId")!.Value), PackageId = Convert.ToInt32(element.Element("PackageId")!.Value), ClientId = Convert.ToInt32(element.Element("ClientId")!.Value), - PackageName = element.Element("PackageName")!.Value, Count = Convert.ToInt32(element.Element("Count")!.Value), Sum = Convert.ToDouble(element.Element("Sum")!.Value), - Status = (OrderStatus)Enum.Parse(typeof(OrderStatus), element.Element("Status")!.Value), - DateCreate = DateTime.ParseExact(element.Element("DateCreate")!.Value, "G", null) + Status = (OrderStatus)Convert.ToInt32(element.Element("Status")!.Value), + 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; } diff --git a/SoftwareInstallation/SoftwareInstallationFileImplement/Models/Package.cs b/SoftwareInstallation/SoftwareInstallationFileImplement/Models/Package.cs index aab99ff..251b0c6 100644 --- a/SoftwareInstallation/SoftwareInstallationFileImplement/Models/Package.cs +++ b/SoftwareInstallation/SoftwareInstallationFileImplement/Models/Package.cs @@ -1,20 +1,23 @@ using SofrwareInstallationContracts.BindingModels; using SofrwareInstallationContracts.ViewModels; using SoftwareInstallationDataModels.Models; +using System.Runtime.Serialization; using System.Xml.Linq; namespace SoftwareInstallationFileImplement.Models { + [DataContract] public class Package : IPackageModel { + [DataMember] public string PackageName { get; private set; } = string.Empty; - + [DataMember] public double Price { get; private set; } public Dictionary Components { get; private set; } = new(); public Dictionary _packageComponents = null; - + [DataMember] public Dictionary PackageComponents { get @@ -27,7 +30,7 @@ namespace SoftwareInstallationFileImplement.Models return _packageComponents; } } - + [DataMember] public int Id { get; private set; } public static Package? Create(PackageBindingModel model) diff --git a/SoftwareInstallation/SoftwareInstallationFileImplement/SoftwareInstallationFileImplement.csproj b/SoftwareInstallation/SoftwareInstallationFileImplement/SoftwareInstallationFileImplement.csproj index 0fdeafe..dafc323 100644 --- a/SoftwareInstallation/SoftwareInstallationFileImplement/SoftwareInstallationFileImplement.csproj +++ b/SoftwareInstallation/SoftwareInstallationFileImplement/SoftwareInstallationFileImplement.csproj @@ -21,4 +21,8 @@ + + + + diff --git a/SoftwareInstallation/SoftwareInstallationListImplement/Implements/BackUpInfo.cs b/SoftwareInstallation/SoftwareInstallationListImplement/Implements/BackUpInfo.cs new file mode 100644 index 0000000..5061713 --- /dev/null +++ b/SoftwareInstallation/SoftwareInstallationListImplement/Implements/BackUpInfo.cs @@ -0,0 +1,17 @@ +using SofrwareInstallationContracts.StoragesContracts; + +namespace SoftwareInstallationListImplement.Implements +{ + public class BackUpInfo : IBackUpInfo + { + public List? GetList() where T : class, new() + { + throw new NotImplementedException(); + } + + public Type? GetTypeByModelInterface(string modelInterfaceName) + { + throw new NotImplementedException(); + } + } +} diff --git a/SoftwareInstallation/SoftwareInstallationListImplement/ListImplementationExtension.cs b/SoftwareInstallation/SoftwareInstallationListImplement/ListImplementationExtension.cs new file mode 100644 index 0000000..c1adfa8 --- /dev/null +++ b/SoftwareInstallation/SoftwareInstallationListImplement/ListImplementationExtension.cs @@ -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(); + DependencyManager.Instance.RegisterType(); + DependencyManager.Instance.RegisterType(); + DependencyManager.Instance.RegisterType(); + DependencyManager.Instance.RegisterType(); + DependencyManager.Instance.RegisterType(); + DependencyManager.Instance.RegisterType(); + } + + } +} diff --git a/SoftwareInstallation/SoftwareInstallationListImplement/Models/Message.cs b/SoftwareInstallation/SoftwareInstallationListImplement/Models/Message.cs index a0d1068..b8fa4aa 100644 --- a/SoftwareInstallation/SoftwareInstallationListImplement/Models/Message.cs +++ b/SoftwareInstallation/SoftwareInstallationListImplement/Models/Message.cs @@ -67,5 +67,7 @@ namespace SoftwareInstallationListImplement.Models ClientId = ClientId, MessageId = MessageId }; + + public int Id => throw new NotImplementedException(); } } diff --git a/SoftwareInstallation/SoftwareInstallationListImplement/SoftwareInstallationListImplement.csproj b/SoftwareInstallation/SoftwareInstallationListImplement/SoftwareInstallationListImplement.csproj index 916bb1e..0b5f35b 100644 --- a/SoftwareInstallation/SoftwareInstallationListImplement/SoftwareInstallationListImplement.csproj +++ b/SoftwareInstallation/SoftwareInstallationListImplement/SoftwareInstallationListImplement.csproj @@ -24,4 +24,8 @@ + + + +