ну и кринж
This commit is contained in:
parent
144ff6f004
commit
86ae282054
@ -15,4 +15,8 @@
|
|||||||
<ProjectReference Include="..\AircraftPlantDataModels\AircraftPlantDataModels.csproj" />
|
<ProjectReference Include="..\AircraftPlantDataModels\AircraftPlantDataModels.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
|
||||||
|
<Exec Command="copy /Y "$(TargetDir)*.dll" "$(SolutionDir)ImplementationExtensions\*.dll"" />
|
||||||
|
</Target>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
21
AircraftPlant/AbstractShopListImplement/BackUpInfo.cs
Normal file
21
AircraftPlant/AbstractShopListImplement/BackUpInfo.cs
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
using AircraftPlantContracts.StoragesContracts;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace AircraftPlantListImplement
|
||||||
|
{
|
||||||
|
public class BackUpInfo : IBackUpInfo
|
||||||
|
{
|
||||||
|
public List<T>? GetList<T>() where T : class, new()
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
public Type? GetTypeByModelInterface(string modelInterfaceName)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,27 @@
|
|||||||
|
using AircraftPlantContracts.DI;
|
||||||
|
using AircraftPlantContracts.StoragesContracts;
|
||||||
|
using AircraftPlantListImplement.Implements;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace AircraftPlantListImplement
|
||||||
|
{
|
||||||
|
public class ImplementationExtension : 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<IPlaneStorage, PlaneStorage>();
|
||||||
|
DependencyManager.Instance.RegisterType<IBackUpInfo, BackUpInfo>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,26 @@
|
|||||||
|
using AircraftPlantContracts.DI;
|
||||||
|
using AircraftPlantContracts.StoragesContracts;
|
||||||
|
using AircraftPlantListImplement.Implements;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace AircraftPlantListImplement
|
||||||
|
{
|
||||||
|
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<IPlaneStorage, PlaneStorage>();
|
||||||
|
DependencyManager.Instance.RegisterType<IBackUpInfo, BackUpInfo>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -17,6 +17,7 @@ namespace AircraftPlantListImplement
|
|||||||
public DateTime DateDelivery { get; set; }
|
public DateTime DateDelivery { get; set; }
|
||||||
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 int Id => throw new NotImplementedException();
|
||||||
public static Message? Create(MessageInfoBindingModel model)
|
public static Message? Create(MessageInfoBindingModel model)
|
||||||
{
|
{
|
||||||
if (model == null)
|
if (model == null)
|
||||||
|
@ -0,0 +1,101 @@
|
|||||||
|
using AircraftPlantContracts.BindingModels;
|
||||||
|
using AircraftPlantContracts.BusinessLogicsContracts;
|
||||||
|
using AircraftPlantContracts.StoragesContracts;
|
||||||
|
using AircraftPlantDataModels;
|
||||||
|
using DocumentFormat.OpenXml.EMMA;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO.Compression;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Reflection;
|
||||||
|
using System.Runtime.Serialization.Json;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace AircraftPlantBusinessLogic.BusinessLogics
|
||||||
|
{
|
||||||
|
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(BackUpSaveBindingModel 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -9,6 +9,8 @@
|
|||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Microsoft.Extensions.Logging" Version="8.0.0" />
|
<PackageReference Include="Microsoft.Extensions.Logging" Version="8.0.0" />
|
||||||
|
<PackageReference Include="Unity" Version="5.11.10" />
|
||||||
|
<PackageReference Include="Unity.Microsoft.Logging" Version="5.11.1" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
@ -0,0 +1,28 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace AircraftPlantContracts.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; }
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,20 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace AircraftPlantContracts.Attributes
|
||||||
|
{
|
||||||
|
public enum GridViewAutoSize
|
||||||
|
{
|
||||||
|
NotSet = 0,
|
||||||
|
None = 1,
|
||||||
|
ColumnHeader = 2,
|
||||||
|
AllCellsExceptHeader = 4,
|
||||||
|
AllCells = 6,
|
||||||
|
DisplayedCellsExceptHeader = 8,
|
||||||
|
DisplayedCells = 10,
|
||||||
|
Fill = 16
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,13 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace AircraftPlantContracts.BindingModels
|
||||||
|
{
|
||||||
|
public class BackUpSaveBindingModel
|
||||||
|
{
|
||||||
|
public string FolderName { get; set; } = string.Empty;
|
||||||
|
}
|
||||||
|
}
|
@ -15,5 +15,6 @@ namespace AircraftPlantContracts.BindingModels
|
|||||||
public DateTime DateDelivery { get; set; }
|
public DateTime DateDelivery { get; set; }
|
||||||
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 int Id => throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,14 @@
|
|||||||
|
using AircraftPlantContracts.BindingModels;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace AircraftPlantContracts.BusinessLogicsContracts
|
||||||
|
{
|
||||||
|
public interface IBackUpLogic
|
||||||
|
{
|
||||||
|
void CreateBackUp(BackUpSaveBindingModel model);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,69 @@
|
|||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace AircraftPlantContracts.DI
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Менеджер для работы с зависимостями
|
||||||
|
/// </summary>
|
||||||
|
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; } }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Иницализация библиотек, в которых идут установки зависомстей
|
||||||
|
/// </summary>
|
||||||
|
public static void InitDependency()
|
||||||
|
{
|
||||||
|
var ext = ServiceProviderLoader.GetImplementationExtensions();
|
||||||
|
if (ext == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException("Отсутствуют компоненты для загрузки зависимостей по модулям");
|
||||||
|
}
|
||||||
|
// регистрируем зависимости
|
||||||
|
ext.RegisterServices();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Регистрация логгера
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="configure"></param>
|
||||||
|
public void AddLogging(Action<ILoggingBuilder> configure) => _dependencyManager.AddLogging(configure);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Добавление зависимости
|
||||||
|
/// </summary>
|
||||||
|
/// <typeparam name="T"></typeparam>
|
||||||
|
/// <typeparam name="U"></typeparam>
|
||||||
|
public void RegisterType<T, U>(bool isSingle = false) where U : class, T where T : class => _dependencyManager.RegisterType<T, U>(isSingle);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Добавление зависимости
|
||||||
|
/// </summary>
|
||||||
|
/// <typeparam name="T"></typeparam>
|
||||||
|
/// <typeparam name="U"></typeparam>
|
||||||
|
public void RegisterType<T>(bool isSingle = false) where T : class => _dependencyManager.RegisterType<T>(isSingle);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Получение класса со всеми зависмостями
|
||||||
|
/// </summary>
|
||||||
|
/// <typeparam name="T"></typeparam>
|
||||||
|
/// <returns></returns>
|
||||||
|
public T Resolve<T>() => _dependencyManager.Resolve<T>();
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,38 @@
|
|||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace AircraftPlantContracts.DI
|
||||||
|
{
|
||||||
|
public interface IDependencyContainer
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Регистрация логгера
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="configure"></param>
|
||||||
|
void AddLogging(Action<ILoggingBuilder> configure);
|
||||||
|
/// <summary>
|
||||||
|
/// Добавление зависимости
|
||||||
|
/// </summary>
|
||||||
|
/// <typeparam name="T"></typeparam>
|
||||||
|
/// <typeparam name="U"></typeparam>
|
||||||
|
/// <param name="isSingle"></param>
|
||||||
|
void RegisterType<T, U>(bool isSingle) where U : class, T where T :
|
||||||
|
class;
|
||||||
|
/// <summary>
|
||||||
|
/// Добавление зависимости
|
||||||
|
/// </summary>
|
||||||
|
/// <typeparam name="T"></typeparam>
|
||||||
|
/// <param name="isSingle"></param>
|
||||||
|
void RegisterType<T>(bool isSingle) where T : class;
|
||||||
|
/// <summary>
|
||||||
|
/// Получение класса со всеми зависмостями
|
||||||
|
/// </summary>
|
||||||
|
/// <typeparam name="T"></typeparam>
|
||||||
|
/// <returns></returns>
|
||||||
|
T Resolve<T>();
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,20 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace AircraftPlantContracts.DI
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Интерфейс для регистрации зависимостей в модулях
|
||||||
|
/// </summary>
|
||||||
|
public interface IImplementationExtension
|
||||||
|
{
|
||||||
|
public int Priority { get; }
|
||||||
|
/// <summary>
|
||||||
|
/// Регистрация сервисов
|
||||||
|
/// </summary>
|
||||||
|
public void RegisterServices();
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,62 @@
|
|||||||
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace AircraftPlantContracts.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>()!;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,58 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Reflection;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace AircraftPlantContracts.DI
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Загрузчик данных
|
||||||
|
/// </summary>
|
||||||
|
public class ServiceProviderLoader
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Загрузка всех классов-реализаций IImplementationExtension
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
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";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,42 @@
|
|||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Unity.Microsoft.Logging;
|
||||||
|
using Unity;
|
||||||
|
|
||||||
|
namespace AircraftPlantContracts.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, U>(bool isSingle) where U : class, T where T : class
|
||||||
|
{
|
||||||
|
_container.RegisterType<T, U>(isSingle ? TypeLifetime.Singleton : TypeLifetime.Transient);
|
||||||
|
}
|
||||||
|
|
||||||
|
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>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,14 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace AircraftPlantContracts.StoragesContracts
|
||||||
|
{
|
||||||
|
public interface IBackUpInfo
|
||||||
|
{
|
||||||
|
List<T>? GetList<T>() where T : class, new();
|
||||||
|
Type? GetTypeByModelInterface(string modelInterfaceName);
|
||||||
|
}
|
||||||
|
}
|
@ -1,4 +1,5 @@
|
|||||||
using AircraftPlantDataModels;
|
using AircraftPlantContracts.Attributes;
|
||||||
|
using AircraftPlantDataModels;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
@ -10,12 +11,13 @@ namespace AircraftPlantContracts.ViewModels
|
|||||||
{
|
{
|
||||||
public class ClientViewModel : IClientModel
|
public class ClientViewModel : IClientModel
|
||||||
{
|
{
|
||||||
public int Id { get; set; }
|
[Column(visible: false)]
|
||||||
[DisplayName("ФИО клиента")]
|
public int Id { get; set; }
|
||||||
public string ClientFIO { get; set; } = string.Empty;
|
[Column(title: "ФИО клиента", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)]
|
||||||
[DisplayName("Логин (эл. почта)")]
|
public string ClientFIO { get; set; } = string.Empty;
|
||||||
|
[Column(title: "Логин (эл. почта)", width: 150)]
|
||||||
public string Email { get; set; } = string.Empty;
|
public string Email { get; set; } = string.Empty;
|
||||||
[DisplayName("Пароль")]
|
[Column(title: "Пароль", width: 150)]
|
||||||
public string Password { get; set; } = string.Empty;
|
public string Password { get; set; } = string.Empty;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
using AircraftPlantDataModels.Models;
|
using AircraftPlantContracts.Attributes;
|
||||||
|
using AircraftPlantDataModels.Models;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
@ -10,10 +11,11 @@ namespace AircraftPlantContracts.ViewModels
|
|||||||
{
|
{
|
||||||
public class ComponentViewModel : IComponentModel
|
public class ComponentViewModel : IComponentModel
|
||||||
{
|
{
|
||||||
|
[Column(visible: false)]
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
[DisplayName("Название компонента")]
|
[Column(title: "Компонент", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)]
|
||||||
public string ComponentName { get; set; } = string.Empty;
|
public string ComponentName { get; set; } = string.Empty;
|
||||||
[DisplayName("Цена")]
|
[Column(title: "Цена", width: 150)]
|
||||||
public double Cost { get; set; }
|
public double Cost { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
using AircraftPlantDataModels;
|
using AircraftPlantContracts.Attributes;
|
||||||
|
using AircraftPlantDataModels;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
@ -10,14 +11,15 @@ namespace AircraftPlantContracts.ViewModels
|
|||||||
{
|
{
|
||||||
public class ImplementerViewModel : IImplementerModel
|
public class ImplementerViewModel : IImplementerModel
|
||||||
{
|
{
|
||||||
|
[Column(visible: false)]
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
[DisplayName("ФИО исполнителя")]
|
[Column(title: "ФИО исполнителя", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)]
|
||||||
public string ImplementerFIO { get; set; } = string.Empty;
|
public string ImplementerFIO { get; set; } = string.Empty;
|
||||||
[DisplayName("Пароль")]
|
[Column(title: "Пароль", width: 100)]
|
||||||
public string Password { get; set; } = string.Empty;
|
public string Password { get; set; } = string.Empty;
|
||||||
[DisplayName("Опыт работы")]
|
[Column(title: "Стаж работы", width: 150)]
|
||||||
public int WorkExperience { get; set; }
|
public int WorkExperience { get; set; }
|
||||||
[DisplayName("Квалификация")]
|
[Column(title: "Квалификация", width: 150)]
|
||||||
public int Qualification { get; set; }
|
public int Qualification { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
using AircraftPlantDataModels;
|
using AircraftPlantContracts.Attributes;
|
||||||
|
using AircraftPlantDataModels;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
@ -10,15 +11,25 @@ namespace AircraftPlantContracts.ViewModels
|
|||||||
{
|
{
|
||||||
public class MessageInfoViewModel : IMessageInfoModel
|
public class MessageInfoViewModel : IMessageInfoModel
|
||||||
{
|
{
|
||||||
|
[Column(visible: false)]
|
||||||
|
public int Id { get; set; }
|
||||||
|
|
||||||
|
[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(title: "Отправитель", width: 150)]
|
||||||
public string SenderName { get; set; } = string.Empty;
|
public string SenderName { get; set; } = string.Empty;
|
||||||
[DisplayName("Дата письма")]
|
|
||||||
|
[Column(title: "Дата письма", width: 120)]
|
||||||
public DateTime DateDelivery { get; set; }
|
public DateTime DateDelivery { get; set; }
|
||||||
[DisplayName("Заголовок")]
|
|
||||||
|
[Column(title: "Заголовок", width: 120)]
|
||||||
public string Subject { get; set; } = string.Empty;
|
public string Subject { get; set; } = string.Empty;
|
||||||
[DisplayName("Текст")]
|
|
||||||
|
[Column(title: "Текст", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)]
|
||||||
public string Body { get; set; } = string.Empty;
|
public string Body { get; set; } = string.Empty;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -6,6 +6,7 @@ using System.ComponentModel;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using AircraftPlantContracts.Attributes;
|
||||||
|
|
||||||
namespace AircraftPlantContracts.ViewModels
|
namespace AircraftPlantContracts.ViewModels
|
||||||
{
|
{
|
||||||
@ -18,69 +19,77 @@ namespace AircraftPlantContracts.ViewModels
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Идентификатор
|
/// Идентификатор
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[DisplayName("Номер")]
|
[Column(title: "Номер", width: 90)]
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Идентификатор изделия
|
/// Идентификатор изделия
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
[Column(visible: false)]
|
||||||
public int PlaneId { get; set; }
|
public int PlaneId { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Название изделия
|
/// Название изделия
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[DisplayName("Изделие")]
|
[Column(title: "Изделие", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)]
|
||||||
public string PlaneName { get; set; } = string.Empty;
|
public string PlaneName { get; set; } = string.Empty;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Идентификатор клиента
|
/// Идентификатор клиента
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
[Column(visible: false)]
|
||||||
public int ClientId { get; set; }
|
public int ClientId { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// ФИО клиента
|
/// ФИО клиента
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[DisplayName("ФИО клиента")]
|
[Column(title: "Имя клиента", width: 190)]
|
||||||
public string ClientFIO { get; set; } = string.Empty;
|
public string ClientFIO { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Email клиента
|
||||||
|
/// </summary>
|
||||||
|
[Column(visible: false)]
|
||||||
|
public string ClientEmail { get; set; } = string.Empty;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Идентификатор исполнителя
|
/// Идентификатор исполнителя
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
[Column(visible: false)]
|
||||||
public int? ImplementerId { get; set; }
|
public int? ImplementerId { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// ФИО исполнителя
|
/// ФИО исполнителя
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[DisplayName("ФИО исполнителя")]
|
[Column(title: "ФИО исполнителя", width: 150)]
|
||||||
public string ImplementerFIO { get; set; } = string.Empty;
|
public string? ImplementerFIO { get; set; } = null;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Количество изделий
|
/// Количество изделий
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[DisplayName("Количество")]
|
[Column(title: "Количество", width: 100)]
|
||||||
public int Count { get; set; }
|
public int Count { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Сумма заказа
|
/// Сумма заказа
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[DisplayName("Сумма")]
|
[Column(title: "Сумма", width: 120)]
|
||||||
public double Sum { get; set; }
|
public double Sum { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Статус заказа
|
/// Статус заказа
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[DisplayName("Статус")]
|
[Column(title: "Статус", width: 70)]
|
||||||
public OrderStatus Status { get; set; } = OrderStatus.Неизвестен;
|
public OrderStatus Status { get; set; } = OrderStatus.Неизвестен;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Дата создания заказа
|
/// Дата создания заказа
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[DisplayName("Дата создания")]
|
[Column(title: "Дата создания", width: 120)]
|
||||||
public DateTime DateCreate { get; set; } = DateTime.Now;
|
public DateTime DateCreate { get; set; } = DateTime.Now;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Дата выполнения заказа
|
/// Дата выполнения заказа
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[DisplayName("Дата выполнения")]
|
[Column(title: "Дата выполнения", width: 120)]
|
||||||
public DateTime? DateImplement { get; set; }
|
public DateTime? DateImplement { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
using AircraftPlantDataModels.Models;
|
using AircraftPlantContracts.Attributes;
|
||||||
|
using AircraftPlantDataModels.Models;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
@ -17,23 +18,25 @@ namespace AircraftPlantContracts.ViewModels
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Идентификатор
|
/// Идентификатор
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
[Column(visible: false)]
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Название изделия
|
/// Название изделия
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[DisplayName("Название изделия")]
|
[Column(title: "Название изделия", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)]
|
||||||
public string PlaneName { get; set; } = string.Empty;
|
public string PlaneName { get; set; } = string.Empty;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Стоимость изделия
|
/// Стоимость изделия
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[DisplayName("Цена")]
|
[Column(title: "Цена", width: 70)]
|
||||||
public double Price { get; set; }
|
public double Price { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Коллекция компонентов изделия
|
/// Коллекция компонентов изделия
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
[Column(visible: false)]
|
||||||
public Dictionary<int, (IComponentModel, int)> PlaneComponents
|
public Dictionary<int, (IComponentModel, int)> PlaneComponents
|
||||||
{
|
{
|
||||||
get;
|
get;
|
||||||
|
@ -6,7 +6,7 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace AircraftPlantDataModels
|
namespace AircraftPlantDataModels
|
||||||
{
|
{
|
||||||
public interface IMessageInfoModel
|
public interface IMessageInfoModel : IId
|
||||||
{
|
{
|
||||||
string MessageId { get; }
|
string MessageId { get; }
|
||||||
int? ClientId { get; }
|
int? ClientId { get; }
|
||||||
|
@ -20,6 +20,10 @@
|
|||||||
<ProjectReference Include="..\AircraftPlantDataModels\AircraftPlantDataModels.csproj" />
|
<ProjectReference Include="..\AircraftPlantDataModels\AircraftPlantDataModels.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
|
||||||
|
<Exec Command="copy /Y "$(TargetDir)*.dll" "$(SolutionDir)ImplementationExtensions\*.dll"" />
|
||||||
|
</Target>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Folder Include="Migrations\" />
|
<Folder Include="Migrations\" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
@ -0,0 +1,27 @@
|
|||||||
|
using AircraftPlantContracts.DI;
|
||||||
|
using AircraftPlantContracts.StoragesContracts;
|
||||||
|
using AircraftPlantDatabaseImplement.Implements;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace AircraftPlantDatabaseImplement
|
||||||
|
{
|
||||||
|
public class ImplementationExtension : IImplementationExtension
|
||||||
|
{
|
||||||
|
public int Priority => 3;
|
||||||
|
|
||||||
|
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<IPlaneStorage, PlaneStorage>();
|
||||||
|
DependencyManager.Instance.RegisterType<IBackUpInfo, BackUpInfo>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,32 @@
|
|||||||
|
using AircraftPlantContracts.StoragesContracts;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace AircraftPlantDatabaseImplement.Implements
|
||||||
|
{
|
||||||
|
public class BackUpInfo : IBackUpInfo
|
||||||
|
{
|
||||||
|
public List<T>? GetList<T>() where T : class, new()
|
||||||
|
{
|
||||||
|
using var context = new AircraftPlantDatabase();
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -6,18 +6,24 @@ using System.Collections.Generic;
|
|||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
using System.ComponentModel.DataAnnotations.Schema;
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Runtime.Serialization;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace AircraftPlantDatabaseImplement.Models
|
namespace AircraftPlantDatabaseImplement.Models
|
||||||
{
|
{
|
||||||
|
[DataContract]
|
||||||
public class Client : IClientModel
|
public class Client : IClientModel
|
||||||
{
|
{
|
||||||
|
[DataMember]
|
||||||
public int Id { get; private set; }
|
public int Id { get; private set; }
|
||||||
|
[DataMember]
|
||||||
[Required]
|
[Required]
|
||||||
public string ClientFIO { get; set; } = string.Empty;
|
public string ClientFIO { get; set; } = string.Empty;
|
||||||
|
[DataMember]
|
||||||
[Required]
|
[Required]
|
||||||
public string Email { get; set; } = string.Empty;
|
public string Email { get; set; } = string.Empty;
|
||||||
|
[DataMember]
|
||||||
[Required]
|
[Required]
|
||||||
public string Password { get; set; } = string.Empty;
|
public string Password { get; set; } = string.Empty;
|
||||||
[ForeignKey("ClientId")]
|
[ForeignKey("ClientId")]
|
||||||
|
@ -5,16 +5,21 @@ using System;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
using System.ComponentModel.DataAnnotations.Schema;
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
using System.Runtime.Serialization;
|
||||||
|
|
||||||
namespace AircraftPlantDatabaseImplement.Models
|
namespace AircraftPlantDatabaseImplement.Models
|
||||||
{
|
{
|
||||||
|
[DataContract]
|
||||||
public class Component : IComponentModel
|
public class Component : IComponentModel
|
||||||
{
|
{
|
||||||
|
[DataMember]
|
||||||
public int Id { get; private set; }
|
public int Id { get; private set; }
|
||||||
|
|
||||||
|
[DataMember]
|
||||||
[Required]
|
[Required]
|
||||||
public string ComponentName { get; private set; } = string.Empty;
|
public string ComponentName { get; private set; } = string.Empty;
|
||||||
|
|
||||||
|
[DataMember]
|
||||||
[Required]
|
[Required]
|
||||||
public double Cost { get; set; }
|
public double Cost { get; set; }
|
||||||
|
|
||||||
|
@ -8,18 +8,29 @@ using System.ComponentModel.DataAnnotations;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using System.Runtime.Serialization;
|
||||||
|
|
||||||
namespace AircraftPlantDatabaseImplement.Models
|
namespace AircraftPlantDatabaseImplement.Models
|
||||||
{
|
{
|
||||||
|
[DataContract]
|
||||||
public class Implementer : IImplementerModel
|
public class Implementer : IImplementerModel
|
||||||
{
|
{
|
||||||
|
[DataMember]
|
||||||
public int Id { get; private set; }
|
public int Id { get; private set; }
|
||||||
|
|
||||||
|
[DataMember]
|
||||||
[Required]
|
[Required]
|
||||||
public string ImplementerFIO { get; private set; } = string.Empty;
|
public string ImplementerFIO { get; private set; } = string.Empty;
|
||||||
|
|
||||||
|
[DataMember]
|
||||||
[Required]
|
[Required]
|
||||||
public string Password { get; private set; } = string.Empty;
|
public string Password { get; private set; } = string.Empty;
|
||||||
|
|
||||||
|
[DataMember]
|
||||||
[Required]
|
[Required]
|
||||||
public int WorkExperience { get; private set; }
|
public int WorkExperience { get; private set; }
|
||||||
|
|
||||||
|
[DataMember]
|
||||||
[Required]
|
[Required]
|
||||||
public int Qualification { get; private set; }
|
public int Qualification { get; private set; }
|
||||||
[ForeignKey("ImplementerId")]
|
[ForeignKey("ImplementerId")]
|
||||||
|
@ -4,7 +4,9 @@ using AircraftPlantDataModels;
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Runtime.Serialization;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
@ -12,16 +14,30 @@ namespace AircraftPlantDatabaseImplement.Models
|
|||||||
{
|
{
|
||||||
public class Message : IMessageInfoModel
|
public class Message : IMessageInfoModel
|
||||||
{
|
{
|
||||||
|
[NotMapped]
|
||||||
|
public int Id { get; private set; }
|
||||||
|
|
||||||
|
[DataMember]
|
||||||
[Key]
|
[Key]
|
||||||
public string MessageId { get; set; } = string.Empty;
|
public string MessageId { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
[DataMember]
|
||||||
public int? ClientId { get; set; }
|
public int? ClientId { get; set; }
|
||||||
public virtual Client? Client { get; set; }
|
public virtual Client? Client { get; set; }
|
||||||
|
|
||||||
|
[DataMember]
|
||||||
[Required]
|
[Required]
|
||||||
public string SenderName { get; set; } = string.Empty;
|
public string SenderName { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
[DataMember]
|
||||||
[Required]
|
[Required]
|
||||||
public DateTime DateDelivery { get; set; }
|
public DateTime DateDelivery { get; set; }
|
||||||
|
|
||||||
|
[DataMember]
|
||||||
[Required]
|
[Required]
|
||||||
public string Subject { get; set; } = string.Empty;
|
public string Subject { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
[DataMember]
|
||||||
[Required]
|
[Required]
|
||||||
public string Body { get; set; } = string.Empty;
|
public string Body { get; set; } = string.Empty;
|
||||||
public static Message? Create(MessageInfoBindingModel model)
|
public static Message? Create(MessageInfoBindingModel model)
|
||||||
|
@ -3,39 +3,51 @@ using AircraftPlantContracts.ViewModels;
|
|||||||
using AircraftPlantDataModels.Enums;
|
using AircraftPlantDataModels.Enums;
|
||||||
using AircraftPlantDataModels.Models;
|
using AircraftPlantDataModels.Models;
|
||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using System.Runtime.Serialization;
|
||||||
|
|
||||||
namespace AircraftPlantDatabaseImplement.Models
|
namespace AircraftPlantDatabaseImplement.Models
|
||||||
{
|
{
|
||||||
|
[DataContract]
|
||||||
public class Order : IOrderModel
|
public class Order : IOrderModel
|
||||||
{
|
{
|
||||||
|
[DataMember]
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
|
|
||||||
|
[DataMember]
|
||||||
[Required]
|
[Required]
|
||||||
public int PlaneId { get; set; }
|
public int PlaneId { get; set; }
|
||||||
|
|
||||||
public virtual Plane Plane { get; set; } = new();
|
public virtual Plane Plane { get; set; } = new();
|
||||||
|
|
||||||
|
[DataMember]
|
||||||
[Required]
|
[Required]
|
||||||
public int ClientId { get; set; }
|
public int ClientId { get; set; }
|
||||||
|
|
||||||
|
[DataMember]
|
||||||
public Client Client { get; set; } = new();
|
public Client Client { get; set; } = new();
|
||||||
|
|
||||||
|
[DataMember]
|
||||||
public int? ImplementerId { get; set; }
|
public int? ImplementerId { get; set; }
|
||||||
|
|
||||||
public virtual Implementer? Implementer { get; set; } = new();
|
public virtual Implementer? Implementer { get; set; } = new();
|
||||||
|
|
||||||
|
[DataMember]
|
||||||
[Required]
|
[Required]
|
||||||
public int Count { get; set; }
|
public int Count { get; set; }
|
||||||
|
|
||||||
|
[DataMember]
|
||||||
[Required]
|
[Required]
|
||||||
public double Sum { get; set; }
|
public double Sum { get; set; }
|
||||||
|
|
||||||
|
[DataMember]
|
||||||
[Required]
|
[Required]
|
||||||
public OrderStatus Status { get; set; }
|
public OrderStatus Status { get; set; }
|
||||||
|
|
||||||
|
[DataMember]
|
||||||
[Required]
|
[Required]
|
||||||
public DateTime DateCreate { get; set; }
|
public DateTime DateCreate { get; set; }
|
||||||
|
|
||||||
|
[DataMember]
|
||||||
public DateTime? DateImplement { get; set; }
|
public DateTime? DateImplement { get; set; }
|
||||||
|
|
||||||
public static Order? Create(AircraftPlantDatabase context, OrderBindingModel? model)
|
public static Order? Create(AircraftPlantDatabase context, OrderBindingModel? model)
|
||||||
|
@ -8,17 +8,26 @@ using AircraftPlantContracts.ViewModels;
|
|||||||
using AircraftPlantDataModels.Models;
|
using AircraftPlantDataModels.Models;
|
||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
using System.ComponentModel.DataAnnotations.Schema;
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
using System.Runtime.Serialization;
|
||||||
|
|
||||||
namespace AircraftPlantDatabaseImplement.Models
|
namespace AircraftPlantDatabaseImplement.Models
|
||||||
{
|
{
|
||||||
|
[DataContract]
|
||||||
public class Plane : IPlaneModel
|
public class Plane : IPlaneModel
|
||||||
{
|
{
|
||||||
|
[DataMember]
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
|
|
||||||
|
[DataMember]
|
||||||
[Required]
|
[Required]
|
||||||
public string PlaneName { get; set; } = string.Empty;
|
public string PlaneName { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
[DataMember]
|
||||||
[Required]
|
[Required]
|
||||||
public double Price { get; set; }
|
public double Price { get; set; }
|
||||||
private Dictionary<int, (IComponentModel, int)>? _planeComponents = null;
|
private Dictionary<int, (IComponentModel, int)>? _planeComponents = null;
|
||||||
|
|
||||||
|
[DataMember]
|
||||||
[NotMapped]
|
[NotMapped]
|
||||||
public Dictionary<int, (IComponentModel, int)> PlaneComponents
|
public Dictionary<int, (IComponentModel, int)> PlaneComponents
|
||||||
{
|
{
|
||||||
|
@ -11,4 +11,8 @@
|
|||||||
<ProjectReference Include="..\AircraftPlantDataModels\AircraftPlantDataModels.csproj" />
|
<ProjectReference Include="..\AircraftPlantDataModels\AircraftPlantDataModels.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
|
||||||
|
<Exec Command="copy /Y "$(TargetDir)*.dll" "$(SolutionDir)ImplementationExtensions\*.dll"" />
|
||||||
|
</Target>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
44
AircraftPlant/AircraftPlantFileImplement/BackUpInfo.cs
Normal file
44
AircraftPlant/AircraftPlantFileImplement/BackUpInfo.cs
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
using AircraftPlantContracts.StoragesContracts;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Reflection;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace AircraftPlantFileImplement
|
||||||
|
{
|
||||||
|
public class BackUpInfo : IBackUpInfo
|
||||||
|
{
|
||||||
|
private readonly DataFileSingleton source;
|
||||||
|
private readonly PropertyInfo[] sourceProperties;
|
||||||
|
|
||||||
|
public BackUpInfo()
|
||||||
|
{
|
||||||
|
source = DataFileSingleton.GetInstance();
|
||||||
|
sourceProperties = source.GetType().GetProperties(BindingFlags.Instance | BindingFlags.Public);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<T>? GetList<T>() where T : class, new()
|
||||||
|
{
|
||||||
|
var requredType = typeof(T);
|
||||||
|
return (List<T>?)sourceProperties.FirstOrDefault(x => x.PropertyType.IsGenericType && x.PropertyType.GetGenericArguments()[0] == requredType)
|
||||||
|
?.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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -4,17 +4,23 @@ using AircraftPlantDataModels;
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Runtime.Serialization;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Xml.Linq;
|
using System.Xml.Linq;
|
||||||
|
|
||||||
namespace AircraftPlantFileImplement
|
namespace AircraftPlantFileImplement
|
||||||
{
|
{
|
||||||
|
[DataContract]
|
||||||
public class Client : IClientModel
|
public class Client : IClientModel
|
||||||
{
|
{
|
||||||
|
[DataMember]
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
|
[DataMember]
|
||||||
public string ClientFIO { get; set; } = string.Empty;
|
public string ClientFIO { get; 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)
|
||||||
{
|
{
|
||||||
|
@ -1,14 +1,19 @@
|
|||||||
using AircraftPlantContracts.BindingModels;
|
using AircraftPlantContracts.BindingModels;
|
||||||
using AircraftPlantContracts.ViewModels;
|
using AircraftPlantContracts.ViewModels;
|
||||||
using AircraftPlantDataModels.Models;
|
using AircraftPlantDataModels.Models;
|
||||||
|
using System.Runtime.Serialization;
|
||||||
using System.Xml.Linq;
|
using System.Xml.Linq;
|
||||||
|
|
||||||
namespace AircraftPlantFileImplement.Models
|
namespace AircraftPlantFileImplement.Models
|
||||||
{
|
{
|
||||||
|
[DataContract]
|
||||||
public class Component : IComponentModel
|
public class Component : IComponentModel
|
||||||
{
|
{
|
||||||
|
[DataMember]
|
||||||
public int Id { get; private set; }
|
public int Id { get; private set; }
|
||||||
|
[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; }
|
||||||
public static Component? Create(ComponentBindingModel model)
|
public static Component? Create(ComponentBindingModel model)
|
||||||
{
|
{
|
||||||
@ -32,8 +37,8 @@ namespace AircraftPlantFileImplement.Models
|
|||||||
return new Component()
|
return new Component()
|
||||||
{
|
{
|
||||||
Id = Convert.ToInt32(element.Attribute("Id")!.Value),
|
Id = Convert.ToInt32(element.Attribute("Id")!.Value),
|
||||||
ComponentName = element.Element("ComponentName")!.Value,
|
ComponentName = element.Element("Компонент")!.Value,
|
||||||
Cost = Convert.ToDouble(element.Element("Cost")!.Value)
|
Cost = Convert.ToDouble(element.Element("Стоимость")!.Value)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
public void Update(ComponentBindingModel model)
|
public void Update(ComponentBindingModel model)
|
||||||
@ -53,7 +58,7 @@ namespace AircraftPlantFileImplement.Models
|
|||||||
};
|
};
|
||||||
public XElement GetXElement => new("Component",
|
public XElement GetXElement => new("Component",
|
||||||
new XAttribute("Id", Id),
|
new XAttribute("Id", Id),
|
||||||
new XElement("ComponentName", ComponentName),
|
new XElement("Компонент", ComponentName),
|
||||||
new XElement("Cost", Cost.ToString()));
|
new XElement("Стоимость", Cost.ToString()));
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -0,0 +1,27 @@
|
|||||||
|
using AircraftPlantContracts.DI;
|
||||||
|
using AircraftPlantContracts.StoragesContracts;
|
||||||
|
using AircraftPlantFileImplement.Implements;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace AircraftPlantFileImplement
|
||||||
|
{
|
||||||
|
public class ImplementationExtension : 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<IPlaneStorage, PlaneStorage>();
|
||||||
|
DependencyManager.Instance.RegisterType<IBackUpInfo, BackUpInfo>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -4,18 +4,25 @@ using AircraftPlantDataModels;
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Runtime.Serialization;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Xml.Linq;
|
using System.Xml.Linq;
|
||||||
|
|
||||||
namespace AircraftPlantFileImplement
|
namespace AircraftPlantFileImplement
|
||||||
{
|
{
|
||||||
|
[DataContract]
|
||||||
public class Implementer : IImplementerModel
|
public class Implementer : IImplementerModel
|
||||||
{
|
{
|
||||||
|
[DataMember]
|
||||||
public int Id { get; private set; }
|
public int Id { get; private set; }
|
||||||
|
[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; }
|
||||||
public static Implementer? Create(ImplementerBindingModel? model)
|
public static Implementer? Create(ImplementerBindingModel? model)
|
||||||
{
|
{
|
||||||
|
@ -4,19 +4,29 @@ using AircraftPlantDataModels;
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Runtime.Serialization;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Xml.Linq;
|
using System.Xml.Linq;
|
||||||
|
|
||||||
namespace AircraftPlantFileImplement
|
namespace AircraftPlantFileImplement
|
||||||
{
|
{
|
||||||
|
[DataContract]
|
||||||
public class Message : IMessageInfoModel
|
public class Message : IMessageInfoModel
|
||||||
{
|
{
|
||||||
|
[DataMember]
|
||||||
|
public int Id { get; private set; }
|
||||||
|
[DataMember]
|
||||||
public string MessageId { get; set; } = string.Empty;
|
public string MessageId { get; set; } = string.Empty;
|
||||||
|
[DataMember]
|
||||||
public int? ClientId { get; set; }
|
public int? ClientId { get; set; }
|
||||||
|
[DataMember]
|
||||||
public string SenderName { get; set; } = string.Empty;
|
public string SenderName { get; set; } = string.Empty;
|
||||||
|
[DataMember]
|
||||||
public DateTime DateDelivery { get; set; }
|
public DateTime DateDelivery { get; set; }
|
||||||
|
[DataMember]
|
||||||
public string Subject { get; set; } = string.Empty;
|
public string Subject { get; set; } = string.Empty;
|
||||||
|
[DataMember]
|
||||||
public string Body { get; set; } = string.Empty;
|
public string Body { get; set; } = string.Empty;
|
||||||
public static Message? Create(MessageInfoBindingModel model)
|
public static Message? Create(MessageInfoBindingModel model)
|
||||||
{
|
{
|
||||||
|
@ -5,22 +5,33 @@ using AircraftPlantDataModels.Models;
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Runtime.Serialization;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Xml.Linq;
|
using System.Xml.Linq;
|
||||||
|
|
||||||
namespace AircraftPlantFileImplement.Models
|
namespace AircraftPlantFileImplement.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 PlaneId { get; private set; }
|
public int PlaneId { get; private set; }
|
||||||
|
[DataMember]
|
||||||
public int ClientId { get; private set; }
|
public int ClientId { get; private set; }
|
||||||
|
[DataMember]
|
||||||
public int? ImplementerId { get; private set; }
|
public int? ImplementerId { get; private set; }
|
||||||
|
[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; }
|
public OrderStatus Status { get; private set; }
|
||||||
|
[DataMember]
|
||||||
public DateTime DateCreate { get; private set; }
|
public DateTime DateCreate { get; private set; }
|
||||||
|
[DataMember]
|
||||||
public DateTime? DateImplement { get; private set; }
|
public DateTime? DateImplement { get; private set; }
|
||||||
public static Order? Create(OrderBindingModel? model)
|
public static Order? Create(OrderBindingModel? model)
|
||||||
{
|
{
|
||||||
|
@ -7,17 +7,22 @@ using AircraftPlantContracts.BindingModels;
|
|||||||
using AircraftPlantContracts.ViewModels;
|
using AircraftPlantContracts.ViewModels;
|
||||||
using AircraftPlantDataModels.Models;
|
using AircraftPlantDataModels.Models;
|
||||||
using System.Xml.Linq;
|
using System.Xml.Linq;
|
||||||
|
using System.Runtime.Serialization;
|
||||||
|
|
||||||
namespace AircraftPlantFileImplement.Models
|
namespace AircraftPlantFileImplement.Models
|
||||||
{
|
{
|
||||||
|
[DataContract]
|
||||||
public class Plane : IPlaneModel
|
public class Plane : IPlaneModel
|
||||||
{
|
{
|
||||||
|
[DataMember]
|
||||||
public int Id { get; private set; }
|
public int Id { get; private set; }
|
||||||
|
[DataMember]
|
||||||
public string PlaneName { get; private set; } = string.Empty;
|
public string PlaneName { 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();
|
||||||
private Dictionary<int, (IComponentModel, int)>? _planeComponents =
|
private Dictionary<int, (IComponentModel, int)>? _planeComponents = null;
|
||||||
null;
|
[DataMember]
|
||||||
public Dictionary<int, (IComponentModel, int)> PlaneComponents
|
public Dictionary<int, (IComponentModel, int)> PlaneComponents
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
|
55
AircraftPlant/AircraftPlantView/DataGridViewExtension.cs
Normal file
55
AircraftPlant/AircraftPlantView/DataGridViewExtension.cs
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
using AircraftPlantContracts.Attributes;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace AircraftPlantView
|
||||||
|
{
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -65,14 +65,7 @@ namespace AircraftPlantView
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var list = _logic.ReadList(null);
|
dataGridViewClients.FillAndConfigGrid(_logic.ReadList(null));
|
||||||
if (list != null)
|
|
||||||
{
|
|
||||||
dataGridViewClients.DataSource = list;
|
|
||||||
dataGridViewClients.Columns["Id"].Visible = false;
|
|
||||||
dataGridViewClients.Columns["ClientFIO"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
|
||||||
dataGridViewClients.Columns["Email"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
|
||||||
}
|
|
||||||
_logger.LogInformation("Загрузка клиентов");
|
_logger.LogInformation("Загрузка клиентов");
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
|
@ -9,6 +9,7 @@ using System.Threading.Tasks;
|
|||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
using AircraftPlantContracts.BindingModels;
|
using AircraftPlantContracts.BindingModels;
|
||||||
using AircraftPlantContracts.BusinessLogicsContracts;
|
using AircraftPlantContracts.BusinessLogicsContracts;
|
||||||
|
using AircraftPlantContracts.DI;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
|
|
||||||
namespace AircraftPlantView
|
namespace AircraftPlantView
|
||||||
@ -51,30 +52,22 @@ namespace AircraftPlantView
|
|||||||
}
|
}
|
||||||
private void ButtonAdd_Click(object sender, EventArgs e)
|
private void ButtonAdd_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
var service =
|
var form = DependencyManager.Instance.Resolve<FormComponent>();
|
||||||
Program.ServiceProvider?.GetService(typeof(FormComponent));
|
if (form.ShowDialog() == DialogResult.OK)
|
||||||
if (service is FormComponent form)
|
|
||||||
{
|
{
|
||||||
if (form.ShowDialog() == DialogResult.OK)
|
LoadData();
|
||||||
{
|
|
||||||
LoadData();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private void ButtonUpd_Click(object sender, EventArgs e)
|
private void ButtonUpd_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
if (dataGridViewComponents.SelectedRows.Count == 1)
|
if (dataGridViewComponents.SelectedRows.Count == 1)
|
||||||
{
|
{
|
||||||
var service =
|
var form = DependencyManager.Instance.Resolve<FormComponent>();
|
||||||
Program.ServiceProvider?.GetService(typeof(FormComponent));
|
|
||||||
if (service is FormComponent form)
|
form.Id = Convert.ToInt32(dataGridViewComponents.SelectedRows[0].Cells["Id"].Value);
|
||||||
|
if (form.ShowDialog() == DialogResult.OK)
|
||||||
{
|
{
|
||||||
form.Id =
|
LoadData();
|
||||||
Convert.ToInt32(dataGridViewComponents.SelectedRows[0].Cells["Id"].Value);
|
|
||||||
if (form.ShowDialog() == DialogResult.OK)
|
|
||||||
{
|
|
||||||
LoadData();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -85,13 +85,7 @@ namespace AircraftPlantView
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var list = _logic.ReadList(null);
|
dataGridViewImplementers.FillAndConfigGrid(_logic.ReadList(null));
|
||||||
if (list != null)
|
|
||||||
{
|
|
||||||
dataGridViewImplementers.DataSource = list;
|
|
||||||
dataGridViewImplementers.Columns["Id"].Visible = false;
|
|
||||||
dataGridViewImplementers.Columns["ImplementerFIO"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
|
||||||
}
|
|
||||||
_logger.LogInformation("Загрузка списка исполнителей");
|
_logger.LogInformation("Загрузка списка исполнителей");
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
|
@ -57,14 +57,7 @@ namespace AircraftPlantView
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var list = _logic.ReadList(null);
|
dataGridView.FillAndConfigGrid(_logic.ReadList(null));
|
||||||
if (list != null)
|
|
||||||
{
|
|
||||||
dataGridView.DataSource = list;
|
|
||||||
dataGridView.Columns["MessageId"].Visible = false;
|
|
||||||
dataGridView.Columns["ClientId"].Visible = false;
|
|
||||||
dataGridView.Columns["Body"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
|
||||||
}
|
|
||||||
_logger.LogInformation("Загрузка писем");
|
_logger.LogInformation("Загрузка писем");
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
|
14
AircraftPlant/AircraftPlantView/FormMain.Designer.cs
generated
14
AircraftPlant/AircraftPlantView/FormMain.Designer.cs
generated
@ -1,4 +1,5 @@
|
|||||||
namespace AircraftPlantView
|
|
||||||
|
namespace AircraftPlantView
|
||||||
{
|
{
|
||||||
partial class FormMain
|
partial class FormMain
|
||||||
{
|
{
|
||||||
@ -44,6 +45,7 @@
|
|||||||
списокЗаказовToolStripMenuItem = new ToolStripMenuItem();
|
списокЗаказовToolStripMenuItem = new ToolStripMenuItem();
|
||||||
запускРаботToolStripMenuItem = new ToolStripMenuItem();
|
запускРаботToolStripMenuItem = new ToolStripMenuItem();
|
||||||
почтаToolStripMenuItem = new ToolStripMenuItem();
|
почтаToolStripMenuItem = new ToolStripMenuItem();
|
||||||
|
создатьБекапToolStripMenuItem = new ToolStripMenuItem();
|
||||||
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
|
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
|
||||||
menuStrip1.SuspendLayout();
|
menuStrip1.SuspendLayout();
|
||||||
SuspendLayout();
|
SuspendLayout();
|
||||||
@ -105,7 +107,7 @@
|
|||||||
// menuStrip1
|
// menuStrip1
|
||||||
//
|
//
|
||||||
menuStrip1.ImageScalingSize = new Size(20, 20);
|
menuStrip1.ImageScalingSize = new Size(20, 20);
|
||||||
menuStrip1.Items.AddRange(new ToolStripItem[] { справочникиToolStripMenuItem, отчётыToolStripMenuItem, запускРаботToolStripMenuItem, почтаToolStripMenuItem });
|
menuStrip1.Items.AddRange(new ToolStripItem[] { справочникиToolStripMenuItem, отчётыToolStripMenuItem, запускРаботToolStripMenuItem, почтаToolStripMenuItem, создатьБекапToolStripMenuItem });
|
||||||
menuStrip1.Location = new Point(0, 0);
|
menuStrip1.Location = new Point(0, 0);
|
||||||
menuStrip1.Name = "menuStrip1";
|
menuStrip1.Name = "menuStrip1";
|
||||||
menuStrip1.Padding = new Padding(7, 3, 0, 3);
|
menuStrip1.Padding = new Padding(7, 3, 0, 3);
|
||||||
@ -190,6 +192,13 @@
|
|||||||
почтаToolStripMenuItem.Text = "Почта";
|
почтаToolStripMenuItem.Text = "Почта";
|
||||||
почтаToolStripMenuItem.Click += ПочтаToolStripMenuItem_Click;
|
почтаToolStripMenuItem.Click += ПочтаToolStripMenuItem_Click;
|
||||||
//
|
//
|
||||||
|
// создатьБекапToolStripMenuItem
|
||||||
|
//
|
||||||
|
создатьБекапToolStripMenuItem.Name = "cоздатьБекапToolStripMenuItem";
|
||||||
|
создатьБекапToolStripMenuItem.Size = new Size(123, 24);
|
||||||
|
создатьБекапToolStripMenuItem.Text = "Создать бекап";
|
||||||
|
создатьБекапToolStripMenuItem.Click += CоздатьБекапToolStripMenuItem_Click;
|
||||||
|
//
|
||||||
// FormMain
|
// FormMain
|
||||||
//
|
//
|
||||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||||
@ -230,5 +239,6 @@
|
|||||||
private ToolStripMenuItem исполнителиToolStripMenuItem;
|
private ToolStripMenuItem исполнителиToolStripMenuItem;
|
||||||
private ToolStripMenuItem запускРаботToolStripMenuItem;
|
private ToolStripMenuItem запускРаботToolStripMenuItem;
|
||||||
private ToolStripMenuItem почтаToolStripMenuItem;
|
private ToolStripMenuItem почтаToolStripMenuItem;
|
||||||
|
private ToolStripMenuItem создатьБекапToolStripMenuItem;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,6 +1,7 @@
|
|||||||
using AircraftPlantBusinessLogic.BusinessLogics;
|
using AircraftPlantBusinessLogic.BusinessLogics;
|
||||||
using AircraftPlantContracts.BindingModels;
|
using AircraftPlantContracts.BindingModels;
|
||||||
using AircraftPlantContracts.BusinessLogicsContracts;
|
using AircraftPlantContracts.BusinessLogicsContracts;
|
||||||
|
using AircraftPlantContracts.DI;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
@ -35,18 +36,21 @@ namespace AircraftPlantView
|
|||||||
/// Имитация деятельности исполнителей
|
/// Имитация деятельности исполнителей
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private readonly IWorkProcess _workProcess;
|
private readonly IWorkProcess _workProcess;
|
||||||
|
|
||||||
|
private readonly IBackUpLogic _backUpLogic;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Конструктор
|
/// Конструктор
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="logger"></param>
|
/// <param name="logger"></param>
|
||||||
/// <param name="logic"></param>
|
/// <param name="logic"></param>
|
||||||
public FormMain(ILogger<FormMain> logger, IOrderLogic orderLogic, IReportLogic reportLogic, IWorkProcess workProcess)
|
public FormMain(ILogger<FormMain> logger, IOrderLogic orderLogic, IReportLogic reportLogic, IWorkProcess workProcess, IBackUpLogic backUpLogic)
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
_orderLogic = orderLogic;
|
_orderLogic = orderLogic;
|
||||||
_reportLogic = reportLogic;
|
_reportLogic = reportLogic;
|
||||||
_workProcess = workProcess;
|
_workProcess = workProcess;
|
||||||
|
_backUpLogic = backUpLogic;
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Загрузка списка заказов
|
/// Загрузка списка заказов
|
||||||
@ -64,11 +68,8 @@ namespace AircraftPlantView
|
|||||||
/// <param name="e"></param>
|
/// <param name="e"></param>
|
||||||
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();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Показать список всех изделий
|
/// Показать список всех изделий
|
||||||
@ -77,11 +78,8 @@ namespace AircraftPlantView
|
|||||||
/// <param name="e"></param>
|
/// <param name="e"></param>
|
||||||
private void ИзделияToolStripMenuItem_Click(object sender, EventArgs e)
|
private void ИзделияToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
var service = Program.ServiceProvider?.GetService(typeof(FormPlanes));
|
var form = DependencyManager.Instance.Resolve<FormPlanes>();
|
||||||
if (service is FormPlanes form)
|
form.ShowDialog();
|
||||||
{
|
|
||||||
form.ShowDialog();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Показать список всех клиентов
|
/// Показать список всех клиентов
|
||||||
@ -90,11 +88,8 @@ namespace AircraftPlantView
|
|||||||
/// <param name="e"></param>
|
/// <param name="e"></param>
|
||||||
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();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -104,11 +99,8 @@ namespace AircraftPlantView
|
|||||||
/// <param name="e"></param>
|
/// <param name="e"></param>
|
||||||
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();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -118,7 +110,7 @@ namespace AircraftPlantView
|
|||||||
/// <param name="e"></param>
|
/// <param name="e"></param>
|
||||||
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -129,11 +121,8 @@ namespace AircraftPlantView
|
|||||||
/// <param name="e"></param>
|
/// <param name="e"></param>
|
||||||
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();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -143,13 +132,34 @@ namespace AircraftPlantView
|
|||||||
/// <param name="e"></param>
|
/// <param name="e"></param>
|
||||||
private void ButtonCreateOrder_Click(object sender, EventArgs e)
|
private void ButtonCreateOrder_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();
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void CоздатьБекапToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
form.ShowDialog();
|
if (_backUpLogic != null)
|
||||||
LoadData();
|
{
|
||||||
|
var fbd = new FolderBrowserDialog();
|
||||||
|
if (fbd.ShowDialog() == DialogResult.OK)
|
||||||
|
{
|
||||||
|
_backUpLogic.CreateBackUp(new BackUpSaveBindingModel
|
||||||
|
{
|
||||||
|
FolderName = fbd.SelectedPath
|
||||||
|
});
|
||||||
|
MessageBox.Show("Бекап создан", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Кнопка "Заказ выдан"
|
/// Кнопка "Заказ выдан"
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -195,15 +205,7 @@ namespace AircraftPlantView
|
|||||||
_logger.LogInformation("Загрузка заказов");
|
_logger.LogInformation("Загрузка заказов");
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var list = _orderLogic.ReadList(null);
|
dataGridView.FillAndConfigGrid(_orderLogic.ReadList(null));
|
||||||
if (list != null)
|
|
||||||
{
|
|
||||||
dataGridView.DataSource = list;
|
|
||||||
dataGridView.Columns["PlaneName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
|
||||||
dataGridView.Columns["PlaneId"].Visible = false;
|
|
||||||
dataGridView.Columns["ClientId"].Visible = false;
|
|
||||||
dataGridView.Columns["ImplementerId"].Visible = false;
|
|
||||||
}
|
|
||||||
_logger.LogInformation("Загрузка заказов");
|
_logger.LogInformation("Загрузка заказов");
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
@ -224,20 +226,14 @@ namespace AircraftPlantView
|
|||||||
|
|
||||||
private void КомпонентыПоСамолётамToolStripMenuItem_Click(object sender, EventArgs e)
|
private void КомпонентыПоСамолётамToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
var service = Program.ServiceProvider?.GetService(typeof(FormReportPlaneComponents));
|
var form = DependencyManager.Instance.Resolve<FormReportPlaneComponents>();
|
||||||
if (service is FormReportPlaneComponents 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();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
using AircraftPlantContracts.BindingModels;
|
using AircraftPlantContracts.BindingModels;
|
||||||
using AircraftPlantContracts.BusinessLogicsContracts;
|
using AircraftPlantContracts.BusinessLogicsContracts;
|
||||||
|
using AircraftPlantContracts.DI;
|
||||||
using AircraftPlantContracts.SearchModels;
|
using AircraftPlantContracts.SearchModels;
|
||||||
|
using AircraftPlantDatabaseImplement.Models;
|
||||||
using AircraftPlantDataModels.Models;
|
using AircraftPlantDataModels.Models;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using System;
|
using System;
|
||||||
@ -84,27 +86,22 @@ namespace AircraftPlantView
|
|||||||
/// <param name="e"></param>
|
/// <param name="e"></param>
|
||||||
private void buttonAdd_Click(object sender, EventArgs e)
|
private void buttonAdd_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
var service = Program.ServiceProvider?.GetService(typeof(FormPlaneComponent));
|
var form = DependencyManager.Instance.Resolve<FormPlaneComponent>();
|
||||||
if (service is FormPlaneComponent form)
|
if (form.ShowDialog() == DialogResult.OK)
|
||||||
{
|
{
|
||||||
if (form.ShowDialog() == DialogResult.OK)
|
return;
|
||||||
{
|
|
||||||
if (form.ComponentModel == null)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
_logger.LogInformation("Добавление нового компонента:{ ComponentName} - { Count}", form.ComponentModel.ComponentName, form.Count);
|
|
||||||
if (_planeComponents.ContainsKey(form.Id))
|
|
||||||
{
|
|
||||||
_planeComponents[form.Id] = (form.ComponentModel, form.Count);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
_planeComponents.Add(form.Id, (form.ComponentModel, form.Count));
|
|
||||||
}
|
|
||||||
LoadData();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
_logger.LogInformation("Добавление нового компонента:{ ComponentName}-{ Count}", form.ComponentModel.ComponentName, form.Count);
|
||||||
|
if (_planeComponents.ContainsKey(form.Id))
|
||||||
|
{
|
||||||
|
_planeComponents[form.Id] = (form.ComponentModel, form.Count);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_planeComponents.Add(form.Id, (form.ComponentModel,
|
||||||
|
form.Count));
|
||||||
|
}
|
||||||
|
LoadData();
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Кнопка "Изменить"
|
/// Кнопка "Изменить"
|
||||||
@ -115,22 +112,19 @@ namespace AircraftPlantView
|
|||||||
{
|
{
|
||||||
if (dataGridView.SelectedRows.Count == 1)
|
if (dataGridView.SelectedRows.Count == 1)
|
||||||
{
|
{
|
||||||
var service = Program.ServiceProvider?.GetService(typeof(FormPlaneComponent));
|
var form = DependencyManager.Instance.Resolve<FormPlaneComponent>();
|
||||||
if (service is FormPlaneComponent form)
|
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells[0].Value);
|
||||||
|
form.Id = id;
|
||||||
|
form.Count = _planeComponents[id].Item2;
|
||||||
|
if (form.ShowDialog() == DialogResult.OK)
|
||||||
{
|
{
|
||||||
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells[0].Value);
|
if (form.ComponentModel == null)
|
||||||
form.Id = id;
|
|
||||||
form.Count = _planeComponents[id].Item2;
|
|
||||||
if (form.ShowDialog() == DialogResult.OK)
|
|
||||||
{
|
{
|
||||||
if (form.ComponentModel == null)
|
return;
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
_logger.LogInformation("Изменение компонента:{ ComponentName} - { Count}", form.ComponentModel.ComponentName, form.Count);
|
|
||||||
_planeComponents[form.Id] = (form.ComponentModel, form.Count);
|
|
||||||
LoadData();
|
|
||||||
}
|
}
|
||||||
|
_logger.LogInformation("Изменение компонента:{ ComponentName}-{ Count}", form.ComponentModel.ComponentName, form.Count);
|
||||||
|
_planeComponents[form.Id] = (form.ComponentModel, form.Count);
|
||||||
|
LoadData();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
using AircraftPlantContracts.BindingModels;
|
using AircraftPlantContracts.BindingModels;
|
||||||
using AircraftPlantContracts.BusinessLogicsContracts;
|
using AircraftPlantContracts.BusinessLogicsContracts;
|
||||||
|
using AircraftPlantContracts.DI;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
@ -55,13 +56,10 @@ namespace AircraftPlantView
|
|||||||
/// <param name="e"></param>
|
/// <param name="e"></param>
|
||||||
private void buttonAdd_Click(object sender, EventArgs e)
|
private void buttonAdd_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
var service = Program.ServiceProvider?.GetService(typeof(FormPlane));
|
var form = DependencyManager.Instance.Resolve<FormPlane>();
|
||||||
if (service is FormPlane form)
|
if (form.ShowDialog() == DialogResult.OK)
|
||||||
{
|
{
|
||||||
if (form.ShowDialog() == DialogResult.OK)
|
LoadData();
|
||||||
{
|
|
||||||
LoadData();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -73,14 +71,11 @@ namespace AircraftPlantView
|
|||||||
{
|
{
|
||||||
if (dataGridViewPlanes.SelectedRows.Count == 1)
|
if (dataGridViewPlanes.SelectedRows.Count == 1)
|
||||||
{
|
{
|
||||||
var service = Program.ServiceProvider?.GetService(typeof(FormPlane));
|
var form = DependencyManager.Instance.Resolve<FormPlane>();
|
||||||
if (service is FormPlane form)
|
form.Id = Convert.ToInt32(dataGridViewPlanes.SelectedRows[0].Cells["Id"].Value);
|
||||||
|
if (form.ShowDialog() == DialogResult.OK)
|
||||||
{
|
{
|
||||||
form.Id = Convert.ToInt32(dataGridViewPlanes.SelectedRows[0].Cells["Id"].Value);
|
LoadData();
|
||||||
if (form.ShowDialog() == DialogResult.OK)
|
|
||||||
{
|
|
||||||
LoadData();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -132,14 +127,7 @@ namespace AircraftPlantView
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var list = _logic.ReadList(null);
|
dataGridViewPlanes.FillAndConfigGrid(_logic.ReadList(null));
|
||||||
if (list != null)
|
|
||||||
{
|
|
||||||
dataGridViewPlanes.DataSource = list;
|
|
||||||
dataGridViewPlanes.Columns["Id"].Visible = false;
|
|
||||||
dataGridViewPlanes.Columns["PlaneName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
|
||||||
dataGridViewPlanes.Columns["PlaneComponents"].Visible = false;
|
|
||||||
}
|
|
||||||
_logger.LogInformation("Загрузка изделий");
|
_logger.LogInformation("Загрузка изделий");
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
|
@ -10,6 +10,7 @@ using NLog.Extensions.Logging;
|
|||||||
using System;
|
using System;
|
||||||
using AircraftPlantBusinessLogic.MailWorker;
|
using AircraftPlantBusinessLogic.MailWorker;
|
||||||
using AircraftPlantContracts.BindingModels;
|
using AircraftPlantContracts.BindingModels;
|
||||||
|
using AircraftPlantContracts.DI;
|
||||||
|
|
||||||
namespace AircraftPlantView
|
namespace AircraftPlantView
|
||||||
{
|
{
|
||||||
@ -31,14 +32,11 @@ namespace AircraftPlantView
|
|||||||
// see https://aka.ms/applicationconfiguration.
|
// see https://aka.ms/applicationconfiguration.
|
||||||
ApplicationConfiguration.Initialize();
|
ApplicationConfiguration.Initialize();
|
||||||
|
|
||||||
var services = new ServiceCollection();
|
InitDependency();
|
||||||
ConfigureServices(services);
|
|
||||||
_serviceProvider = services.BuildServiceProvider();
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var mailSender =
|
var mailSender = DependencyManager.Instance.Resolve<AbstractMailWorker>();
|
||||||
_serviceProvider.GetService<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,
|
||||||
@ -53,63 +51,58 @@ namespace AircraftPlantView
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
var logger = _serviceProvider.GetService<ILogger>();
|
var logger = DependencyManager.Instance.Resolve<ILogger>();
|
||||||
logger?.LogError(ex, "Îøèáêà ðàáîòû ñ ïî÷òîé");
|
logger?.LogError(ex, "Îøèáêà ðàáîòû ñ ïî÷òîé");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Application.Run(_serviceProvider.GetRequiredService<FormMain>());
|
Application.Run(DependencyManager.Instance.Resolve<FormMain>());
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Íàñòðîéêà IoC-êîíòåéíåðà è ëîããåðà
|
/// Íàñòðîéêà IoC-êîíòåéíåðà è ëîããåðà
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="services"></param>
|
/// <param name="services"></param>
|
||||||
private static void ConfigureServices(ServiceCollection services)
|
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<IComponentStorage, ComponentStorage>();
|
DependencyManager.Instance.RegisterType<IClientLogic, ClientLogic>();
|
||||||
services.AddTransient<IOrderStorage, OrderStorage>();
|
DependencyManager.Instance.RegisterType<IComponentLogic, ComponentLogic>();
|
||||||
services.AddTransient<IPlaneStorage, PlaneStorage>();
|
DependencyManager.Instance.RegisterType<IOrderLogic, OrderLogic>();
|
||||||
services.AddTransient<IClientStorage, ClientStorage>();
|
DependencyManager.Instance.RegisterType<IPlaneLogic, PlaneLogic>();
|
||||||
services.AddTransient<IImplementerStorage, ImplementerStorage>();
|
DependencyManager.Instance.RegisterType<IReportLogic, ReportLogic>();
|
||||||
services.AddTransient<IMessageInfoStorage, MessageInfoStorage>();
|
DependencyManager.Instance.RegisterType<IImplementerLogic, ImplementerLogic>();
|
||||||
|
DependencyManager.Instance.RegisterType<IMessageInfoLogic, MessageInfoLogic>();
|
||||||
|
DependencyManager.Instance.RegisterType<IBackUpLogic, BackUpLogic>();
|
||||||
|
|
||||||
|
DependencyManager.Instance.RegisterType<AbstractSaveToWord, SaveToWord>();
|
||||||
|
DependencyManager.Instance.RegisterType<AbstractSaveToExcel, SaveToExcel>();
|
||||||
|
DependencyManager.Instance.RegisterType<AbstractSaveToPdf, SaveToPdf>();
|
||||||
|
DependencyManager.Instance.RegisterType<AbstractMailWorker, MailKitWorker>(true);
|
||||||
|
|
||||||
services.AddTransient<IComponentLogic, ComponentLogic>();
|
DependencyManager.Instance.RegisterType<IWorkProcess, WorkModeling>();
|
||||||
services.AddTransient<IOrderLogic, OrderLogic>();
|
|
||||||
services.AddTransient<IPlaneLogic, PlaneLogic>();
|
|
||||||
services.AddTransient<IReportLogic, ReportLogic>();
|
|
||||||
services.AddTransient<IClientLogic, ClientLogic>();
|
|
||||||
services.AddTransient<IImplementerLogic, ImplementerLogic>();
|
|
||||||
services.AddTransient<IMessageInfoLogic, MessageInfoLogic>();
|
|
||||||
|
|
||||||
services.AddTransient<IWorkProcess, WorkModeling>();
|
DependencyManager.Instance.RegisterType<FormMain>();
|
||||||
services.AddSingleton<AbstractMailWorker, MailKitWorker>();
|
DependencyManager.Instance.RegisterType<FormComponent>();
|
||||||
|
DependencyManager.Instance.RegisterType<FormComponents>();
|
||||||
services.AddTransient<AbstractSaveToWord, SaveToWord>();
|
DependencyManager.Instance.RegisterType<FormCreateOrder>();
|
||||||
services.AddTransient<AbstractSaveToExcel, SaveToExcel>();
|
DependencyManager.Instance.RegisterType<FormPlane>();
|
||||||
services.AddTransient<AbstractSaveToPdf, SaveToPdf>();
|
DependencyManager.Instance.RegisterType<FormPlaneComponent>();
|
||||||
|
DependencyManager.Instance.RegisterType<FormPlanes>();
|
||||||
services.AddTransient<FormMain>();
|
DependencyManager.Instance.RegisterType<FormReportOrders>();
|
||||||
services.AddTransient<FormComponent>();
|
DependencyManager.Instance.RegisterType<FormReportPlaneComponents>();
|
||||||
services.AddTransient<FormComponents>();
|
DependencyManager.Instance.RegisterType<FormClients>();
|
||||||
services.AddTransient<FormCreateOrder>();
|
DependencyManager.Instance.RegisterType<FormImplementers>();
|
||||||
services.AddTransient<FormPlane>();
|
DependencyManager.Instance.RegisterType<FormImplementer>();
|
||||||
services.AddTransient<FormPlaneComponent>();
|
DependencyManager.Instance.RegisterType<FormMails>();
|
||||||
services.AddTransient<FormPlanes>();
|
|
||||||
services.AddTransient<FormReportOrders>();
|
|
||||||
services.AddTransient<FormReportPlaneComponents>();
|
|
||||||
services.AddTransient<FormClients>();
|
|
||||||
services.AddTransient<FormImplementers>();
|
|
||||||
services.AddTransient<FormImplementer>();
|
|
||||||
services.AddTransient<FormMails>();
|
|
||||||
}
|
}
|
||||||
private static void MailCheck(object obj) => ServiceProvider?.GetService<AbstractMailWorker>()?.MailCheck();
|
private static void MailCheck(object obj) => DependencyManager.Instance.Resolve<AbstractMailWorker>()?.MailCheck();
|
||||||
}
|
}
|
||||||
}
|
}
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue
Block a user