Compare commits
No commits in common. "46724ecdc340fc74e8f577a62beb2106355026c1" and "aa2a70b80c57ba77d7f8726a47745f28235a5631" have entirely different histories.
46724ecdc3
...
aa2a70b80c
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1,98 +0,0 @@
|
|||||||
using Microsoft.Extensions.Logging;
|
|
||||||
using MotorPlantContracts.BindingModels;
|
|
||||||
using MotorPlantContracts.BusinessLogicsContracts;
|
|
||||||
using MotorPlantContracts.StoragesContracts;
|
|
||||||
using MotorPlantDataModels;
|
|
||||||
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 MotorPlantBusinessLogic.BusinessLogic
|
|
||||||
{
|
|
||||||
public class BackUpLogic : IBackUpLogic
|
|
||||||
{
|
|
||||||
private readonly ILogger _logger;
|
|
||||||
private readonly IBackUpInfo _backUpInfo;
|
|
||||||
public BackUpLogic(ILogger<BackUpLogic> logger, IBackUpInfo backUpInfo)
|
|
||||||
{
|
|
||||||
_logger = logger;
|
|
||||||
_backUpInfo = backUpInfo;
|
|
||||||
}
|
|
||||||
public void CreateBackUp(BackUpSaveBinidngModel model)
|
|
||||||
{
|
|
||||||
if (_backUpInfo == null)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
try
|
|
||||||
{
|
|
||||||
_logger.LogDebug("Clear folder");
|
|
||||||
var dirInfo = new DirectoryInfo(model.FolderName);
|
|
||||||
if (dirInfo.Exists)
|
|
||||||
{
|
|
||||||
foreach (var file in dirInfo.GetFiles())
|
|
||||||
{
|
|
||||||
file.Delete();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
_logger.LogDebug("Delete archive");
|
|
||||||
string fileName = $"{model.FolderName}.zip";
|
|
||||||
if (File.Exists(fileName))
|
|
||||||
{
|
|
||||||
File.Delete(fileName);
|
|
||||||
}
|
|
||||||
// берем метод для сохранения
|
|
||||||
_logger.LogDebug("Get assembly");
|
|
||||||
var typeIId = typeof(IId);
|
|
||||||
var assembly = typeIId.Assembly;
|
|
||||||
if (assembly == null)
|
|
||||||
{
|
|
||||||
throw new ArgumentNullException("Сборка не найдена", nameof(assembly));
|
|
||||||
}
|
|
||||||
var types = assembly.GetTypes();
|
|
||||||
var method = GetType().GetMethod("SaveToFile", BindingFlags.NonPublic | BindingFlags.Instance);
|
|
||||||
_logger.LogDebug("Find {count} types", types.Length);
|
|
||||||
foreach (var type in types)
|
|
||||||
{
|
|
||||||
if (type.IsInterface && type.GetInterface(typeIId.Name) != null)
|
|
||||||
{
|
|
||||||
var modelType = _backUpInfo.GetTypeByModelInterface(type.Name);
|
|
||||||
if (modelType == null)
|
|
||||||
{
|
|
||||||
throw new InvalidOperationException($"Не найден класс-модель для {type.Name}");
|
|
||||||
}
|
|
||||||
_logger.LogDebug("Call SaveToFile method for {name} type", type.Name);
|
|
||||||
// вызываем метод на выполнение
|
|
||||||
method?.MakeGenericMethod(modelType).Invoke(this, new object[] { model.FolderName });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
_logger.LogDebug("Create zip and remove folder");
|
|
||||||
// архивируем
|
|
||||||
ZipFile.CreateFromDirectory(model.FolderName, fileName);
|
|
||||||
// удаляем папку
|
|
||||||
dirInfo.Delete(true);
|
|
||||||
}
|
|
||||||
catch (Exception)
|
|
||||||
{
|
|
||||||
throw;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
private void SaveToFile<T>(string folderName) where T : class, new()
|
|
||||||
{
|
|
||||||
var records = _backUpInfo.GetList<T>();
|
|
||||||
if (records == null)
|
|
||||||
{
|
|
||||||
_logger.LogWarning("{type} type get null list", typeof(T).Name);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
var jsonFormatter = new DataContractJsonSerializer(typeof(List<T>));
|
|
||||||
using var fs = new FileStream(string.Format("{0}/{1}.json", folderName, typeof(T).Name), FileMode.OpenOrCreate);
|
|
||||||
jsonFormatter.WriteObject(fs, records);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,26 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace MotorPlantContracts.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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,20 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace MotorPlantContracts.Attributes
|
|
||||||
{
|
|
||||||
public enum GridViewAutoSize
|
|
||||||
{
|
|
||||||
NotSet = 0,
|
|
||||||
None = 1,
|
|
||||||
ColumnHeader = 2,
|
|
||||||
AllCellsExceptHeader = 4,
|
|
||||||
AllCells = 6,
|
|
||||||
DisplayedCellsExceptHeader = 8,
|
|
||||||
DisplayedCells = 10,
|
|
||||||
Fill = 16
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,13 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace MotorPlantContracts.BindingModels
|
|
||||||
{
|
|
||||||
public class BackUpSaveBinidngModel
|
|
||||||
{
|
|
||||||
public string FolderName { get; set; } = string.Empty;
|
|
||||||
}
|
|
||||||
}
|
|
@ -15,6 +15,5 @@ namespace MotorPlantContracts.BindingModels
|
|||||||
public string Subject { get; set; } = string.Empty;
|
public string Subject { get; set; } = string.Empty;
|
||||||
public string Body { get; set; } = string.Empty;
|
public string Body { get; set; } = string.Empty;
|
||||||
public DateTime DateDelivery { get; set; }
|
public DateTime DateDelivery { get; set; }
|
||||||
public int Id => throw new NotImplementedException();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,14 +0,0 @@
|
|||||||
using MotorPlantContracts.BindingModels;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace MotorPlantContracts.BusinessLogicsContracts
|
|
||||||
{
|
|
||||||
public interface IBackUpLogic
|
|
||||||
{
|
|
||||||
void CreateBackUp(BackUpSaveBinidngModel model);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,58 +0,0 @@
|
|||||||
using Microsoft.Extensions.Logging;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace MotorPlantContracts.DI
|
|
||||||
{
|
|
||||||
public class DependencyManager
|
|
||||||
{
|
|
||||||
private readonly IDependencyContainer _dependencyManager;
|
|
||||||
private static DependencyManager? _manager;
|
|
||||||
private static readonly object _locjObject = new();
|
|
||||||
private DependencyManager()
|
|
||||||
{
|
|
||||||
_dependencyManager = new ServiceDependencyContainer();
|
|
||||||
}
|
|
||||||
public static DependencyManager Instance { get { if (_manager == null) { lock (_locjObject) { _manager = new DependencyManager(); } } return _manager; } }
|
|
||||||
|
|
||||||
/// <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>();
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,37 +0,0 @@
|
|||||||
using Microsoft.Extensions.Logging;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace MotorPlantContracts.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>();
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,17 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace MotorPlantContracts.DI
|
|
||||||
{
|
|
||||||
public interface IImplementationExtension
|
|
||||||
{
|
|
||||||
public int Priority { get; }
|
|
||||||
/// <summary>
|
|
||||||
/// Регистрация сервисов
|
|
||||||
/// </summary>
|
|
||||||
public void RegisterServices();
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,56 +0,0 @@
|
|||||||
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 MotorPlantContracts.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>()!;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,54 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Reflection;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace MotorPlantContracts.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";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,14 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace MotorPlantContracts.StoragesContracts
|
|
||||||
{
|
|
||||||
public interface IBackUpInfo
|
|
||||||
{
|
|
||||||
List<T>? GetList<T>() where T : class, new();
|
|
||||||
Type? GetTypeByModelInterface(string modelInterfaceName);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,18 +1,16 @@
|
|||||||
using MotorPlantDataModels.Models;
|
using MotorPlantDataModels.Models;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using MotorPlantContracts.Attributes;
|
|
||||||
|
|
||||||
namespace MotorPlantContracts.ViewModels
|
namespace MotorPlantContracts.ViewModels
|
||||||
{
|
{
|
||||||
public class ClientViewModel : IClientModel
|
public class ClientViewModel : IClientModel
|
||||||
{
|
{
|
||||||
[Column(visible: false)]
|
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
[Column(title: "ФИО клиента", width: 150)]
|
[DisplayName("ФИО клиента")]
|
||||||
public string ClientFIO { get; set; } = string.Empty;
|
public string ClientFIO { get; set; } = string.Empty;
|
||||||
[Column(title: "Логин (эл. почта)", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)]
|
[DisplayName("Логин (эл. почта)")]
|
||||||
public string Email { get; set; } = string.Empty;
|
public string Email { get; set; } = string.Empty;
|
||||||
[Column(title: "Пароль", width: 150)]
|
[DisplayName("Пароль")]
|
||||||
public string Password { get; set; } = string.Empty;
|
public string Password { get; set; } = string.Empty;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,16 +1,14 @@
|
|||||||
using MotorPlantDataModels.Models;
|
using MotorPlantDataModels.Models;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using MotorPlantContracts.Attributes;
|
|
||||||
|
|
||||||
namespace MotorPlantContracts.ViewModels
|
namespace MotorPlantContracts.ViewModels
|
||||||
{
|
{
|
||||||
public class ComponentViewModel : IComponentModel
|
public class ComponentViewModel : IComponentModel
|
||||||
{
|
{
|
||||||
[Column(visible: false)]
|
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
[Column(title: "Название компонента", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)]
|
[DisplayName("Название компонента")]
|
||||||
public string ComponentName { get; set; } = string.Empty;
|
public string ComponentName { get; set; } = string.Empty;
|
||||||
[Column(title: "Цена", width: 150)]
|
[DisplayName("Цена")]
|
||||||
public double Cost { get; set; }
|
public double Cost { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,18 +1,15 @@
|
|||||||
using MotorPlantDataModels.Models;
|
using MotorPlantDataModels.Models;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using MotorPlantContracts.Attributes;
|
|
||||||
|
|
||||||
namespace MotorPlantContracts.ViewModels
|
namespace MotorPlantContracts.ViewModels
|
||||||
{
|
{
|
||||||
public class EngineViewModel : IEngineModel
|
public class EngineViewModel : IEngineModel
|
||||||
{
|
{
|
||||||
[Column(visible: false)]
|
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
[Column(title: "Название изделия", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)]
|
[DisplayName("Название изделия")]
|
||||||
public string EngineName { get; set; } = string.Empty;
|
public string EngineName { get; set; } = string.Empty;
|
||||||
[Column(title: "Цена", width: 70)]
|
[DisplayName("Цена")]
|
||||||
public double Price { get; set; }
|
public double Price { get; set; }
|
||||||
[Column(visible: false)]
|
|
||||||
public Dictionary<int, (IComponentModel, int)> EngineComponents
|
public Dictionary<int, (IComponentModel, int)> EngineComponents
|
||||||
{
|
{
|
||||||
get;
|
get;
|
||||||
|
@ -5,21 +5,19 @@ using System.ComponentModel;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using MotorPlantContracts.Attributes;
|
|
||||||
|
|
||||||
namespace MotorPlantContracts.ViewModels
|
namespace MotorPlantContracts.ViewModels
|
||||||
{
|
{
|
||||||
public class ImplementerViewModel : IImplementerModel
|
public class ImplementerViewModel : IImplementerModel
|
||||||
{
|
{
|
||||||
[Column(visible: false)]
|
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
[Column(title: "ФИО исполнителя", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)]
|
[DisplayName("ФИО исполнителя")]
|
||||||
public string ImplementerFIO { get; set; } = string.Empty;
|
public string ImplementerFIO { get; set; } = string.Empty;
|
||||||
[Column(title: "Стаж работы", width: 60)]
|
[DisplayName("Стаж работы")]
|
||||||
public int WorkExperience { get; set; } = 0;
|
public int WorkExperience { get; set; } = 0;
|
||||||
[Column(title: "Квалификация", width: 60)]
|
[DisplayName("Квалификация")]
|
||||||
public int Qualification { get; set; } = 0;
|
public int Qualification { get; set; } = 0;
|
||||||
[Column(title: "Пароль", width: 100)]
|
[DisplayName("Пароль")]
|
||||||
public string Password { get; set; } = string.Empty;
|
public string Password { get; set; } = string.Empty;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,25 +5,20 @@ using System.ComponentModel;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using MotorPlantContracts.Attributes;
|
|
||||||
|
|
||||||
namespace MotorPlantContracts.ViewModels
|
namespace MotorPlantContracts.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; }
|
||||||
[Column(title: "Отправитель", width: 150)]
|
[DisplayName("Отправитель")]
|
||||||
public string SenderName { get; set; } = string.Empty;
|
public string SenderName { get; set; } = string.Empty;
|
||||||
[Column(title: "Дата письма", width: 120)]
|
[DisplayName("Дата письма")]
|
||||||
public DateTime DateDelivery { get; set; }
|
public DateTime DateDelivery { get; set; }
|
||||||
[Column(title: "Заголовок", width: 120)]
|
[DisplayName("Заголовок")]
|
||||||
public string Subject { get; set; } = string.Empty;
|
public string Subject { get; set; } = string.Empty;
|
||||||
[Column(title: "Текст", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)]
|
[DisplayName("Текст")]
|
||||||
public string Body { get; set; } = string.Empty;
|
public string Body { get; set; } = string.Empty;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,35 +1,31 @@
|
|||||||
using MotorPlantDataModels.Enums;
|
using MotorPlantDataModels.Enums;
|
||||||
using MotorPlantDataModels.Models;
|
using MotorPlantDataModels.Models;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using MotorPlantContracts.Attributes;
|
|
||||||
|
|
||||||
namespace MotorPlantContracts.ViewModels
|
namespace MotorPlantContracts.ViewModels
|
||||||
{
|
{
|
||||||
public class OrderViewModel : IOrderModel
|
public class OrderViewModel : IOrderModel
|
||||||
{
|
{
|
||||||
[Column(title: "Номер", width: 90)]
|
[DisplayName("Номер")]
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
[Column(visible: false)]
|
|
||||||
public int EngineId { get; set; }
|
public int EngineId { get; set; }
|
||||||
[Column(visible: false)]
|
|
||||||
public int ClientId { get; set; }
|
public int ClientId { get; set; }
|
||||||
[Column(visible: false)]
|
|
||||||
public int? ImplementerId { get; set; } = null;
|
public int? ImplementerId { get; set; } = null;
|
||||||
[Column(title: "Клиент", width: 190)]
|
[DisplayName("Клиент")]
|
||||||
public string ClientFIO { get; set; } = string.Empty;
|
public string ClientFIO { get; set; } = string.Empty;
|
||||||
[Column(title: "Двигатель", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)]
|
[DisplayName("Двигатель")]
|
||||||
public string EngineName { get; set; } = string.Empty;
|
public string EngineName { get; set; } = string.Empty;
|
||||||
[Column(title: "Исполнитель", width: 150)]
|
[DisplayName("Исполнитель")]
|
||||||
public string ImplementerFIO { get; set; } = string.Empty;
|
public string ImplementerFIO { get; set; } = string.Empty;
|
||||||
[Column(title: "Количество", width: 100)]
|
[DisplayName("Количество")]
|
||||||
public int Count { get; set; }
|
public int Count { get; set; }
|
||||||
[Column(title: "Сумма", width: 120)]
|
[DisplayName("Сумма")]
|
||||||
public double Sum { get; set; }
|
public double Sum { get; set; }
|
||||||
[Column(title: "Статус", width: 70)]
|
[DisplayName("Статус")]
|
||||||
public OrderStatus Status { get; set; } = OrderStatus.Неизвестен;
|
public OrderStatus Status { get; set; } = OrderStatus.Неизвестен;
|
||||||
[Column(title: "Дата создания", width: 120)]
|
[DisplayName("Дата создания")]
|
||||||
public DateTime DateCreate { get; set; } = DateTime.Now;
|
public DateTime DateCreate { get; set; } = DateTime.Now;
|
||||||
[Column(title: "Дата выполнения", width: 120)]
|
[DisplayName("Дата выполнения")]
|
||||||
public DateTime? DateImplement { get; set; }
|
public DateTime? DateImplement { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace MotorPlantDataModels
|
namespace MotorPlantDataModels
|
||||||
{
|
{
|
||||||
public interface IImplementerModel : IId
|
public interface IImplementerModel
|
||||||
{
|
{
|
||||||
string ImplementerFIO { get; }
|
string ImplementerFIO { get; }
|
||||||
string Password { get; }
|
string Password { get; }
|
||||||
|
@ -6,7 +6,7 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace MotorPlantDataModels.Models
|
namespace MotorPlantDataModels.Models
|
||||||
{
|
{
|
||||||
public interface IMessageInfoModel : IId
|
public interface IMessageInfoModel
|
||||||
{
|
{
|
||||||
string MessageId { get; }
|
string MessageId { get; }
|
||||||
int? ClientId { get; }
|
int? ClientId { get; }
|
||||||
|
@ -1,31 +0,0 @@
|
|||||||
using MotorPlantContracts.StoragesContracts;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace MotorPlantDatabaseImplement.Implements
|
|
||||||
{
|
|
||||||
public class BackUpInfo : IBackUpInfo
|
|
||||||
{
|
|
||||||
public List<T>? GetList<T>() where T : class, new()
|
|
||||||
{
|
|
||||||
using var context = new MotorPlantDataBase();
|
|
||||||
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,24 +6,18 @@ 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 MotorPlantDatabaseImplement.Models
|
namespace MotorPlantDatabaseImplement.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")]
|
||||||
|
@ -3,19 +3,14 @@ using MotorPlantContracts.ViewModels;
|
|||||||
using MotorPlantDataModels.Models;
|
using MotorPlantDataModels.Models;
|
||||||
using System.ComponentModel.DataAnnotations.Schema;
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
using System.Runtime.Serialization;
|
|
||||||
|
|
||||||
namespace MotorPlantDatabaseImplement.Models
|
namespace MotorPlantDatabaseImplement.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; }
|
||||||
[ForeignKey("ComponentId")]
|
[ForeignKey("ComponentId")]
|
||||||
|
@ -3,23 +3,18 @@ using MotorPlantContracts.ViewModels;
|
|||||||
using MotorPlantDataModels.Models;
|
using MotorPlantDataModels.Models;
|
||||||
using System.ComponentModel.DataAnnotations.Schema;
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
using System.Runtime.Serialization;
|
|
||||||
|
|
||||||
namespace MotorPlantDatabaseImplement.Models
|
namespace MotorPlantDatabaseImplement.Models
|
||||||
{
|
{
|
||||||
[DataContract]
|
|
||||||
public class Engine : IEngineModel
|
public class Engine : IEngineModel
|
||||||
{
|
{
|
||||||
[DataMember]
|
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
[DataMember]
|
|
||||||
[Required]
|
[Required]
|
||||||
public string EngineName { get; set; } = string.Empty;
|
public string EngineName { get; set; } = string.Empty;
|
||||||
[DataMember]
|
|
||||||
[Required]
|
[Required]
|
||||||
public double Price { get; set; }
|
public double Price { get; set; }
|
||||||
private Dictionary<int, (IComponentModel, int)>? _EngineComponents = null;
|
private Dictionary<int, (IComponentModel, int)>? _EngineComponents =
|
||||||
[DataMember]
|
null;
|
||||||
[NotMapped]
|
[NotMapped]
|
||||||
public Dictionary<int, (IComponentModel, int)> EngineComponents
|
public Dictionary<int, (IComponentModel, int)> EngineComponents
|
||||||
{
|
{
|
||||||
|
@ -1,21 +0,0 @@
|
|||||||
using MotorPlantContracts.DI;
|
|
||||||
using MotorPlantContracts.StoragesContracts;
|
|
||||||
using MotorPlantDatabaseImplement.Implements;
|
|
||||||
|
|
||||||
namespace MotorPlantDatabaseImplement
|
|
||||||
{
|
|
||||||
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<IEngineStorage, EngineStorage>();
|
|
||||||
DependencyManager.Instance.RegisterType<IBackUpInfo, BackUpInfo>();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -8,25 +8,18 @@ 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 MotorPlantDatabaseImplement.Models
|
namespace MotorPlantDatabaseImplement.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; set; } = string.Empty;
|
public string Password { get; set; } = string.Empty;
|
||||||
[DataMember]
|
|
||||||
[Required]
|
[Required]
|
||||||
public int Qualification { get; set; } = 0;
|
public int Qualification { get; set; } = 0;
|
||||||
[DataMember]
|
|
||||||
[Required]
|
[Required]
|
||||||
public int WorkExperience { get; set; } = 0;
|
public int WorkExperience { get; set; } = 0;
|
||||||
[ForeignKey("ImplementerId")]
|
[ForeignKey("ImplementerId")]
|
||||||
|
@ -4,9 +4,7 @@ using MotorPlantDataModels.Models;
|
|||||||
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;
|
||||||
|
|
||||||
@ -14,25 +12,12 @@ namespace MotorPlantDatabaseImplement.Models
|
|||||||
{
|
{
|
||||||
public class MessageInfo : IMessageInfoModel
|
public class MessageInfo : IMessageInfoModel
|
||||||
{
|
{
|
||||||
[NotMapped]
|
|
||||||
public int Id { get; private set; }
|
|
||||||
[DataMember]
|
|
||||||
[Key]
|
[Key]
|
||||||
[DatabaseGenerated(DatabaseGeneratedOption.None)]
|
|
||||||
public string MessageId { get; private set; } = string.Empty;
|
public string MessageId { get; private set; } = string.Empty;
|
||||||
[DataMember]
|
|
||||||
public int? ClientId { get; private set; }
|
public int? ClientId { get; private set; }
|
||||||
[DataMember]
|
|
||||||
[Required]
|
|
||||||
public string SenderName { get; private set; } = string.Empty;
|
public string SenderName { get; private set; } = string.Empty;
|
||||||
[DataMember]
|
|
||||||
[Required]
|
|
||||||
public DateTime DateDelivery { get; private set; } = DateTime.Now;
|
public DateTime DateDelivery { get; private set; } = DateTime.Now;
|
||||||
[DataMember]
|
|
||||||
[Required]
|
|
||||||
public string Subject { get; private set; } = string.Empty;
|
public string Subject { get; private set; } = string.Empty;
|
||||||
[DataMember]
|
|
||||||
[Required]
|
|
||||||
public string Body { get; private set; } = string.Empty;
|
public string Body { get; private set; } = string.Empty;
|
||||||
public Client? Client { get; private set; }
|
public Client? Client { get; private set; }
|
||||||
public static MessageInfo? Create(MotorPlantDataBase context, MessageInfoBindingModel model)
|
public static MessageInfo? Create(MotorPlantDataBase context, MessageInfoBindingModel model)
|
||||||
|
@ -20,8 +20,4 @@
|
|||||||
<ProjectReference Include="..\MotorPlantDataModels\MotorPlantDataModels.csproj" />
|
<ProjectReference Include="..\MotorPlantDataModels\MotorPlantDataModels.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
|
|
||||||
<Exec Command="copy /Y "$(TargetDir)*.dll" "$(SolutionDir)ImplementationExtensions\*.dll"" />
|
|
||||||
</Target>
|
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
@ -3,38 +3,27 @@ using MotorPlantContracts.ViewModels;
|
|||||||
using MotorPlantDataModels.Enums;
|
using MotorPlantDataModels.Enums;
|
||||||
using MotorPlantDataModels.Models;
|
using MotorPlantDataModels.Models;
|
||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
using System.Runtime.Serialization;
|
|
||||||
|
|
||||||
namespace MotorPlantDatabaseImplement.Models
|
namespace MotorPlantDatabaseImplement.Models
|
||||||
{
|
{
|
||||||
[DataContract]
|
|
||||||
public class Order : IOrderModel
|
public class Order : IOrderModel
|
||||||
{
|
{
|
||||||
[DataMember]
|
|
||||||
public int Id { get; private set; }
|
public int Id { get; private set; }
|
||||||
[DataMember]
|
|
||||||
[Required]
|
[Required]
|
||||||
public int Count { get; private set; }
|
public int Count { get; private set; }
|
||||||
[DataMember]
|
|
||||||
[Required]
|
[Required]
|
||||||
public double Sum { get; private set; }
|
public double Sum { get; private set; }
|
||||||
[DataMember]
|
|
||||||
[Required]
|
[Required]
|
||||||
public OrderStatus Status { get; private set; }
|
public OrderStatus Status { get; private set; }
|
||||||
[DataMember]
|
|
||||||
[Required]
|
[Required]
|
||||||
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; }
|
||||||
[DataMember]
|
|
||||||
[Required]
|
[Required]
|
||||||
public int EngineId { get; private set; }
|
public int EngineId { get; private set; }
|
||||||
public virtual Engine Engine { get; private set; }
|
public virtual Engine Engine { get; private set; }
|
||||||
[DataMember]
|
|
||||||
[Required]
|
[Required]
|
||||||
public int ClientId { get; private set; }
|
public int ClientId { get; private set; }
|
||||||
public virtual Client Client { get; private set; }
|
public virtual Client Client { get; private set; }
|
||||||
[DataMember]
|
|
||||||
public int? ImplementerId { get; private set; } = null;
|
public int? ImplementerId { get; private set; } = null;
|
||||||
public virtual Implementer? Implementer { get; private set; }
|
public virtual Implementer? Implementer { get; private set; }
|
||||||
public static Order? Create(MotorPlantDataBase context, OrderBindingModel model)
|
public static Order? Create(MotorPlantDataBase context, OrderBindingModel model)
|
||||||
|
@ -1,41 +0,0 @@
|
|||||||
using MotorPlantContracts.StoragesContracts;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Reflection;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace MotorPlantFileImplement.Implements
|
|
||||||
{
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -9,20 +9,14 @@ using System.Linq;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Xml.Linq;
|
using System.Xml.Linq;
|
||||||
using System.Runtime.Serialization;
|
|
||||||
|
|
||||||
namespace MotorPlantFileImplement.Models
|
namespace MotorPlantFileImplement.Models
|
||||||
{
|
{
|
||||||
[DataContract]
|
|
||||||
public class Client : IClientModel
|
public class Client : IClientModel
|
||||||
{
|
{
|
||||||
[DataMember]
|
|
||||||
public int Id { get; private set; }
|
public int Id { get; private set; }
|
||||||
[DataMember]
|
|
||||||
public string ClientFIO { get; private set; } = string.Empty;
|
public string ClientFIO { get; private set; } = string.Empty;
|
||||||
[DataMember]
|
|
||||||
public string Email { get; set; } = string.Empty;
|
public string Email { get; set; } = string.Empty;
|
||||||
[DataMember]
|
|
||||||
public string Password { get; set; } = string.Empty;
|
public string Password { get; set; } = string.Empty;
|
||||||
public static Client? Create(ClientBindingModel model)
|
public static Client? Create(ClientBindingModel model)
|
||||||
{
|
{
|
||||||
|
@ -1,19 +1,14 @@
|
|||||||
using MotorPlantContracts.BindingModels;
|
using MotorPlantContracts.BindingModels;
|
||||||
using MotorPlantContracts.ViewModels;
|
using MotorPlantContracts.ViewModels;
|
||||||
using MotorPlantDataModels.Models;
|
using MotorPlantDataModels.Models;
|
||||||
using System.Runtime.Serialization;
|
|
||||||
using System.Xml.Linq;
|
using System.Xml.Linq;
|
||||||
|
|
||||||
namespace MotorPlantFileImplement.Models
|
namespace MotorPlantFileImplement.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)
|
||||||
{
|
{
|
||||||
|
@ -1,19 +1,14 @@
|
|||||||
using MotorPlantContracts.BindingModels;
|
using MotorPlantContracts.BindingModels;
|
||||||
using MotorPlantContracts.ViewModels;
|
using MotorPlantContracts.ViewModels;
|
||||||
using MotorPlantDataModels.Models;
|
using MotorPlantDataModels.Models;
|
||||||
using System.Runtime.Serialization;
|
|
||||||
using System.Xml.Linq;
|
using System.Xml.Linq;
|
||||||
|
|
||||||
namespace MotorPlantFileImplement.Models
|
namespace MotorPlantFileImplement.Models
|
||||||
{
|
{
|
||||||
[DataContract]
|
|
||||||
public class Engine : IEngineModel
|
public class Engine : IEngineModel
|
||||||
{
|
{
|
||||||
[DataMember]
|
|
||||||
public int Id { get; private set; }
|
public int Id { get; private set; }
|
||||||
[DataMember]
|
|
||||||
public string EngineName { get; private set; } = string.Empty;
|
public string EngineName { 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)>? _EngineComponents = null;
|
private Dictionary<int, (IComponentModel, int)>? _EngineComponents = null;
|
||||||
|
@ -1,21 +0,0 @@
|
|||||||
using MotorPlantContracts.DI;
|
|
||||||
using MotorPlantContracts.StoragesContracts;
|
|
||||||
using MotorPlantFileImplement.Implements;
|
|
||||||
|
|
||||||
namespace MotorPlantFileImplement
|
|
||||||
{
|
|
||||||
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<IEngineStorage, EngineStorage>();
|
|
||||||
DependencyManager.Instance.RegisterType<IBackUpInfo, BackUpInfo>();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -4,25 +4,18 @@ using MotorPlantDataModels;
|
|||||||
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 MotorPlantFileImplement.Models
|
namespace MotorPlantFileImplement.Models
|
||||||
{
|
{
|
||||||
[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; set; } = string.Empty;
|
public string Password { get; set; } = string.Empty;
|
||||||
[DataMember]
|
|
||||||
public int Qualification { get; set; } = 0;
|
public int Qualification { get; set; } = 0;
|
||||||
[DataMember]
|
|
||||||
public int WorkExperience { get; set; } = 0;
|
public int WorkExperience { get; set; } = 0;
|
||||||
public static Implementer? Create(ImplementerBindingModel model)
|
public static Implementer? Create(ImplementerBindingModel model)
|
||||||
{
|
{
|
||||||
|
@ -4,29 +4,19 @@ using MotorPlantDataModels.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 MotorPlantFileImplement.Models
|
namespace MotorPlantFileImplement.Models
|
||||||
{
|
{
|
||||||
[DataContract]
|
|
||||||
public class MessageInfo : IMessageInfoModel
|
public class MessageInfo : IMessageInfoModel
|
||||||
{
|
{
|
||||||
[DataMember]
|
|
||||||
public int Id { get; private set; }
|
|
||||||
[DataMember]
|
|
||||||
public string MessageId { get; private set; } = string.Empty;
|
public string MessageId { get; private set; } = string.Empty;
|
||||||
[DataMember]
|
|
||||||
public int? ClientId { get; private set; }
|
public int? ClientId { get; private set; }
|
||||||
[DataMember]
|
|
||||||
public string SenderName { get; private set; } = string.Empty;
|
public string SenderName { get; private set; } = string.Empty;
|
||||||
[DataMember]
|
|
||||||
public DateTime DateDelivery { get; private set; } = DateTime.Now;
|
public DateTime DateDelivery { get; private set; } = DateTime.Now;
|
||||||
[DataMember]
|
|
||||||
public string Subject { get; private set; } = string.Empty;
|
public string Subject { get; private set; } = string.Empty;
|
||||||
[DataMember]
|
|
||||||
public string Body { get; private set; } = string.Empty;
|
public string Body { get; private set; } = string.Empty;
|
||||||
public static MessageInfo? Create(MessageInfoBindingModel model)
|
public static MessageInfo? Create(MessageInfoBindingModel model)
|
||||||
{
|
{
|
||||||
|
@ -11,8 +11,4 @@
|
|||||||
<ProjectReference Include="..\MotorPlantDataModels\MotorPlantDataModels.csproj" />
|
<ProjectReference Include="..\MotorPlantDataModels\MotorPlantDataModels.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
|
|
||||||
<Exec Command="copy /Y "$(TargetDir)*.dll" "$(SolutionDir)ImplementationExtensions\*.dll"" />
|
|
||||||
</Target>
|
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
@ -2,31 +2,20 @@
|
|||||||
using MotorPlantContracts.ViewModels;
|
using MotorPlantContracts.ViewModels;
|
||||||
using MotorPlantDataModels.Enums;
|
using MotorPlantDataModels.Enums;
|
||||||
using MotorPlantDataModels.Models;
|
using MotorPlantDataModels.Models;
|
||||||
using System.Runtime.Serialization;
|
|
||||||
using System.Xml.Linq;
|
using System.Xml.Linq;
|
||||||
|
|
||||||
namespace MotorPlantFileImplement.Models
|
namespace MotorPlantFileImplement.Models
|
||||||
{
|
{
|
||||||
[DataContract]
|
|
||||||
public class Order : IOrderModel
|
public class Order : IOrderModel
|
||||||
{
|
{
|
||||||
[DataMember]
|
|
||||||
public int EngineId { get; private set; }
|
public int EngineId { get; private set; }
|
||||||
[DataMember]
|
|
||||||
public int ClientId { get; private set; }
|
public int ClientId { get; private set; }
|
||||||
[DataMember]
|
|
||||||
public int? ImplementerId { get; private set; } = null;
|
public int? ImplementerId { get; private set; } = null;
|
||||||
[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; }
|
||||||
[DataMember]
|
|
||||||
public int Id { get; private set; }
|
public int Id { get; private set; }
|
||||||
public static Order? Create(OrderBindingModel? model)
|
public static Order? Create(OrderBindingModel? model)
|
||||||
{
|
{
|
||||||
|
@ -1,21 +0,0 @@
|
|||||||
using MotorPlantContracts.StoragesContracts;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace MotorPlantListImplement.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();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,21 +0,0 @@
|
|||||||
using MotorPlantContracts.DI;
|
|
||||||
using MotorPlantContracts.StoragesContracts;
|
|
||||||
using MotorPlantListImplement.Implements;
|
|
||||||
|
|
||||||
namespace MotorPlantListImplement
|
|
||||||
{
|
|
||||||
internal 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<IEngineStorage, EngineStorage>();
|
|
||||||
DependencyManager.Instance.RegisterType<IBackUpInfo, BackUpInfo>();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -17,7 +17,6 @@ namespace MotorPlantListImplement.Models
|
|||||||
public DateTime DateDelivery { get; private set; } = DateTime.Now;
|
public DateTime DateDelivery { get; private set; } = DateTime.Now;
|
||||||
public string Subject { get; private set; } = string.Empty;
|
public string Subject { get; private set; } = string.Empty;
|
||||||
public string Body { get; private set; } = string.Empty;
|
public string Body { get; private set; } = string.Empty;
|
||||||
public int Id => throw new NotImplementedException();
|
|
||||||
public static MessageInfo? Create(MessageInfoBindingModel model)
|
public static MessageInfo? Create(MessageInfoBindingModel model)
|
||||||
{
|
{
|
||||||
if (model == null)
|
if (model == null)
|
||||||
|
@ -11,8 +11,4 @@
|
|||||||
<ProjectReference Include="..\MotorPlantDataModels\MotorPlantDataModels.csproj" />
|
<ProjectReference Include="..\MotorPlantDataModels\MotorPlantDataModels.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
|
|
||||||
<Exec Command="copy /Y "$(TargetDir)*.dll" "$(SolutionDir)ImplementationExtensions\*.dll"" />
|
|
||||||
</Target>
|
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
@ -1,51 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using MotorPlantContracts.Attributes;
|
|
||||||
|
|
||||||
namespace MotorPlantView.Forms
|
|
||||||
{
|
|
||||||
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,7 +27,18 @@ namespace MotorPlantView.Forms
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
DataGridView.FillAndConfigGrid(_logic.ReadList(null));
|
var list = _logic.ReadList(null);
|
||||||
|
if (list != null)
|
||||||
|
{
|
||||||
|
DataGridView.DataSource = list;
|
||||||
|
DataGridView.Columns["Id"].Visible = false;
|
||||||
|
DataGridView.Columns["ClientFIO"].AutoSizeMode =
|
||||||
|
DataGridViewAutoSizeColumnMode.Fill;
|
||||||
|
DataGridView.Columns["Email"].AutoSizeMode =
|
||||||
|
DataGridViewAutoSizeColumnMode.Fill;
|
||||||
|
DataGridView.Columns["Password"].AutoSizeMode =
|
||||||
|
DataGridViewAutoSizeColumnMode.Fill;
|
||||||
|
}
|
||||||
_logger.LogInformation("Загрузка клиентов");
|
_logger.LogInformation("Загрузка клиентов");
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using MotorPlantContracts.BindingModels;
|
using MotorPlantContracts.BindingModels;
|
||||||
using MotorPlantContracts.BusinessLogicsContracts;
|
using MotorPlantContracts.BusinessLogicsContracts;
|
||||||
using MotorPlantContracts.DI;
|
|
||||||
|
|
||||||
namespace MotorPlantView.Forms
|
namespace MotorPlantView.Forms
|
||||||
{
|
{
|
||||||
@ -43,19 +42,23 @@ namespace MotorPlantView.Forms
|
|||||||
|
|
||||||
private void buttonAdd_Click(object sender, EventArgs e)
|
private void buttonAdd_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
var form = DependencyManager.Instance.Resolve<FormComponent>();
|
var service = Program.ServiceProvider?.GetService(typeof(FormComponent));
|
||||||
|
if (service is FormComponent form)
|
||||||
|
{
|
||||||
if (form.ShowDialog() == DialogResult.OK)
|
if (form.ShowDialog() == DialogResult.OK)
|
||||||
{
|
{
|
||||||
LoadData();
|
LoadData();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void buttonUpd_Click(object sender, EventArgs e)
|
private void buttonUpd_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
if (dataGridView.SelectedRows.Count == 1)
|
if (dataGridView.SelectedRows.Count == 1)
|
||||||
{
|
{
|
||||||
var form = DependencyManager.Instance.Resolve<FormComponent>();
|
var service = Program.ServiceProvider?.GetService(typeof(FormComponent));
|
||||||
|
if (service is FormComponent form)
|
||||||
|
{
|
||||||
form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||||
if (form.ShowDialog() == DialogResult.OK)
|
if (form.ShowDialog() == DialogResult.OK)
|
||||||
{
|
{
|
||||||
@ -63,6 +66,7 @@ namespace MotorPlantView.Forms
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void buttonDel_Click(object sender, EventArgs e)
|
private void buttonDel_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
|
@ -3,8 +3,6 @@ using MotorPlantDataModels.Models;
|
|||||||
using MotorPlantContracts.BusinessLogicsContracts;
|
using MotorPlantContracts.BusinessLogicsContracts;
|
||||||
using MotorPlantContracts.SearchModels;
|
using MotorPlantContracts.SearchModels;
|
||||||
using MotorPlantContracts.BindingModels;
|
using MotorPlantContracts.BindingModels;
|
||||||
using MotorPlantContracts.DI;
|
|
||||||
using MotorPlantDatabaseImplement.Models;
|
|
||||||
|
|
||||||
namespace MotorPlantView.Forms
|
namespace MotorPlantView.Forms
|
||||||
{
|
{
|
||||||
@ -13,14 +11,14 @@ namespace MotorPlantView.Forms
|
|||||||
private readonly ILogger _logger;
|
private readonly ILogger _logger;
|
||||||
private readonly IEngineLogic _logic;
|
private readonly IEngineLogic _logic;
|
||||||
private int? _id;
|
private int? _id;
|
||||||
private Dictionary<int, (IComponentModel, int)> _engineComponents;
|
private Dictionary<int, (IComponentModel, int)> _productComponents;
|
||||||
public int Id { set { _id = value; } }
|
public int Id { set { _id = value; } }
|
||||||
public FormEngine(ILogger<FormEngine> logger, IEngineLogic logic)
|
public FormEngine(ILogger<FormEngine> logger, IEngineLogic logic)
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
_logic = logic;
|
_logic = logic;
|
||||||
_engineComponents = new Dictionary<int, (IComponentModel, int)>();
|
_productComponents = new Dictionary<int, (IComponentModel, int)>();
|
||||||
}
|
}
|
||||||
private void FormEngine_Load(object sender, EventArgs e)
|
private void FormEngine_Load(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
@ -37,7 +35,7 @@ namespace MotorPlantView.Forms
|
|||||||
{
|
{
|
||||||
textBoxName.Text = view.EngineName;
|
textBoxName.Text = view.EngineName;
|
||||||
textBoxPrice.Text = view.Price.ToString();
|
textBoxPrice.Text = view.Price.ToString();
|
||||||
_engineComponents = view.EngineComponents ?? new Dictionary<int, (IComponentModel, int)>();
|
_productComponents = view.EngineComponents ?? new Dictionary<int, (IComponentModel, int)>();
|
||||||
LoadData();
|
LoadData();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -52,10 +50,10 @@ namespace MotorPlantView.Forms
|
|||||||
_logger.LogInformation("Загрузка компонент изделия");
|
_logger.LogInformation("Загрузка компонент изделия");
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (_engineComponents != null)
|
if (_productComponents != null)
|
||||||
{
|
{
|
||||||
dataGridView.Rows.Clear();
|
dataGridView.Rows.Clear();
|
||||||
foreach (var pc in _engineComponents)
|
foreach (var pc in _productComponents)
|
||||||
{
|
{
|
||||||
dataGridView.Rows.Add(new object[] { pc.Key, pc.Value.Item1.ComponentName, pc.Value.Item2 });
|
dataGridView.Rows.Add(new object[] { pc.Key, pc.Value.Item1.ComponentName, pc.Value.Item2 });
|
||||||
}
|
}
|
||||||
@ -69,44 +67,51 @@ namespace MotorPlantView.Forms
|
|||||||
}
|
}
|
||||||
private void buttonAdd_Click(object sender, EventArgs e)
|
private void buttonAdd_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
var form = DependencyManager.Instance.Resolve<FormEngineComponent>();
|
var service = Program.ServiceProvider?.GetService(typeof(FormEngineComponent));
|
||||||
if (form.ShowDialog() == DialogResult.OK)
|
if (service is FormEngineComponent form)
|
||||||
{
|
{
|
||||||
return;
|
|
||||||
}
|
|
||||||
_logger.LogInformation("Добавление нового ингридиента:{ ComponentName}-{ Count}", form.ComponentModel.ComponentName, form.Count);
|
|
||||||
if (_engineComponents.ContainsKey(form.Id))
|
|
||||||
{
|
|
||||||
_engineComponents[form.Id] = (form.ComponentModel,
|
|
||||||
form.Count);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
_engineComponents.Add(form.Id, (form.ComponentModel,
|
|
||||||
form.Count));
|
|
||||||
}
|
|
||||||
LoadData();
|
|
||||||
}
|
|
||||||
private void buttonUpd_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
if (dataGridView.SelectedRows.Count == 1)
|
|
||||||
{
|
|
||||||
var form = DependencyManager.Instance.Resolve<FormEngineComponent>();
|
|
||||||
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells[0].Value);
|
|
||||||
form.Id = id;
|
|
||||||
form.Count = _engineComponents[id].Item2;
|
|
||||||
if (form.ShowDialog() == DialogResult.OK)
|
if (form.ShowDialog() == DialogResult.OK)
|
||||||
{
|
{
|
||||||
if (form.ComponentModel == null)
|
if (form.ComponentModel == null)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
_logger.LogInformation("Изменение ингридиента:{ ComponentName}-{ Count}", form.ComponentModel.ComponentName, form.Count);
|
_logger.LogInformation("Добавление нового компонента: { ComponentName} - { Count} ", form.ComponentModel.ComponentName, form.Count);
|
||||||
_engineComponents[form.Id] = (form.ComponentModel, form.Count);
|
if (_productComponents.ContainsKey(form.Id))
|
||||||
|
{
|
||||||
|
_productComponents[form.Id] = (form.ComponentModel, form.Count);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_productComponents.Add(form.Id, (form.ComponentModel, form.Count));
|
||||||
|
}
|
||||||
LoadData();
|
LoadData();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
private void buttonUpd_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (dataGridView.SelectedRows.Count == 1)
|
||||||
|
{
|
||||||
|
var service = Program.ServiceProvider?.GetService(typeof(FormEngineComponent));
|
||||||
|
if (service is FormEngineComponent form)
|
||||||
|
{
|
||||||
|
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells[0].Value);
|
||||||
|
form.Id = id;
|
||||||
|
form.Count = _productComponents[id].Item2;
|
||||||
|
if (form.ShowDialog() == DialogResult.OK)
|
||||||
|
{
|
||||||
|
if (form.ComponentModel == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
_logger.LogInformation("Изменение компонента: { ComponentName} - { Count}", form.ComponentModel.ComponentName, form.Count);
|
||||||
|
_productComponents[form.Id] = (form.ComponentModel, form.Count);
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
private void buttonDel_Click(object sender, EventArgs e)
|
private void buttonDel_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
if (dataGridView.SelectedRows.Count == 1)
|
if (dataGridView.SelectedRows.Count == 1)
|
||||||
@ -116,7 +121,7 @@ namespace MotorPlantView.Forms
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
_logger.LogInformation("Удаление компонента: { ComponentName} - { Count}", dataGridView.SelectedRows[0].Cells[1].Value);
|
_logger.LogInformation("Удаление компонента: { ComponentName} - { Count}", dataGridView.SelectedRows[0].Cells[1].Value);
|
||||||
_engineComponents?.Remove(Convert.ToInt32(dataGridView.SelectedRows[0].Cells[0].Value));
|
_productComponents?.Remove(Convert.ToInt32(dataGridView.SelectedRows[0].Cells[0].Value));
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
@ -142,7 +147,7 @@ namespace MotorPlantView.Forms
|
|||||||
MessageBox.Show("Заполните цену", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
MessageBox.Show("Заполните цену", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (_engineComponents == null || _engineComponents.Count == 0)
|
if (_productComponents == null || _productComponents.Count == 0)
|
||||||
{
|
{
|
||||||
MessageBox.Show("Заполните компоненты", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
MessageBox.Show("Заполните компоненты", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
return;
|
return;
|
||||||
@ -155,7 +160,7 @@ namespace MotorPlantView.Forms
|
|||||||
Id = _id ?? 0,
|
Id = _id ?? 0,
|
||||||
EngineName = textBoxName.Text,
|
EngineName = textBoxName.Text,
|
||||||
Price = Convert.ToDouble(textBoxPrice.Text),
|
Price = Convert.ToDouble(textBoxPrice.Text),
|
||||||
EngineComponents = _engineComponents
|
EngineComponents = _productComponents
|
||||||
};
|
};
|
||||||
var operationResult = _id.HasValue ? _logic.Update(model) : _logic.Create(model);
|
var operationResult = _id.HasValue ? _logic.Update(model) : _logic.Create(model);
|
||||||
if (!operationResult)
|
if (!operationResult)
|
||||||
@ -181,7 +186,7 @@ namespace MotorPlantView.Forms
|
|||||||
private double CalcPrice()
|
private double CalcPrice()
|
||||||
{
|
{
|
||||||
double price = 0;
|
double price = 0;
|
||||||
foreach (var elem in _engineComponents)
|
foreach (var elem in _productComponents)
|
||||||
{
|
{
|
||||||
price += ((elem.Value.Item1?.Cost ?? 0) * elem.Value.Item2);
|
price += ((elem.Value.Item1?.Cost ?? 0) * elem.Value.Item2);
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using MotorPlantContracts.BindingModels;
|
using MotorPlantContracts.BindingModels;
|
||||||
using MotorPlantContracts.BusinessLogicsContracts;
|
using MotorPlantContracts.BusinessLogicsContracts;
|
||||||
using MotorPlantContracts.DI;
|
|
||||||
|
|
||||||
namespace MotorPlantView.Forms
|
namespace MotorPlantView.Forms
|
||||||
{
|
{
|
||||||
@ -25,7 +24,14 @@ namespace MotorPlantView.Forms
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
dataGridView.FillAndConfigGrid(_logic.ReadList(null));
|
var list = _logic.ReadList(null);
|
||||||
|
if (list != null)
|
||||||
|
{
|
||||||
|
dataGridView.DataSource = list;
|
||||||
|
dataGridView.Columns["Id"].Visible = false;
|
||||||
|
dataGridView.Columns["EngineComponents"].Visible = false;
|
||||||
|
dataGridView.Columns["EngineName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||||
|
}
|
||||||
_logger.LogInformation("Загрузка компонентов");
|
_logger.LogInformation("Загрузка компонентов");
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
@ -36,18 +42,23 @@ namespace MotorPlantView.Forms
|
|||||||
|
|
||||||
private void buttonAdd_Click(object sender, EventArgs e)
|
private void buttonAdd_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
var form = DependencyManager.Instance.Resolve<FormEngine>();
|
var service = Program.ServiceProvider?.GetService(typeof(FormEngine));
|
||||||
|
if (service is FormEngine form)
|
||||||
|
{
|
||||||
if (form.ShowDialog() == DialogResult.OK)
|
if (form.ShowDialog() == DialogResult.OK)
|
||||||
{
|
{
|
||||||
LoadData();
|
LoadData();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void buttonUpd_Click(object sender, EventArgs e)
|
private void buttonUpd_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
if (dataGridView.SelectedRows.Count == 1)
|
if (dataGridView.SelectedRows.Count == 1)
|
||||||
{
|
{
|
||||||
var form = DependencyManager.Instance.Resolve<FormEngine>();
|
var service = Program.ServiceProvider?.GetService(typeof(FormEngine));
|
||||||
|
if (service is FormEngine form)
|
||||||
|
{
|
||||||
form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||||
if (form.ShowDialog() == DialogResult.OK)
|
if (form.ShowDialog() == DialogResult.OK)
|
||||||
{
|
{
|
||||||
@ -55,6 +66,7 @@ namespace MotorPlantView.Forms
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void buttonDel_Click(object sender, EventArgs e)
|
private void buttonDel_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
|
19
MotorPlant/MotorPlantView/FormMain.Designer.cs
generated
19
MotorPlant/MotorPlantView/FormMain.Designer.cs
generated
@ -45,7 +45,6 @@
|
|||||||
buttonOrderReady = new Button();
|
buttonOrderReady = new Button();
|
||||||
buttonIssuedOrder = new Button();
|
buttonIssuedOrder = new Button();
|
||||||
buttonRef = new Button();
|
buttonRef = new Button();
|
||||||
создатьБекапToolStripMenuItem = new ToolStripMenuItem();
|
|
||||||
dataGridView = new DataGridView();
|
dataGridView = new DataGridView();
|
||||||
toolStrip1.SuspendLayout();
|
toolStrip1.SuspendLayout();
|
||||||
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
|
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
|
||||||
@ -54,7 +53,7 @@
|
|||||||
// toolStrip1
|
// toolStrip1
|
||||||
//
|
//
|
||||||
toolStrip1.ImageScalingSize = new Size(20, 20);
|
toolStrip1.ImageScalingSize = new Size(20, 20);
|
||||||
toolStrip1.Items.AddRange(new ToolStripItem[] { toolStripDropDownButton1, ReportsToolStripMenuItem, запускРаботToolStripMenuItem, почтаToolStripMenuItem, создатьБекапToolStripMenuItem });
|
toolStrip1.Items.AddRange(new ToolStripItem[] { toolStripDropDownButton1, ReportsToolStripMenuItem, запускРаботToolStripMenuItem, почтаToolStripMenuItem });
|
||||||
toolStrip1.Location = new Point(0, 0);
|
toolStrip1.Location = new Point(0, 0);
|
||||||
toolStrip1.Name = "toolStrip1";
|
toolStrip1.Name = "toolStrip1";
|
||||||
toolStrip1.Size = new Size(969, 25);
|
toolStrip1.Size = new Size(969, 25);
|
||||||
@ -73,14 +72,14 @@
|
|||||||
// КомпонентыToolStripMenuItem
|
// КомпонентыToolStripMenuItem
|
||||||
//
|
//
|
||||||
КомпонентыToolStripMenuItem.Name = "КомпонентыToolStripMenuItem";
|
КомпонентыToolStripMenuItem.Name = "КомпонентыToolStripMenuItem";
|
||||||
КомпонентыToolStripMenuItem.Size = new Size(174, 22);
|
КомпонентыToolStripMenuItem.Size = new Size(180, 22);
|
||||||
КомпонентыToolStripMenuItem.Text = "Компоненты";
|
КомпонентыToolStripMenuItem.Text = "Компоненты";
|
||||||
КомпонентыToolStripMenuItem.Click += КомпонентыToolStripMenuItem_Click;
|
КомпонентыToolStripMenuItem.Click += КомпонентыToolStripMenuItem_Click;
|
||||||
//
|
//
|
||||||
// ДвигателиToolStripMenuItem
|
// ДвигателиToolStripMenuItem
|
||||||
//
|
//
|
||||||
ДвигателиToolStripMenuItem.Name = "ДвигателиToolStripMenuItem";
|
ДвигателиToolStripMenuItem.Name = "ДвигателиToolStripMenuItem";
|
||||||
ДвигателиToolStripMenuItem.Size = new Size(174, 22);
|
ДвигателиToolStripMenuItem.Size = new Size(180, 22);
|
||||||
ДвигателиToolStripMenuItem.Text = "Двигатели";
|
ДвигателиToolStripMenuItem.Text = "Двигатели";
|
||||||
ДвигателиToolStripMenuItem.Click += ИзделияToolStripMenuItem_Click;
|
ДвигателиToolStripMenuItem.Click += ИзделияToolStripMenuItem_Click;
|
||||||
//
|
//
|
||||||
@ -184,14 +183,14 @@
|
|||||||
// клиентыToolStripMenuItem
|
// клиентыToolStripMenuItem
|
||||||
//
|
//
|
||||||
клиентыToolStripMenuItem.Name = "клиентыToolStripMenuItem";
|
клиентыToolStripMenuItem.Name = "клиентыToolStripMenuItem";
|
||||||
клиентыToolStripMenuItem.Size = new Size(174, 22);
|
клиентыToolStripMenuItem.Size = new Size(180, 22);
|
||||||
клиентыToolStripMenuItem.Text = "Клиенты";
|
клиентыToolStripMenuItem.Text = "Клиенты";
|
||||||
клиентыToolStripMenuItem.Click += клиентыToolStripMenuItem_Click;
|
клиентыToolStripMenuItem.Click += клиентыToolStripMenuItem_Click;
|
||||||
//
|
//
|
||||||
// исполнителиToolStripMenuItem
|
// исполнителиToolStripMenuItem
|
||||||
//
|
//
|
||||||
исполнителиToolStripMenuItem.Name = "исполнителиToolStripMenuItem";
|
исполнителиToolStripMenuItem.Name = "исполнителиToolStripMenuItem";
|
||||||
исполнителиToolStripMenuItem.Size = new Size(174, 22);
|
исполнителиToolStripMenuItem.Size = new Size(180, 22);
|
||||||
исполнителиToolStripMenuItem.Text = "Исполнители";
|
исполнителиToolStripMenuItem.Text = "Исполнители";
|
||||||
исполнителиToolStripMenuItem.Click += исполнителиToolStripMenuItem_Click;
|
исполнителиToolStripMenuItem.Click += исполнителиToolStripMenuItem_Click;
|
||||||
//
|
//
|
||||||
@ -202,13 +201,6 @@
|
|||||||
почтаToolStripMenuItem.Text = "Почта";
|
почтаToolStripMenuItem.Text = "Почта";
|
||||||
почтаToolStripMenuItem.Click += почтаToolStripMenuItem_Click;
|
почтаToolStripMenuItem.Click += почтаToolStripMenuItem_Click;
|
||||||
//
|
//
|
||||||
// создатьБекапToolStripMenuItem
|
|
||||||
//
|
|
||||||
создатьБекапToolStripMenuItem.Name = "создатьБекапToolStripMenuItem";
|
|
||||||
создатьБекапToolStripMenuItem.Size = new Size(97, 25);
|
|
||||||
создатьБекапToolStripMenuItem.Text = "Создать Бекап";
|
|
||||||
создатьБекапToolStripMenuItem.Click += createBackUpToolStripMenuItem_Click;
|
|
||||||
//
|
|
||||||
// FormMain
|
// FormMain
|
||||||
//
|
//
|
||||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||||
@ -251,6 +243,5 @@
|
|||||||
private ToolStripMenuItem запускРаботToolStripMenuItem;
|
private ToolStripMenuItem запускРаботToolStripMenuItem;
|
||||||
private ToolStripMenuItem исполнителиToolStripMenuItem;
|
private ToolStripMenuItem исполнителиToolStripMenuItem;
|
||||||
private ToolStripMenuItem почтаToolStripMenuItem;
|
private ToolStripMenuItem почтаToolStripMenuItem;
|
||||||
private ToolStripMenuItem создатьБекапToolStripMenuItem;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -2,8 +2,6 @@
|
|||||||
using MotorPlantContracts.BindingModels;
|
using MotorPlantContracts.BindingModels;
|
||||||
using MotorPlantContracts.BusinessLogicsContracts;
|
using MotorPlantContracts.BusinessLogicsContracts;
|
||||||
using MotorPlantBusinessLogic;
|
using MotorPlantBusinessLogic;
|
||||||
using MotorPlantContracts.DI;
|
|
||||||
using System.Windows.Forms;
|
|
||||||
|
|
||||||
namespace MotorPlantView.Forms
|
namespace MotorPlantView.Forms
|
||||||
{
|
{
|
||||||
@ -13,16 +11,13 @@ namespace MotorPlantView.Forms
|
|||||||
private readonly IOrderLogic _orderLogic;
|
private readonly IOrderLogic _orderLogic;
|
||||||
private readonly IReportLogic _reportLogic;
|
private readonly IReportLogic _reportLogic;
|
||||||
private readonly IWorkProcess _workProcess;
|
private readonly IWorkProcess _workProcess;
|
||||||
private readonly IBackUpLogic _backUpLogic;
|
public FormMain(ILogger<FormMain> logger, 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;
|
|
||||||
}
|
}
|
||||||
private void FormMain_Load(object sender, EventArgs e)
|
private void FormMain_Load(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
@ -30,33 +25,53 @@ namespace MotorPlantView.Forms
|
|||||||
}
|
}
|
||||||
private void LoadData()
|
private void LoadData()
|
||||||
{
|
{
|
||||||
|
_logger.LogInformation("Загрузка заказов");
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
dataGridView.FillAndConfigGrid(_orderLogic.ReadList(null));
|
var list = _orderLogic.ReadList(null);
|
||||||
|
|
||||||
|
if (list != null)
|
||||||
|
{
|
||||||
|
dataGridView.DataSource = list;
|
||||||
|
dataGridView.Columns["EngineId"].Visible = false;
|
||||||
|
dataGridView.Columns["ClientId"].Visible = false;
|
||||||
|
dataGridView.Columns["ImplementerId"].Visible = false;
|
||||||
|
dataGridView.Columns["EngineName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||||
|
}
|
||||||
|
|
||||||
_logger.LogInformation("Загрузка заказов");
|
_logger.LogInformation("Загрузка заказов");
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
_logger.LogError(ex, "Ошибка загрузки заказов");
|
_logger.LogError(ex, "Ошибка загрузки заказов");
|
||||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private void КомпонентыToolStripMenuItem_Click(object sender, EventArgs e)
|
private void КомпонентыToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
var form = DependencyManager.Instance.Resolve<FormComponents>();
|
var service = Program.ServiceProvider?.GetService(typeof(FormComponents));
|
||||||
|
if (service is FormComponents form)
|
||||||
|
{
|
||||||
form.ShowDialog();
|
form.ShowDialog();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
private void ИзделияToolStripMenuItem_Click(object sender, EventArgs e)
|
private void ИзделияToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
var form = DependencyManager.Instance.Resolve<FormEngines>();
|
var service = Program.ServiceProvider?.GetService(typeof(FormEngines));
|
||||||
|
|
||||||
|
if (service is FormEngines form)
|
||||||
|
{
|
||||||
form.ShowDialog();
|
form.ShowDialog();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
private void buttonCreateOrder_Click(object sender, EventArgs e)
|
private void buttonCreateOrder_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
var form = DependencyManager.Instance.Resolve<FormCreateOrder>();
|
var service = Program.ServiceProvider?.GetService(typeof(FormCreateOrder));
|
||||||
|
if (service is FormCreateOrder form)
|
||||||
|
{
|
||||||
form.ShowDialog();
|
form.ShowDialog();
|
||||||
LoadData();
|
LoadData();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
private void buttonTakeOrderInWork_Click(object sender, EventArgs e)
|
private void buttonTakeOrderInWork_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
if (dataGridView.SelectedRows.Count == 1)
|
if (dataGridView.SelectedRows.Count == 1)
|
||||||
@ -139,63 +154,62 @@ namespace MotorPlantView.Forms
|
|||||||
using var dialog = new SaveFileDialog { Filter = "docx|*.docx" };
|
using var dialog = new SaveFileDialog { Filter = "docx|*.docx" };
|
||||||
if (dialog.ShowDialog() == DialogResult.OK)
|
if (dialog.ShowDialog() == DialogResult.OK)
|
||||||
{
|
{
|
||||||
_reportLogic.SaveEnginesToWordFile(new ReportBindingModel { FileName = dialog.FileName });
|
_reportLogic.SaveEnginesToWordFile(new ReportBindingModel
|
||||||
MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
{
|
||||||
|
FileName = dialog.FileName
|
||||||
|
});
|
||||||
|
MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK,
|
||||||
|
MessageBoxIcon.Information);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private void компонентыПоДвигателямToolStripMenuItem_Click(object sender, EventArgs e)
|
private void компонентыПоДвигателямToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
var form = DependencyManager.Instance.Resolve<FormReportEngineComponents>();
|
var service = Program.ServiceProvider?.GetService(typeof(FormReportEngineComponents));
|
||||||
|
if (service is FormReportEngineComponents form)
|
||||||
|
{
|
||||||
form.ShowDialog();
|
form.ShowDialog();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
private void списокЗаказовToolStripMenuItem_Click(object sender, EventArgs e)
|
private void списокЗаказовToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
var form = DependencyManager.Instance.Resolve<FormReportOrders>();
|
var service = Program.ServiceProvider?.GetService(typeof(FormReportOrders));
|
||||||
|
if (service is FormReportOrders form)
|
||||||
|
{
|
||||||
form.ShowDialog();
|
form.ShowDialog();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
private void клиентыToolStripMenuItem_Click(object sender, EventArgs e)
|
private void клиентыToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
var form = DependencyManager.Instance.Resolve<FormClients>();
|
var service = Program.ServiceProvider?.GetService(typeof(FormClients));
|
||||||
|
if (service is FormClients form)
|
||||||
|
{
|
||||||
form.ShowDialog();
|
form.ShowDialog();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
private void запускРаботToolStripMenuItem_Click(object sender, EventArgs e)
|
private void запускРаботToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
_workProcess.DoWork(DependencyManager.Instance.Resolve<IImplementerLogic>(), _orderLogic);
|
_workProcess.DoWork((Program.ServiceProvider?.GetService(typeof(IImplementerLogic
|
||||||
MessageBox.Show("Процесс обработки запущен", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
)) as IImplementerLogic)!, _orderLogic);
|
||||||
|
MessageBox.Show("Процесс обработки запущен", "Сообщение",
|
||||||
|
MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||||
}
|
}
|
||||||
private void исполнителиToolStripMenuItem_Click(object sender, EventArgs e)
|
private void исполнителиToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
var form = DependencyManager.Instance.Resolve<ImplementersForm>();
|
var service =
|
||||||
|
Program.ServiceProvider?.GetService(typeof(ImplementersForm));
|
||||||
|
if (service is ImplementersForm form)
|
||||||
|
{
|
||||||
form.ShowDialog();
|
form.ShowDialog();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
private void почтаToolStripMenuItem_Click(object sender, EventArgs e)
|
private void почтаToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
var form = DependencyManager.Instance.Resolve<FormViewMail>();
|
var service =
|
||||||
|
Program.ServiceProvider?.GetService(typeof(FormViewMail));
|
||||||
|
if (service is FormViewMail form)
|
||||||
|
{
|
||||||
form.ShowDialog();
|
form.ShowDialog();
|
||||||
}
|
}
|
||||||
private void createBackUpToolStripMenuItem_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);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -42,14 +42,14 @@
|
|||||||
dataGridView.Size = new Size(776, 426);
|
dataGridView.Size = new Size(776, 426);
|
||||||
dataGridView.TabIndex = 0;
|
dataGridView.TabIndex = 0;
|
||||||
//
|
//
|
||||||
// ViewMailForm
|
// FormViewMail
|
||||||
//
|
//
|
||||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||||
AutoScaleMode = AutoScaleMode.Font;
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
ClientSize = new Size(800, 450);
|
ClientSize = new Size(800, 450);
|
||||||
Controls.Add(dataGridView);
|
Controls.Add(dataGridView);
|
||||||
Name = "ViewMailForm";
|
Name = "FormViewMail";
|
||||||
Text = "ViewMailForm";
|
Text = "Письма";
|
||||||
Load += ViewMailForm_Load;
|
Load += ViewMailForm_Load;
|
||||||
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
|
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
|
||||||
ResumeLayout(false);
|
ResumeLayout(false);
|
||||||
|
@ -26,7 +26,14 @@ namespace MotorPlantView.Forms
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
dataGridView.FillAndConfigGrid(_logic.ReadList(null));
|
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;
|
||||||
|
}
|
||||||
_logger.LogInformation("Загрузка списка писем");
|
_logger.LogInformation("Загрузка списка писем");
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
|
@ -31,8 +31,21 @@ namespace MotorPlantView.Forms
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
dataGridView1.FillAndConfigGrid(_logic.ReadList(null));
|
var list = _logic.ReadList(null);
|
||||||
_logger.LogInformation("Загрузка исполнителей");
|
if (list != null)
|
||||||
|
{
|
||||||
|
dataGridView1.DataSource = list;
|
||||||
|
dataGridView1.Columns["Id"].Visible = false;
|
||||||
|
dataGridView1.Columns["ImplementerFIO"].AutoSizeMode =
|
||||||
|
DataGridViewAutoSizeColumnMode.Fill;
|
||||||
|
dataGridView1.Columns["Password"].AutoSizeMode =
|
||||||
|
DataGridViewAutoSizeColumnMode.Fill;
|
||||||
|
dataGridView1.Columns["Qualification"].AutoSizeMode =
|
||||||
|
DataGridViewAutoSizeColumnMode.Fill;
|
||||||
|
dataGridView1.Columns["WorkExperience"].AutoSizeMode =
|
||||||
|
DataGridViewAutoSizeColumnMode.Fill;
|
||||||
|
}
|
||||||
|
_logger.LogInformation("Загрузка компонентов");
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
@ -11,7 +11,6 @@ using MotorPlantBusinessLogic;
|
|||||||
using MotorPlantBusinessLogic.BusinessLogic;
|
using MotorPlantBusinessLogic.BusinessLogic;
|
||||||
using MotorPlantBusinessLogic.MailWorker;
|
using MotorPlantBusinessLogic.MailWorker;
|
||||||
using MotorPlantContracts.BindingModels;
|
using MotorPlantContracts.BindingModels;
|
||||||
using MotorPlantContracts.DI;
|
|
||||||
|
|
||||||
namespace MotorPlantView.Forms
|
namespace MotorPlantView.Forms
|
||||||
{
|
{
|
||||||
@ -28,66 +27,84 @@ namespace MotorPlantView.Forms
|
|||||||
// To customize application configuration such as set high DPI settings or default font,
|
// To customize application configuration such as set high DPI settings or default font,
|
||||||
// see https://aka.ms/applicationconfiguration.
|
// see https://aka.ms/applicationconfiguration.
|
||||||
ApplicationConfiguration.Initialize();
|
ApplicationConfiguration.Initialize();
|
||||||
InitDependency();
|
var services = new ServiceCollection();
|
||||||
|
ConfigureServices(services);
|
||||||
|
_serviceProvider = services.BuildServiceProvider();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var mailSender = DependencyManager.Instance.Resolve<AbstractMailWorker>();
|
var mailSender =
|
||||||
|
_serviceProvider.GetService<AbstractMailWorker>();
|
||||||
mailSender?.MailConfig(new MailConfigBindingModel
|
mailSender?.MailConfig(new MailConfigBindingModel
|
||||||
{
|
{
|
||||||
MailLogin = System.Configuration.ConfigurationManager.AppSettings["MailLogin"] ?? string.Empty,
|
MailLogin =
|
||||||
MailPassword = System.Configuration.ConfigurationManager.AppSettings["MailPassword"] ?? string.Empty,
|
System.Configuration.ConfigurationManager.AppSettings["MailLogin"] ??
|
||||||
SmtpClientHost = System.Configuration.ConfigurationManager.AppSettings["SmtpClientHost"] ?? string.Empty,
|
string.Empty,
|
||||||
SmtpClientPort = Convert.ToInt32(System.Configuration.ConfigurationManager.AppSettings["SmtpClientPort"]),
|
MailPassword =
|
||||||
PopHost = System.Configuration.ConfigurationManager.AppSettings["PopHost"] ?? string.Empty,
|
System.Configuration.ConfigurationManager.AppSettings["MailPassword"] ??
|
||||||
PopPort = Convert.ToInt32(System.Configuration.ConfigurationManager.AppSettings["PopPort"])
|
string.Empty,
|
||||||
|
SmtpClientHost =
|
||||||
|
System.Configuration.ConfigurationManager.AppSettings["SmtpClientHost"] ??
|
||||||
|
string.Empty,
|
||||||
|
SmtpClientPort =
|
||||||
|
Convert.ToInt32(System.Configuration.ConfigurationManager.AppSettings["SmtpClientPort"]),
|
||||||
|
PopHost =
|
||||||
|
System.Configuration.ConfigurationManager.AppSettings["PopHost"] ?? string.Empty,
|
||||||
|
PopPort =
|
||||||
|
Convert.ToInt32(System.Configuration.ConfigurationManager.AppSettings["PopPort"])
|
||||||
});
|
});
|
||||||
var timer = new System.Threading.Timer(new TimerCallback(MailCheck!), null, 0, 100000);
|
// ñîçäàåì òàéìåð
|
||||||
|
var timer = new System.Threading.Timer(new
|
||||||
|
TimerCallback(MailCheck!), null, 0, 100000);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
var logger = DependencyManager.Instance.Resolve<ILogger>();
|
var logger = _serviceProvider.GetService<ILogger>();
|
||||||
logger?.LogError(ex, "Mails Problem");
|
logger?.LogError(ex, "Îøèáêà ðàáîòû ñ ïî÷òîé");
|
||||||
}
|
}
|
||||||
Application.Run(DependencyManager.Instance.Resolve<FormMain>());
|
Application.Run(_serviceProvider.GetRequiredService<FormMain>());
|
||||||
}
|
}
|
||||||
private static void InitDependency()
|
private static void ConfigureServices(ServiceCollection services)
|
||||||
{
|
{
|
||||||
DependencyManager.InitDependency();
|
services.AddLogging(option =>
|
||||||
|
|
||||||
DependencyManager.Instance.AddLogging(option =>
|
|
||||||
{
|
{
|
||||||
option.SetMinimumLevel(LogLevel.Information);
|
option.SetMinimumLevel(LogLevel.Information);
|
||||||
option.AddNLog("nlog.config");
|
option.AddNLog("nlog.config");
|
||||||
});
|
});
|
||||||
DependencyManager.Instance.RegisterType<IComponentLogic, ComponentLogic>();
|
services.AddTransient<IComponentStorage, ComponentStorage>();
|
||||||
DependencyManager.Instance.RegisterType<IOrderLogic, OrderLogic>();
|
services.AddTransient<IOrderStorage, OrderStorage>();
|
||||||
DependencyManager.Instance.RegisterType<IEngineLogic, EngineLogic>();
|
services.AddTransient<IEngineStorage, EngineStorage>();
|
||||||
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>();
|
services.AddTransient<IComponentLogic, ComponentLogic>();
|
||||||
DependencyManager.Instance.RegisterType<AbstractSaveToWord, SaveToWord>();
|
services.AddTransient<IOrderLogic, OrderLogic>();
|
||||||
DependencyManager.Instance.RegisterType<AbstractSaveToPdf, SaveToPdf>();
|
services.AddTransient<IEngineLogic, EngineLogic>();
|
||||||
DependencyManager.Instance.RegisterType<AbstractMailWorker, MailKitWorker>();
|
services.AddTransient<IReportLogic, ReportLogic>();
|
||||||
|
services.AddTransient<IClientLogic, ClientLogic>();
|
||||||
|
services.AddTransient<IClientStorage, ClientStorage>();
|
||||||
|
services.AddTransient<IImplementerLogic, ImplementerLogic>();
|
||||||
|
services.AddTransient<IImplementerStorage, ImplementerStorage>();
|
||||||
|
services.AddTransient<IWorkProcess, WorkModeling>();
|
||||||
|
services.AddTransient<IMessageInfoStorage, MessageInfoStorage>();
|
||||||
|
services.AddTransient<IMessageInfoLogic, MessageInfoLogic>();
|
||||||
|
|
||||||
DependencyManager.Instance.RegisterType<FormMain>();
|
services.AddTransient<FormMain>();
|
||||||
DependencyManager.Instance.RegisterType<FormComponent>();
|
services.AddTransient<FormComponent>();
|
||||||
DependencyManager.Instance.RegisterType<FormComponents>();
|
services.AddTransient<FormComponents>();
|
||||||
DependencyManager.Instance.RegisterType<FormCreateOrder>();
|
services.AddTransient<FormCreateOrder>();
|
||||||
DependencyManager.Instance.RegisterType<FormEngine>();
|
services.AddTransient<FormEngine>();
|
||||||
DependencyManager.Instance.RegisterType<FormEngineComponent>();
|
services.AddTransient<FormEngineComponent>();
|
||||||
DependencyManager.Instance.RegisterType<FormEngines>();
|
services.AddTransient<FormEngines>();
|
||||||
DependencyManager.Instance.RegisterType<FormReportEngineComponents>();
|
services.AddTransient<FormReportEngineComponents>();
|
||||||
DependencyManager.Instance.RegisterType<FormReportOrders>();
|
services.AddTransient<FormReportOrders>();
|
||||||
DependencyManager.Instance.RegisterType<FormClients>();
|
services.AddTransient<AbstractSaveToExcel, SaveToExcel>();
|
||||||
DependencyManager.Instance.RegisterType<ImplementersForm>();
|
services.AddTransient<AbstractSaveToWord, SaveToWord>();
|
||||||
DependencyManager.Instance.RegisterType<ImplementerForm>();
|
services.AddTransient<AbstractSaveToPdf, SaveToPdf>();
|
||||||
DependencyManager.Instance.RegisterType<FormViewMail>();
|
services.AddSingleton<AbstractMailWorker, MailKitWorker>();
|
||||||
|
services.AddTransient<FormClients>();
|
||||||
|
services.AddTransient<ImplementersForm>();
|
||||||
|
services.AddTransient<ImplementerForm>();
|
||||||
|
services.AddTransient<FormViewMail>();
|
||||||
}
|
}
|
||||||
private static void MailCheck(object obj) => DependencyManager.Instance.Resolve<AbstractMailWorker>()?.MailCheck();
|
private static void MailCheck(object obj) =>
|
||||||
|
ServiceProvider?.GetService<AbstractMailWorker>()?.MailCheck();
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user