Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 0993f66878 | |||
| 8439fa0f90 | |||
| 27dcee9ac8 |
3
.gitignore
vendored
3
.gitignore
vendored
@@ -13,6 +13,8 @@
|
|||||||
|
|
||||||
# User-specific files (MonoDevelop/Xamarin Studio)
|
# User-specific files (MonoDevelop/Xamarin Studio)
|
||||||
*.userprefs
|
*.userprefs
|
||||||
|
ImplementationExtensions
|
||||||
|
BusinessLogicExtensions
|
||||||
|
|
||||||
# Mono auto generated files
|
# Mono auto generated files
|
||||||
mono_crash.*
|
mono_crash.*
|
||||||
@@ -398,3 +400,4 @@ FodyWeavers.xsd
|
|||||||
# JetBrains Rider
|
# JetBrains Rider
|
||||||
*.sln.iml
|
*.sln.iml
|
||||||
|
|
||||||
|
/CarRepairShop/ImplementationExtensions
|
||||||
|
|||||||
@@ -0,0 +1,98 @@
|
|||||||
|
using CarRepairShopContracts.BusinessLogicsContracts;
|
||||||
|
using CarRepairShopContracts.BindingModels;
|
||||||
|
using CarRepairShopContracts.StoragesContracts;
|
||||||
|
using CarRepairShopDataModels;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using System.IO.Compression;
|
||||||
|
using System.Reflection;
|
||||||
|
using System.Runtime.Serialization.Json;
|
||||||
|
|
||||||
|
namespace CarRepairShopBusinessLogic.BusinessLogics
|
||||||
|
{
|
||||||
|
public class BackUpLogic : IBackUpLogic
|
||||||
|
{
|
||||||
|
private readonly ILogger _logger;
|
||||||
|
|
||||||
|
private readonly IBackUpInfo _backUpInfo;
|
||||||
|
|
||||||
|
public BackUpLogic(ILogger<BackUpLogic> logger, IBackUpInfo backUpInfo)
|
||||||
|
{
|
||||||
|
_logger = logger;
|
||||||
|
_backUpInfo = backUpInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void CreateBackUp(BackUpSaveBindingModel model)
|
||||||
|
{
|
||||||
|
if (_backUpInfo == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_logger.LogDebug("Clear folder");
|
||||||
|
// зачистка папки и удаление старого архива
|
||||||
|
var dirInfo = new DirectoryInfo(model.FolderName);
|
||||||
|
if (dirInfo.Exists)
|
||||||
|
{
|
||||||
|
foreach (var file in dirInfo.GetFiles())
|
||||||
|
{
|
||||||
|
file.Delete();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_logger.LogDebug("Delete archive");
|
||||||
|
string fileName = $"{model.FolderName}.zip";
|
||||||
|
if (File.Exists(fileName))
|
||||||
|
{
|
||||||
|
File.Delete(fileName);
|
||||||
|
}
|
||||||
|
// берем метод для сохранения
|
||||||
|
_logger.LogDebug("Get assembly");
|
||||||
|
var typeIId = typeof(IId);
|
||||||
|
var assembly = typeIId.Assembly;
|
||||||
|
if (assembly == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException("Сборка не найдена", nameof(assembly));
|
||||||
|
}
|
||||||
|
var types = assembly.GetTypes();
|
||||||
|
var method = GetType().GetMethod("SaveToFile", BindingFlags.NonPublic | BindingFlags.Instance);
|
||||||
|
_logger.LogDebug("Find {count} types", types.Length);
|
||||||
|
foreach (var type in types)
|
||||||
|
{
|
||||||
|
if (type.IsInterface && type.GetInterface(typeIId.Name) != null)
|
||||||
|
{
|
||||||
|
var modelType = _backUpInfo.GetTypeByModelInterface(type.Name);
|
||||||
|
if (modelType == null)
|
||||||
|
{
|
||||||
|
throw new InvalidOperationException($"Не найден класс-модель для {type.Name}");
|
||||||
|
}
|
||||||
|
_logger.LogDebug("Call SaveToFile method for {name} type", type.Name);
|
||||||
|
// вызываем метод на выполнение
|
||||||
|
method?.MakeGenericMethod(modelType).Invoke(this, new object[] { model.FolderName });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_logger.LogDebug("Create zip and remove folder");
|
||||||
|
// архивируем
|
||||||
|
ZipFile.CreateFromDirectory(model.FolderName, fileName);
|
||||||
|
// удаляем папку
|
||||||
|
dirInfo.Delete(true);
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void SaveToFile<T>(string folderName) where T : class, new()
|
||||||
|
{
|
||||||
|
var records = _backUpInfo.GetList<T>();
|
||||||
|
if (records == null)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("{type} type get null list", typeof(T).Name);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var jsonFormatter = new DataContractJsonSerializer(typeof(List<T>));
|
||||||
|
using var fs = new FileStream(string.Format("{0}/{1}.json", folderName, typeof(T).Name), FileMode.OpenOrCreate);
|
||||||
|
jsonFormatter.WriteObject(fs, records);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
using System;
|
||||||
|
|
||||||
|
namespace CarRepairShopContracts.Attributes
|
||||||
|
{
|
||||||
|
[AttributeUsage(AttributeTargets.Property)]
|
||||||
|
public class ColumnAttribute : Attribute
|
||||||
|
{
|
||||||
|
public ColumnAttribute(string title = "", bool visible = true,
|
||||||
|
int width = 0, GridViewAutoSize gridViewAutoSize = GridViewAutoSize.None,
|
||||||
|
bool isUseAutoSize = false)
|
||||||
|
{
|
||||||
|
Title = title;
|
||||||
|
Visible = visible;
|
||||||
|
Width = width;
|
||||||
|
GridViewAutoSize = gridViewAutoSize;
|
||||||
|
IsUseAutoSize = isUseAutoSize;
|
||||||
|
}
|
||||||
|
public string Title { get; private set; }
|
||||||
|
|
||||||
|
public bool Visible { get; private set; }
|
||||||
|
|
||||||
|
public int Width { get; private set; }
|
||||||
|
|
||||||
|
public GridViewAutoSize GridViewAutoSize { get; private set; }
|
||||||
|
|
||||||
|
public bool IsUseAutoSize { get; private set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
namespace CarRepairShopContracts.Attributes
|
||||||
|
{
|
||||||
|
public enum GridViewAutoSize
|
||||||
|
{
|
||||||
|
NotSet = 0,
|
||||||
|
|
||||||
|
None = 1,
|
||||||
|
|
||||||
|
ColumnHeader = 2,
|
||||||
|
|
||||||
|
AllCellsExceptHeader = 4,
|
||||||
|
|
||||||
|
AllCells = 6,
|
||||||
|
|
||||||
|
DisplayedCellsExceptHeader = 8,
|
||||||
|
|
||||||
|
DisplayedCells = 10,
|
||||||
|
|
||||||
|
Fill = 16
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
namespace CarRepairShopContracts.BindingModels
|
||||||
|
{
|
||||||
|
public class BackUpSaveBindingModel
|
||||||
|
{
|
||||||
|
public string FolderName { get; set; } = string.Empty;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
using CarRepairShopContracts.BindingModels;
|
||||||
|
|
||||||
|
namespace CarRepairShopContracts.BusinessLogicsContracts
|
||||||
|
{
|
||||||
|
public interface IBackUpLogic
|
||||||
|
{
|
||||||
|
void CreateBackUp(BackUpSaveBindingModel model);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -6,6 +6,12 @@
|
|||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Microsoft.Extensions.Logging" Version="7.0.0" />
|
||||||
|
<PackageReference Include="Unity" Version="5.11.10" />
|
||||||
|
<PackageReference Include="Unity.Microsoft.Logging" Version="5.11.1" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\CarRepairShopDataModels\CarRepairShopDataModels.csproj" />
|
<ProjectReference Include="..\CarRepairShopDataModels\CarRepairShopDataModels.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|||||||
61
CarRepairShop/CarRepairShopContracts/DI/DependencyManager.cs
Normal file
61
CarRepairShop/CarRepairShopContracts/DI/DependencyManager.cs
Normal file
@@ -0,0 +1,61 @@
|
|||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
|
||||||
|
namespace CarRepairShopContracts.DI
|
||||||
|
{
|
||||||
|
public class DependencyManager
|
||||||
|
{
|
||||||
|
private readonly IDependencyContainer _dependencyManager;
|
||||||
|
|
||||||
|
private static DependencyManager? _manager;
|
||||||
|
|
||||||
|
private static readonly object _locjObject = new();
|
||||||
|
|
||||||
|
private DependencyManager()
|
||||||
|
{
|
||||||
|
_dependencyManager = new UnityDependencyContainer();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static DependencyManager Instance { get { if (_manager == null) { lock (_locjObject) { _manager = new DependencyManager(); } } return _manager; } }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Иницализация библиотек, в которых идут установки зависомстей
|
||||||
|
/// </summary>
|
||||||
|
public static void InitDependency()
|
||||||
|
{
|
||||||
|
var ext = ServiceProviderLoader.GetImplementationExtensions();
|
||||||
|
if (ext == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException("Отсутствуют компоненты для загрузки зависимостей по модулям");
|
||||||
|
}
|
||||||
|
// регистрируем зависимости
|
||||||
|
ext.RegisterServices();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Регистрация логгера
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="configure"></param>
|
||||||
|
public void AddLogging(Action<ILoggingBuilder> configure) => _dependencyManager.AddLogging(configure);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Добавление зависимости
|
||||||
|
/// </summary>
|
||||||
|
/// <typeparam name="T"></typeparam>
|
||||||
|
/// <typeparam name="U"></typeparam>
|
||||||
|
public void RegisterType<T, U>(bool isSingle = false) where U : class, T where T : class => _dependencyManager.RegisterType<T, U>(isSingle);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Добавление зависимости
|
||||||
|
/// </summary>
|
||||||
|
/// <typeparam name="T"></typeparam>
|
||||||
|
/// <typeparam name="U"></typeparam>
|
||||||
|
public void RegisterType<T>(bool isSingle = false) where T : class => _dependencyManager.RegisterType<T>(isSingle);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Получение класса со всеми зависмостями
|
||||||
|
/// </summary>
|
||||||
|
/// <typeparam name="T"></typeparam>
|
||||||
|
/// <returns></returns>
|
||||||
|
public T Resolve<T>() => _dependencyManager.Resolve<T>();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
|
||||||
|
namespace CarRepairShopContracts.DI
|
||||||
|
{
|
||||||
|
public interface IDependencyContainer
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Регистрация логгера
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="configure"></param>
|
||||||
|
void AddLogging(Action<ILoggingBuilder> configure);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Добавление зависимости
|
||||||
|
/// </summary>
|
||||||
|
/// <typeparam name="T"></typeparam>
|
||||||
|
/// <typeparam name="U"></typeparam>
|
||||||
|
/// <param name="isSingle"></param>
|
||||||
|
void RegisterType<T, U>(bool isSingle) where U : class, T where T : class;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Добавление зависимости
|
||||||
|
/// </summary>
|
||||||
|
/// <typeparam name="T"></typeparam>
|
||||||
|
/// <param name="isSingle"></param>
|
||||||
|
void RegisterType<T>(bool isSingle) where T : class;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Получение класса со всеми зависимостями
|
||||||
|
/// </summary>
|
||||||
|
/// <typeparam name="T"></typeparam>
|
||||||
|
/// <returns></returns>
|
||||||
|
T Resolve<T>();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
namespace CarRepairShopContracts.DI
|
||||||
|
{
|
||||||
|
public interface IImplementationExtension
|
||||||
|
{
|
||||||
|
public int Priority { get; }
|
||||||
|
/// <summary>
|
||||||
|
/// Регистрация сервисов
|
||||||
|
/// </summary>
|
||||||
|
public void RegisterServices();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,57 @@
|
|||||||
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
|
||||||
|
namespace CarRepairShopContracts.DI
|
||||||
|
{
|
||||||
|
public class ServiceDependencyContainer : IDependencyContainer
|
||||||
|
{
|
||||||
|
private ServiceProvider? _serviceProvider;
|
||||||
|
|
||||||
|
private readonly ServiceCollection _serviceCollection;
|
||||||
|
|
||||||
|
public ServiceDependencyContainer()
|
||||||
|
{
|
||||||
|
_serviceCollection = new ServiceCollection();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void AddLogging(Action<ILoggingBuilder> configure)
|
||||||
|
{
|
||||||
|
_serviceCollection.AddLogging(configure);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void RegisterType<T, U>(bool isSingle) where U : class, T where T : class
|
||||||
|
{
|
||||||
|
if (isSingle)
|
||||||
|
{
|
||||||
|
_serviceCollection.AddSingleton<T, U>();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_serviceCollection.AddTransient<T, U>();
|
||||||
|
}
|
||||||
|
_serviceProvider = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void RegisterType<T>(bool isSingle) where T : class
|
||||||
|
{
|
||||||
|
if (isSingle)
|
||||||
|
{
|
||||||
|
_serviceCollection.AddSingleton<T>();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_serviceCollection.AddTransient<T>();
|
||||||
|
}
|
||||||
|
_serviceProvider = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public T Resolve<T>()
|
||||||
|
{
|
||||||
|
if (_serviceProvider == null)
|
||||||
|
{
|
||||||
|
_serviceProvider = _serviceCollection.BuildServiceProvider();
|
||||||
|
}
|
||||||
|
return _serviceProvider.GetService<T>()!;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,50 @@
|
|||||||
|
using System.Reflection;
|
||||||
|
|
||||||
|
namespace CarRepairShopContracts.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";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,50 @@
|
|||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using Unity;
|
||||||
|
using Unity.Microsoft.Logging;
|
||||||
|
|
||||||
|
namespace CarRepairShopContracts.DI
|
||||||
|
{
|
||||||
|
public class UnityDependencyContainer : IDependencyContainer
|
||||||
|
{
|
||||||
|
private readonly UnityContainer _container;
|
||||||
|
|
||||||
|
public UnityDependencyContainer()
|
||||||
|
{
|
||||||
|
_container = new UnityContainer();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void AddLogging(Action<ILoggingBuilder> configure)
|
||||||
|
{
|
||||||
|
_container.AddExtension(new LoggingExtension(LoggerFactory.Create(configure)));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void RegisterType<T, U>(bool isSingle) where U : class, T where T : class
|
||||||
|
{
|
||||||
|
if (isSingle)
|
||||||
|
{
|
||||||
|
_container.RegisterSingleton<T, U>();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_container.RegisterType<T, U>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void RegisterType<T>(bool isSingle) where T : class
|
||||||
|
{
|
||||||
|
if (isSingle)
|
||||||
|
{
|
||||||
|
_container.RegisterSingleton<T>();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_container.RegisterType<T>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public T Resolve<T>()
|
||||||
|
{
|
||||||
|
return _container.Resolve<T>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
namespace CarRepairShopContracts.StoragesContracts
|
||||||
|
{
|
||||||
|
public interface IBackUpInfo
|
||||||
|
{
|
||||||
|
List<T>? GetList<T>() where T : class, new();
|
||||||
|
|
||||||
|
Type? GetTypeByModelInterface(string modelInterfaceName);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,19 +1,20 @@
|
|||||||
using CarRepairShopDataModels.Models;
|
using CarRepairShopDataModels.Models;
|
||||||
using System.ComponentModel;
|
using CarRepairShopContracts.Attributes;
|
||||||
|
|
||||||
namespace CarRepairShopContracts.ViewModels
|
namespace CarRepairShopContracts.ViewModels
|
||||||
{
|
{
|
||||||
public class ClientViewModel : IClientModel
|
public class ClientViewModel : IClientModel
|
||||||
{
|
{
|
||||||
|
[Column(visible: false)]
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
|
|
||||||
[DisplayName("Клиент")]
|
[Column(title: "Клиент", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)]
|
||||||
public string ClientFIO { get; set; } = string.Empty;
|
public string ClientFIO { get; set; } = string.Empty;
|
||||||
|
|
||||||
[DisplayName("Логин (эл. почта)")]
|
[Column(title: "Логин (эл. почта)", width: 200)]
|
||||||
public string Email { get; set; } = string.Empty;
|
public string Email { get; set; } = string.Empty;
|
||||||
|
|
||||||
[DisplayName("Пароль")]
|
[Column(title: "Пароль", width: 100)]
|
||||||
public string Password { get; set; } = string.Empty;
|
public string Password { get; set; } = string.Empty;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,22 +1,23 @@
|
|||||||
using CarRepairShopDataModels.Models;
|
using CarRepairShopDataModels.Models;
|
||||||
using System.ComponentModel;
|
using CarRepairShopContracts.Attributes;
|
||||||
|
|
||||||
namespace CarRepairShopContracts.ViewModels
|
namespace CarRepairShopContracts.ViewModels
|
||||||
{
|
{
|
||||||
public class ImplementerViewModel : IImplementerModel
|
public class ImplementerViewModel : IImplementerModel
|
||||||
{
|
{
|
||||||
|
[Column(visible: false)]
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
|
|
||||||
[DisplayName("ФИО исполнителя")]
|
[Column(title: "ФИО исполнителя", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)]
|
||||||
public string ImplementerFIO { get; set; } = string.Empty;
|
public string ImplementerFIO { get; set; } = string.Empty;
|
||||||
|
|
||||||
[DisplayName("Пароль")]
|
[Column(title: "Пароль", width: 100)]
|
||||||
public string Password { get; set; } = string.Empty;
|
public string Password { get; set; } = string.Empty;
|
||||||
|
|
||||||
[DisplayName("Стаж работы")]
|
[Column(title: "Стаж работы", width: 100)]
|
||||||
public int WorkExperience { get; set; }
|
public int WorkExperience { get; set; }
|
||||||
|
|
||||||
[DisplayName("Квалификация")]
|
[Column(title: "Квалификация", width: 100)]
|
||||||
public int Qualification { get; set; }
|
public int Qualification { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,24 +1,30 @@
|
|||||||
using CarRepairShopDataModels.Models;
|
using CarRepairShopDataModels.Models;
|
||||||
using System.ComponentModel;
|
using CarRepairShopContracts.Attributes;
|
||||||
|
|
||||||
namespace CarRepairShopContracts.ViewModels
|
namespace CarRepairShopContracts.ViewModels
|
||||||
{
|
{
|
||||||
public class MessageInfoViewModel : IMessageInfoModel
|
public class MessageInfoViewModel : IMessageInfoModel
|
||||||
{
|
{
|
||||||
|
[Column(visible: false)]
|
||||||
public string MessageId { get; set; } = string.Empty;
|
public string MessageId { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
[Column(visible: false)]
|
||||||
public int? ClientId { get; set; }
|
public int? ClientId { get; set; }
|
||||||
|
|
||||||
[DisplayName("Отправитель")]
|
[Column(title: "Отправитель", width: 150)]
|
||||||
public string SenderName { get; set; } = string.Empty;
|
public string SenderName { get; set; } = string.Empty;
|
||||||
|
|
||||||
[DisplayName("Дата отправки")]
|
[Column(title: "Дата отправки", width: 150)]
|
||||||
public DateTime DateDelivery { get; set; }
|
public DateTime DateDelivery { get; set; }
|
||||||
|
|
||||||
[DisplayName("Заголовок")]
|
[Column(title: "Заголовок", width: 150)]
|
||||||
public string Subject { get; set; } = string.Empty;
|
public string Subject { get; set; } = string.Empty;
|
||||||
|
|
||||||
[DisplayName("Текст")]
|
[Column(title: "Текст", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)]
|
||||||
public string Body { get; set; } = string.Empty;
|
public string Body { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
[Column(visible: false)]
|
||||||
|
public int Id => throw new NotImplementedException();
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,14 +1,15 @@
|
|||||||
using CarRepairShopDataModels.Models;
|
using CarRepairShopDataModels.Models;
|
||||||
using System.ComponentModel;
|
using CarRepairShopContracts.Attributes;
|
||||||
|
|
||||||
namespace CarRepairShopContracts.ViewModels
|
namespace CarRepairShopContracts.ViewModels
|
||||||
{
|
{
|
||||||
public class OilViewModel : IOilModel
|
public class OilViewModel : IOilModel
|
||||||
{
|
{
|
||||||
|
[Column(visible: false)]
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
[DisplayName("Название масла")]
|
[Column(title: "Название масла", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)]
|
||||||
public string OilName { get; set; } = string.Empty;
|
public string OilName { get; set; } = string.Empty;
|
||||||
[DisplayName("Цена")]
|
[Column(title: "Цена", width: 150)]
|
||||||
public double Cost { get; set; }
|
public double Cost { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,31 +1,34 @@
|
|||||||
using CarRepairShopDataModels.Enums;
|
using CarRepairShopDataModels.Enums;
|
||||||
using CarRepairShopDataModels.Models;
|
using CarRepairShopDataModels.Models;
|
||||||
using System.ComponentModel;
|
using CarRepairShopContracts.Attributes;
|
||||||
|
|
||||||
namespace CarRepairShopContracts.ViewModels
|
namespace CarRepairShopContracts.ViewModels
|
||||||
{
|
{
|
||||||
public class OrderViewModel : IOrderModel
|
public class OrderViewModel : IOrderModel
|
||||||
{
|
{
|
||||||
[DisplayName("Номер")]
|
[Column(title: "Номер", width: 50)]
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
|
[Column(visible: false)]
|
||||||
public int RepairId { get; set; }
|
public int RepairId { get; set; }
|
||||||
|
[Column(visible: false)]
|
||||||
public int ClientId { get; set; }
|
public int ClientId { get; set; }
|
||||||
|
[Column(visible: false)]
|
||||||
public int? ImplementerId { get; set; }
|
public int? ImplementerId { get; set; }
|
||||||
[DisplayName("Вид ремонта")]
|
[Column(title: "Вид ремонта", width: 100)]
|
||||||
public string RepairName { get; set; } = string.Empty;
|
public string RepairName { get; set; } = string.Empty;
|
||||||
[DisplayName("Клиент")]
|
[Column(title: "Клиент", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)]
|
||||||
public string ClientFIO { get; set; } = string.Empty;
|
public string ClientFIO { get; set; } = string.Empty;
|
||||||
[DisplayName("Исполнитель")]
|
[Column(title: "Исполнитель", width: 105)]
|
||||||
public string ImplementerFIO { get; set; } = string.Empty;
|
public string ImplementerFIO { get; set; } = string.Empty;
|
||||||
[DisplayName("Количество")]
|
[Column(title: "Количество", width: 100)]
|
||||||
public int Count { get; set; }
|
public int Count { get; set; }
|
||||||
[DisplayName("Сумма")]
|
[Column(title: "Сумма", width: 100)]
|
||||||
public double Sum { get; set; }
|
public double Sum { get; set; }
|
||||||
[DisplayName("Статус")]
|
[Column(title: "Статус", width: 100)]
|
||||||
public OrderStatus Status { get; set; } = OrderStatus.Неизвестен;
|
public OrderStatus Status { get; set; } = OrderStatus.Неизвестен;
|
||||||
[DisplayName("Дата создания")]
|
[Column(title: "Дата создания", width: 150)]
|
||||||
public DateTime DateCreate { get; set; } = DateTime.Now;
|
public DateTime DateCreate { get; set; } = DateTime.Now;
|
||||||
[DisplayName("Дата выполнения")]
|
[Column(title: "Дата выполнения", width: 150)]
|
||||||
public DateTime? DateImplement { get; set; }
|
public DateTime? DateImplement { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,15 +1,17 @@
|
|||||||
using CarRepairShopDataModels.Models;
|
using CarRepairShopDataModels.Models;
|
||||||
using System.ComponentModel;
|
using CarRepairShopContracts.Attributes;
|
||||||
|
|
||||||
namespace CarRepairShopContracts.ViewModels
|
namespace CarRepairShopContracts.ViewModels
|
||||||
{
|
{
|
||||||
public class RepairViewModel : IRepairModel
|
public class RepairViewModel : IRepairModel
|
||||||
{
|
{
|
||||||
|
[Column(visible: false)]
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
[DisplayName("Название услуги")]
|
[Column(title: "Название услуги", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)]
|
||||||
public string RepairName { get; set; } = string.Empty;
|
public string RepairName { get; set; } = string.Empty;
|
||||||
[DisplayName("Цена")]
|
[Column(title: "Цена", width: 150)]
|
||||||
public double Price { get; set; }
|
public double Price { get; set; }
|
||||||
|
[Column(visible: false)]
|
||||||
public Dictionary<int, (IOilModel, int)> RepairOils
|
public Dictionary<int, (IOilModel, int)> RepairOils
|
||||||
{
|
{
|
||||||
get;
|
get;
|
||||||
|
|||||||
@@ -20,4 +20,8 @@
|
|||||||
<ProjectReference Include="..\CarRepairShopDataModels\CarRepairShopDataModels.csproj" />
|
<ProjectReference Include="..\CarRepairShopDataModels\CarRepairShopDataModels.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
|
||||||
|
<Exec Command="copy /Y "$(TargetDir)*.dll" "$(SolutionDir)ImplementationExtensions\*.dll"" />
|
||||||
|
</Target>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
@@ -0,0 +1,22 @@
|
|||||||
|
using CarRepairShopContracts.DI;
|
||||||
|
using CarRepairShopContracts.StoragesContracts;
|
||||||
|
using CarRepairShopDatabaseImplement.Implements;
|
||||||
|
|
||||||
|
namespace CarRepairShopDatabaseImplement
|
||||||
|
{
|
||||||
|
public class DatabaseImplementationExtension : IImplementationExtension
|
||||||
|
{
|
||||||
|
public int Priority => 2;
|
||||||
|
|
||||||
|
public void RegisterServices()
|
||||||
|
{
|
||||||
|
DependencyManager.Instance.RegisterType<IClientStorage, ClientStorage>();
|
||||||
|
DependencyManager.Instance.RegisterType<IOilStorage, OilStorage>();
|
||||||
|
DependencyManager.Instance.RegisterType<IImplementerStorage, ImplementerStorage>();
|
||||||
|
DependencyManager.Instance.RegisterType<IMessageInfoStorage, MessageInfoStorage>();
|
||||||
|
DependencyManager.Instance.RegisterType<IOrderStorage, OrderStorage>();
|
||||||
|
DependencyManager.Instance.RegisterType<IRepairStorage, RepairStorage>();
|
||||||
|
DependencyManager.Instance.RegisterType<IBackUpInfo, BackUpInfo>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
using CarRepairShopContracts.StoragesContracts;
|
||||||
|
|
||||||
|
namespace CarRepairShopDatabaseImplement.Implements
|
||||||
|
{
|
||||||
|
public class BackUpInfo : IBackUpInfo
|
||||||
|
{
|
||||||
|
public List<T>? GetList<T>() where T : class, new()
|
||||||
|
{
|
||||||
|
using var context = new CarRepairShopDatabase();
|
||||||
|
return context.Set<T>().ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Type? GetTypeByModelInterface(string modelInterfaceName)
|
||||||
|
{
|
||||||
|
var assembly = typeof(BackUpInfo).Assembly;
|
||||||
|
var types = assembly.GetTypes();
|
||||||
|
foreach (var type in types)
|
||||||
|
{
|
||||||
|
if (type.IsClass && type.GetInterface(modelInterfaceName) != null)
|
||||||
|
{
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -3,16 +3,22 @@ using CarRepairShopContracts.ViewModels;
|
|||||||
using CarRepairShopDataModels.Models;
|
using CarRepairShopDataModels.Models;
|
||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
using System.ComponentModel.DataAnnotations.Schema;
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
using System.Runtime.Serialization;
|
||||||
|
|
||||||
namespace CarRepairShopDatabaseImplement.Models
|
namespace CarRepairShopDatabaseImplement.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;
|
||||||
|
|
||||||
|
|||||||
@@ -3,18 +3,25 @@ using CarRepairShopContracts.ViewModels;
|
|||||||
using CarRepairShopDataModels.Models;
|
using CarRepairShopDataModels.Models;
|
||||||
using System.ComponentModel.DataAnnotations.Schema;
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using System.Runtime.Serialization;
|
||||||
|
|
||||||
namespace CarRepairShopDatabaseImplement.Models
|
namespace CarRepairShopDatabaseImplement.Models
|
||||||
{
|
{
|
||||||
|
[DataContract]
|
||||||
public class Implementer : IImplementerModel
|
public class Implementer : IImplementerModel
|
||||||
{
|
{
|
||||||
|
[DataMember]
|
||||||
public int Id { get; private set; }
|
public int Id { get; private set; }
|
||||||
|
[DataMember]
|
||||||
[Required]
|
[Required]
|
||||||
public string ImplementerFIO { get; private set; } = string.Empty;
|
public string ImplementerFIO { get; private set; } = string.Empty;
|
||||||
|
[DataMember]
|
||||||
[Required]
|
[Required]
|
||||||
public string Password { get; private set; } = string.Empty;
|
public string Password { get; private set; } = string.Empty;
|
||||||
|
[DataMember]
|
||||||
[Required]
|
[Required]
|
||||||
public int WorkExperience { get; private set; }
|
public int WorkExperience { get; private set; }
|
||||||
|
[DataMember]
|
||||||
[Required]
|
[Required]
|
||||||
public int Qualification { get; private set; }
|
public int Qualification { get; private set; }
|
||||||
[ForeignKey("ImplementerId")]
|
[ForeignKey("ImplementerId")]
|
||||||
|
|||||||
@@ -2,20 +2,28 @@
|
|||||||
using CarRepairShopContracts.ViewModels;
|
using CarRepairShopContracts.ViewModels;
|
||||||
using CarRepairShopDataModels.Models;
|
using CarRepairShopDataModels.Models;
|
||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using System.Runtime.Serialization;
|
||||||
|
|
||||||
namespace CarRepairShopDatabaseImplement.Models
|
namespace CarRepairShopDatabaseImplement.Models
|
||||||
{
|
{
|
||||||
|
[DataContract]
|
||||||
public class Message : IMessageInfoModel
|
public class Message : IMessageInfoModel
|
||||||
{
|
{
|
||||||
|
[DataMember]
|
||||||
[Key]
|
[Key]
|
||||||
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]
|
[Required]
|
||||||
public string SenderName { get; private set; } = string.Empty;
|
public string SenderName { get; private set; } = string.Empty;
|
||||||
|
[DataMember]
|
||||||
[Required]
|
[Required]
|
||||||
public DateTime DateDelivery { get; private set; } = DateTime.Now;
|
public DateTime DateDelivery { get; private set; } = DateTime.Now;
|
||||||
|
[DataMember]
|
||||||
[Required]
|
[Required]
|
||||||
public string Subject { get; private set; } = string.Empty;
|
public string Subject { get; private set; } = string.Empty;
|
||||||
|
[DataMember]
|
||||||
[Required]
|
[Required]
|
||||||
public string Body { get; private set; } = string.Empty;
|
public string Body { get; private set; } = string.Empty;
|
||||||
|
|
||||||
|
|||||||
@@ -3,16 +3,19 @@ using CarRepairShopContracts.ViewModels;
|
|||||||
using CarRepairShopDataModels.Models;
|
using CarRepairShopDataModels.Models;
|
||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
using System.ComponentModel.DataAnnotations.Schema;
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
using System.Runtime.Serialization;
|
||||||
|
|
||||||
namespace CarRepairShopDatabaseImplement.Models
|
namespace CarRepairShopDatabaseImplement.Models
|
||||||
{
|
{
|
||||||
|
[DataContract]
|
||||||
public class Oil : IOilModel
|
public class Oil : IOilModel
|
||||||
{
|
{
|
||||||
|
[DataMember]
|
||||||
public int Id { get; private set; }
|
public int Id { get; private set; }
|
||||||
|
[DataMember]
|
||||||
[Required]
|
[Required]
|
||||||
public string OilName { get; private set; } = string.Empty;
|
public string OilName { get; private set; } = string.Empty;
|
||||||
|
[DataMember]
|
||||||
[Required]
|
[Required]
|
||||||
public double Cost { get; set; }
|
public double Cost { get; set; }
|
||||||
|
|
||||||
|
|||||||
@@ -3,25 +3,36 @@ using CarRepairShopContracts.ViewModels;
|
|||||||
using CarRepairShopDataModels.Enums;
|
using CarRepairShopDataModels.Enums;
|
||||||
using CarRepairShopDataModels.Models;
|
using CarRepairShopDataModels.Models;
|
||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using System.Runtime.Serialization;
|
||||||
|
|
||||||
namespace CarRepairShopDatabaseImplement.Models
|
namespace CarRepairShopDatabaseImplement.Models
|
||||||
{
|
{
|
||||||
|
[DataContract]
|
||||||
public class Order : IOrderModel
|
public class Order : IOrderModel
|
||||||
{
|
{
|
||||||
|
[DataMember]
|
||||||
[Required]
|
[Required]
|
||||||
public int RepairId { get; set; }
|
public int RepairId { get; set; }
|
||||||
|
[DataMember]
|
||||||
[Required]
|
[Required]
|
||||||
public int ClientId { get; set; }
|
public int ClientId { get; set; }
|
||||||
|
[DataMember]
|
||||||
public int? ImplementerId { get; private set; }
|
public int? ImplementerId { get; private set; }
|
||||||
|
[DataMember]
|
||||||
[Required]
|
[Required]
|
||||||
public int Count { get; set; }
|
public int Count { get; set; }
|
||||||
|
[DataMember]
|
||||||
[Required]
|
[Required]
|
||||||
public double Sum { get; set; }
|
public double Sum { get; set; }
|
||||||
|
[DataMember]
|
||||||
[Required]
|
[Required]
|
||||||
public OrderStatus Status { get; set; }
|
public OrderStatus Status { get; set; }
|
||||||
|
[DataMember]
|
||||||
[Required]
|
[Required]
|
||||||
public DateTime DateCreate { get; set; }
|
public DateTime DateCreate { get; set; }
|
||||||
|
[DataMember]
|
||||||
public DateTime? DateImplement { get; set; }
|
public DateTime? DateImplement { get; set; }
|
||||||
|
[DataMember]
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
public Repair Repair { get; set; }
|
public Repair Repair { get; set; }
|
||||||
public Client Client { get; set; }
|
public Client Client { get; set; }
|
||||||
|
|||||||
@@ -3,21 +3,24 @@ using CarRepairShopContracts.ViewModels;
|
|||||||
using CarRepairShopDataModels.Models;
|
using CarRepairShopDataModels.Models;
|
||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
using System.ComponentModel.DataAnnotations.Schema;
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
using System.Runtime.Serialization;
|
||||||
|
|
||||||
namespace CarRepairShopDatabaseImplement.Models
|
namespace CarRepairShopDatabaseImplement.Models
|
||||||
{
|
{
|
||||||
|
[DataContract]
|
||||||
public class Repair : IRepairModel
|
public class Repair : IRepairModel
|
||||||
{
|
{
|
||||||
|
[DataMember]
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
|
[DataMember]
|
||||||
[Required]
|
[Required]
|
||||||
public string RepairName { get; set; } = string.Empty;
|
public string RepairName { get; set; } = string.Empty;
|
||||||
|
[DataMember]
|
||||||
[Required]
|
[Required]
|
||||||
public double Price { get; set; }
|
public double Price { get; set; }
|
||||||
|
|
||||||
private Dictionary<int, (IOilModel, int)>? _repairOils = null;
|
private Dictionary<int, (IOilModel, int)>? _repairOils = null;
|
||||||
|
[DataMember]
|
||||||
[NotMapped]
|
[NotMapped]
|
||||||
public Dictionary<int, (IOilModel, int)> RepairOils
|
public Dictionary<int, (IOilModel, int)> RepairOils
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -11,4 +11,8 @@
|
|||||||
<ProjectReference Include="..\CarRepairShopDataModels\CarRepairShopDataModels.csproj" />
|
<ProjectReference Include="..\CarRepairShopDataModels\CarRepairShopDataModels.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
|
||||||
|
<Exec Command="copy /Y "$(TargetDir)*.dll" "$(SolutionDir)ImplementationExtensions\*.dll"" />
|
||||||
|
</Target>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
using CarRepairShopFileImplement.Models;
|
using CarRepairShopFileImplement.Models;
|
||||||
using System.ComponentModel;
|
|
||||||
using System.Xml.Linq;
|
using System.Xml.Linq;
|
||||||
|
|
||||||
namespace CarRepairShopFileImplement
|
namespace CarRepairShopFileImplement
|
||||||
|
|||||||
@@ -0,0 +1,22 @@
|
|||||||
|
using CarRepairShopContracts.DI;
|
||||||
|
using CarRepairShopContracts.StoragesContracts;
|
||||||
|
using CarRepairShopFileImplement.Implements;
|
||||||
|
|
||||||
|
namespace CarRepairShopFileImplement
|
||||||
|
{
|
||||||
|
public class FileImplementationExtension : IImplementationExtension
|
||||||
|
{
|
||||||
|
public int Priority => 1;
|
||||||
|
|
||||||
|
public void RegisterServices()
|
||||||
|
{
|
||||||
|
DependencyManager.Instance.RegisterType<IClientStorage, ClientStorage>();
|
||||||
|
DependencyManager.Instance.RegisterType<IOilStorage, OilStorage>();
|
||||||
|
DependencyManager.Instance.RegisterType<IImplementerStorage, ImplementerStorage>();
|
||||||
|
DependencyManager.Instance.RegisterType<IMessageInfoStorage, MessageInfoStorage>();
|
||||||
|
DependencyManager.Instance.RegisterType<IOrderStorage, OrderStorage>();
|
||||||
|
DependencyManager.Instance.RegisterType<IRepairStorage, RepairStorage>();
|
||||||
|
DependencyManager.Instance.RegisterType<IBackUpInfo, BackUpInfo>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
using CarRepairShopContracts.StoragesContracts;
|
||||||
|
|
||||||
|
namespace CarRepairShopFileImplement.Implements
|
||||||
|
{
|
||||||
|
public class BackUpInfo : IBackUpInfo
|
||||||
|
{
|
||||||
|
public List<T>? GetList<T>() where T : class, new()
|
||||||
|
{
|
||||||
|
var source = DataFileSingleton.GetInstance();
|
||||||
|
return (List<T>?)source.GetType().GetProperties()
|
||||||
|
.FirstOrDefault(x => x.PropertyType.IsGenericType && x.PropertyType.GetGenericArguments()[0] == typeof(T))
|
||||||
|
?.GetValue(source);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Type? GetTypeByModelInterface(string modelInterfaceName)
|
||||||
|
{
|
||||||
|
var assembly = typeof(BackUpInfo).Assembly;
|
||||||
|
var types = assembly.GetTypes();
|
||||||
|
foreach (var type in types)
|
||||||
|
{
|
||||||
|
if (type.IsClass && type.GetInterface(modelInterfaceName) != null)
|
||||||
|
{
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -21,21 +21,28 @@ namespace CarRepairShopFileImplement.Implements
|
|||||||
|
|
||||||
public List<OrderViewModel> GetFilteredList(OrderSearchModel model)
|
public List<OrderViewModel> GetFilteredList(OrderSearchModel model)
|
||||||
{
|
{
|
||||||
if (model.DateFrom.HasValue)
|
if (model.DateFrom.HasValue && model.DateTo.HasValue)
|
||||||
{
|
{
|
||||||
return source.Orders
|
return source.Orders
|
||||||
.Where(x => x.DateCreate >= model.DateFrom && x.DateCreate <= model.DateTo)
|
.Where(x => x.DateCreate >= model.DateFrom && x.DateCreate <= model.DateTo)
|
||||||
.Select(x => GetViewModel(x))
|
.Select(x => GetViewModel(x))
|
||||||
.ToList();
|
.ToList();
|
||||||
}
|
}
|
||||||
if (model.ClientId.HasValue && !model.Id.HasValue)
|
else if (model.ClientId.HasValue && !model.Id.HasValue)
|
||||||
{
|
{
|
||||||
return source.Orders
|
return source.Orders
|
||||||
.Where(x => x.ClientId == model.ClientId)
|
.Where(x => x.ClientId == model.ClientId)
|
||||||
.Select(x => x.GetViewModel)
|
.Select(x => x.GetViewModel)
|
||||||
.ToList();
|
.ToList();
|
||||||
}
|
}
|
||||||
if (model.Id.HasValue)
|
else if (model.OrderStatus.HasValue)
|
||||||
|
{
|
||||||
|
return source.Orders
|
||||||
|
.Where(x => x.Status == model.OrderStatus)
|
||||||
|
.Select(x => x.GetViewModel)
|
||||||
|
.ToList();
|
||||||
|
}
|
||||||
|
else if (model.Id.HasValue)
|
||||||
{
|
{
|
||||||
return source.Orders
|
return source.Orders
|
||||||
.Where(x => x.Id.Equals(model.Id))
|
.Where(x => x.Id.Equals(model.Id))
|
||||||
@@ -47,13 +54,24 @@ namespace CarRepairShopFileImplement.Implements
|
|||||||
|
|
||||||
public OrderViewModel? GetElement(OrderSearchModel model)
|
public OrderViewModel? GetElement(OrderSearchModel model)
|
||||||
{
|
{
|
||||||
if (!model.Id.HasValue)
|
if (model.Id.HasValue)
|
||||||
{
|
{
|
||||||
return null;
|
return source.Orders.FirstOrDefault(x => x.Id == model.Id)?.GetViewModel;
|
||||||
}
|
}
|
||||||
|
else if (model.ImplementerId.HasValue && model.OrderStatus.HasValue)
|
||||||
return source.Orders.FirstOrDefault(x =>
|
{
|
||||||
(model.Id.HasValue && x.Id == model.Id))?.GetViewModel;
|
return source.Orders
|
||||||
|
.FirstOrDefault(x => x.ImplementerId == model.ImplementerId &&
|
||||||
|
x.Status == model.OrderStatus)
|
||||||
|
?.GetViewModel;
|
||||||
|
}
|
||||||
|
else if (model.ImplementerId.HasValue)
|
||||||
|
{
|
||||||
|
return source.Orders
|
||||||
|
.FirstOrDefault(x => x.ImplementerId == model.ImplementerId)
|
||||||
|
?.GetViewModel;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private OrderViewModel GetViewModel(Order order)
|
private OrderViewModel GetViewModel(Order order)
|
||||||
@@ -63,11 +81,15 @@ namespace CarRepairShopFileImplement.Implements
|
|||||||
.Repairs.FirstOrDefault(x => x.Id == order.RepairId);
|
.Repairs.FirstOrDefault(x => x.Id == order.RepairId);
|
||||||
var client = source
|
var client = source
|
||||||
.Clients.FirstOrDefault(x => x.Id == order.ClientId);
|
.Clients.FirstOrDefault(x => x.Id == order.ClientId);
|
||||||
|
var implementer = source
|
||||||
|
.Implementers.FirstOrDefault(x => x.Id == order.ImplementerId);
|
||||||
|
|
||||||
if (repair != null)
|
if (repair != null)
|
||||||
viewModel.RepairName = repair.RepairName;
|
viewModel.RepairName = repair.RepairName;
|
||||||
if (client != null)
|
if (client != null)
|
||||||
viewModel.ClientFIO = client.ClientFIO;
|
viewModel.ClientFIO = client.ClientFIO;
|
||||||
|
if (implementer != null)
|
||||||
|
viewModel.ImplementerFIO = implementer.ImplementerFIO;
|
||||||
return viewModel;
|
return viewModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,15 +1,21 @@
|
|||||||
using CarRepairShopContracts.BindingModels;
|
using CarRepairShopContracts.BindingModels;
|
||||||
using CarRepairShopContracts.ViewModels;
|
using CarRepairShopContracts.ViewModels;
|
||||||
using CarRepairShopDataModels.Models;
|
using CarRepairShopDataModels.Models;
|
||||||
|
using System.Runtime.Serialization;
|
||||||
using System.Xml.Linq;
|
using System.Xml.Linq;
|
||||||
|
|
||||||
namespace CarRepairShopFileImplement.Models
|
namespace CarRepairShopFileImplement.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,20 +1,23 @@
|
|||||||
using CarRepairShopContracts.BindingModels;
|
using CarRepairShopContracts.BindingModels;
|
||||||
using CarRepairShopContracts.ViewModels;
|
using CarRepairShopContracts.ViewModels;
|
||||||
using CarRepairShopDataModels.Models;
|
using CarRepairShopDataModels.Models;
|
||||||
|
using System.Runtime.Serialization;
|
||||||
using System.Xml.Linq;
|
using System.Xml.Linq;
|
||||||
|
|
||||||
namespace CarRepairShopFileImplement.Models
|
namespace CarRepairShopFileImplement.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; private set; } = string.Empty;
|
public string Password { get; private set; } = string.Empty;
|
||||||
|
[DataMember]
|
||||||
public int WorkExperience { get; private set; }
|
public int WorkExperience { get; private set; }
|
||||||
|
[DataMember]
|
||||||
public int Qualification { get; private set; }
|
public int Qualification { get; private set; }
|
||||||
|
|
||||||
public static Implementer? Create(ImplementerBindingModel? model)
|
public static Implementer? Create(ImplementerBindingModel? model)
|
||||||
|
|||||||
@@ -1,22 +1,26 @@
|
|||||||
using CarRepairShopContracts.BindingModels;
|
using CarRepairShopContracts.BindingModels;
|
||||||
using CarRepairShopContracts.ViewModels;
|
using CarRepairShopContracts.ViewModels;
|
||||||
using CarRepairShopDataModels.Models;
|
using CarRepairShopDataModels.Models;
|
||||||
|
using System.Reflection;
|
||||||
|
using System.Runtime.Serialization;
|
||||||
using System.Xml.Linq;
|
using System.Xml.Linq;
|
||||||
|
|
||||||
namespace CarRepairShopFileImplement.Models
|
namespace CarRepairShopFileImplement.Models
|
||||||
{
|
{
|
||||||
internal class Message : IMessageInfoModel
|
[DataContract]
|
||||||
|
public class Message : IMessageInfoModel
|
||||||
{
|
{
|
||||||
|
[DataMember]
|
||||||
public string MessageId { get; private set; } = string.Empty;
|
public string MessageId { get; private set; } = string.Empty;
|
||||||
|
[DataMember]
|
||||||
public int? ClientId { get; private set; }
|
public int? ClientId { get; private set; }
|
||||||
|
[DataMember]
|
||||||
public string SenderName { get; private set; } = string.Empty;
|
public string SenderName { get; private set; } = string.Empty;
|
||||||
|
[DataMember]
|
||||||
public DateTime DateDelivery { get; private set; }
|
public DateTime DateDelivery { get; private set; }
|
||||||
|
[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 Message? Create(MessageInfoBindingModel model)
|
public static Message? Create(MessageInfoBindingModel model)
|
||||||
|
|||||||
@@ -1,14 +1,19 @@
|
|||||||
using CarRepairShopContracts.BindingModels;
|
using CarRepairShopContracts.BindingModels;
|
||||||
using CarRepairShopContracts.ViewModels;
|
using CarRepairShopContracts.ViewModels;
|
||||||
using CarRepairShopDataModels.Models;
|
using CarRepairShopDataModels.Models;
|
||||||
|
using System.Runtime.Serialization;
|
||||||
using System.Xml.Linq;
|
using System.Xml.Linq;
|
||||||
|
|
||||||
namespace CarRepairShopFileImplement.Models
|
namespace CarRepairShopFileImplement.Models
|
||||||
{
|
{
|
||||||
|
[DataContract]
|
||||||
public class Oil : IOilModel
|
public class Oil : IOilModel
|
||||||
{
|
{
|
||||||
|
[DataMember]
|
||||||
public int Id { get; private set; }
|
public int Id { get; private set; }
|
||||||
|
[DataMember]
|
||||||
public string OilName { get; private set; } = string.Empty;
|
public string OilName { get; private set; } = string.Empty;
|
||||||
|
[DataMember]
|
||||||
public double Cost { get; set; }
|
public double Cost { get; set; }
|
||||||
|
|
||||||
public static Oil? Create(OilBindingModel model)
|
public static Oil? Create(OilBindingModel model)
|
||||||
|
|||||||
@@ -2,19 +2,31 @@
|
|||||||
using CarRepairShopContracts.ViewModels;
|
using CarRepairShopContracts.ViewModels;
|
||||||
using CarRepairShopDataModels.Enums;
|
using CarRepairShopDataModels.Enums;
|
||||||
using CarRepairShopDataModels.Models;
|
using CarRepairShopDataModels.Models;
|
||||||
|
using System.Runtime.Serialization;
|
||||||
using System.Xml.Linq;
|
using System.Xml.Linq;
|
||||||
|
|
||||||
namespace CarRepairShopFileImplement.Models
|
namespace CarRepairShopFileImplement.Models
|
||||||
{
|
{
|
||||||
|
[DataContract]
|
||||||
public class Order : IOrderModel
|
public class Order : IOrderModel
|
||||||
{
|
{
|
||||||
|
[DataMember]
|
||||||
public int Id { get; private set; }
|
public int Id { get; private set; }
|
||||||
|
[DataMember]
|
||||||
public int RepairId { get; private set; }
|
public int RepairId { get; private set; }
|
||||||
|
[DataMember]
|
||||||
public int ClientId { get; private set; }
|
public int ClientId { get; private set; }
|
||||||
|
[DataMember]
|
||||||
|
public int? ImplementerId { get; private set; }
|
||||||
|
[DataMember]
|
||||||
public int Count { get; private set; }
|
public int Count { get; private set; }
|
||||||
|
[DataMember]
|
||||||
public double Sum { get; private set; }
|
public double Sum { get; private set; }
|
||||||
|
[DataMember]
|
||||||
public OrderStatus Status { get; private set; } = OrderStatus.Неизвестен;
|
public OrderStatus Status { get; private set; } = OrderStatus.Неизвестен;
|
||||||
|
[DataMember]
|
||||||
public DateTime DateCreate { get; private set; } = DateTime.Now;
|
public DateTime DateCreate { get; private set; } = DateTime.Now;
|
||||||
|
[DataMember]
|
||||||
public DateTime? DateImplement { get; private set; }
|
public DateTime? DateImplement { get; private set; }
|
||||||
public static Order? Create(OrderBindingModel? model)
|
public static Order? Create(OrderBindingModel? model)
|
||||||
{
|
{
|
||||||
@@ -27,6 +39,7 @@ namespace CarRepairShopFileImplement.Models
|
|||||||
Id = model.Id,
|
Id = model.Id,
|
||||||
RepairId = model.RepairId,
|
RepairId = model.RepairId,
|
||||||
ClientId = model.ClientId,
|
ClientId = model.ClientId,
|
||||||
|
ImplementerId = model.ImplementerId,
|
||||||
Count = model.Count,
|
Count = model.Count,
|
||||||
Sum = model.Sum,
|
Sum = model.Sum,
|
||||||
Status = model.Status,
|
Status = model.Status,
|
||||||
@@ -46,12 +59,13 @@ namespace CarRepairShopFileImplement.Models
|
|||||||
Id = Convert.ToInt32(element.Attribute("Id")!.Value),
|
Id = Convert.ToInt32(element.Attribute("Id")!.Value),
|
||||||
RepairId = Convert.ToInt32(element.Element("RepairId")!.Value),
|
RepairId = Convert.ToInt32(element.Element("RepairId")!.Value),
|
||||||
ClientId = Convert.ToInt32(element.Element("ClientId")!.Value),
|
ClientId = Convert.ToInt32(element.Element("ClientId")!.Value),
|
||||||
|
ImplementerId = Convert.ToInt32(element.Element("ImplementerId")!.Value),
|
||||||
Sum = Convert.ToDouble(element.Element("Sum")!.Value),
|
Sum = Convert.ToDouble(element.Element("Sum")!.Value),
|
||||||
Count = Convert.ToInt32(element.Element("Count")!.Value),
|
Count = Convert.ToInt32(element.Element("Count")!.Value),
|
||||||
Status = (OrderStatus)Enum.Parse(typeof(OrderStatus), element.Element("Status")!.Value),
|
Status = (OrderStatus)Enum.Parse(typeof(OrderStatus), element.Element("Status")!.Value),
|
||||||
DateCreate = Convert.ToDateTime(element.Element("DateCreate")!.Value),
|
DateCreate = Convert.ToDateTime(element.Element("DateCreate")!.Value),
|
||||||
DateImplement = string.IsNullOrEmpty(element.Element("DateImplement")!.Value) ?
|
DateImplement = string.IsNullOrEmpty(element.Element("DateImplement")!.Value)
|
||||||
null : Convert.ToDateTime(element.Element("DateImplement")!.Value)
|
? null : Convert.ToDateTime(element.Element("DateImplement")!.Value)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -63,12 +77,15 @@ namespace CarRepairShopFileImplement.Models
|
|||||||
}
|
}
|
||||||
Status = model.Status;
|
Status = model.Status;
|
||||||
DateImplement = model.DateImplement;
|
DateImplement = model.DateImplement;
|
||||||
|
if (model.ImplementerId.HasValue)
|
||||||
|
ImplementerId = model.ImplementerId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public OrderViewModel GetViewModel => new()
|
public OrderViewModel GetViewModel => new()
|
||||||
{
|
{
|
||||||
RepairId = RepairId,
|
RepairId = RepairId,
|
||||||
ClientId = ClientId,
|
ClientId = ClientId,
|
||||||
|
ImplementerId = ImplementerId,
|
||||||
Count = Count,
|
Count = Count,
|
||||||
Sum = Sum,
|
Sum = Sum,
|
||||||
DateCreate = DateCreate,
|
DateCreate = DateCreate,
|
||||||
@@ -81,6 +98,7 @@ namespace CarRepairShopFileImplement.Models
|
|||||||
new XAttribute("Id", Id),
|
new XAttribute("Id", Id),
|
||||||
new XElement("RepairId", RepairId),
|
new XElement("RepairId", RepairId),
|
||||||
new XElement("ClientId", ClientId),
|
new XElement("ClientId", ClientId),
|
||||||
|
new XElement("ImplementerId", ImplementerId),
|
||||||
new XElement("Count", Count.ToString()),
|
new XElement("Count", Count.ToString()),
|
||||||
new XElement("Sum", Sum.ToString()),
|
new XElement("Sum", Sum.ToString()),
|
||||||
new XElement("Status", Status.ToString()),
|
new XElement("Status", Status.ToString()),
|
||||||
|
|||||||
@@ -1,18 +1,24 @@
|
|||||||
using CarRepairShopContracts.BindingModels;
|
using CarRepairShopContracts.BindingModels;
|
||||||
using CarRepairShopContracts.ViewModels;
|
using CarRepairShopContracts.ViewModels;
|
||||||
using CarRepairShopDataModels.Models;
|
using CarRepairShopDataModels.Models;
|
||||||
|
using System.Runtime.Serialization;
|
||||||
using System.Xml.Linq;
|
using System.Xml.Linq;
|
||||||
|
|
||||||
namespace CarRepairShopFileImplement.Models
|
namespace CarRepairShopFileImplement.Models
|
||||||
{
|
{
|
||||||
|
[DataContract]
|
||||||
public class Repair : IRepairModel
|
public class Repair : IRepairModel
|
||||||
{
|
{
|
||||||
|
[DataMember]
|
||||||
public int Id { get; private set; }
|
public int Id { get; private set; }
|
||||||
|
[DataMember]
|
||||||
public string RepairName { get; private set; } = string.Empty;
|
public string RepairName { get; private set; } = string.Empty;
|
||||||
|
[DataMember]
|
||||||
public double Price { get; private set; }
|
public double Price { get; private set; }
|
||||||
public Dictionary<int, int> Oils { get; private set; } = new();
|
public Dictionary<int, int> Oils { get; private set; } = new();
|
||||||
private Dictionary<int, (IOilModel, int)>? _repairOils =
|
private Dictionary<int, (IOilModel, int)>? _repairOils =
|
||||||
null;
|
null;
|
||||||
|
[DataMember]
|
||||||
public Dictionary<int, (IOilModel, int)> RepairOils
|
public Dictionary<int, (IOilModel, int)> RepairOils
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
|
|||||||
@@ -11,4 +11,8 @@
|
|||||||
<ProjectReference Include="..\CarRepairShopDataModels\CarRepairShopDataModels.csproj" />
|
<ProjectReference Include="..\CarRepairShopDataModels\CarRepairShopDataModels.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
|
||||||
|
<Exec Command="copy /Y "$(TargetDir)*.dll" "$(SolutionDir)ImplementationExtensions\*.dll"" />
|
||||||
|
</Target>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
@@ -0,0 +1,17 @@
|
|||||||
|
using CarRepairShopContracts.StoragesContracts;
|
||||||
|
|
||||||
|
namespace CarRepairShopListImplement.Implements
|
||||||
|
{
|
||||||
|
public class BackUpInfo : IBackUpInfo
|
||||||
|
{
|
||||||
|
public List<T>? GetList<T>() where T : class, new()
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Type? GetTypeByModelInterface(string modelInterfaceName)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
using CarRepairShopContracts.DI;
|
||||||
|
using CarRepairShopContracts.StoragesContracts;
|
||||||
|
using CarRepairShopListImplement.Implements;
|
||||||
|
|
||||||
|
namespace CarRepairShopListImplement
|
||||||
|
{
|
||||||
|
public class ListImplementationExtension : IImplementationExtension
|
||||||
|
{
|
||||||
|
public int Priority => 0;
|
||||||
|
|
||||||
|
public void RegisterServices()
|
||||||
|
{
|
||||||
|
DependencyManager.Instance.RegisterType<IClientStorage, ClientStorage>();
|
||||||
|
DependencyManager.Instance.RegisterType<IOilStorage, OilStorage>();
|
||||||
|
DependencyManager.Instance.RegisterType<IImplementerStorage, ImplementerStorage>();
|
||||||
|
DependencyManager.Instance.RegisterType<IMessageInfoStorage, MessageInfoStorage>();
|
||||||
|
DependencyManager.Instance.RegisterType<IOrderStorage, OrderStorage>();
|
||||||
|
DependencyManager.Instance.RegisterType<IRepairStorage, RepairStorage>();
|
||||||
|
DependencyManager.Instance.RegisterType<IBackUpInfo, BackUpInfo>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -44,5 +44,7 @@ namespace CarRepairShopListImplement.Models
|
|||||||
ClientId = ClientId,
|
ClientId = ClientId,
|
||||||
MessageId = MessageId
|
MessageId = MessageId
|
||||||
};
|
};
|
||||||
|
|
||||||
|
public int Id => throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
46
CarRepairShop/CarRepairShopView/DataGridViewExtension.cs
Normal file
46
CarRepairShop/CarRepairShopView/DataGridViewExtension.cs
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
using CarRepairShopContracts.Attributes;
|
||||||
|
|
||||||
|
namespace CarRepairShopView
|
||||||
|
{
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -29,8 +29,6 @@
|
|||||||
private void InitializeComponent()
|
private void InitializeComponent()
|
||||||
{
|
{
|
||||||
this.dataGridView = new System.Windows.Forms.DataGridView();
|
this.dataGridView = new System.Windows.Forms.DataGridView();
|
||||||
this.ColumnId = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
|
||||||
this.ColumnFIO = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
|
||||||
this.ButtonRef = new System.Windows.Forms.Button();
|
this.ButtonRef = new System.Windows.Forms.Button();
|
||||||
this.ButtonDel = new System.Windows.Forms.Button();
|
this.ButtonDel = new System.Windows.Forms.Button();
|
||||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
|
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
|
||||||
@@ -39,9 +37,6 @@
|
|||||||
// dataGridView
|
// dataGridView
|
||||||
//
|
//
|
||||||
this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||||
this.dataGridView.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
|
|
||||||
this.ColumnId,
|
|
||||||
this.ColumnFIO});
|
|
||||||
this.dataGridView.Location = new System.Drawing.Point(12, 12);
|
this.dataGridView.Location = new System.Drawing.Point(12, 12);
|
||||||
this.dataGridView.Name = "dataGridView";
|
this.dataGridView.Name = "dataGridView";
|
||||||
this.dataGridView.RowHeadersWidth = 51;
|
this.dataGridView.RowHeadersWidth = 51;
|
||||||
@@ -49,21 +44,6 @@
|
|||||||
this.dataGridView.Size = new System.Drawing.Size(524, 426);
|
this.dataGridView.Size = new System.Drawing.Size(524, 426);
|
||||||
this.dataGridView.TabIndex = 0;
|
this.dataGridView.TabIndex = 0;
|
||||||
//
|
//
|
||||||
// ColumnId
|
|
||||||
//
|
|
||||||
this.ColumnId.HeaderText = "Id";
|
|
||||||
this.ColumnId.MinimumWidth = 6;
|
|
||||||
this.ColumnId.Name = "ColumnId";
|
|
||||||
this.ColumnId.Visible = false;
|
|
||||||
this.ColumnId.Width = 125;
|
|
||||||
//
|
|
||||||
// ColumnFIO
|
|
||||||
//
|
|
||||||
this.ColumnFIO.HeaderText = "ФИО клиента";
|
|
||||||
this.ColumnFIO.MinimumWidth = 6;
|
|
||||||
this.ColumnFIO.Name = "ColumnFIO";
|
|
||||||
this.ColumnFIO.Width = 125;
|
|
||||||
//
|
|
||||||
// ButtonRef
|
// ButtonRef
|
||||||
//
|
//
|
||||||
this.ButtonRef.Location = new System.Drawing.Point(596, 61);
|
this.ButtonRef.Location = new System.Drawing.Point(596, 61);
|
||||||
@@ -103,8 +83,6 @@
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
private DataGridView dataGridView;
|
private DataGridView dataGridView;
|
||||||
private DataGridViewTextBoxColumn ColumnId;
|
|
||||||
private DataGridViewTextBoxColumn ColumnFIO;
|
|
||||||
private Button ButtonRef;
|
private Button ButtonRef;
|
||||||
private Button ButtonDel;
|
private Button ButtonDel;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -58,13 +58,7 @@ namespace CarRepairShopView
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var list = _logic.ReadList(null);
|
dataGridView.FillAndConfigGrid(_logic.ReadList(null));
|
||||||
if (list != null)
|
|
||||||
{
|
|
||||||
dataGridView.DataSource = list;
|
|
||||||
dataGridView.Columns["Id"].Visible = false;
|
|
||||||
dataGridView.Columns["ClientFIO"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
|
||||||
}
|
|
||||||
_logger.LogInformation("Загрузка клиентов");
|
_logger.LogInformation("Загрузка клиентов");
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
|
|||||||
@@ -57,16 +57,4 @@
|
|||||||
<resheader name="writer">
|
<resheader name="writer">
|
||||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
</resheader>
|
</resheader>
|
||||||
<metadata name="ColumnId.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
|
||||||
<value>True</value>
|
|
||||||
</metadata>
|
|
||||||
<metadata name="ColumnFIO.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
|
||||||
<value>True</value>
|
|
||||||
</metadata>
|
|
||||||
<metadata name="ColumnId.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
|
||||||
<value>True</value>
|
|
||||||
</metadata>
|
|
||||||
<metadata name="ColumnFIO.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
|
||||||
<value>True</value>
|
|
||||||
</metadata>
|
|
||||||
</root>
|
</root>
|
||||||
@@ -33,15 +33,12 @@
|
|||||||
this.ButtonDelete = new System.Windows.Forms.Button();
|
this.ButtonDelete = new System.Windows.Forms.Button();
|
||||||
this.ButtonEdit = new System.Windows.Forms.Button();
|
this.ButtonEdit = new System.Windows.Forms.Button();
|
||||||
this.ButtonUpdate = new System.Windows.Forms.Button();
|
this.ButtonUpdate = new System.Windows.Forms.Button();
|
||||||
this.ColumnId = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
|
||||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
|
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
|
||||||
this.SuspendLayout();
|
this.SuspendLayout();
|
||||||
//
|
//
|
||||||
// dataGridView
|
// dataGridView
|
||||||
//
|
//
|
||||||
this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||||
this.dataGridView.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
|
|
||||||
this.ColumnId});
|
|
||||||
this.dataGridView.Location = new System.Drawing.Point(3, 2);
|
this.dataGridView.Location = new System.Drawing.Point(3, 2);
|
||||||
this.dataGridView.Name = "dataGridView";
|
this.dataGridView.Name = "dataGridView";
|
||||||
this.dataGridView.RowHeadersWidth = 51;
|
this.dataGridView.RowHeadersWidth = 51;
|
||||||
@@ -89,14 +86,6 @@
|
|||||||
this.ButtonUpdate.UseVisualStyleBackColor = true;
|
this.ButtonUpdate.UseVisualStyleBackColor = true;
|
||||||
this.ButtonUpdate.Click += new System.EventHandler(this.ButtonUpdate_Click);
|
this.ButtonUpdate.Click += new System.EventHandler(this.ButtonUpdate_Click);
|
||||||
//
|
//
|
||||||
// ColumnId
|
|
||||||
//
|
|
||||||
this.ColumnId.HeaderText = "Id";
|
|
||||||
this.ColumnId.MinimumWidth = 6;
|
|
||||||
this.ColumnId.Name = "ColumnId";
|
|
||||||
this.ColumnId.Visible = false;
|
|
||||||
this.ColumnId.Width = 125;
|
|
||||||
//
|
|
||||||
// FormImplementers
|
// FormImplementers
|
||||||
//
|
//
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
|
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
|
||||||
@@ -122,6 +111,5 @@
|
|||||||
private Button ButtonDelete;
|
private Button ButtonDelete;
|
||||||
private Button ButtonEdit;
|
private Button ButtonEdit;
|
||||||
private Button ButtonUpdate;
|
private Button ButtonUpdate;
|
||||||
private DataGridViewTextBoxColumn ColumnId;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using CarRepairShopContracts.BindingModels;
|
using CarRepairShopContracts.BindingModels;
|
||||||
using CarRepairShopContracts.BusinessLogicsContracts;
|
using CarRepairShopContracts.BusinessLogicsContracts;
|
||||||
|
using CarRepairShopContracts.DI;
|
||||||
|
|
||||||
namespace CarRepairShopView
|
namespace CarRepairShopView
|
||||||
{
|
{
|
||||||
@@ -18,7 +19,7 @@ namespace CarRepairShopView
|
|||||||
|
|
||||||
private void ButtonAdd_Click(object sender, EventArgs e)
|
private void ButtonAdd_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
var service = Program.ServiceProvider?.GetService(typeof(FormImplementer));
|
var service = DependencyManager.Instance.Resolve<FormImplementer>();
|
||||||
if (service is FormImplementer form)
|
if (service is FormImplementer form)
|
||||||
{
|
{
|
||||||
if (form.ShowDialog() == DialogResult.OK)
|
if (form.ShowDialog() == DialogResult.OK)
|
||||||
@@ -68,7 +69,8 @@ namespace CarRepairShopView
|
|||||||
{
|
{
|
||||||
if (dataGridView.SelectedRows.Count == 1)
|
if (dataGridView.SelectedRows.Count == 1)
|
||||||
{
|
{
|
||||||
var service = Program.ServiceProvider?.GetService(typeof(FormImplementer));
|
var service = DependencyManager.Instance.Resolve<FormImplementer>();
|
||||||
|
|
||||||
if (service is FormImplementer form)
|
if (service is FormImplementer form)
|
||||||
{
|
{
|
||||||
form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||||
@@ -89,13 +91,7 @@ namespace CarRepairShopView
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var list = _logic.ReadList(null);
|
dataGridView.FillAndConfigGrid(_logic.ReadList(null));
|
||||||
if (list != null)
|
|
||||||
{
|
|
||||||
dataGridView.DataSource = list;
|
|
||||||
dataGridView.Columns["Id"].Visible = false;
|
|
||||||
dataGridView.Columns["ImplementerFIO"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
|
||||||
}
|
|
||||||
_logger.LogInformation("Загрузка исполнителей");
|
_logger.LogInformation("Загрузка исполнителей");
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
|
|||||||
@@ -57,7 +57,4 @@
|
|||||||
<resheader name="writer">
|
<resheader name="writer">
|
||||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
</resheader>
|
</resheader>
|
||||||
<metadata name="ColumnId.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
|
||||||
<value>True</value>
|
|
||||||
</metadata>
|
|
||||||
</root>
|
</root>
|
||||||
@@ -19,14 +19,7 @@ namespace CarRepairShopView
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var list = _logic.ReadList(null);
|
dataGridView.FillAndConfigGrid(_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
CarRepairShop/CarRepairShopView/FormMain.Designer.cs
generated
31
CarRepairShop/CarRepairShopView/FormMain.Designer.cs
generated
@@ -46,6 +46,7 @@
|
|||||||
this.OrdersToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
this.OrdersToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
this.ToolStripButtonDoWork = new System.Windows.Forms.ToolStripButton();
|
this.ToolStripButtonDoWork = new System.Windows.Forms.ToolStripButton();
|
||||||
this.toolStripButtonMessages = new System.Windows.Forms.ToolStripButton();
|
this.toolStripButtonMessages = new System.Windows.Forms.ToolStripButton();
|
||||||
|
this.toolStripButtonCreateBackUp = new System.Windows.Forms.ToolStripButton();
|
||||||
this.DataGridView = new System.Windows.Forms.DataGridView();
|
this.DataGridView = new System.Windows.Forms.DataGridView();
|
||||||
this.toolStrip1.SuspendLayout();
|
this.toolStrip1.SuspendLayout();
|
||||||
((System.ComponentModel.ISupportInitialize)(this.DataGridView)).BeginInit();
|
((System.ComponentModel.ISupportInitialize)(this.DataGridView)).BeginInit();
|
||||||
@@ -53,7 +54,7 @@
|
|||||||
//
|
//
|
||||||
// ButtonCreateOrder
|
// ButtonCreateOrder
|
||||||
//
|
//
|
||||||
this.ButtonCreateOrder.Location = new System.Drawing.Point(1207, 56);
|
this.ButtonCreateOrder.Location = new System.Drawing.Point(1311, 53);
|
||||||
this.ButtonCreateOrder.Name = "ButtonCreateOrder";
|
this.ButtonCreateOrder.Name = "ButtonCreateOrder";
|
||||||
this.ButtonCreateOrder.Size = new System.Drawing.Size(178, 29);
|
this.ButtonCreateOrder.Size = new System.Drawing.Size(178, 29);
|
||||||
this.ButtonCreateOrder.TabIndex = 1;
|
this.ButtonCreateOrder.TabIndex = 1;
|
||||||
@@ -63,7 +64,7 @@
|
|||||||
//
|
//
|
||||||
// ButtonTakeOrderInWork
|
// ButtonTakeOrderInWork
|
||||||
//
|
//
|
||||||
this.ButtonTakeOrderInWork.Location = new System.Drawing.Point(1207, 152);
|
this.ButtonTakeOrderInWork.Location = new System.Drawing.Point(1311, 154);
|
||||||
this.ButtonTakeOrderInWork.Name = "ButtonTakeOrderInWork";
|
this.ButtonTakeOrderInWork.Name = "ButtonTakeOrderInWork";
|
||||||
this.ButtonTakeOrderInWork.Size = new System.Drawing.Size(178, 31);
|
this.ButtonTakeOrderInWork.Size = new System.Drawing.Size(178, 31);
|
||||||
this.ButtonTakeOrderInWork.TabIndex = 2;
|
this.ButtonTakeOrderInWork.TabIndex = 2;
|
||||||
@@ -73,7 +74,7 @@
|
|||||||
//
|
//
|
||||||
// ButtonOrderReady
|
// ButtonOrderReady
|
||||||
//
|
//
|
||||||
this.ButtonOrderReady.Location = new System.Drawing.Point(1207, 248);
|
this.ButtonOrderReady.Location = new System.Drawing.Point(1311, 259);
|
||||||
this.ButtonOrderReady.Name = "ButtonOrderReady";
|
this.ButtonOrderReady.Name = "ButtonOrderReady";
|
||||||
this.ButtonOrderReady.Size = new System.Drawing.Size(178, 29);
|
this.ButtonOrderReady.Size = new System.Drawing.Size(178, 29);
|
||||||
this.ButtonOrderReady.TabIndex = 3;
|
this.ButtonOrderReady.TabIndex = 3;
|
||||||
@@ -83,7 +84,7 @@
|
|||||||
//
|
//
|
||||||
// ButtonIssuedOrder
|
// ButtonIssuedOrder
|
||||||
//
|
//
|
||||||
this.ButtonIssuedOrder.Location = new System.Drawing.Point(1207, 341);
|
this.ButtonIssuedOrder.Location = new System.Drawing.Point(1311, 359);
|
||||||
this.ButtonIssuedOrder.Name = "ButtonIssuedOrder";
|
this.ButtonIssuedOrder.Name = "ButtonIssuedOrder";
|
||||||
this.ButtonIssuedOrder.Size = new System.Drawing.Size(178, 29);
|
this.ButtonIssuedOrder.Size = new System.Drawing.Size(178, 29);
|
||||||
this.ButtonIssuedOrder.TabIndex = 4;
|
this.ButtonIssuedOrder.TabIndex = 4;
|
||||||
@@ -93,7 +94,7 @@
|
|||||||
//
|
//
|
||||||
// ButtonRef
|
// ButtonRef
|
||||||
//
|
//
|
||||||
this.ButtonRef.Location = new System.Drawing.Point(1207, 434);
|
this.ButtonRef.Location = new System.Drawing.Point(1311, 452);
|
||||||
this.ButtonRef.Name = "ButtonRef";
|
this.ButtonRef.Name = "ButtonRef";
|
||||||
this.ButtonRef.Size = new System.Drawing.Size(178, 29);
|
this.ButtonRef.Size = new System.Drawing.Size(178, 29);
|
||||||
this.ButtonRef.TabIndex = 5;
|
this.ButtonRef.TabIndex = 5;
|
||||||
@@ -108,10 +109,11 @@
|
|||||||
this.ToolStripDropDownButton,
|
this.ToolStripDropDownButton,
|
||||||
this.toolStripSplitButtonReports,
|
this.toolStripSplitButtonReports,
|
||||||
this.ToolStripButtonDoWork,
|
this.ToolStripButtonDoWork,
|
||||||
this.toolStripButtonMessages});
|
this.toolStripButtonMessages,
|
||||||
|
this.toolStripButtonCreateBackUp});
|
||||||
this.toolStrip1.Location = new System.Drawing.Point(0, 0);
|
this.toolStrip1.Location = new System.Drawing.Point(0, 0);
|
||||||
this.toolStrip1.Name = "toolStrip1";
|
this.toolStrip1.Name = "toolStrip1";
|
||||||
this.toolStrip1.Size = new System.Drawing.Size(1397, 27);
|
this.toolStrip1.Size = new System.Drawing.Size(1501, 27);
|
||||||
this.toolStrip1.TabIndex = 6;
|
this.toolStrip1.TabIndex = 6;
|
||||||
this.toolStrip1.Text = "toolStrip1";
|
this.toolStrip1.Text = "toolStrip1";
|
||||||
//
|
//
|
||||||
@@ -210,6 +212,16 @@
|
|||||||
this.toolStripButtonMessages.Text = "Письма";
|
this.toolStripButtonMessages.Text = "Письма";
|
||||||
this.toolStripButtonMessages.Click += new System.EventHandler(this.toolStripButtonMessages_Click);
|
this.toolStripButtonMessages.Click += new System.EventHandler(this.toolStripButtonMessages_Click);
|
||||||
//
|
//
|
||||||
|
// toolStripButtonCreateBackUp
|
||||||
|
//
|
||||||
|
this.toolStripButtonCreateBackUp.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text;
|
||||||
|
this.toolStripButtonCreateBackUp.Image = ((System.Drawing.Image)(resources.GetObject("toolStripButtonCreateBackUp.Image")));
|
||||||
|
this.toolStripButtonCreateBackUp.ImageTransparentColor = System.Drawing.Color.Magenta;
|
||||||
|
this.toolStripButtonCreateBackUp.Name = "toolStripButtonCreateBackUp";
|
||||||
|
this.toolStripButtonCreateBackUp.Size = new System.Drawing.Size(113, 24);
|
||||||
|
this.toolStripButtonCreateBackUp.Text = "Создать бекап";
|
||||||
|
this.toolStripButtonCreateBackUp.Click += new System.EventHandler(this.toolStripButtonCreateBackUp_Click);
|
||||||
|
//
|
||||||
// DataGridView
|
// DataGridView
|
||||||
//
|
//
|
||||||
this.DataGridView.BackgroundColor = System.Drawing.SystemColors.ButtonHighlight;
|
this.DataGridView.BackgroundColor = System.Drawing.SystemColors.ButtonHighlight;
|
||||||
@@ -218,14 +230,14 @@
|
|||||||
this.DataGridView.Name = "DataGridView";
|
this.DataGridView.Name = "DataGridView";
|
||||||
this.DataGridView.RowHeadersWidth = 51;
|
this.DataGridView.RowHeadersWidth = 51;
|
||||||
this.DataGridView.RowTemplate.Height = 29;
|
this.DataGridView.RowTemplate.Height = 29;
|
||||||
this.DataGridView.Size = new System.Drawing.Size(1201, 528);
|
this.DataGridView.Size = new System.Drawing.Size(1305, 528);
|
||||||
this.DataGridView.TabIndex = 7;
|
this.DataGridView.TabIndex = 7;
|
||||||
//
|
//
|
||||||
// FormMain
|
// FormMain
|
||||||
//
|
//
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
|
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
this.ClientSize = new System.Drawing.Size(1397, 556);
|
this.ClientSize = new System.Drawing.Size(1501, 556);
|
||||||
this.Controls.Add(this.DataGridView);
|
this.Controls.Add(this.DataGridView);
|
||||||
this.Controls.Add(this.toolStrip1);
|
this.Controls.Add(this.toolStrip1);
|
||||||
this.Controls.Add(this.ButtonRef);
|
this.Controls.Add(this.ButtonRef);
|
||||||
@@ -263,5 +275,6 @@
|
|||||||
private ToolStripButton ToolStripButtonDoWork;
|
private ToolStripButton ToolStripButtonDoWork;
|
||||||
private ToolStripMenuItem ImplementersToolStripMenuItem;
|
private ToolStripMenuItem ImplementersToolStripMenuItem;
|
||||||
private ToolStripButton toolStripButtonMessages;
|
private ToolStripButton toolStripButtonMessages;
|
||||||
|
private ToolStripButton toolStripButtonCreateBackUp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
using CarRepairShopContracts.BindingModels;
|
using CarRepairShopContracts.BindingModels;
|
||||||
using CarRepairShopContracts.BusinessLogicsContracts;
|
using CarRepairShopContracts.BusinessLogicsContracts;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
|
using CarRepairShopContracts.DI;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
|
|
||||||
namespace CarRepairShopView
|
namespace CarRepairShopView
|
||||||
@@ -11,13 +12,15 @@ namespace CarRepairShopView
|
|||||||
private readonly IOrderLogic _orderLogic;
|
private readonly IOrderLogic _orderLogic;
|
||||||
private readonly IReportLogic _reportLogic;
|
private readonly IReportLogic _reportLogic;
|
||||||
private readonly IWorkProcess _workProcess;
|
private readonly IWorkProcess _workProcess;
|
||||||
public FormMain(ILogger<FormMain> logger, IOrderLogic orderLogic, IReportLogic reportLogic, IWorkProcess workProcess)
|
private readonly IBackUpLogic _backUpLogic;
|
||||||
|
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,17 +33,7 @@ namespace CarRepairShopView
|
|||||||
_logger.LogInformation("Загрузка заказов");
|
_logger.LogInformation("Загрузка заказов");
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var list = _orderLogic.ReadList(null);
|
DataGridView.FillAndConfigGrid(_orderLogic.ReadList(null));
|
||||||
if (list != null)
|
|
||||||
{
|
|
||||||
DataGridView.DataSource = list;
|
|
||||||
DataGridView.Columns["RepairId"].Visible = false;
|
|
||||||
DataGridView.Columns["ClientId"].Visible = false;
|
|
||||||
DataGridView.Columns["ImplementerId"].Visible = false;
|
|
||||||
DataGridView.Columns["RepairName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
|
||||||
DataGridView.Columns["ClientFIO"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
|
||||||
DataGridView.Columns["ImplementerFIO"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
|
||||||
}
|
|
||||||
_logger.LogInformation("Загрузка заказов");
|
_logger.LogInformation("Загрузка заказов");
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
@@ -52,7 +45,7 @@ namespace CarRepairShopView
|
|||||||
|
|
||||||
private void OilsToolStripMenuItem_Click(object sender, EventArgs e)
|
private void OilsToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
var service = Program.ServiceProvider?.GetService(typeof(FormOils));
|
var service = DependencyManager.Instance.Resolve<FormOils>();
|
||||||
if (service is FormOils form)
|
if (service is FormOils form)
|
||||||
{
|
{
|
||||||
form.ShowDialog();
|
form.ShowDialog();
|
||||||
@@ -61,7 +54,7 @@ namespace CarRepairShopView
|
|||||||
|
|
||||||
private void RepairsToolStripMenuItem_Click(object sender, EventArgs e)
|
private void RepairsToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
var service = Program.ServiceProvider?.GetService(typeof(FormRepairs));
|
var service = DependencyManager.Instance.Resolve<FormRepairs>();
|
||||||
if (service is FormRepairs form)
|
if (service is FormRepairs form)
|
||||||
{
|
{
|
||||||
form.ShowDialog();
|
form.ShowDialog();
|
||||||
@@ -70,7 +63,7 @@ namespace CarRepairShopView
|
|||||||
|
|
||||||
private void ButtonCreateOrder_Click(object sender, EventArgs e)
|
private void ButtonCreateOrder_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
var service = Program.ServiceProvider?.GetService(typeof(FormCreateOrder));
|
var service = DependencyManager.Instance.Resolve<FormCreateOrder>();
|
||||||
if (service is FormCreateOrder form)
|
if (service is FormCreateOrder form)
|
||||||
{
|
{
|
||||||
form.ShowDialog();
|
form.ShowDialog();
|
||||||
@@ -82,8 +75,7 @@ namespace CarRepairShopView
|
|||||||
{
|
{
|
||||||
if (DataGridView.SelectedRows.Count == 1)
|
if (DataGridView.SelectedRows.Count == 1)
|
||||||
{
|
{
|
||||||
int id =
|
int id = Convert.ToInt32(DataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||||
Convert.ToInt32(DataGridView.SelectedRows[0].Cells["Id"].Value);
|
|
||||||
_logger.LogInformation("Заказ №{id}. Меняется статус на 'В работе'", id);
|
_logger.LogInformation("Заказ №{id}. Меняется статус на 'В работе'", id);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -109,8 +101,7 @@ namespace CarRepairShopView
|
|||||||
{
|
{
|
||||||
if (DataGridView.SelectedRows.Count == 1)
|
if (DataGridView.SelectedRows.Count == 1)
|
||||||
{
|
{
|
||||||
int id =
|
int id = Convert.ToInt32(DataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||||
Convert.ToInt32(DataGridView.SelectedRows[0].Cells["Id"].Value);
|
|
||||||
_logger.LogInformation("Заказ №{id}. Меняется статус на 'Готов'",
|
_logger.LogInformation("Заказ №{id}. Меняется статус на 'Готов'",
|
||||||
id);
|
id);
|
||||||
try
|
try
|
||||||
@@ -137,8 +128,7 @@ namespace CarRepairShopView
|
|||||||
{
|
{
|
||||||
if (DataGridView.SelectedRows.Count == 1)
|
if (DataGridView.SelectedRows.Count == 1)
|
||||||
{
|
{
|
||||||
int id =
|
int id = Convert.ToInt32(DataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||||
Convert.ToInt32(DataGridView.SelectedRows[0].Cells["Id"].Value);
|
|
||||||
_logger.LogInformation("Заказ №{id}. Меняется статус на 'Выдан'",
|
_logger.LogInformation("Заказ №{id}. Меняется статус на 'Выдан'",
|
||||||
id);
|
id);
|
||||||
try
|
try
|
||||||
@@ -183,7 +173,7 @@ namespace CarRepairShopView
|
|||||||
|
|
||||||
private void OilRepairToolStripMenuItem_Click(object sender, EventArgs e)
|
private void OilRepairToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
var service = Program.ServiceProvider?.GetService(typeof(FormReportRepairOils));
|
var service = DependencyManager.Instance.Resolve<FormReportRepairOils>();
|
||||||
if (service is FormReportRepairOils form)
|
if (service is FormReportRepairOils form)
|
||||||
{
|
{
|
||||||
form.ShowDialog();
|
form.ShowDialog();
|
||||||
@@ -192,7 +182,7 @@ namespace CarRepairShopView
|
|||||||
|
|
||||||
private void OrdersToolStripMenuItem_Click(object sender, EventArgs e)
|
private void OrdersToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
var service = Program.ServiceProvider?.GetService(typeof(FormReportOrders));
|
var service = DependencyManager.Instance.Resolve<FormReportOrders>();
|
||||||
if (service is FormReportOrders form)
|
if (service is FormReportOrders form)
|
||||||
{
|
{
|
||||||
form.ShowDialog();
|
form.ShowDialog();
|
||||||
@@ -202,7 +192,7 @@ namespace CarRepairShopView
|
|||||||
|
|
||||||
private void ClientsToolStripMenuItem_Click(object sender, EventArgs e)
|
private void ClientsToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
var service = Program.ServiceProvider?.GetService(typeof(FormClients));
|
var service = DependencyManager.Instance.Resolve<FormClients>();
|
||||||
if (service is FormClients form)
|
if (service is FormClients form)
|
||||||
{
|
{
|
||||||
form.ShowDialog();
|
form.ShowDialog();
|
||||||
@@ -212,7 +202,7 @@ namespace CarRepairShopView
|
|||||||
private void ToolStripButtonDoWork_Click(object sender, EventArgs e)
|
private void ToolStripButtonDoWork_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
_workProcess.DoWork((
|
_workProcess.DoWork((
|
||||||
Program.ServiceProvider?.GetService(typeof(IImplementerLogic)) as IImplementerLogic)!,
|
DependencyManager.Instance.Resolve<IImplementerLogic>() as IImplementerLogic)!,
|
||||||
_orderLogic);
|
_orderLogic);
|
||||||
MessageBox.Show("Процесс обработки запущен", "Сообщение",
|
MessageBox.Show("Процесс обработки запущен", "Сообщение",
|
||||||
MessageBoxButtons.OK, MessageBoxIcon.Information);
|
MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||||
@@ -220,7 +210,7 @@ namespace CarRepairShopView
|
|||||||
|
|
||||||
private void ImplementersToolStripMenuItem_Click(object sender, EventArgs e)
|
private void ImplementersToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
var service = Program.ServiceProvider?.GetService(typeof(FormImplementers));
|
var service = DependencyManager.Instance.Resolve<FormImplementers>();
|
||||||
if (service is FormImplementers form)
|
if (service is FormImplementers form)
|
||||||
{
|
{
|
||||||
form.ShowDialog();
|
form.ShowDialog();
|
||||||
@@ -229,11 +219,36 @@ namespace CarRepairShopView
|
|||||||
|
|
||||||
private void toolStripButtonMessages_Click(object sender, EventArgs e)
|
private void toolStripButtonMessages_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
var service = Program.ServiceProvider?.GetService(typeof(FormMails));
|
var service = DependencyManager.Instance.Resolve<FormMails>();
|
||||||
if(service is FormMails form)
|
if (service is FormMails form)
|
||||||
{
|
{
|
||||||
form.ShowDialog();
|
form.ShowDialog();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void toolStripButtonCreateBackUp_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (_backUpLogic != null)
|
||||||
|
{
|
||||||
|
var fbd = new FolderBrowserDialog();
|
||||||
|
if (fbd.ShowDialog() == DialogResult.OK)
|
||||||
|
{
|
||||||
|
_backUpLogic.CreateBackUp(new BackUpSaveBindingModel
|
||||||
|
{
|
||||||
|
FolderName = fbd.SelectedPath
|
||||||
|
});
|
||||||
|
MessageBox.Show("Бекап создан", "Сообщение",
|
||||||
|
MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
|
||||||
|
MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -92,9 +92,20 @@
|
|||||||
U87f4aUApcXhnrI9Jzg/laQKFntXlHM+lSQK5psL5fvbp/JvJLGCQqmSWM5JkiCT84igXGtSrruKLQ0T
|
U87f4aUApcXhnrI9Jzg/laQKFntXlHM+lSQK5psL5fvbp/JvJLGCQqmSWM5JkiCT84igXGtSrruKLQ0T
|
||||||
luAdmZxHBG37FFuWBC/j5XKOmX8WAH7rcI6ZMffPgjQwN2bXJgDo/COBTpjneQ2dML0PY3cISreGe8HM
|
luAdmZxHBG37FFuWBC/j5XKOmX8WAH7rcI6ZMffPgjQwN2bXJgDo/COBTpjneQ2dML0PY3cISreGe8HM
|
||||||
qgAAAABJRU5ErkJggg==
|
qgAAAABJRU5ErkJggg==
|
||||||
|
</value>
|
||||||
|
</data>
|
||||||
|
<data name="toolStripButtonCreateBackUp.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||||
|
<value>
|
||||||
|
iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
|
||||||
|
YQUAAAAJcEhZcwAAEnQAABJ0Ad5mH3gAAAEKSURBVEhL3ZG9DsFQHMXvczDZvIOtXsHObuhqkViI3Quw
|
||||||
|
6CYmNoMYJJ0NBiFFIoIytOuf0+TeXP3yde+iyS+3OcP53Z4y3/dJJ4HAsiwyTVMp6BQCBIZhKAWdEcHV
|
||||||
|
vSlBmeB82NFy1KLluEWOPRC5MoHdMWhazwi4RJlALgf4EuT6BI+5kCsTrGddUY658E+QvyXYHq9UnRyC
|
||||||
|
U87f4aUApcXhnrI9Jzg/laQKFntXlHM+lSQK5psL5fvbp/JvJLGCQqmSWM5JkiCT84igXGtSrruKLQ0T
|
||||||
|
luAdmZxHBG37FFuWBC/j5XKOmX8WAH7rcI6ZMffPgjQwN2bXJgDo/COBTpjneQ2dML0PY3cISreGe8HM
|
||||||
|
qgAAAABJRU5ErkJggg==
|
||||||
</value>
|
</value>
|
||||||
</data>
|
</data>
|
||||||
<metadata name="$this.TrayHeight" type="System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
<metadata name="$this.TrayHeight" type="System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
<value>35</value>
|
<value>41</value>
|
||||||
</metadata>
|
</metadata>
|
||||||
</root>
|
</root>
|
||||||
@@ -1,6 +1,8 @@
|
|||||||
using CarRepairShopContracts.BindingModels;
|
using CarRepairShopContracts.BindingModels;
|
||||||
using CarRepairShopContracts.BusinessLogicsContracts;
|
using CarRepairShopContracts.BusinessLogicsContracts;
|
||||||
|
using CarRepairShopContracts.DI;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
|
||||||
namespace CarRepairShopView
|
namespace CarRepairShopView
|
||||||
{
|
{
|
||||||
@@ -24,14 +26,7 @@ namespace CarRepairShopView
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var list = _logic.ReadList(null);
|
DataGridView.FillAndConfigGrid(_logic.ReadList(null));
|
||||||
if (list != null)
|
|
||||||
{
|
|
||||||
DataGridView.DataSource = list;
|
|
||||||
DataGridView.Columns["Id"].Visible = false;
|
|
||||||
DataGridView.Columns["OilName"].AutoSizeMode =
|
|
||||||
DataGridViewAutoSizeColumnMode.Fill;
|
|
||||||
}
|
|
||||||
_logger.LogInformation("Загрузка компонентов");
|
_logger.LogInformation("Загрузка компонентов");
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
@@ -45,7 +40,7 @@ namespace CarRepairShopView
|
|||||||
|
|
||||||
private void ButtonAdd_Click(object sender, EventArgs e)
|
private void ButtonAdd_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
var service = Program.ServiceProvider?.GetService(typeof(FormOil));
|
var service = DependencyManager.Instance.Resolve<FormOil>();
|
||||||
if (service is FormOil form)
|
if (service is FormOil form)
|
||||||
{
|
{
|
||||||
if (form.ShowDialog() == DialogResult.OK)
|
if (form.ShowDialog() == DialogResult.OK)
|
||||||
@@ -96,8 +91,7 @@ namespace CarRepairShopView
|
|||||||
{
|
{
|
||||||
if (DataGridView.SelectedRows.Count == 1)
|
if (DataGridView.SelectedRows.Count == 1)
|
||||||
{
|
{
|
||||||
var service =
|
var service = DependencyManager.Instance.Resolve<FormOil>();
|
||||||
Program.ServiceProvider?.GetService(typeof(FormOil));
|
|
||||||
if (service is FormOil form)
|
if (service is FormOil form)
|
||||||
{
|
{
|
||||||
form.Id =
|
form.Id =
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
using CarRepairShopContracts.BindingModels;
|
using CarRepairShopContracts.BindingModels;
|
||||||
using CarRepairShopContracts.BusinessLogicsContracts;
|
using CarRepairShopContracts.BusinessLogicsContracts;
|
||||||
|
using CarRepairShopContracts.DI;
|
||||||
using CarRepairShopContracts.SearchModels;
|
using CarRepairShopContracts.SearchModels;
|
||||||
using CarRepairShopDataModels.Models;
|
using CarRepairShopDataModels.Models;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
@@ -80,8 +81,7 @@ namespace CarRepairShopView
|
|||||||
|
|
||||||
private void ButtonAdd_Click(object sender, EventArgs e)
|
private void ButtonAdd_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
var service =
|
var service = DependencyManager.Instance.Resolve<FormRepairOil>();
|
||||||
Program.ServiceProvider?.GetService(typeof(FormRepairOil));
|
|
||||||
if (service is FormRepairOil form)
|
if (service is FormRepairOil form)
|
||||||
{
|
{
|
||||||
if (form.ShowDialog() == DialogResult.OK)
|
if (form.ShowDialog() == DialogResult.OK)
|
||||||
@@ -111,8 +111,7 @@ Program.ServiceProvider?.GetService(typeof(FormRepairOil));
|
|||||||
{
|
{
|
||||||
if (DataGridView.SelectedRows.Count == 1)
|
if (DataGridView.SelectedRows.Count == 1)
|
||||||
{
|
{
|
||||||
var service =
|
var service = DependencyManager.Instance.Resolve<FormRepairOil>();
|
||||||
Program.ServiceProvider?.GetService(typeof(FormRepairOil));
|
|
||||||
if (service is FormRepairOil form)
|
if (service is FormRepairOil form)
|
||||||
{
|
{
|
||||||
int id =
|
int id =
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
using CarRepairShopContracts.BindingModels;
|
using CarRepairShopContracts.BindingModels;
|
||||||
using CarRepairShopContracts.BusinessLogicsContracts;
|
using CarRepairShopContracts.BusinessLogicsContracts;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
|
using CarRepairShopContracts.DI;
|
||||||
|
|
||||||
namespace CarRepairShopView
|
namespace CarRepairShopView
|
||||||
{
|
{
|
||||||
@@ -24,14 +25,7 @@ namespace CarRepairShopView
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var list = _logic.ReadList(null);
|
DataGridView.FillAndConfigGrid(_logic.ReadList(null));
|
||||||
if (list != null)
|
|
||||||
{
|
|
||||||
DataGridView.DataSource = list;
|
|
||||||
DataGridView.Columns["Id"].Visible = false;
|
|
||||||
DataGridView.Columns["RepairName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
|
||||||
DataGridView.Columns["RepairOils"].Visible = false;
|
|
||||||
}
|
|
||||||
_logger.LogInformation("Загрузка видов ремонта");
|
_logger.LogInformation("Загрузка видов ремонта");
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
@@ -43,7 +37,7 @@ namespace CarRepairShopView
|
|||||||
|
|
||||||
private void ButtonAdd_Click(object sender, EventArgs e)
|
private void ButtonAdd_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
var service = Program.ServiceProvider?.GetService(typeof(FormRepair));
|
var service = DependencyManager.Instance.Resolve<FormRepair>();
|
||||||
if (service is FormRepair form)
|
if (service is FormRepair form)
|
||||||
{
|
{
|
||||||
if (form.ShowDialog() == DialogResult.OK)
|
if (form.ShowDialog() == DialogResult.OK)
|
||||||
@@ -57,7 +51,7 @@ namespace CarRepairShopView
|
|||||||
{
|
{
|
||||||
if (DataGridView.SelectedRows.Count == 1)
|
if (DataGridView.SelectedRows.Count == 1)
|
||||||
{
|
{
|
||||||
var service = Program.ServiceProvider?.GetService(typeof(FormRepair));
|
var service = DependencyManager.Instance.Resolve<FormRepair>();
|
||||||
if (service is FormRepair form)
|
if (service is FormRepair form)
|
||||||
{
|
{
|
||||||
form.Id = Convert.ToInt32(DataGridView.SelectedRows[0].Cells["Id"].Value);
|
form.Id = Convert.ToInt32(DataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||||
|
|||||||
@@ -1,21 +1,17 @@
|
|||||||
using CarRepairShopBusinessLogic.BusinessLogics;
|
using CarRepairShopBusinessLogic.BusinessLogics;
|
||||||
using CarRepairShopBusinessLogic.MailWorker;
|
using CarRepairShopBusinessLogic.MailWorker;
|
||||||
using CarRepairShopContracts.BusinessLogicsContracts;
|
using CarRepairShopContracts.BusinessLogicsContracts;
|
||||||
using CarRepairShopContracts.StoragesContracts;
|
|
||||||
using CarRepairShopDatabaseImplement.Implements;
|
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using NLog.Extensions.Logging;
|
using NLog.Extensions.Logging;
|
||||||
using CarRepairShopBusinessLogic.OfficePackage;
|
using CarRepairShopBusinessLogic.OfficePackage;
|
||||||
using CarRepairShopBusinessLogic.OfficePackage.Implements;
|
using CarRepairShopBusinessLogic.OfficePackage.Implements;
|
||||||
using CarRepairShopContracts.BindingModels;
|
using CarRepairShopContracts.BindingModels;
|
||||||
|
using CarRepairShopContracts.DI;
|
||||||
|
|
||||||
namespace CarRepairShopView
|
namespace CarRepairShopView
|
||||||
{
|
{
|
||||||
internal static class Program
|
internal static class Program
|
||||||
{
|
{
|
||||||
private static ServiceProvider? _serviceProvider;
|
|
||||||
public static ServiceProvider? ServiceProvider => _serviceProvider;
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The main entry point for the application.
|
/// The main entry point for the application.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -25,12 +21,10 @@ namespace CarRepairShopView
|
|||||||
// 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();
|
||||||
var services = new ServiceCollection();
|
InitDependency();
|
||||||
ConfigureServices(services);
|
|
||||||
_serviceProvider = services.BuildServiceProvider();
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var mailSender = _serviceProvider.GetService<AbstractMailWorker>();
|
var mailSender = DependencyManager.Instance.Resolve<AbstractMailWorker>();
|
||||||
mailSender?.MailConfig(new MailConfigBindingModel
|
mailSender?.MailConfig(new MailConfigBindingModel
|
||||||
{
|
{
|
||||||
MailLogin = System.Configuration.ConfigurationManager.AppSettings["MailLogin"] ?? string.Empty,
|
MailLogin = System.Configuration.ConfigurationManager.AppSettings["MailLogin"] ?? string.Empty,
|
||||||
@@ -45,56 +39,54 @@ namespace CarRepairShopView
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
var logger = _serviceProvider.GetService<ILogger>();
|
var logger = DependencyManager.Instance.Resolve<ILogger>();
|
||||||
logger?.LogError(ex, "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
|
logger?.LogError(ex, "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
|
||||||
}
|
}
|
||||||
|
|
||||||
Application.Run(_serviceProvider.GetRequiredService<FormMain>());
|
Application.Run(DependencyManager.Instance.Resolve<FormMain>());
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void ConfigureServices(ServiceCollection services)
|
private static void InitDependency()
|
||||||
{
|
{
|
||||||
services.AddLogging(option =>
|
DependencyManager.InitDependency();
|
||||||
|
|
||||||
|
DependencyManager.Instance.AddLogging(option =>
|
||||||
{
|
{
|
||||||
option.SetMinimumLevel(LogLevel.Information);
|
option.SetMinimumLevel(LogLevel.Information);
|
||||||
option.AddNLog("nlog.config");
|
option.AddNLog("nlog.config");
|
||||||
});
|
});
|
||||||
services.AddTransient<IClientStorage, ClientStorage>();
|
;
|
||||||
services.AddTransient<IOilStorage, OilStorage>();
|
DependencyManager.Instance.RegisterType<IClientLogic, ClientLogic>();
|
||||||
services.AddTransient<IOrderStorage, OrderStorage>();
|
DependencyManager.Instance.RegisterType<IOilLogic, OilLogic>();
|
||||||
services.AddTransient<IRepairStorage, RepairStorage>();
|
DependencyManager.Instance.RegisterType<IOrderLogic, OrderLogic>();
|
||||||
services.AddTransient<IImplementerStorage, ImplementerStorage>();
|
DependencyManager.Instance.RegisterType<IRepairLogic, RepairLogic>();
|
||||||
services.AddTransient<IMessageInfoStorage, MessageInfoStorage>();
|
DependencyManager.Instance.RegisterType<IReportLogic, ReportLogic>();
|
||||||
|
DependencyManager.Instance.RegisterType<IImplementerLogic, ImplementerLogic>();
|
||||||
|
DependencyManager.Instance.RegisterType<IMessageInfoLogic, MessageInfoLogic>();
|
||||||
|
DependencyManager.Instance.RegisterType<IBackUpLogic, BackUpLogic>();
|
||||||
|
|
||||||
services.AddTransient<IClientLogic, ClientLogic>();
|
DependencyManager.Instance.RegisterType<IWorkProcess, WorkModeling>();
|
||||||
services.AddTransient<IOilLogic, OilLogic>();
|
DependencyManager.Instance.RegisterType<AbstractMailWorker, MailKitWorker>(true);
|
||||||
services.AddTransient<IOrderLogic, OrderLogic>();
|
|
||||||
services.AddTransient<IRepairLogic, RepairLogic>();
|
|
||||||
services.AddTransient<IReportLogic, ReportLogic>();
|
|
||||||
services.AddTransient<IImplementerLogic, ImplementerLogic>();
|
|
||||||
services.AddTransient<IWorkProcess, WorkModeling>();
|
|
||||||
services.AddTransient<IMessageInfoLogic, MessageInfoLogic>();
|
|
||||||
|
|
||||||
services.AddTransient<AbstractSaveToExcel, SaveToExcel>();
|
DependencyManager.Instance.RegisterType<AbstractSaveToExcel, SaveToExcel>();
|
||||||
services.AddTransient<AbstractSaveToWord, SaveToWord>();
|
DependencyManager.Instance.RegisterType<AbstractSaveToWord, SaveToWord>();
|
||||||
services.AddTransient<AbstractSaveToPdf, SaveToPdf>();
|
DependencyManager.Instance.RegisterType<AbstractSaveToPdf, SaveToPdf>();
|
||||||
services.AddSingleton<AbstractMailWorker, MailKitWorker>();
|
|
||||||
|
|
||||||
services.AddTransient<FormMain>();
|
DependencyManager.Instance.RegisterType<FormMain>();
|
||||||
services.AddTransient<FormClients>();
|
DependencyManager.Instance.RegisterType<FormClients>();
|
||||||
services.AddTransient<FormOil>();
|
DependencyManager.Instance.RegisterType<FormOil>();
|
||||||
services.AddTransient<FormOils>();
|
DependencyManager.Instance.RegisterType<FormOils>();
|
||||||
services.AddTransient<FormCreateOrder>();
|
DependencyManager.Instance.RegisterType<FormCreateOrder>();
|
||||||
services.AddTransient<FormRepair>();
|
DependencyManager.Instance.RegisterType<FormRepair>();
|
||||||
services.AddTransient<FormRepairOil>();
|
DependencyManager.Instance.RegisterType<FormRepairOil>();
|
||||||
services.AddTransient<FormRepairs>();
|
DependencyManager.Instance.RegisterType<FormRepairs>();
|
||||||
services.AddTransient<FormReportRepairOils>();
|
DependencyManager.Instance.RegisterType<FormReportRepairOils>();
|
||||||
services.AddTransient<FormReportOrders>();
|
DependencyManager.Instance.RegisterType<FormReportOrders>();
|
||||||
services.AddTransient<FormImplementers>();
|
DependencyManager.Instance.RegisterType<FormImplementers>();
|
||||||
services.AddTransient<FormImplementer>();
|
DependencyManager.Instance.RegisterType<FormImplementer>();
|
||||||
services.AddTransient<FormMails>();
|
DependencyManager.Instance.RegisterType<FormMails>();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void MailCheck(object obj) => ServiceProvider?.GetService<AbstractMailWorker>()?.MailCheck();
|
private static void MailCheck(object obj) => DependencyManager.Instance.Resolve<AbstractMailWorker>()?.MailCheck();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user