PIbd-21_Sagirov_M.M._Shipyard Lab8_Base #10
BIN
Shipyard/ImplementationExtensions/ShipyardContracts.dll
Normal file
BIN
Shipyard/ImplementationExtensions/ShipyardContracts.dll
Normal file
Binary file not shown.
BIN
Shipyard/ImplementationExtensions/ShipyardDataBaseImplement.dll
Normal file
BIN
Shipyard/ImplementationExtensions/ShipyardDataBaseImplement.dll
Normal file
Binary file not shown.
BIN
Shipyard/ImplementationExtensions/ShipyardDataModels.dll
Normal file
BIN
Shipyard/ImplementationExtensions/ShipyardDataModels.dll
Normal file
Binary file not shown.
BIN
Shipyard/ImplementationExtensions/ShipyardFileImplement.dll
Normal file
BIN
Shipyard/ImplementationExtensions/ShipyardFileImplement.dll
Normal file
Binary file not shown.
BIN
Shipyard/ImplementationExtensions/ShipyardListImplement.dll
Normal file
BIN
Shipyard/ImplementationExtensions/ShipyardListImplement.dll
Normal file
Binary file not shown.
99
Shipyard/ShipyardBusinessLogic/BusinessLogics/BackUpLogic.cs
Normal file
99
Shipyard/ShipyardBusinessLogic/BusinessLogics/BackUpLogic.cs
Normal file
@ -0,0 +1,99 @@
|
||||
using DocumentFormat.OpenXml.EMMA;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using ShipyardContracts.BindingModels;
|
||||
using ShipyardContracts.BusinessLogicsContracts;
|
||||
using ShipyardContracts.StoragesContracts;
|
||||
using ShipyardDataModels;
|
||||
using System.IO.Compression;
|
||||
using System.Reflection;
|
||||
using System.Runtime.Serialization.Json;
|
||||
|
||||
namespace ShipyardBusinessLogic
|
||||
{
|
||||
public class BackUpLogic : IBackUpLogic
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
|
||||
private readonly IBackUpInfo _backUpInfo;
|
||||
|
||||
public BackUpLogic(ILogger<BackUpLogic> logger, IBackUpInfo backUpInfo)
|
||||
{
|
||||
_logger = logger;
|
||||
_backUpInfo = backUpInfo;
|
||||
}
|
||||
|
||||
public void CreateBackUp(BackUpSaveBinidngModel model)
|
||||
{
|
||||
if (_backUpInfo == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
try
|
||||
{
|
||||
_logger.LogDebug("Clear folder");
|
||||
// зачистка папки и удаление старого архива
|
||||
var dirInfo = new DirectoryInfo(model.FolderName);
|
||||
if (dirInfo.Exists)
|
||||
{
|
||||
foreach (var file in dirInfo.GetFiles())
|
||||
{
|
||||
file.Delete();
|
||||
}
|
||||
}
|
||||
_logger.LogDebug("Delete archive");
|
||||
string fileName = $"{model.FolderName}.zip";
|
||||
if (File.Exists(fileName))
|
||||
{
|
||||
File.Delete(fileName);
|
||||
}
|
||||
// берем метод для сохранения
|
||||
_logger.LogDebug("Get assembly");
|
||||
var typeIId = typeof(IId);
|
||||
var assembly = typeIId.Assembly;
|
||||
if (assembly == null)
|
||||
{
|
||||
throw new ArgumentNullException("Сборка не найдена", nameof(assembly));
|
||||
}
|
||||
var types = assembly.GetTypes();
|
||||
var method = GetType().GetMethod("SaveToFile", BindingFlags.NonPublic | BindingFlags.Instance);
|
||||
_logger.LogDebug("Find {count} types", types.Length);
|
||||
foreach (var type in types)
|
||||
{
|
||||
if (type.IsInterface && type.GetInterface(typeIId.Name) != null)
|
||||
{
|
||||
var modelType = _backUpInfo.GetTypeByModelInterface(type.Name);
|
||||
if (modelType == null)
|
||||
{
|
||||
throw new InvalidOperationException($"Не найден класс-модель для {type.Name}");
|
||||
}
|
||||
_logger.LogDebug("Call SaveToFile method for {name} type", type.Name);
|
||||
// вызываем метод на выполнение
|
||||
method?.MakeGenericMethod(modelType).Invoke(this, new object[] { model.FolderName });
|
||||
}
|
||||
}
|
||||
_logger.LogDebug("Create zip and remove folder");
|
||||
// архивируем
|
||||
ZipFile.CreateFromDirectory(model.FolderName, fileName);
|
||||
// удаляем папку
|
||||
dirInfo.Delete(true);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
private void SaveToFile<T>(string folderName) where T : class, new()
|
||||
{
|
||||
var records = _backUpInfo.GetList<T>();
|
||||
if (records == null)
|
||||
{
|
||||
_logger.LogWarning("{type} type get null list", typeof(T).Name);
|
||||
return;
|
||||
}
|
||||
var jsonFormatter = new DataContractJsonSerializer(typeof(List<T>));
|
||||
using var fs = new FileStream(string.Format("{0}/{1}.json", folderName, typeof(T).Name), FileMode.OpenOrCreate);
|
||||
jsonFormatter.WriteObject(fs, records);
|
||||
}
|
||||
}
|
||||
}
|
25
Shipyard/ShipyardContracts/Attributes/ColumnAttribute.cs
Normal file
25
Shipyard/ShipyardContracts/Attributes/ColumnAttribute.cs
Normal file
@ -0,0 +1,25 @@
|
||||
namespace ShipyardContracts.Attributes
|
||||
{
|
||||
[AttributeUsage(AttributeTargets.Property)]
|
||||
public class ColumnAttribute : Attribute
|
||||
{
|
||||
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; }
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
21
Shipyard/ShipyardContracts/Attributes/GridViewAutoSize.cs
Normal file
21
Shipyard/ShipyardContracts/Attributes/GridViewAutoSize.cs
Normal file
@ -0,0 +1,21 @@
|
||||
namespace ShipyardContracts.Attributes
|
||||
{
|
||||
public enum GridViewAutoSize
|
||||
{
|
||||
NotSet = 0,
|
||||
|
||||
None = 1,
|
||||
|
||||
ColumnHeader = 2,
|
||||
|
||||
AllCellsExceptHeader = 4,
|
||||
|
||||
AllCells = 6,
|
||||
|
||||
DisplayedCellsExceptHeader = 8,
|
||||
|
||||
DisplayedCells = 10,
|
||||
|
||||
Fill = 16
|
||||
}
|
||||
}
|
@ -0,0 +1,7 @@
|
||||
namespace ShipyardContracts.BindingModels
|
||||
{
|
||||
public class BackUpSaveBinidngModel
|
||||
{
|
||||
public string FolderName { get; set; } = string.Empty;
|
||||
}
|
||||
}
|
@ -15,5 +15,6 @@ namespace ShipyardContracts.BindingModels
|
||||
public string Body { get; set; } = string.Empty;
|
||||
|
||||
public DateTime DateDelivery { get; set; }
|
||||
public int Id => throw new NotImplementedException();
|
||||
}
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
using ShipyardContracts.BindingModels;
|
||||
namespace ShipyardContracts.BusinessLogicsContracts
|
||||
{
|
||||
public interface IBackUpLogic
|
||||
{
|
||||
void CreateBackUp(BackUpSaveBinidngModel model);
|
||||
}
|
||||
}
|
61
Shipyard/ShipyardContracts/DI/DependencyManager.cs
Normal file
61
Shipyard/ShipyardContracts/DI/DependencyManager.cs
Normal file
@ -0,0 +1,61 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace ShipyardContracts.DI
|
||||
{
|
||||
public class DependencyManager
|
||||
{
|
||||
private readonly IDependencyContainer _dependencyManager;
|
||||
|
||||
private static DependencyManager? _manager;
|
||||
|
||||
private static readonly object _locjObject = new();
|
||||
|
||||
private DependencyManager()
|
||||
{
|
||||
_dependencyManager = new UnityDependencyContainer();
|
||||
}
|
||||
|
||||
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>();
|
||||
}
|
||||
}
|
35
Shipyard/ShipyardContracts/DI/IDependencyContainer.cs
Normal file
35
Shipyard/ShipyardContracts/DI/IDependencyContainer.cs
Normal file
@ -0,0 +1,35 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace ShipyardContracts.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>();
|
||||
}
|
||||
}
|
11
Shipyard/ShipyardContracts/DI/IImplementationExtension.cs
Normal file
11
Shipyard/ShipyardContracts/DI/IImplementationExtension.cs
Normal file
@ -0,0 +1,11 @@
|
||||
namespace ShipyardContracts.DI
|
||||
{
|
||||
public interface IImplementationExtension
|
||||
{
|
||||
public int Priority { get; }
|
||||
/// <summary>
|
||||
/// Регистрация сервисов
|
||||
/// </summary>
|
||||
public void RegisterServices();
|
||||
}
|
||||
}
|
62
Shipyard/ShipyardContracts/DI/ServiceDependencyContainer.cs
Normal file
62
Shipyard/ShipyardContracts/DI/ServiceDependencyContainer.cs
Normal file
@ -0,0 +1,62 @@
|
||||
using System;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System.Threading.Tasks;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace ShipyardContracts.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>()!;
|
||||
}
|
||||
}
|
||||
}
|
50
Shipyard/ShipyardContracts/DI/ServiceProviderLoader.cs
Normal file
50
Shipyard/ShipyardContracts/DI/ServiceProviderLoader.cs
Normal file
@ -0,0 +1,50 @@
|
||||
using System.Reflection;
|
||||
|
||||
namespace ShipyardContracts.DI
|
||||
{
|
||||
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";
|
||||
}
|
||||
}
|
||||
}
|
38
Shipyard/ShipyardContracts/DI/UnityDependencyContainer.cs
Normal file
38
Shipyard/ShipyardContracts/DI/UnityDependencyContainer.cs
Normal file
@ -0,0 +1,38 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Unity.Microsoft.Logging;
|
||||
using Unity;
|
||||
|
||||
namespace ShipyardContracts.DI
|
||||
{
|
||||
public class UnityDependencyContainer : IDependencyContainer
|
||||
{
|
||||
private readonly IUnityContainer _container;
|
||||
|
||||
public UnityDependencyContainer()
|
||||
{
|
||||
_container = new UnityContainer();
|
||||
}
|
||||
|
||||
public void AddLogging(Action<ILoggingBuilder> configure)
|
||||
{
|
||||
var factory = LoggerFactory.Create(configure);
|
||||
_container.AddExtension(new LoggingExtension(factory));
|
||||
}
|
||||
|
||||
public void RegisterType<T>(bool isSingle) where T : class
|
||||
{
|
||||
_container.RegisterType<T>(isSingle ? TypeLifetime.Singleton : TypeLifetime.Transient);
|
||||
|
||||
}
|
||||
|
||||
public T Resolve<T>()
|
||||
{
|
||||
return _container.Resolve<T>();
|
||||
}
|
||||
|
||||
void IDependencyContainer.RegisterType<T, U>(bool isSingle)
|
||||
{
|
||||
_container.RegisterType<T, U>(isSingle ? TypeLifetime.Singleton : TypeLifetime.Transient);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
@ -6,6 +6,13 @@
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="8.0.0" />
|
||||
<PackageReference Include="NLog.Extensions.Logging" Version="5.3.11" />
|
||||
<PackageReference Include="Unity" Version="5.11.10" />
|
||||
<PackageReference Include="Unity.Microsoft.Logging" Version="5.11.1" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\ShipyardDataModels\ShipyardDataModels.csproj" />
|
||||
</ItemGroup>
|
||||
|
@ -0,0 +1,9 @@
|
||||
namespace ShipyardContracts.StoragesContracts
|
||||
{
|
||||
public interface IBackUpInfo
|
||||
{
|
||||
List<T>? GetList<T>() where T : class, new();
|
||||
|
||||
Type? GetTypeByModelInterface(string modelInterfaceName);
|
||||
}
|
||||
}
|
@ -1,19 +1,21 @@
|
||||
using ShipyardDataModels.Models;
|
||||
using System.ComponentModel;
|
||||
using ShipyardContracts.Attributes;
|
||||
|
||||
namespace ShipyardContracts.ViewModels
|
||||
{
|
||||
public class ClientViewModel : IClientModel
|
||||
{
|
||||
[Column(visible: false)]
|
||||
public int Id { get; set; }
|
||||
|
||||
[DisplayName("ФИО клиента")]
|
||||
[Column(title: "ФИО клиента", width: 150)]
|
||||
public string ClientFIO { get; set; } = string.Empty;
|
||||
|
||||
[DisplayName("Логин (эл. почта)")]
|
||||
[Column(title: "Логин (эл. почта)", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)]
|
||||
public string Email { get; set; } = string.Empty;
|
||||
|
||||
[DisplayName("Пароль")]
|
||||
[Column(title: "Пароль", width: 150)]
|
||||
public string Password { get; set; } = string.Empty;
|
||||
}
|
||||
}
|
@ -1,14 +1,16 @@
|
||||
using ShipyardDataModels.Models;
|
||||
using System.ComponentModel;
|
||||
using ShipyardContracts.Attributes;
|
||||
|
||||
namespace ShipyardContracts.ViewModels
|
||||
{
|
||||
public class DetailViewModel : IDetailModel
|
||||
{
|
||||
[Column(visible: false)]
|
||||
public int Id { get; set; }
|
||||
[DisplayName("Название детали")]
|
||||
[Column(title: "Название детали", width: 150)]
|
||||
public string DetailName { get; set; } = string.Empty;
|
||||
[DisplayName("Цена")]
|
||||
[Column(title: "Цена", width: 150)]
|
||||
public double Cost { get; set; }
|
||||
|
||||
}
|
||||
|
@ -1,22 +1,24 @@
|
||||
using ShipyardDataModels.Models;
|
||||
using System.ComponentModel;
|
||||
using ShipyardContracts.Attributes;
|
||||
|
||||
namespace ShipyardContracts.ViewModels
|
||||
{
|
||||
public class ImplementerViewModel : IImplementerModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
[Column(visible: false)]
|
||||
public int Id { get; set; }
|
||||
|
||||
[DisplayName("ФИО исполнителя")]
|
||||
public string ImplementerFIO { get; set; } = string.Empty;
|
||||
[Column(title: "ФИО исполнителя", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)]
|
||||
public string ImplementerFIO { get; set; } = string.Empty;
|
||||
|
||||
[DisplayName("Пароль")]
|
||||
public string Password { get; set; } = string.Empty;
|
||||
[Column(title: "Пароль", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)]
|
||||
public string Password { get; set; } = string.Empty;
|
||||
|
||||
[DisplayName("Стаж работы")]
|
||||
public int WorkExperience { get; set; }
|
||||
[Column(title: "Стаж работы", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)]
|
||||
public int WorkExperience { get; set; }
|
||||
|
||||
[DisplayName("Квалификация")]
|
||||
public int Qualification { get; set; }
|
||||
[Column(title: "Квалификация", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)]
|
||||
public int Qualification { get; set; }
|
||||
}
|
||||
}
|
@ -1,24 +1,28 @@
|
||||
using ShipyardDataModels.Models;
|
||||
using System.ComponentModel;
|
||||
using ShipyardContracts.Attributes;
|
||||
|
||||
namespace ShipyardContracts.ViewModels
|
||||
{
|
||||
public class MessageInfoViewModel : IMessageInfoModel
|
||||
{
|
||||
[Column(visible: false)]
|
||||
public string MessageId { get; set; } = string.Empty;
|
||||
|
||||
[Column(visible: false)]
|
||||
public int? ClientId { get; set; }
|
||||
|
||||
[DisplayName("Отправитель")]
|
||||
[Column(title: "Отправитель", width: 150)]
|
||||
public string SenderName { get; set; } = string.Empty;
|
||||
|
||||
[DisplayName("Дата письма")]
|
||||
[Column(title: "Дата письма", width: 150)]
|
||||
public DateTime DateDelivery { get; set; }
|
||||
|
||||
[DisplayName("Заголовок")]
|
||||
[Column(title: "Заголовок", width: 150)]
|
||||
public string Subject { get; set; } = string.Empty;
|
||||
|
||||
[DisplayName("Текст")]
|
||||
[Column(title: "Текст", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)]
|
||||
public string Body { get; set; } = string.Empty;
|
||||
[Column(visible: false)]
|
||||
public int Id => throw new NotImplementedException();
|
||||
}
|
||||
}
|
@ -1,31 +1,35 @@
|
||||
using ShipyardDataModels.Enums;
|
||||
using ShipyardDataModels.Models;
|
||||
using System.ComponentModel;
|
||||
using ShipyardContracts.Attributes;
|
||||
|
||||
namespace ShipyardContracts.ViewModels
|
||||
{
|
||||
public class OrderViewModel : IOrderModel
|
||||
{
|
||||
[DisplayName("Номер")]
|
||||
[Column(title: "Номер", width: 150)]
|
||||
public int Id { get; set; }
|
||||
[Column(visible: false)]
|
||||
public int ShipId { get; set; }
|
||||
[DisplayName("Название")]
|
||||
[Column(title: "Название", width: 150)]
|
||||
public string ShipName { get; set; } = string.Empty;
|
||||
[Column(visible: false)]
|
||||
public int ClientId { get; set; }
|
||||
[DisplayName("Клиент")]
|
||||
[Column(title: "Клиент", width: 150)]
|
||||
public string ClientFIO { get; set; } = string.Empty;
|
||||
public int? ImplementerId { get; set; }
|
||||
[DisplayName("Исполнитель")]
|
||||
[Column(visible: false)]
|
||||
public int? ImplementerId { get; set; }
|
||||
[Column(title: "Исполнитель", width: 150)]
|
||||
public string ImplementerFIO { get; set; } = string.Empty;
|
||||
[DisplayName("Количество")]
|
||||
[Column(title: "Количество", width: 150)]
|
||||
public int Count { get; set; }
|
||||
[DisplayName("Сумма")]
|
||||
[Column(title: "Сумма", width: 150)]
|
||||
public double Sum { get; set; }
|
||||
[DisplayName("Статус")]
|
||||
[Column(title: "Статус", width: 150)]
|
||||
public OrderStatus Status { get; set; } = OrderStatus.Неизвестен;
|
||||
[DisplayName("Дата создания")]
|
||||
[Column(title: "Дата создания", width: 150)]
|
||||
public DateTime DateCreate { get; set; } = DateTime.Now;
|
||||
[DisplayName("Дата выполнения")]
|
||||
[Column(title: "Дата выполнения", width: 150)]
|
||||
public DateTime? DateImplement { get; set; }
|
||||
}
|
||||
}
|
@ -1,15 +1,18 @@
|
||||
using ShipyardDataModels.Models;
|
||||
using System.ComponentModel;
|
||||
using ShipyardContracts.Attributes;
|
||||
|
||||
namespace ShipyardContracts.ViewModels
|
||||
{
|
||||
public class ShipViewModel : IShipModel
|
||||
{
|
||||
[Column(visible: false)]
|
||||
public int Id { get; set; }
|
||||
[DisplayName("Название корабля")]
|
||||
[Column(title: "Название корабля", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)]
|
||||
public string ShipName { get; set; } = string.Empty;
|
||||
[DisplayName("Цена")]
|
||||
[Column(title: "Цена", width: 150)]
|
||||
public double Price { get; set; }
|
||||
[Column(visible: false)]
|
||||
public Dictionary<int, (IDetailModel, int)> ShipDetails { get; set; } = new();
|
||||
}
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
using ShipyardContracts.DI;
|
||||
using ShipyardContracts.StoragesContracts;
|
||||
using ShipyardDataBaseImplement.Implements;
|
||||
|
||||
namespace ShipyardDataBaseImplement
|
||||
{
|
||||
public class DataBaseImplementationExtension : IImplementationExtension
|
||||
{
|
||||
public int Priority => 2;
|
||||
|
||||
public void RegisterServices()
|
||||
{
|
||||
DependencyManager.Instance.RegisterType<IClientStorage, ClientStorage>();
|
||||
DependencyManager.Instance.RegisterType<IDetailStorage, DetailStorage>();
|
||||
DependencyManager.Instance.RegisterType<IImplementerStorage, ImplementerStorage>();
|
||||
DependencyManager.Instance.RegisterType<IMessageInfoStorage, MessageInfoStorage>();
|
||||
DependencyManager.Instance.RegisterType<IOrderStorage, OrderStorage>();
|
||||
DependencyManager.Instance.RegisterType<IShipStorage, ShipStorage>();
|
||||
DependencyManager.Instance.RegisterType<IBackUpInfo, BackUpInfo>();
|
||||
}
|
||||
}
|
||||
}
|
27
Shipyard/ShipyardDataBaseImplement/Implements/BackUpInfo.cs
Normal file
27
Shipyard/ShipyardDataBaseImplement/Implements/BackUpInfo.cs
Normal file
@ -0,0 +1,27 @@
|
||||
using ShipyardContracts.StoragesContracts;
|
||||
|
||||
namespace ShipyardDataBaseImplement.Implements
|
||||
{
|
||||
public class BackUpInfo : IBackUpInfo
|
||||
{
|
||||
public List<T>? GetList<T>() where T : class, new()
|
||||
{
|
||||
using var context = new ShipyardDataBase();
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
@ -3,17 +3,23 @@ using ShipyardContracts.ViewModels;
|
||||
using ShipyardDataModels.Models;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace ShipyardDataBaseImplement.Models
|
||||
{
|
||||
[DataContract]
|
||||
public class Client : IClientModel
|
||||
{
|
||||
[DataMember]
|
||||
public int Id { get; set; }
|
||||
[Required]
|
||||
[DataMember]
|
||||
public string ClientFIO { get; set; } = string.Empty;
|
||||
[Required]
|
||||
[DataMember]
|
||||
public string Email { get; set; } = string.Empty;
|
||||
[Required]
|
||||
[DataMember]
|
||||
public string Password { get; set; } = string.Empty;
|
||||
[ForeignKey("ClientId")]
|
||||
public virtual List<Order> Orders { get; set; } = new();
|
||||
|
@ -3,15 +3,20 @@ using ShipyardContracts.ViewModels;
|
||||
using ShipyardDataModels.Models;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace ShipyardDataBaseImplement.Models
|
||||
{
|
||||
[DataContract]
|
||||
public class Detail : IDetailModel
|
||||
{
|
||||
[DataMember]
|
||||
public int Id { get; private set; }
|
||||
[Required]
|
||||
[DataMember]
|
||||
public string DetailName { get; private set; } = string.Empty;
|
||||
[Required]
|
||||
[DataMember]
|
||||
public double Cost { get; set; }
|
||||
[ForeignKey("DetailId")]
|
||||
public virtual List<ShipDetail> ShipDetails { get; set; } = new();
|
||||
|
@ -3,24 +3,31 @@ using ShipyardContracts.ViewModels;
|
||||
using ShipyardDataModels.Models;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace ShipyardDataBaseImplement.Models
|
||||
{
|
||||
public class Implementer : IImplementerModel
|
||||
[DataContract]
|
||||
public class Implementer : IImplementerModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
[DataMember]
|
||||
public int Id { get; set; }
|
||||
|
||||
[Required]
|
||||
public string ImplementerFIO { get; set; } = String.Empty;
|
||||
[DataMember]
|
||||
public string ImplementerFIO { get; set; } = String.Empty;
|
||||
|
||||
[Required]
|
||||
public string Password { get; set; } = String.Empty;
|
||||
[DataMember]
|
||||
public string Password { get; set; } = String.Empty;
|
||||
|
||||
[Required]
|
||||
public int WorkExperience { get; set; }
|
||||
[DataMember]
|
||||
public int WorkExperience { get; set; }
|
||||
|
||||
[Required]
|
||||
public int Qualification { get; set; }
|
||||
[DataMember]
|
||||
public int Qualification { get; set; }
|
||||
|
||||
[ForeignKey("ImplementerId")]
|
||||
public virtual List<Order> Orders { get; set; } = new();
|
||||
|
@ -2,12 +2,15 @@
|
||||
using ShipyardContracts.ViewModels;
|
||||
using ShipyardDataModels.Models;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace ShipyardDataBaseImplement.Models
|
||||
{
|
||||
[DataContract]
|
||||
public class Message : IMessageInfoModel
|
||||
{
|
||||
[Key]
|
||||
[DataMember]
|
||||
public string MessageId { get; private set; } = string.Empty;
|
||||
|
||||
public int? ClientId { get; private set; }
|
||||
@ -20,6 +23,8 @@ namespace ShipyardDataBaseImplement.Models
|
||||
|
||||
public string Body { get; private set; } = string.Empty;
|
||||
|
||||
public int Id => throw new NotImplementedException();
|
||||
|
||||
public Client? Client { get; private set; }
|
||||
public static Message? Create(MessageInfoBindingModel model)
|
||||
{
|
||||
|
@ -3,25 +3,36 @@ using ShipyardContracts.ViewModels;
|
||||
using ShipyardDataModels.Enums;
|
||||
using ShipyardDataModels.Models;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace ShipyardDataBaseImplement.Models
|
||||
{
|
||||
[DataContract]
|
||||
public class Order : IOrderModel
|
||||
{
|
||||
[Required]
|
||||
[DataMember]
|
||||
public int ShipId { get; set; }
|
||||
[Required]
|
||||
[DataMember]
|
||||
public int ClientId { get; set; }
|
||||
public int? ImplementerId { get; set; }
|
||||
[DataMember]
|
||||
public int? ImplementerId { get; set; }
|
||||
[Required]
|
||||
[DataMember]
|
||||
public int Count { get; set; }
|
||||
[Required]
|
||||
[DataMember]
|
||||
public double Sum { get; set; }
|
||||
[Required]
|
||||
[DataMember]
|
||||
public OrderStatus Status { get; set; }
|
||||
[Required]
|
||||
[DataMember]
|
||||
public DateTime DateCreate { get; set; }
|
||||
[DataMember]
|
||||
public DateTime? DateImplement { get; set; }
|
||||
[DataMember]
|
||||
public int Id { get; set; }
|
||||
public virtual Ship Ship { get; set; }
|
||||
public virtual Client Client { get; set; }
|
||||
|
@ -3,18 +3,24 @@ using ShipyardContracts.ViewModels;
|
||||
using ShipyardDataModels.Models;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace ShipyardDataBaseImplement.Models
|
||||
{
|
||||
[DataContract]
|
||||
public class Ship : IShipModel
|
||||
{
|
||||
[DataMember]
|
||||
public int Id { get; set; }
|
||||
[Required]
|
||||
[DataMember]
|
||||
public string ShipName { get; set; } = string.Empty;
|
||||
[Required]
|
||||
[DataMember]
|
||||
public double Price { get; set; }
|
||||
private Dictionary<int, (IDetailModel, int)>? _shipDetails = null;
|
||||
[NotMapped]
|
||||
[DataMember]
|
||||
public Dictionary<int, (IDetailModel, int)> ShipDetails
|
||||
{
|
||||
get
|
||||
|
@ -24,4 +24,8 @@
|
||||
<Folder Include="Migrations\" />
|
||||
</ItemGroup>
|
||||
|
||||
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
|
||||
<Exec Command="copy /Y "$(TargetDir)*.dll" "$(SolutionDir)ImplementationExtensions\*.dll"" />
|
||||
</Target>
|
||||
|
||||
</Project>
|
||||
|
@ -1,6 +1,6 @@
|
||||
namespace ShipyardDataModels.Models
|
||||
{
|
||||
public interface IMessageInfoModel
|
||||
public interface IMessageInfoModel : IId
|
||||
{
|
||||
string MessageId { get; }
|
||||
|
||||
|
@ -0,0 +1,22 @@
|
||||
using ShipyardContracts.DI;
|
||||
using ShipyardContracts.StoragesContracts;
|
||||
using ShipyardFileImplement.Implements;
|
||||
|
||||
namespace ShipyardFileImplement
|
||||
{
|
||||
public class FileImplementationExtension : IImplementationExtension
|
||||
{
|
||||
public int Priority => 1;
|
||||
|
||||
public void RegisterServices()
|
||||
{
|
||||
DependencyManager.Instance.RegisterType<IClientStorage, ClientStorage>();
|
||||
DependencyManager.Instance.RegisterType<IDetailStorage, DetailStorage>();
|
||||
DependencyManager.Instance.RegisterType<IImplementerStorage, ImplementerStorage>();
|
||||
DependencyManager.Instance.RegisterType<IMessageInfoStorage, MessageInfoStorage>();
|
||||
DependencyManager.Instance.RegisterType<IOrderStorage, OrderStorage>();
|
||||
DependencyManager.Instance.RegisterType<IShipStorage, ShipStorage>();
|
||||
DependencyManager.Instance.RegisterType<IBackUpInfo, BackUpInfo>();
|
||||
}
|
||||
}
|
||||
}
|
29
Shipyard/ShipyardFileImplement/Implements/BackUpInfo.cs
Normal file
29
Shipyard/ShipyardFileImplement/Implements/BackUpInfo.cs
Normal file
@ -0,0 +1,29 @@
|
||||
using ShipyardContracts.StoragesContracts;
|
||||
|
||||
namespace ShipyardFileImplement.Implements
|
||||
{
|
||||
public class BackUpInfo : IBackUpInfo
|
||||
{
|
||||
public List<T>? GetList<T>() where T : class, new()
|
||||
{
|
||||
var source = DataFileSingleton.GetInstance();
|
||||
return (List<T>?)source.GetType().GetProperties()
|
||||
.FirstOrDefault(x => x.PropertyType.IsGenericType && x.PropertyType.GetGenericArguments()[0] == typeof(T))
|
||||
?.GetValue(source);
|
||||
}
|
||||
|
||||
public Type? GetTypeByModelInterface(string modelInterfaceName)
|
||||
{
|
||||
var assembly = typeof(BackUpInfo).Assembly;
|
||||
var types = assembly.GetTypes();
|
||||
foreach (var type in types)
|
||||
{
|
||||
if (type.IsClass && type.GetInterface(modelInterfaceName) != null)
|
||||
{
|
||||
return type;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,15 +1,21 @@
|
||||
using ShipyardContracts.BindingModels;
|
||||
using ShipyardContracts.ViewModels;
|
||||
using ShipyardDataModels.Models;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Xml.Linq;
|
||||
|
||||
namespace ShipyardFileImplement.Models
|
||||
{
|
||||
[DataContract]
|
||||
public class Client : IClientModel
|
||||
{
|
||||
[DataMember]
|
||||
public int Id { get; set; }
|
||||
[DataMember]
|
||||
public string ClientFIO { get; set; } = string.Empty;
|
||||
[DataMember]
|
||||
public string Email { get; set; } = string.Empty;
|
||||
[DataMember]
|
||||
public string Password { get; set; } = string.Empty;
|
||||
public static Client? Create(ClientBindingModel model)
|
||||
{
|
||||
|
@ -1,14 +1,19 @@
|
||||
using ShipyardContracts.BindingModels;
|
||||
using ShipyardContracts.ViewModels;
|
||||
using ShipyardDataModels.Models;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Xml.Linq;
|
||||
|
||||
namespace ShipyardFileImplement.Models
|
||||
{
|
||||
[DataContract]
|
||||
public class Detail : IDetailModel
|
||||
{
|
||||
[DataMember]
|
||||
public int Id { get; private set; }
|
||||
[DataMember]
|
||||
public string DetailName { get; private set; } = string.Empty;
|
||||
[DataMember]
|
||||
public double Cost { get; set; }
|
||||
public static Detail? Create(DetailBindingModel model)
|
||||
{
|
||||
|
@ -1,21 +1,24 @@
|
||||
using ShipyardContracts.BindingModels;
|
||||
using ShipyardContracts.ViewModels;
|
||||
using ShipyardDataModels.Models;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Xml.Linq;
|
||||
|
||||
namespace ShipyardFileImplement.Models
|
||||
{
|
||||
public class Implementer : IImplementerModel
|
||||
[DataContract]
|
||||
public class Implementer : IImplementerModel
|
||||
{
|
||||
public string ImplementerFIO { get; set; } = String.Empty;
|
||||
|
||||
public string Password { get; set; } = String.Empty;
|
||||
|
||||
public int WorkExperience { get; set; }
|
||||
|
||||
public int Qualification { get; set; }
|
||||
|
||||
public int Id { get; set; }
|
||||
[DataMember]
|
||||
public string ImplementerFIO { get; set; } = String.Empty;
|
||||
[DataMember]
|
||||
public string Password { get; set; } = String.Empty;
|
||||
[DataMember]
|
||||
public int WorkExperience { get; set; }
|
||||
[DataMember]
|
||||
public int Qualification { get; set; }
|
||||
[DataMember]
|
||||
public int Id { get; set; }
|
||||
|
||||
public static Implementer? Create(ImplementerBindingModel? model)
|
||||
{
|
||||
|
@ -1,23 +1,27 @@
|
||||
using ShipyardContracts.BindingModels;
|
||||
using ShipyardContracts.ViewModels;
|
||||
using ShipyardDataModels.Models;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Xml.Linq;
|
||||
|
||||
namespace ShipyardFileImplement.Models
|
||||
{
|
||||
[DataContract]
|
||||
public class Message : IMessageInfoModel
|
||||
{
|
||||
[DataMember]
|
||||
public string MessageId { get; private set; } = string.Empty;
|
||||
|
||||
[DataMember]
|
||||
public int? ClientId { get; private set; }
|
||||
|
||||
[DataMember]
|
||||
public string SenderName { get; private set; } = string.Empty;
|
||||
|
||||
[DataMember]
|
||||
public DateTime DateDelivery { get; private set; } = DateTime.Now;
|
||||
|
||||
[DataMember]
|
||||
public string Subject { get; private set; } = string.Empty;
|
||||
|
||||
[DataMember]
|
||||
public string Body { get; private set; } = string.Empty;
|
||||
public int Id => throw new NotImplementedException();
|
||||
public static Message? Create(MessageInfoBindingModel model)
|
||||
{
|
||||
if (model == null)
|
||||
|
@ -2,20 +2,31 @@
|
||||
using ShipyardContracts.ViewModels;
|
||||
using ShipyardDataModels.Enums;
|
||||
using ShipyardDataModels.Models;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Xml.Linq;
|
||||
|
||||
namespace ShipyardFileImplement.Models
|
||||
{
|
||||
[DataContract]
|
||||
public class Order : IOrderModel
|
||||
{
|
||||
[DataMember]
|
||||
public int Id { get; private set; }
|
||||
[DataMember]
|
||||
public int ShipId { get; private set; }
|
||||
[DataMember]
|
||||
public int ClientId { get; private set; }
|
||||
[DataMember]
|
||||
public int? ImplementerId { get; private set; }
|
||||
[DataMember]
|
||||
public int Count { get; private set; }
|
||||
[DataMember]
|
||||
public double Sum { get; private set; }
|
||||
[DataMember]
|
||||
public OrderStatus Status { get; private set; } = OrderStatus.Неизвестен;
|
||||
[DataMember]
|
||||
public DateTime DateCreate { get; private set; } = DateTime.Now;
|
||||
[DataMember]
|
||||
public DateTime? DateImplement { get; private set; }
|
||||
public static Order? Create(OrderBindingModel? model)
|
||||
{
|
||||
|
@ -1,17 +1,23 @@
|
||||
using ShipyardContracts.BindingModels;
|
||||
using ShipyardContracts.ViewModels;
|
||||
using ShipyardDataModels.Models;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Xml.Linq;
|
||||
|
||||
namespace ShipyardFileImplement.Models
|
||||
{
|
||||
[DataContract]
|
||||
public class Ship : IShipModel
|
||||
{
|
||||
[DataMember]
|
||||
public int Id { get; private set; }
|
||||
[DataMember]
|
||||
public string ShipName { get; private set; } = string.Empty;
|
||||
[DataMember]
|
||||
public double Price { get; private set; }
|
||||
public Dictionary<int, int> Details { get; private set; } = new();
|
||||
private Dictionary<int, (IDetailModel, int)>? _shipDetails = null;
|
||||
[DataMember]
|
||||
public Dictionary<int, (IDetailModel, int)> ShipDetails
|
||||
{
|
||||
get
|
||||
|
@ -10,5 +10,8 @@
|
||||
<ProjectReference Include="..\ShipyardContracts\ShipyardContracts.csproj" />
|
||||
<ProjectReference Include="..\ShipyardDataModels\ShipyardDataModels.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
|
||||
<Exec Command="copy /Y "$(TargetDir)*.dll" "$(SolutionDir)ImplementationExtensions\*.dll"" />
|
||||
</Target>
|
||||
</Project>
|
||||
|
17
Shipyard/ShipyardListImplement/Implements/BackUpInfo.cs
Normal file
17
Shipyard/ShipyardListImplement/Implements/BackUpInfo.cs
Normal file
@ -0,0 +1,17 @@
|
||||
using ShipyardContracts.StoragesContracts;
|
||||
|
||||
namespace ShipyardListImplement.Implements
|
||||
{
|
||||
public class BackUpInfo : IBackUpInfo
|
||||
{
|
||||
public List<T>? GetList<T>() where T : class, new()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public Type? GetTypeByModelInterface(string modelInterfaceName)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
using ShipyardContracts.DI;
|
||||
using ShipyardContracts.StoragesContracts;
|
||||
using ShipyardListImplement.Implements;
|
||||
|
||||
namespace ShipyardListImplement
|
||||
{
|
||||
public class ListImplementationExtension : IImplementationExtension
|
||||
{
|
||||
public int Priority => 0;
|
||||
|
||||
public void RegisterServices()
|
||||
{
|
||||
DependencyManager.Instance.RegisterType<IClientStorage, ClientStorage>();
|
||||
DependencyManager.Instance.RegisterType<IDetailStorage, DetailStorage>();
|
||||
DependencyManager.Instance.RegisterType<IImplementerStorage, ImplementerStorage>();
|
||||
DependencyManager.Instance.RegisterType<IMessageInfoStorage, MessageInfoStorage>();
|
||||
DependencyManager.Instance.RegisterType<IOrderStorage, OrderStorage>();
|
||||
DependencyManager.Instance.RegisterType<IShipStorage, ShipStorage>();
|
||||
DependencyManager.Instance.RegisterType<IBackUpInfo, BackUpInfo>();
|
||||
}
|
||||
}
|
||||
}
|
@ -17,7 +17,7 @@ namespace ShipyardListImplement.Models
|
||||
public string Subject { get; private set; } = string.Empty;
|
||||
|
||||
public string Body { get; private set; } = string.Empty;
|
||||
|
||||
public int Id => throw new NotImplementedException();
|
||||
public static Message? Create(MessageInfoBindingModel model)
|
||||
{
|
||||
if (model == null)
|
||||
|
@ -11,4 +11,8 @@
|
||||
<ProjectReference Include="..\ShipyardDataModels\ShipyardDataModels.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
|
||||
<Exec Command="copy /Y "$(TargetDir)*.dll" "$(SolutionDir)ImplementationExtensions\*.dll"" />
|
||||
</Target>
|
||||
|
||||
</Project>
|
||||
|
45
Shipyard/ShipyardView/DataGridViewExtension.cs
Normal file
45
Shipyard/ShipyardView/DataGridViewExtension.cs
Normal file
@ -0,0 +1,45 @@
|
||||
using ShipyardContracts.Attributes;
|
||||
namespace ShipyardView
|
||||
{
|
||||
internal 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -27,13 +27,7 @@ namespace ShipyardView
|
||||
{
|
||||
try
|
||||
{
|
||||
var list = _logic.ReadList(null);
|
||||
if (list != null)
|
||||
{
|
||||
dataGridView.DataSource = list;
|
||||
dataGridView.Columns["Id"].Visible = false;
|
||||
dataGridView.Columns["ClientFIO"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||
}
|
||||
dataGridView.FillAndConfigGrid(_logic.ReadList(null));
|
||||
_logger.LogInformation("Загрузка клиентов");
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
1
Shipyard/ShipyardView/FormDetails.Designer.cs
generated
1
Shipyard/ShipyardView/FormDetails.Designer.cs
generated
@ -42,6 +42,7 @@
|
||||
dataGridView.AllowUserToDeleteRows = false;
|
||||
dataGridView.AllowUserToResizeColumns = false;
|
||||
dataGridView.AllowUserToResizeRows = false;
|
||||
dataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
|
||||
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
dataGridView.Location = new Point(-2, -1);
|
||||
dataGridView.Name = "dataGridView";
|
||||
|
@ -1,6 +1,7 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
using ShipyardContracts.BindingModels;
|
||||
using ShipyardContracts.BusinessLogicsContracts;
|
||||
using ShipyardContracts.DI;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace ShipyardView
|
||||
@ -24,13 +25,7 @@ namespace ShipyardView
|
||||
{
|
||||
try
|
||||
{
|
||||
var list = _logic.ReadList(null);
|
||||
if (list != null)
|
||||
{
|
||||
dataGridView.DataSource = list;
|
||||
dataGridView.Columns["Id"].Visible = false;
|
||||
dataGridView.Columns["DetailName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||
}
|
||||
dataGridView.FillAndConfigGrid(_logic.ReadList(null));
|
||||
_logger.LogInformation("Загрузка деталей");
|
||||
}
|
||||
catch (Exception ex)
|
||||
@ -42,13 +37,10 @@ namespace ShipyardView
|
||||
|
||||
private void ButtonAdd_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormDetail));
|
||||
if (service is FormDetail form)
|
||||
var form = DependencyManager.Instance.Resolve<FormDetail>();
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -56,14 +48,11 @@ namespace ShipyardView
|
||||
{
|
||||
if (dataGridView.SelectedRows.Count == 1)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormDetail));
|
||||
if (service is FormDetail form)
|
||||
var form = DependencyManager.Instance.Resolve<FormDetail>();
|
||||
form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
using ShipyardContracts.BindingModels;
|
||||
using ShipyardContracts.BusinessLogicsContracts;
|
||||
using ShipyardContracts.DI;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace ShipyardView
|
||||
@ -24,17 +25,8 @@ namespace ShipyardView
|
||||
{
|
||||
try
|
||||
{
|
||||
var list = _logic.ReadList(null);
|
||||
if (list != null)
|
||||
{
|
||||
dataGridView.DataSource = list;
|
||||
dataGridView.Columns["Id"].Visible = false;
|
||||
dataGridView.Columns["ImplementerFIO"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||
dataGridView.Columns["Password"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||
dataGridView.Columns["WorkExperience"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||
dataGridView.Columns["Qualification"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||
}
|
||||
_logger.LogInformation("Загрузка исполнителей");
|
||||
dataGridView.FillAndConfigGrid(_logic.ReadList(null));
|
||||
_logger.LogInformation("Загрузка исполнителей");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@ -45,13 +37,10 @@ namespace ShipyardView
|
||||
|
||||
private void ButtonAdd_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormImplementer));
|
||||
if (service is FormImplementer form)
|
||||
{
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
var form = DependencyManager.Instance.Resolve<FormImplementer>();
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -59,14 +48,11 @@ namespace ShipyardView
|
||||
{
|
||||
if (dataGridView.SelectedRows.Count == 1)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormImplementer));
|
||||
if (service is FormImplementer form)
|
||||
{
|
||||
form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
var form = DependencyManager.Instance.Resolve<FormImplementer>();
|
||||
form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -20,14 +20,7 @@ namespace ShipyardView
|
||||
{
|
||||
try
|
||||
{
|
||||
var list = _logic.ReadList(null);
|
||||
if (list != null)
|
||||
{
|
||||
dataGridView.DataSource = list;
|
||||
dataGridView.Columns["ClientId"].Visible = false;
|
||||
dataGridView.Columns["MessageId"].Visible = false;
|
||||
dataGridView.Columns["Body"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||
}
|
||||
dataGridView.FillAndConfigGrid(_logic.ReadList(null));
|
||||
_logger.LogInformation("Загрузка писем");
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
14
Shipyard/ShipyardView/FormMain.Designer.cs
generated
14
Shipyard/ShipyardView/FormMain.Designer.cs
generated
@ -45,6 +45,7 @@
|
||||
buttonCreateOrder = new Button();
|
||||
buttonIssue = new Button();
|
||||
buttonRefresh = new Button();
|
||||
создатьБекапToolStripMenuItem = new ToolStripButton();
|
||||
toolStrip.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
|
||||
SuspendLayout();
|
||||
@ -52,7 +53,7 @@
|
||||
// toolStrip
|
||||
//
|
||||
toolStrip.ImageScalingSize = new Size(20, 20);
|
||||
toolStrip.Items.AddRange(new ToolStripItem[] { toolStripMenu, отчетыToolStripMenuItem, startWorkToolStripMenuItem, mailsToolStripMenuItem });
|
||||
toolStrip.Items.AddRange(new ToolStripItem[] { toolStripMenu, отчетыToolStripMenuItem, startWorkToolStripMenuItem, mailsToolStripMenuItem, создатьБекапToolStripMenuItem });
|
||||
toolStrip.Location = new Point(0, 0);
|
||||
toolStrip.Name = "toolStrip";
|
||||
toolStrip.Size = new Size(1522, 27);
|
||||
@ -195,6 +196,16 @@
|
||||
buttonRefresh.UseVisualStyleBackColor = true;
|
||||
buttonRefresh.Click += ButtonRef_Click;
|
||||
//
|
||||
// создатьБекапToolStripMenuItem
|
||||
//
|
||||
создатьБекапToolStripMenuItem.DisplayStyle = ToolStripItemDisplayStyle.Text;
|
||||
создатьБекапToolStripMenuItem.Image = (Image)resources.GetObject("создатьБекапToolStripMenuItem.Image");
|
||||
создатьБекапToolStripMenuItem.ImageTransparentColor = Color.Magenta;
|
||||
создатьБекапToolStripMenuItem.Name = "создатьБекапToolStripMenuItem";
|
||||
создатьБекапToolStripMenuItem.Size = new Size(113, 24);
|
||||
создатьБекапToolStripMenuItem.Text = "Создать бекап";
|
||||
создатьБекапToolStripMenuItem.Click += создатьБекапToolStripMenuItem_Click;
|
||||
//
|
||||
// FormMain
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
@ -233,5 +244,6 @@
|
||||
private ToolStripMenuItem исполнителиToolStripMenuItem;
|
||||
private ToolStripButton startWorkToolStripMenuItem;
|
||||
private ToolStripButton mailsToolStripMenuItem;
|
||||
private ToolStripButton создатьБекапToolStripMenuItem;
|
||||
}
|
||||
}
|
@ -1,6 +1,7 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
using ShipyardContracts.BindingModels;
|
||||
using ShipyardContracts.BusinessLogicsContracts;
|
||||
using ShipyardContracts.DI;
|
||||
using ShipyardDataModels.Enums;
|
||||
using ShipyardView;
|
||||
using System.Windows.Forms;
|
||||
@ -13,15 +14,17 @@ namespace ShipyardView
|
||||
private readonly IOrderLogic _orderLogic;
|
||||
private readonly IReportLogic _reportLogic;
|
||||
private readonly IWorkProcess _workProcess;
|
||||
public FormMain(ILogger<FormMain> logger, IOrderLogic orderLogic, IReportLogic reportLogic, IWorkProcess workProcess)
|
||||
{
|
||||
InitializeComponent();
|
||||
_logger = logger;
|
||||
_orderLogic = orderLogic;
|
||||
_reportLogic = reportLogic;
|
||||
_workProcess = workProcess;
|
||||
}
|
||||
private void FormMain_Load(object sender, EventArgs e)
|
||||
private readonly IBackUpLogic _backUpLogic;
|
||||
public FormMain(ILogger<FormMain> logger, IOrderLogic orderLogic, IReportLogic reportLogic, IWorkProcess workProcess, IBackUpLogic backUpLogic)
|
||||
{
|
||||
InitializeComponent();
|
||||
_logger = logger;
|
||||
_orderLogic = orderLogic;
|
||||
_reportLogic = reportLogic;
|
||||
_workProcess = workProcess;
|
||||
_backUpLogic = backUpLogic;
|
||||
}
|
||||
private void FormMain_Load(object sender, EventArgs e)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
@ -29,15 +32,8 @@ namespace ShipyardView
|
||||
{
|
||||
try
|
||||
{
|
||||
var list = _orderLogic.ReadList(null);
|
||||
if (list != null)
|
||||
{
|
||||
dataGridView.DataSource = list;
|
||||
dataGridView.Columns["ShipId"].Visible = false;
|
||||
dataGridView.Columns["ClientId"].Visible = false;
|
||||
dataGridView.Columns["ImplementerId"].Visible = false;
|
||||
}
|
||||
_logger.LogInformation("Загрузка заказов");
|
||||
dataGridView.FillAndConfigGrid(_orderLogic.ReadList(null));
|
||||
_logger.LogInformation("Загрузка заказов");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@ -47,29 +43,20 @@ namespace ShipyardView
|
||||
}
|
||||
private void ДеталиToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormDetails));
|
||||
if (service is FormDetails form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
}
|
||||
}
|
||||
var form = DependencyManager.Instance.Resolve<FormDetails>();
|
||||
form.ShowDialog();
|
||||
}
|
||||
private void КораблиToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormShips));
|
||||
if (service is FormShips form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
}
|
||||
}
|
||||
var form = DependencyManager.Instance.Resolve<FormShips>();
|
||||
form.ShowDialog();
|
||||
}
|
||||
private void ButtonCreateOrder_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormCreateOrder));
|
||||
if (service is FormCreateOrder form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
var form = DependencyManager.Instance.Resolve<FormCreateOrder>();
|
||||
form.ShowDialog();
|
||||
LoadData();
|
||||
}
|
||||
private void ButtonIssuedOrder_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (dataGridView.SelectedRows.Count == 1)
|
||||
@ -109,50 +96,61 @@ namespace ShipyardView
|
||||
|
||||
private void shipDetailsToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormReportShipDetails));
|
||||
if (service is FormReportShipDetails form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
}
|
||||
}
|
||||
var form = DependencyManager.Instance.Resolve<FormReportShipDetails>();
|
||||
form.ShowDialog();
|
||||
}
|
||||
|
||||
private void ordersToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormReportOrders));
|
||||
if (service is FormReportOrders form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
}
|
||||
}
|
||||
var form = DependencyManager.Instance.Resolve<FormReportOrders>();
|
||||
form.ShowDialog();
|
||||
}
|
||||
private void clientsToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormClients));
|
||||
if (service is FormClients form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
}
|
||||
}
|
||||
var form = DependencyManager.Instance.Resolve<FormClients>();
|
||||
form.ShowDialog();
|
||||
}
|
||||
private void mailsToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormMails));
|
||||
if (service is FormMails form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
}
|
||||
var form = DependencyManager.Instance.Resolve<FormMails>();
|
||||
form.ShowDialog();
|
||||
}
|
||||
private void ImplementerToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormImplementers));
|
||||
if (service is FormImplementers form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
}
|
||||
}
|
||||
var form = DependencyManager.Instance.Resolve<FormImplementers>();
|
||||
form.ShowDialog();
|
||||
}
|
||||
private void startWorkToolStripMenuItem_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);
|
||||
}
|
||||
}
|
||||
|
||||
private void создатьБекапToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (_backUpLogic != null)
|
||||
{
|
||||
var fbd = new FolderBrowserDialog();
|
||||
if (fbd.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
_backUpLogic.CreateBackUp(new BackUpSaveBinidngModel
|
||||
{
|
||||
FolderName = fbd.SelectedPath
|
||||
});
|
||||
MessageBox.Show("Бекап создан", "Сообщение",
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
|
||||
MessageBoxIcon.Error);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
@ -163,6 +163,17 @@
|
||||
U87f4aUApcXhnrI9Jzg/laQKFntXlHM+lSQK5psL5fvbp/JvJLGCQqmSWM5JkiCT84igXGtSrruKLQ0T
|
||||
luAdmZxHBG37FFuWBC/j5XKOmX8WAH7rcI6ZMffPgjQwN2bXJgDo/COBTpjneQ2dML0PY3cISreGe8HM
|
||||
qgAAAABJRU5ErkJggg==
|
||||
</value>
|
||||
</data>
|
||||
<data name="создатьБекапToolStripMenuItem.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>
|
||||
iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
|
||||
YQUAAAAJcEhZcwAAEnQAABJ0Ad5mH3gAAAEISURBVEhL3ZErDsJAGIR7DlA47oArV8CDR9RiSDAQPBcA
|
||||
Qx1BgUMQBEk1ooJAKE0I4Wlqf5gmu1n6oqW7hiZfthkx33aqeZ5HKvEFpmmSYRhSQScXINB1XSroDAke
|
||||
96cUpAmupyPZsx7Z8x4drAnPpQmsgU7LdoHDJNIEYjnAlyBXJ3jPhVyaYLca8nLMhX+CPJXAOT+ouTj5
|
||||
p5in4asApdWpS8XRwT+zShIFG/fOyxlZJbGC9f5G5bHzUf6LJFJQqTViyxlxEmRiHhLUW10qDbeRpUGC
|
||||
ErwjE/OQoG9dIsviYGWsXMwxc24BYLcO5pgZc+cWJIG5MbsyAUDnHwlUAkFHJZraR9NeMVq3zi+WF/0A
|
||||
AAAASUVORK5CYII=
|
||||
</value>
|
||||
</data>
|
||||
</root>
|
@ -1,6 +1,7 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
using ShipyardContracts.BindingModels;
|
||||
using ShipyardContracts.BusinessLogicsContracts;
|
||||
using ShipyardContracts.DI;
|
||||
using ShipyardContracts.SearchModels;
|
||||
using ShipyardDataModels.Models;
|
||||
using System.Windows.Forms;
|
||||
@ -75,26 +76,23 @@ namespace ShipyardView
|
||||
|
||||
private void ButtonAdd_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormShipDetail));
|
||||
if (service is FormShipDetail form)
|
||||
var form = DependencyManager.Instance.Resolve<FormShipDetail>();
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
if (form.DetailModel == null)
|
||||
{
|
||||
if (form.DetailModel == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_logger.LogInformation("Добавление новой детали:{ DetailName} - { Count}", form.DetailModel.DetailName, form.Count);
|
||||
if (_shipDetails.ContainsKey(form.Id))
|
||||
{
|
||||
_shipDetails[form.Id] = (form.DetailModel, form.Count);
|
||||
}
|
||||
else
|
||||
{
|
||||
_shipDetails.Add(form.Id, (form.DetailModel, form.Count));
|
||||
}
|
||||
LoadData();
|
||||
return;
|
||||
}
|
||||
_logger.LogInformation("Добавление новой детали:{ DetailName} - { Count}", form.DetailModel.DetailName, form.Count);
|
||||
if (_shipDetails.ContainsKey(form.Id))
|
||||
{
|
||||
_shipDetails[form.Id] = (form.DetailModel, form.Count);
|
||||
}
|
||||
else
|
||||
{
|
||||
_shipDetails.Add(form.Id, (form.DetailModel, form.Count));
|
||||
}
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
|
||||
@ -102,22 +100,19 @@ namespace ShipyardView
|
||||
{
|
||||
if (dataGridView.SelectedRows.Count == 1)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormShipDetail));
|
||||
if (service is FormShipDetail form)
|
||||
var form = DependencyManager.Instance.Resolve<FormShipDetail>();
|
||||
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells[0].Value);
|
||||
form.Id = id;
|
||||
form.Count = _shipDetails[id].Item2;
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells[0].Value);
|
||||
form.Id = id;
|
||||
form.Count = _shipDetails[id].Item2;
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
if (form.DetailModel == null)
|
||||
{
|
||||
if (form.DetailModel == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_logger.LogInformation("Изменение детали: { DetailName} - { Count}", form.DetailModel.DetailName, form.Count);
|
||||
_shipDetails[form.Id] = (form.DetailModel, form.Count);
|
||||
LoadData();
|
||||
return;
|
||||
}
|
||||
_logger.LogInformation("Изменение детали: { DetailName} - { Count}", form.DetailModel.DetailName, form.Count);
|
||||
_shipDetails[form.Id] = (form.DetailModel, form.Count);
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
using ShipyardContracts.BindingModels;
|
||||
using ShipyardContracts.BusinessLogicsContracts;
|
||||
using ShipyardContracts.DI;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace ShipyardView
|
||||
@ -24,14 +25,7 @@ namespace ShipyardView
|
||||
{
|
||||
try
|
||||
{
|
||||
var list = _logic.ReadList(null);
|
||||
if (list != null)
|
||||
{
|
||||
dataGridView.DataSource = list;
|
||||
dataGridView.Columns["Id"].Visible = false;
|
||||
dataGridView.Columns["ShipName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||
dataGridView.Columns["ShipDetails"].Visible = false;
|
||||
}
|
||||
dataGridView.FillAndConfigGrid(_logic.ReadList(null));
|
||||
_logger.LogInformation("Загрузка кораблей");
|
||||
}
|
||||
catch (Exception ex)
|
||||
@ -43,13 +37,10 @@ namespace ShipyardView
|
||||
|
||||
private void ButtonAdd_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormShip));
|
||||
if (service is FormShip form)
|
||||
var form = DependencyManager.Instance.Resolve<FormShip>();
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -57,14 +48,11 @@ namespace ShipyardView
|
||||
{
|
||||
if (dataGridView.SelectedRows.Count == 1)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormShip));
|
||||
if (service is FormShip form)
|
||||
var form = DependencyManager.Instance.Resolve<FormShip>();
|
||||
form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -9,14 +9,14 @@ using ShipyardBusinessLogic.OfficePackage.Implements;
|
||||
using ShipyardBusinessLogic.OfficePackage;
|
||||
using NLog.Extensions.Logging;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using ShipyardBusinessLogic;
|
||||
using ShipyardContracts.DI;
|
||||
|
||||
|
||||
namespace ShipyardView
|
||||
{
|
||||
internal static class Program
|
||||
{
|
||||
private static ServiceProvider? _serviceProvider;
|
||||
public static ServiceProvider? ServiceProvider => _serviceProvider;
|
||||
/// <summary>
|
||||
/// The main entry point for the application.
|
||||
/// </summary>
|
||||
@ -24,12 +24,10 @@ namespace ShipyardView
|
||||
static void Main()
|
||||
{
|
||||
ApplicationConfiguration.Initialize();
|
||||
var services = new ServiceCollection();
|
||||
ConfigureServices(services);
|
||||
_serviceProvider = services.BuildServiceProvider();
|
||||
InitDependency();
|
||||
try
|
||||
{
|
||||
var mailSender = _serviceProvider.GetService<AbstractMailWorker>();
|
||||
var mailSender = DependencyManager.Instance.Resolve<AbstractMailWorker>();
|
||||
mailSender?.MailConfig(new MailConfigBindingModel
|
||||
{
|
||||
MailLogin = System.Configuration.ConfigurationManager.AppSettings["MailLogin"] ?? string.Empty,
|
||||
@ -44,50 +42,46 @@ namespace ShipyardView
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
var logger = _serviceProvider.GetService<ILogger>();
|
||||
var logger = DependencyManager.Instance.Resolve<ILogger>();
|
||||
logger?.LogError(ex, "Îøèáêà ðàáîòû ñ ïî÷òîé");
|
||||
}
|
||||
Application.Run(_serviceProvider.GetRequiredService<FormMain>());
|
||||
Application.Run(DependencyManager.Instance.Resolve<FormMain>());
|
||||
}
|
||||
private static void ConfigureServices(ServiceCollection services)
|
||||
private static void InitDependency()
|
||||
{
|
||||
services.AddLogging(option =>
|
||||
DependencyManager.InitDependency();
|
||||
|
||||
DependencyManager.Instance.AddLogging(option =>
|
||||
{
|
||||
option.AddNLog("NLog.config");
|
||||
});
|
||||
services.AddTransient<IDetailStorage, DetailStorage>();
|
||||
services.AddTransient<IOrderStorage, OrderStorage>();
|
||||
services.AddTransient<IShipStorage, ShipStorage>();
|
||||
services.AddTransient<IClientStorage, ClientStorage>();
|
||||
services.AddTransient<IImplementerStorage, ImplementerStorage>();
|
||||
services.AddTransient<IMessageInfoStorage, MessageInfoStorage>();
|
||||
services.AddTransient<IDetailLogic, DetailLogic>();
|
||||
services.AddTransient<IOrderLogic, OrderLogic>();
|
||||
services.AddTransient<IShipLogic, ShipLogic>();
|
||||
services.AddTransient<IClientLogic, ClientLogic>();
|
||||
services.AddTransient<IReportLogic, ReportLogic>();
|
||||
services.AddTransient<IImplementerLogic, ImplementerLogic>();
|
||||
services.AddTransient<IMessageInfoLogic, MessageInfoLogic>();
|
||||
services.AddTransient<IWorkProcess, WorkModeling>();
|
||||
services.AddTransient<AbstractSaveToExcel, SaveToExcel>();
|
||||
services.AddTransient<AbstractSaveToWord, SaveToWord>();
|
||||
services.AddTransient<AbstractSaveToPdf, SaveToPdf>();
|
||||
services.AddSingleton<AbstractMailWorker, MailKitWorker>();
|
||||
services.AddTransient<FormMain>();
|
||||
services.AddTransient<FormDetail>();
|
||||
services.AddTransient<FormDetails>();
|
||||
services.AddTransient<FormClients>();
|
||||
services.AddTransient<FormCreateOrder>();
|
||||
services.AddTransient<FormShip>();
|
||||
services.AddTransient<FormShipDetail>();
|
||||
services.AddTransient<FormShips>();
|
||||
services.AddTransient<FormImplementer>();
|
||||
services.AddTransient<FormImplementers>();
|
||||
services.AddTransient<FormReportShipDetails>();
|
||||
services.AddTransient<FormReportOrders>();
|
||||
services.AddTransient<FormMails>();
|
||||
DependencyManager.Instance.RegisterType<IDetailLogic, DetailLogic>();
|
||||
DependencyManager.Instance.RegisterType<IOrderLogic, OrderLogic>();
|
||||
DependencyManager.Instance.RegisterType<IShipLogic, ShipLogic>();
|
||||
DependencyManager.Instance.RegisterType<IReportLogic, ReportLogic>();
|
||||
DependencyManager.Instance.RegisterType<IClientLogic, ClientLogic>();
|
||||
DependencyManager.Instance.RegisterType<IImplementerLogic, ImplementerLogic>();
|
||||
DependencyManager.Instance.RegisterType<IMessageInfoLogic, MessageInfoLogic>();
|
||||
DependencyManager.Instance.RegisterType<IBackUpLogic, BackUpLogic>();
|
||||
DependencyManager.Instance.RegisterType<IWorkProcess, WorkModeling>();
|
||||
DependencyManager.Instance.RegisterType<AbstractSaveToExcel, SaveToExcel>();
|
||||
DependencyManager.Instance.RegisterType<AbstractSaveToWord, SaveToWord>();
|
||||
DependencyManager.Instance.RegisterType<AbstractSaveToPdf, SaveToPdf>();
|
||||
DependencyManager.Instance.RegisterType<AbstractMailWorker, MailKitWorker>(true);
|
||||
DependencyManager.Instance.RegisterType<FormMain>();
|
||||
DependencyManager.Instance.RegisterType<FormDetail>();
|
||||
DependencyManager.Instance.RegisterType<FormDetails>();
|
||||
DependencyManager.Instance.RegisterType<FormCreateOrder>();
|
||||
DependencyManager.Instance.RegisterType<FormShips>();
|
||||
DependencyManager.Instance.RegisterType<FormShip>();
|
||||
DependencyManager.Instance.RegisterType<FormShipDetail>();
|
||||
DependencyManager.Instance.RegisterType<FormReportShipDetails>();
|
||||
DependencyManager.Instance.RegisterType<FormReportOrders>();
|
||||
DependencyManager.Instance.RegisterType<FormClients>();
|
||||
DependencyManager.Instance.RegisterType<FormMails>();
|
||||
DependencyManager.Instance.RegisterType<FormImplementer>();
|
||||
DependencyManager.Instance.RegisterType<FormImplementers>();
|
||||
}
|
||||
private static void MailCheck(object obj) => ServiceProvider?.GetService<AbstractMailWorker>()?.MailCheck();
|
||||
private static void MailCheck(object obj) => DependencyManager.Instance?.Resolve<AbstractMailWorker>()?.MailCheck();
|
||||
}
|
||||
|
||||
}
|
@ -17,7 +17,7 @@
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="NLog.Extensions.Logging" Version="5.3.8" />
|
||||
<PackageReference Include="NLog.Extensions.Logging" Version="5.3.11" />
|
||||
<PackageReference Include="ReportViewerCore.WinForms" Version="15.1.19" />
|
||||
</ItemGroup>
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user