8 лаба
This commit is contained in:
parent
f2a6d47960
commit
da7f9c64e9
2
.gitignore
vendored
2
.gitignore
vendored
@ -3,7 +3,7 @@
|
|||||||
## files generated by popular Visual Studio add-ons.
|
## files generated by popular Visual Studio add-ons.
|
||||||
##
|
##
|
||||||
## Get latest from https://github.com/github/gitignore/blob/main/VisualStudio.gitignore
|
## Get latest from https://github.com/github/gitignore/blob/main/VisualStudio.gitignore
|
||||||
|
ImplementationExtensions/
|
||||||
# User-specific files
|
# User-specific files
|
||||||
*.rsuser
|
*.rsuser
|
||||||
*.suo
|
*.suo
|
||||||
|
@ -0,0 +1,103 @@
|
|||||||
|
using AutomobilePlantContracts.BindingModels;
|
||||||
|
using AutomobilePlantContracts.BusinessLogicsContracts;
|
||||||
|
using AutomobilePlantContracts.StoragesContracts;
|
||||||
|
using AutomobilePlantDataModels;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO.Compression;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Reflection;
|
||||||
|
using System.Runtime.Serialization.Json;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace AutomobilePlantBusinessLogic.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(BackUpSaveBinidngModel model)
|
||||||
|
{
|
||||||
|
if (_backUpInfo == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_logger.LogDebug("Clear folder");
|
||||||
|
// зачистка папки и удаление старого архива
|
||||||
|
var dirInfo = new DirectoryInfo(model.FolderName);
|
||||||
|
if (dirInfo.Exists)
|
||||||
|
{
|
||||||
|
foreach (var file in dirInfo.GetFiles())
|
||||||
|
{
|
||||||
|
file.Delete();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_logger.LogDebug("Delete archive");
|
||||||
|
string fileName = $"{model.FolderName}.zip";
|
||||||
|
if (File.Exists(fileName))
|
||||||
|
{
|
||||||
|
File.Delete(fileName);
|
||||||
|
}
|
||||||
|
// берем метод для сохранения
|
||||||
|
_logger.LogDebug("Get assembly");
|
||||||
|
var typeIId = typeof(IId);
|
||||||
|
var assembly = typeIId.Assembly;
|
||||||
|
if (assembly == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException("Сборка не найдена", nameof(assembly));
|
||||||
|
}
|
||||||
|
var types = assembly.GetTypes();
|
||||||
|
var method = GetType().GetMethod("SaveToFile", BindingFlags.NonPublic | BindingFlags.Instance);
|
||||||
|
_logger.LogDebug("Find {count} types", types.Length);
|
||||||
|
foreach (var type in types)
|
||||||
|
{
|
||||||
|
if (type.IsInterface && type.GetInterface(typeIId.Name) != null)
|
||||||
|
{
|
||||||
|
var modelType = _backUpInfo.GetTypeByModelInterface(type.Name);
|
||||||
|
if (modelType == null)
|
||||||
|
{
|
||||||
|
throw new InvalidOperationException($"Не найден класс-модель для {type.Name}");
|
||||||
|
}
|
||||||
|
_logger.LogDebug("Call SaveToFile method for {name} type", type.Name);
|
||||||
|
// вызываем метод на выполнение
|
||||||
|
method?.MakeGenericMethod(modelType).Invoke(this, new object[] { model.FolderName });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_logger.LogDebug("Create zip and remove folder");
|
||||||
|
// архивируем
|
||||||
|
ZipFile.CreateFromDirectory(model.FolderName, fileName);
|
||||||
|
// удаляем папку
|
||||||
|
dirInfo.Delete(true);
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void SaveToFile<T>(string folderName) where T : class, new()
|
||||||
|
{
|
||||||
|
var records = _backUpInfo.GetList<T>();
|
||||||
|
if (records == null)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("{type} type get null list", typeof(T).Name);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var jsonFormatter = new DataContractJsonSerializer(typeof(List<T>));
|
||||||
|
using var fs = new FileStream(string.Format("{0}/{1}.json", folderName, typeof(T).Name), FileMode.OpenOrCreate);
|
||||||
|
jsonFormatter.WriteObject(fs, records);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,31 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace AutomobilePlantContracts.Attributes
|
||||||
|
{
|
||||||
|
[AttributeUsage(AttributeTargets.Property)]
|
||||||
|
public class ColumnAttribute : Attribute
|
||||||
|
{
|
||||||
|
public string Title { get; private set; }
|
||||||
|
|
||||||
|
public bool Visible { get; private set; }
|
||||||
|
|
||||||
|
public int Width { get; private set; }
|
||||||
|
|
||||||
|
public GridViewAutoSize GridViewAutoSize { get; private set; }
|
||||||
|
|
||||||
|
public bool IsUseAutoSize { get; private set; }
|
||||||
|
|
||||||
|
public ColumnAttribute(string title = "", bool visible = true, int width = 0, GridViewAutoSize gridViewAutoSize = GridViewAutoSize.None, bool isUseAutoSize = false)
|
||||||
|
{
|
||||||
|
Title = title;
|
||||||
|
Visible = visible;
|
||||||
|
Width = width;
|
||||||
|
GridViewAutoSize = gridViewAutoSize;
|
||||||
|
IsUseAutoSize = isUseAutoSize;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,27 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace AutomobilePlantContracts.Attributes
|
||||||
|
{
|
||||||
|
public enum GridViewAutoSize
|
||||||
|
{
|
||||||
|
NotSet = 0,
|
||||||
|
|
||||||
|
None = 1,
|
||||||
|
|
||||||
|
ColumnHeader = 2,
|
||||||
|
|
||||||
|
AllCellsExceptHeader = 4,
|
||||||
|
|
||||||
|
AllCells = 6,
|
||||||
|
|
||||||
|
DisplayedCellsExceptHeader = 8,
|
||||||
|
|
||||||
|
DisplayedCells = 10,
|
||||||
|
|
||||||
|
Fill = 16
|
||||||
|
}
|
||||||
|
}
|
@ -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="..\AbstractAutoDataModels\AutomobilePlantDataModels.csproj" />
|
<ProjectReference Include="..\AbstractAutoDataModels\AutomobilePlantDataModels.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
@ -0,0 +1,13 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace AutomobilePlantContracts.BindingModels
|
||||||
|
{
|
||||||
|
public class BackUpSaveBinidngModel
|
||||||
|
{
|
||||||
|
public string FolderName { get; set; } = string.Empty;
|
||||||
|
}
|
||||||
|
}
|
@ -15,5 +15,7 @@ namespace AutomobilePlantContracts.BindingModels
|
|||||||
public string Body { get; set; } = string.Empty;
|
public string Body { get; set; } = string.Empty;
|
||||||
|
|
||||||
public DateTime DateDelivery { get; set; }
|
public DateTime DateDelivery { get; set; }
|
||||||
|
|
||||||
|
public int Id { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -0,0 +1,15 @@
|
|||||||
|
using AutomobilePlantContracts.BindingModels;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace AutomobilePlantContracts.BusinessLogicsContracts
|
||||||
|
{
|
||||||
|
public interface IBackUpLogic
|
||||||
|
{
|
||||||
|
void CreateBackUp(BackUpSaveBinidngModel model);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,67 @@
|
|||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Unity;
|
||||||
|
|
||||||
|
namespace AutomobilePlantContracts.DI
|
||||||
|
{
|
||||||
|
public class DependencyManager
|
||||||
|
{
|
||||||
|
private readonly IDependencyContainer _dependencyManager;
|
||||||
|
|
||||||
|
private static DependencyManager? _manager;
|
||||||
|
|
||||||
|
private static readonly object _locjObject = new();
|
||||||
|
|
||||||
|
private DependencyManager()
|
||||||
|
{
|
||||||
|
_dependencyManager = new UnityServiceContainer();
|
||||||
|
}
|
||||||
|
|
||||||
|
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,40 @@
|
|||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace AutomobilePlantContracts.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,17 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace AutomobilePlantContracts.DI
|
||||||
|
{
|
||||||
|
public interface IImplementationExtension
|
||||||
|
{
|
||||||
|
public int Priority { get; }
|
||||||
|
/// <summary>
|
||||||
|
/// Регистрация сервисов
|
||||||
|
/// </summary>
|
||||||
|
public void RegisterServices();
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,62 @@
|
|||||||
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace AutomobilePlantContracts.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,55 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Reflection;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace AutomobilePlantContracts.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,59 @@
|
|||||||
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Unity;
|
||||||
|
using Unity.Microsoft.Logging;
|
||||||
|
|
||||||
|
namespace AutomobilePlantContracts.DI
|
||||||
|
{
|
||||||
|
public class UnityServiceContainer : IDependencyContainer
|
||||||
|
{
|
||||||
|
private UnityContainer? _unityContainer;
|
||||||
|
|
||||||
|
public UnityServiceContainer()
|
||||||
|
{
|
||||||
|
_unityContainer = new UnityContainer();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void AddLogging(Action<ILoggingBuilder> configure)
|
||||||
|
{
|
||||||
|
_unityContainer.AddExtension(new LoggingExtension(LoggerFactory.Create(configure)));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void RegisterType<T, U>(bool isSingle) where U : class, T where T : class
|
||||||
|
{
|
||||||
|
if (isSingle)
|
||||||
|
{
|
||||||
|
_unityContainer.RegisterSingleton<T, U>();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_unityContainer.RegisterType<T, U>();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void RegisterType<T>(bool isSingle) where T : class
|
||||||
|
{
|
||||||
|
if (isSingle)
|
||||||
|
{
|
||||||
|
_unityContainer.RegisterSingleton<T>();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_unityContainer.RegisterType<T>();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public T Resolve<T>()
|
||||||
|
{
|
||||||
|
|
||||||
|
return _unityContainer.Resolve<T>()!;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,15 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace AutomobilePlantContracts.StoragesContracts
|
||||||
|
{
|
||||||
|
public interface IBackUpInfo
|
||||||
|
{
|
||||||
|
List<T>? GetList<T>() where T : class, new();
|
||||||
|
|
||||||
|
Type? GetTypeByModelInterface(string modelInterfaceName);
|
||||||
|
}
|
||||||
|
}
|
@ -5,15 +5,19 @@ using System.Linq;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
|
using AutomobilePlantContracts.Attributes;
|
||||||
|
|
||||||
namespace AutomobilePlantContracts.ViewModel
|
namespace AutomobilePlantContracts.ViewModel
|
||||||
{
|
{
|
||||||
public class CarViewModel : ICarModel
|
public class CarViewModel : ICarModel
|
||||||
{
|
{
|
||||||
|
[Column(visible: false)]
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
[DisplayName("Название изделия")]
|
[Column(title: "Название", width: 150)]
|
||||||
public string CarName { get; set; } = string.Empty;
|
public string CarName { get; set; } = string.Empty;
|
||||||
[DisplayName("Цена")]
|
[Column(title: "Цена", width: 50)]
|
||||||
public double Price { get; set; }
|
public double Price { get; set; }
|
||||||
|
[Column(visible: false)]
|
||||||
public Dictionary<int, (IComponentModel, int)> CarComponents
|
public Dictionary<int, (IComponentModel, int)> CarComponents
|
||||||
{
|
{
|
||||||
get;
|
get;
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
using AutomobilePlantDataModels.Models;
|
using AutomobilePlantContracts.Attributes;
|
||||||
|
using AutomobilePlantDataModels.Models;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
@ -10,12 +11,13 @@ namespace AutomobilePlantContracts.ViewModel
|
|||||||
{
|
{
|
||||||
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: "Логин (эл. почта)", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)]
|
||||||
public string Email { get; set; } = string.Empty;
|
public string Email { get; set; } = string.Empty;
|
||||||
[DisplayName("Пароль")]
|
[Column(title: "Пароль", width: 150)]
|
||||||
public string Password { get; set; } = string.Empty;
|
public string Password { get; set; } = string.Empty;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,14 +5,17 @@ using System.Linq;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
|
using AutomobilePlantContracts.Attributes;
|
||||||
|
|
||||||
namespace AutomobilePlantContracts.ViewModel
|
namespace AutomobilePlantContracts.ViewModel
|
||||||
{
|
{
|
||||||
public class ComponentViewModel : IComponentModel
|
public class ComponentViewModel : IComponentModel
|
||||||
{
|
{
|
||||||
|
[Column(visible: false)]
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
[DisplayName("Название компонента")]
|
[Column(title: "Название", width: 150)]
|
||||||
public string ComponentName { get; set; } = string.Empty;
|
public string ComponentName { get; set; } = string.Empty;
|
||||||
[DisplayName("Цена")]
|
[Column(title: "Цена", width: 150)]
|
||||||
public double Cost { get; set; }
|
public double Cost { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
using AutomobilePlantDataModels.Models;
|
using AutomobilePlantContracts.Attributes;
|
||||||
|
using AutomobilePlantDataModels.Models;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
@ -10,18 +11,19 @@ namespace AutomobilePlantContracts.ViewModel
|
|||||||
{
|
{
|
||||||
public class ImplementerViewModel : IImplementerModel
|
public class ImplementerViewModel : IImplementerModel
|
||||||
{
|
{
|
||||||
|
[Column(visible: false)]
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
|
|
||||||
[DisplayName("ФИО исполнителя")]
|
[Column(title: "Имя", width: 150)]
|
||||||
public string ImplementerFIO { get; set; } = string.Empty;
|
public string ImplementerFIO { get; set; } = string.Empty;
|
||||||
|
|
||||||
[DisplayName("Пароль")]
|
[Column(title: "Пароль", width: 150)]
|
||||||
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,28 @@
|
|||||||
using AutomobilePlantDataModels.Models;
|
using AutomobilePlantContracts.Attributes;
|
||||||
|
using AutomobilePlantDataModels.Models;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
|
|
||||||
namespace AutomobilePlantContracts.ViewModel
|
namespace AutomobilePlantContracts.ViewModel
|
||||||
{
|
{
|
||||||
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: 100)]
|
||||||
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 { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -6,31 +6,35 @@ using System.Text;
|
|||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using AutomobilePlantDataModels.Enums;
|
using AutomobilePlantDataModels.Enums;
|
||||||
|
using AutomobilePlantContracts.Attributes;
|
||||||
|
|
||||||
namespace AutomobilePlantContracts.ViewModel
|
namespace AutomobilePlantContracts.ViewModel
|
||||||
{
|
{
|
||||||
public class OrderViewModel : IOrderModel
|
public class OrderViewModel : IOrderModel
|
||||||
{
|
{
|
||||||
[DisplayName("Номер")]
|
[Column(visible: false)]
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
[DisplayName("Клиент")]
|
[Column(title: "Клиент", width: 150)]
|
||||||
public string ClientName { get; set; } = string.Empty;
|
public string ClientName { get; set; } = string.Empty;
|
||||||
|
[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: 150)]
|
||||||
public string? ImplementerName { get; set; } = string.Empty;
|
public string? ImplementerName { get; set; } = string.Empty;
|
||||||
|
[Column(visible: false)]
|
||||||
public int CarId { get; set; }
|
public int CarId { get; set; }
|
||||||
[DisplayName("Изделие")]
|
[Column(title: "Машина", width: 150)]
|
||||||
public string CarName { get; set; } = string.Empty;
|
public string CarName { get; set; } = string.Empty;
|
||||||
[DisplayName("Количество")]
|
[Column(title: "Кол-во", width: 150)]
|
||||||
public int Count { get; set; }
|
public int Count { get; set; }
|
||||||
[DisplayName("Сумма")]
|
[Column(title: "Сумма", width: 150)]
|
||||||
public double Sum { get; set; }
|
public double Sum { get; set; }
|
||||||
[DisplayName("Статус")]
|
[Column(title: "Статус", width: 150)]
|
||||||
public OrderStatus Status { get; set; } = OrderStatus.Неизвестен;
|
public OrderStatus Status { get; set; } = OrderStatus.Неизвестен;
|
||||||
[DisplayName("Дата создания")]
|
[Column(title: "Дата создания", width: 150)]
|
||||||
public DateTime DateCreate { get; set; } = DateTime.SpecifyKind(DateTime.Now, DateTimeKind.Utc);
|
public DateTime DateCreate { get; set; } = DateTime.SpecifyKind(DateTime.Now, DateTimeKind.Utc);
|
||||||
[DisplayName("Дата выполнения")]
|
[Column(title: "Дата выполнения", width: 150)]
|
||||||
public DateTime? DateImplement { get; set; }
|
public DateTime? DateImplement { get; set; }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,7 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace AutomobilePlantDataModels.Models
|
namespace AutomobilePlantDataModels.Models
|
||||||
{
|
{
|
||||||
public interface IMessageInfoModel
|
public interface IMessageInfoModel : IId
|
||||||
{
|
{
|
||||||
string MessageId { get; }
|
string MessageId { get; }
|
||||||
|
|
||||||
|
@ -11,4 +11,8 @@
|
|||||||
<ProjectReference Include="..\AbstractAutoDataModels\AutomobilePlantDataModels.csproj" />
|
<ProjectReference Include="..\AbstractAutoDataModels\AutomobilePlantDataModels.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 AutomobilePlantContracts.StoragesContracts;
|
||||||
|
|
||||||
|
namespace AutomobilePlantListImplement.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,28 @@
|
|||||||
|
using AbstractShopContracts.StoragesContracts;
|
||||||
|
using AutomobilePlantContracts.DI;
|
||||||
|
using AutomobilePlantContracts.StoragesContracts;
|
||||||
|
using AutomobilePlantListImplement.Implements;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace AutomobilePlantListImplement
|
||||||
|
{
|
||||||
|
public class ListImplementationExtension : IImplementationExtension
|
||||||
|
{
|
||||||
|
public int Priority => 0;
|
||||||
|
|
||||||
|
public void RegisterServices()
|
||||||
|
{
|
||||||
|
DependencyManager.Instance.RegisterType<IClientStorage, ClientStorage>();
|
||||||
|
DependencyManager.Instance.RegisterType<IComponentStorage, ComponentStorage>();
|
||||||
|
DependencyManager.Instance.RegisterType<IImplementerStorage, ImplementerStorage>();
|
||||||
|
DependencyManager.Instance.RegisterType<IMessageInfoStorage, MessageInfoStorage>();
|
||||||
|
DependencyManager.Instance.RegisterType<IOrderStorage, OrderStorage>();
|
||||||
|
DependencyManager.Instance.RegisterType<ICarStorage, CarStorage>();
|
||||||
|
DependencyManager.Instance.RegisterType<IBackUpInfo, BackUpInfo>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -32,6 +32,7 @@ namespace AutomobilePlantListImplement.Models
|
|||||||
}
|
}
|
||||||
return new MessageInfoModel()
|
return new MessageInfoModel()
|
||||||
{
|
{
|
||||||
|
Id = model.Id,
|
||||||
MessageId = model.MessageId,
|
MessageId = model.MessageId,
|
||||||
ClientId = model.ClientId,
|
ClientId = model.ClientId,
|
||||||
SenderName = model.SenderName,
|
SenderName = model.SenderName,
|
||||||
@ -42,6 +43,7 @@ namespace AutomobilePlantListImplement.Models
|
|||||||
}
|
}
|
||||||
public MessageInfoViewModel GetViewModel => new()
|
public MessageInfoViewModel GetViewModel => new()
|
||||||
{
|
{
|
||||||
|
Id = Id,
|
||||||
MessageId = MessageId,
|
MessageId = MessageId,
|
||||||
ClientId = ClientId,
|
ClientId = ClientId,
|
||||||
SenderName = SenderName,
|
SenderName = SenderName,
|
||||||
@ -49,6 +51,7 @@ namespace AutomobilePlantListImplement.Models
|
|||||||
Subject = Subject,
|
Subject = Subject,
|
||||||
Body = Body,
|
Body = Body,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
public int Id { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
51
AutomobilePlant/AutomobilePlant/DataGridViewExtension.cs
Normal file
51
AutomobilePlant/AutomobilePlant/DataGridViewExtension.cs
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
using AutomobilePlantContracts.Attributes;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace AutomobilePlant
|
||||||
|
{
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
75
AutomobilePlant/AutomobilePlant/FormCar.Designer.cs
generated
75
AutomobilePlant/AutomobilePlant/FormCar.Designer.cs
generated
@ -53,33 +53,35 @@
|
|||||||
// CarNameLabel
|
// CarNameLabel
|
||||||
//
|
//
|
||||||
this.CarNameLabel.AutoSize = true;
|
this.CarNameLabel.AutoSize = true;
|
||||||
this.CarNameLabel.Location = new System.Drawing.Point(12, 9);
|
this.CarNameLabel.Location = new System.Drawing.Point(14, 12);
|
||||||
this.CarNameLabel.Name = "PackageNameLabel";
|
this.CarNameLabel.Name = "CarNameLabel";
|
||||||
this.CarNameLabel.Size = new System.Drawing.Size(65, 15);
|
this.CarNameLabel.Size = new System.Drawing.Size(84, 20);
|
||||||
this.CarNameLabel.TabIndex = 0;
|
this.CarNameLabel.TabIndex = 0;
|
||||||
this.CarNameLabel.Text = "Название: ";
|
this.CarNameLabel.Text = "Название: ";
|
||||||
//
|
//
|
||||||
// PriceLabel
|
// PriceLabel
|
||||||
//
|
//
|
||||||
this.PriceLabel.AutoSize = true;
|
this.PriceLabel.AutoSize = true;
|
||||||
this.PriceLabel.Location = new System.Drawing.Point(12, 43);
|
this.PriceLabel.Location = new System.Drawing.Point(14, 57);
|
||||||
this.PriceLabel.Name = "PriceLabel";
|
this.PriceLabel.Name = "PriceLabel";
|
||||||
this.PriceLabel.Size = new System.Drawing.Size(73, 15);
|
this.PriceLabel.Size = new System.Drawing.Size(90, 20);
|
||||||
this.PriceLabel.TabIndex = 1;
|
this.PriceLabel.TabIndex = 1;
|
||||||
this.PriceLabel.Text = "Стоимость: ";
|
this.PriceLabel.Text = "Стоимость: ";
|
||||||
//
|
//
|
||||||
// CarNameTextBox
|
// CarNameTextBox
|
||||||
//
|
//
|
||||||
this.CarNameTextBox.Location = new System.Drawing.Point(83, 6);
|
this.CarNameTextBox.Location = new System.Drawing.Point(95, 8);
|
||||||
this.CarNameTextBox.Name = "PackageNameTextBox";
|
this.CarNameTextBox.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||||
this.CarNameTextBox.Size = new System.Drawing.Size(283, 23);
|
this.CarNameTextBox.Name = "CarNameTextBox";
|
||||||
|
this.CarNameTextBox.Size = new System.Drawing.Size(323, 27);
|
||||||
this.CarNameTextBox.TabIndex = 2;
|
this.CarNameTextBox.TabIndex = 2;
|
||||||
//
|
//
|
||||||
// PriceTextBox
|
// PriceTextBox
|
||||||
//
|
//
|
||||||
this.PriceTextBox.Location = new System.Drawing.Point(83, 40);
|
this.PriceTextBox.Location = new System.Drawing.Point(95, 53);
|
||||||
|
this.PriceTextBox.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||||
this.PriceTextBox.Name = "PriceTextBox";
|
this.PriceTextBox.Name = "PriceTextBox";
|
||||||
this.PriceTextBox.Size = new System.Drawing.Size(283, 23);
|
this.PriceTextBox.Size = new System.Drawing.Size(323, 27);
|
||||||
this.PriceTextBox.TabIndex = 3;
|
this.PriceTextBox.TabIndex = 3;
|
||||||
//
|
//
|
||||||
// ComponentsGroupBox
|
// ComponentsGroupBox
|
||||||
@ -89,18 +91,21 @@
|
|||||||
this.ComponentsGroupBox.Controls.Add(this.ChangeButton);
|
this.ComponentsGroupBox.Controls.Add(this.ChangeButton);
|
||||||
this.ComponentsGroupBox.Controls.Add(this.AddButton);
|
this.ComponentsGroupBox.Controls.Add(this.AddButton);
|
||||||
this.ComponentsGroupBox.Controls.Add(this.DataGridView);
|
this.ComponentsGroupBox.Controls.Add(this.DataGridView);
|
||||||
this.ComponentsGroupBox.Location = new System.Drawing.Point(12, 80);
|
this.ComponentsGroupBox.Location = new System.Drawing.Point(14, 107);
|
||||||
|
this.ComponentsGroupBox.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||||
this.ComponentsGroupBox.Name = "ComponentsGroupBox";
|
this.ComponentsGroupBox.Name = "ComponentsGroupBox";
|
||||||
this.ComponentsGroupBox.Size = new System.Drawing.Size(722, 350);
|
this.ComponentsGroupBox.Padding = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||||
|
this.ComponentsGroupBox.Size = new System.Drawing.Size(825, 467);
|
||||||
this.ComponentsGroupBox.TabIndex = 5;
|
this.ComponentsGroupBox.TabIndex = 5;
|
||||||
this.ComponentsGroupBox.TabStop = false;
|
this.ComponentsGroupBox.TabStop = false;
|
||||||
this.ComponentsGroupBox.Text = "Компоненты";
|
this.ComponentsGroupBox.Text = "Компоненты";
|
||||||
//
|
//
|
||||||
// UpdateButton
|
// UpdateButton
|
||||||
//
|
//
|
||||||
this.UpdateButton.Location = new System.Drawing.Point(590, 203);
|
this.UpdateButton.Location = new System.Drawing.Point(674, 271);
|
||||||
|
this.UpdateButton.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||||
this.UpdateButton.Name = "UpdateButton";
|
this.UpdateButton.Name = "UpdateButton";
|
||||||
this.UpdateButton.Size = new System.Drawing.Size(110, 38);
|
this.UpdateButton.Size = new System.Drawing.Size(126, 51);
|
||||||
this.UpdateButton.TabIndex = 4;
|
this.UpdateButton.TabIndex = 4;
|
||||||
this.UpdateButton.Text = "Обновить";
|
this.UpdateButton.Text = "Обновить";
|
||||||
this.UpdateButton.UseVisualStyleBackColor = true;
|
this.UpdateButton.UseVisualStyleBackColor = true;
|
||||||
@ -108,9 +113,10 @@
|
|||||||
//
|
//
|
||||||
// DeleteButton
|
// DeleteButton
|
||||||
//
|
//
|
||||||
this.DeleteButton.Location = new System.Drawing.Point(590, 143);
|
this.DeleteButton.Location = new System.Drawing.Point(674, 191);
|
||||||
|
this.DeleteButton.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||||
this.DeleteButton.Name = "DeleteButton";
|
this.DeleteButton.Name = "DeleteButton";
|
||||||
this.DeleteButton.Size = new System.Drawing.Size(110, 38);
|
this.DeleteButton.Size = new System.Drawing.Size(126, 51);
|
||||||
this.DeleteButton.TabIndex = 3;
|
this.DeleteButton.TabIndex = 3;
|
||||||
this.DeleteButton.Text = "Удалить";
|
this.DeleteButton.Text = "Удалить";
|
||||||
this.DeleteButton.UseVisualStyleBackColor = true;
|
this.DeleteButton.UseVisualStyleBackColor = true;
|
||||||
@ -118,9 +124,10 @@
|
|||||||
//
|
//
|
||||||
// ChangeButton
|
// ChangeButton
|
||||||
//
|
//
|
||||||
this.ChangeButton.Location = new System.Drawing.Point(590, 82);
|
this.ChangeButton.Location = new System.Drawing.Point(674, 109);
|
||||||
|
this.ChangeButton.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||||
this.ChangeButton.Name = "ChangeButton";
|
this.ChangeButton.Name = "ChangeButton";
|
||||||
this.ChangeButton.Size = new System.Drawing.Size(110, 38);
|
this.ChangeButton.Size = new System.Drawing.Size(126, 51);
|
||||||
this.ChangeButton.TabIndex = 2;
|
this.ChangeButton.TabIndex = 2;
|
||||||
this.ChangeButton.Text = "Изменить";
|
this.ChangeButton.Text = "Изменить";
|
||||||
this.ChangeButton.UseVisualStyleBackColor = true;
|
this.ChangeButton.UseVisualStyleBackColor = true;
|
||||||
@ -128,9 +135,10 @@
|
|||||||
//
|
//
|
||||||
// AddButton
|
// AddButton
|
||||||
//
|
//
|
||||||
this.AddButton.Location = new System.Drawing.Point(590, 22);
|
this.AddButton.Location = new System.Drawing.Point(674, 29);
|
||||||
|
this.AddButton.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||||
this.AddButton.Name = "AddButton";
|
this.AddButton.Name = "AddButton";
|
||||||
this.AddButton.Size = new System.Drawing.Size(110, 38);
|
this.AddButton.Size = new System.Drawing.Size(126, 51);
|
||||||
this.AddButton.TabIndex = 1;
|
this.AddButton.TabIndex = 1;
|
||||||
this.AddButton.Text = "Добавить";
|
this.AddButton.Text = "Добавить";
|
||||||
this.AddButton.UseVisualStyleBackColor = true;
|
this.AddButton.UseVisualStyleBackColor = true;
|
||||||
@ -159,7 +167,8 @@
|
|||||||
dataGridViewCellStyle2.SelectionForeColor = System.Drawing.SystemColors.HighlightText;
|
dataGridViewCellStyle2.SelectionForeColor = System.Drawing.SystemColors.HighlightText;
|
||||||
dataGridViewCellStyle2.WrapMode = System.Windows.Forms.DataGridViewTriState.False;
|
dataGridViewCellStyle2.WrapMode = System.Windows.Forms.DataGridViewTriState.False;
|
||||||
this.DataGridView.DefaultCellStyle = dataGridViewCellStyle2;
|
this.DataGridView.DefaultCellStyle = dataGridViewCellStyle2;
|
||||||
this.DataGridView.Location = new System.Drawing.Point(6, 22);
|
this.DataGridView.Location = new System.Drawing.Point(7, 29);
|
||||||
|
this.DataGridView.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||||
this.DataGridView.Name = "DataGridView";
|
this.DataGridView.Name = "DataGridView";
|
||||||
dataGridViewCellStyle3.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
|
dataGridViewCellStyle3.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
|
||||||
dataGridViewCellStyle3.BackColor = System.Drawing.SystemColors.Control;
|
dataGridViewCellStyle3.BackColor = System.Drawing.SystemColors.Control;
|
||||||
@ -169,32 +178,39 @@
|
|||||||
dataGridViewCellStyle3.SelectionForeColor = System.Drawing.SystemColors.HighlightText;
|
dataGridViewCellStyle3.SelectionForeColor = System.Drawing.SystemColors.HighlightText;
|
||||||
dataGridViewCellStyle3.WrapMode = System.Windows.Forms.DataGridViewTriState.True;
|
dataGridViewCellStyle3.WrapMode = System.Windows.Forms.DataGridViewTriState.True;
|
||||||
this.DataGridView.RowHeadersDefaultCellStyle = dataGridViewCellStyle3;
|
this.DataGridView.RowHeadersDefaultCellStyle = dataGridViewCellStyle3;
|
||||||
|
this.DataGridView.RowHeadersWidth = 51;
|
||||||
this.DataGridView.RowTemplate.Height = 25;
|
this.DataGridView.RowTemplate.Height = 25;
|
||||||
this.DataGridView.Size = new System.Drawing.Size(561, 322);
|
this.DataGridView.Size = new System.Drawing.Size(641, 429);
|
||||||
this.DataGridView.TabIndex = 0;
|
this.DataGridView.TabIndex = 0;
|
||||||
//
|
//
|
||||||
// ID
|
// ID
|
||||||
//
|
//
|
||||||
this.ID.HeaderText = "ID";
|
this.ID.HeaderText = "ID";
|
||||||
|
this.ID.MinimumWidth = 6;
|
||||||
this.ID.Name = "ID";
|
this.ID.Name = "ID";
|
||||||
this.ID.Visible = false;
|
this.ID.Visible = false;
|
||||||
|
this.ID.Width = 125;
|
||||||
//
|
//
|
||||||
// ComponentNameField
|
// ComponentNameField
|
||||||
//
|
//
|
||||||
this.ComponentNameField.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
|
this.ComponentNameField.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
|
||||||
this.ComponentNameField.HeaderText = "Компонент";
|
this.ComponentNameField.HeaderText = "Компонент";
|
||||||
|
this.ComponentNameField.MinimumWidth = 6;
|
||||||
this.ComponentNameField.Name = "ComponentNameField";
|
this.ComponentNameField.Name = "ComponentNameField";
|
||||||
//
|
//
|
||||||
// CountField
|
// CountField
|
||||||
//
|
//
|
||||||
this.CountField.HeaderText = "Количество";
|
this.CountField.HeaderText = "Количество";
|
||||||
|
this.CountField.MinimumWidth = 6;
|
||||||
this.CountField.Name = "CountField";
|
this.CountField.Name = "CountField";
|
||||||
|
this.CountField.Width = 125;
|
||||||
//
|
//
|
||||||
// ButtonCancel
|
// ButtonCancel
|
||||||
//
|
//
|
||||||
this.ButtonCancel.Location = new System.Drawing.Point(602, 446);
|
this.ButtonCancel.Location = new System.Drawing.Point(688, 595);
|
||||||
|
this.ButtonCancel.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||||
this.ButtonCancel.Name = "ButtonCancel";
|
this.ButtonCancel.Name = "ButtonCancel";
|
||||||
this.ButtonCancel.Size = new System.Drawing.Size(110, 34);
|
this.ButtonCancel.Size = new System.Drawing.Size(126, 45);
|
||||||
this.ButtonCancel.TabIndex = 7;
|
this.ButtonCancel.TabIndex = 7;
|
||||||
this.ButtonCancel.Text = "Отмена";
|
this.ButtonCancel.Text = "Отмена";
|
||||||
this.ButtonCancel.UseVisualStyleBackColor = true;
|
this.ButtonCancel.UseVisualStyleBackColor = true;
|
||||||
@ -202,9 +218,10 @@
|
|||||||
//
|
//
|
||||||
// SaveButton
|
// SaveButton
|
||||||
//
|
//
|
||||||
this.SaveButton.Location = new System.Drawing.Point(486, 446);
|
this.SaveButton.Location = new System.Drawing.Point(555, 595);
|
||||||
|
this.SaveButton.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||||
this.SaveButton.Name = "SaveButton";
|
this.SaveButton.Name = "SaveButton";
|
||||||
this.SaveButton.Size = new System.Drawing.Size(110, 34);
|
this.SaveButton.Size = new System.Drawing.Size(126, 45);
|
||||||
this.SaveButton.TabIndex = 8;
|
this.SaveButton.TabIndex = 8;
|
||||||
this.SaveButton.Text = "Сохранить";
|
this.SaveButton.Text = "Сохранить";
|
||||||
this.SaveButton.UseVisualStyleBackColor = true;
|
this.SaveButton.UseVisualStyleBackColor = true;
|
||||||
@ -212,9 +229,9 @@
|
|||||||
//
|
//
|
||||||
// FormCar
|
// FormCar
|
||||||
//
|
//
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
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(746, 498);
|
this.ClientSize = new System.Drawing.Size(853, 664);
|
||||||
this.Controls.Add(this.SaveButton);
|
this.Controls.Add(this.SaveButton);
|
||||||
this.Controls.Add(this.ButtonCancel);
|
this.Controls.Add(this.ButtonCancel);
|
||||||
this.Controls.Add(this.ComponentsGroupBox);
|
this.Controls.Add(this.ComponentsGroupBox);
|
||||||
@ -222,8 +239,10 @@
|
|||||||
this.Controls.Add(this.CarNameTextBox);
|
this.Controls.Add(this.CarNameTextBox);
|
||||||
this.Controls.Add(this.PriceLabel);
|
this.Controls.Add(this.PriceLabel);
|
||||||
this.Controls.Add(this.CarNameLabel);
|
this.Controls.Add(this.CarNameLabel);
|
||||||
|
this.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||||
this.Name = "FormCar";
|
this.Name = "FormCar";
|
||||||
this.Text = "Изделие";
|
this.Text = "Изделие";
|
||||||
|
this.Load += new System.EventHandler(this.FormCar_Load);
|
||||||
this.ComponentsGroupBox.ResumeLayout(false);
|
this.ComponentsGroupBox.ResumeLayout(false);
|
||||||
((System.ComponentModel.ISupportInitialize)(this.DataGridView)).EndInit();
|
((System.ComponentModel.ISupportInitialize)(this.DataGridView)).EndInit();
|
||||||
this.ResumeLayout(false);
|
this.ResumeLayout(false);
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
using AutomobilePlantContracts.BindingModels;
|
using AutomobilePlantContracts.BindingModels;
|
||||||
using AutomobilePlantContracts.BusinessLogicsContracts;
|
using AutomobilePlantContracts.BusinessLogicsContracts;
|
||||||
|
using AutomobilePlantContracts.DI;
|
||||||
using AutomobilePlantContracts.SearchModel;
|
using AutomobilePlantContracts.SearchModel;
|
||||||
using AutomobilePlantDataModels.Models;
|
using AutomobilePlantDataModels.Models;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
@ -83,7 +84,7 @@ namespace AutomobilePlant
|
|||||||
private void AddButton_Click(object sender, EventArgs e)
|
private void AddButton_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
var service =
|
var service =
|
||||||
Program.ServiceProvider?.GetService(typeof(FormCarComponent));
|
DependencyManager.Instance.Resolve<FormCarComponent>();
|
||||||
if (service is FormCarComponent form)
|
if (service is FormCarComponent form)
|
||||||
{
|
{
|
||||||
if (form.ShowDialog() == DialogResult.OK)
|
if (form.ShowDialog() == DialogResult.OK)
|
||||||
@ -112,7 +113,7 @@ namespace AutomobilePlant
|
|||||||
if (DataGridView.SelectedRows.Count == 1)
|
if (DataGridView.SelectedRows.Count == 1)
|
||||||
{
|
{
|
||||||
var service =
|
var service =
|
||||||
Program.ServiceProvider?.GetService(typeof(FormCarComponent));
|
DependencyManager.Instance.Resolve<FormCarComponent>();
|
||||||
if (service is FormCarComponent form)
|
if (service is FormCarComponent form)
|
||||||
{
|
{
|
||||||
int id =
|
int id =
|
||||||
|
@ -1,64 +1,4 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<root>
|
||||||
<root>
|
|
||||||
<!--
|
|
||||||
Microsoft ResX Schema
|
|
||||||
|
|
||||||
Version 2.0
|
|
||||||
|
|
||||||
The primary goals of this format is to allow a simple XML format
|
|
||||||
that is mostly human readable. The generation and parsing of the
|
|
||||||
various data types are done through the TypeConverter classes
|
|
||||||
associated with the data types.
|
|
||||||
|
|
||||||
Example:
|
|
||||||
|
|
||||||
... ado.net/XML headers & schema ...
|
|
||||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
|
||||||
<resheader name="version">2.0</resheader>
|
|
||||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
|
||||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
|
||||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
|
||||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
|
||||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
|
||||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
|
||||||
</data>
|
|
||||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
|
||||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
|
||||||
<comment>This is a comment</comment>
|
|
||||||
</data>
|
|
||||||
|
|
||||||
There are any number of "resheader" rows that contain simple
|
|
||||||
name/value pairs.
|
|
||||||
|
|
||||||
Each data row contains a name, and value. The row also contains a
|
|
||||||
type or mimetype. Type corresponds to a .NET class that support
|
|
||||||
text/value conversion through the TypeConverter architecture.
|
|
||||||
Classes that don't support this are serialized and stored with the
|
|
||||||
mimetype set.
|
|
||||||
|
|
||||||
The mimetype is used for serialized objects, and tells the
|
|
||||||
ResXResourceReader how to depersist the object. This is currently not
|
|
||||||
extensible. For a given mimetype the value must be set accordingly:
|
|
||||||
|
|
||||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
|
||||||
that the ResXResourceWriter will generate, however the reader can
|
|
||||||
read any of the formats listed below.
|
|
||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.binary.base64
|
|
||||||
value : The object must be serialized with
|
|
||||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
|
||||||
: and then encoded with base64 encoding.
|
|
||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.soap.base64
|
|
||||||
value : The object must be serialized with
|
|
||||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
|
||||||
: and then encoded with base64 encoding.
|
|
||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
|
||||||
value : The object must be serialized into a byte array
|
|
||||||
: using a System.ComponentModel.TypeConverter
|
|
||||||
: and then encoded with base64 encoding.
|
|
||||||
-->
|
|
||||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||||
<xsd:element name="root" msdata:IsDataSet="true">
|
<xsd:element name="root" msdata:IsDataSet="true">
|
||||||
|
@ -10,6 +10,7 @@ using System.Linq;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
|
using AutomobilePlantContracts.DI;
|
||||||
|
|
||||||
namespace AutomobilePlant
|
namespace AutomobilePlant
|
||||||
{
|
{
|
||||||
@ -34,15 +35,7 @@ namespace AutomobilePlant
|
|||||||
{
|
{
|
||||||
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["CarName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
|
||||||
DataGridView.Columns["CarComponents"].Visible = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
_logger.LogInformation("Загрузка изделий");
|
_logger.LogInformation("Загрузка изделий");
|
||||||
|
|
||||||
@ -56,7 +49,7 @@ namespace AutomobilePlant
|
|||||||
|
|
||||||
private void AddButton_Click(object sender, EventArgs e)
|
private void AddButton_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
var service = Program.ServiceProvider?.GetService(typeof(FormCar));
|
var service = DependencyManager.Instance.Resolve<FormCar>();
|
||||||
|
|
||||||
if (service is FormCar form)
|
if (service is FormCar form)
|
||||||
{
|
{
|
||||||
@ -70,7 +63,7 @@ namespace AutomobilePlant
|
|||||||
{
|
{
|
||||||
if (DataGridView.SelectedRows.Count == 1)
|
if (DataGridView.SelectedRows.Count == 1)
|
||||||
{
|
{
|
||||||
var service = Program.ServiceProvider?.GetService(typeof(FormCar));
|
var service = DependencyManager.Instance.Resolve<FormCar>();
|
||||||
|
|
||||||
if (service is FormCar form)
|
if (service is FormCar form)
|
||||||
{
|
{
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
using AutomobilePlantContracts.BindingModels;
|
using AutomobilePlant;
|
||||||
|
using AutomobilePlantContracts.BindingModels;
|
||||||
using AutomobilePlantContracts.BusinessLogicsContracts;
|
using AutomobilePlantContracts.BusinessLogicsContracts;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
|
|
||||||
@ -26,13 +27,7 @@ namespace AbstractShopView
|
|||||||
{
|
{
|
||||||
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)
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
using AutomobilePlantContracts.BindingModels;
|
using AutomobilePlantContracts.BindingModels;
|
||||||
using AutomobilePlantContracts.BusinessLogicsContracts;
|
using AutomobilePlantContracts.BusinessLogicsContracts;
|
||||||
|
using AutomobilePlantContracts.DI;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
@ -32,14 +33,7 @@ namespace AutomobilePlant
|
|||||||
{
|
{
|
||||||
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["ComponentName"].AutoSizeMode =
|
|
||||||
DataGridViewAutoSizeColumnMode.Fill;
|
|
||||||
}
|
|
||||||
_logger.LogInformation("Загрузка компонентов");
|
_logger.LogInformation("Загрузка компонентов");
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
@ -52,7 +46,7 @@ namespace AutomobilePlant
|
|||||||
private void AddButton_Click(object sender, EventArgs e)
|
private void AddButton_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
var service =
|
var service =
|
||||||
Program.ServiceProvider?.GetService(typeof(FormComponent));
|
DependencyManager.Instance.Resolve<FormComponent>();
|
||||||
if (service is FormComponent form)
|
if (service is FormComponent form)
|
||||||
{
|
{
|
||||||
if (form.ShowDialog() == DialogResult.OK)
|
if (form.ShowDialog() == DialogResult.OK)
|
||||||
@ -66,7 +60,7 @@ namespace AutomobilePlant
|
|||||||
if (DataGridView.SelectedRows.Count == 1)
|
if (DataGridView.SelectedRows.Count == 1)
|
||||||
{
|
{
|
||||||
var service =
|
var service =
|
||||||
Program.ServiceProvider?.GetService(typeof(FormComponent));
|
DependencyManager.Instance.Resolve<FormComponent>();
|
||||||
if (service is FormComponent form)
|
if (service is FormComponent form)
|
||||||
{
|
{
|
||||||
form.Id =
|
form.Id =
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
using AutomobilePlantContracts.BindingModels;
|
using AutomobilePlantContracts.BindingModels;
|
||||||
using AutomobilePlantContracts.BusinessLogicsContracts;
|
using AutomobilePlantContracts.BusinessLogicsContracts;
|
||||||
|
using AutomobilePlantContracts.DI;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
@ -33,14 +34,7 @@ namespace AutomobilePlant
|
|||||||
{
|
{
|
||||||
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)
|
||||||
@ -53,7 +47,7 @@ namespace AutomobilePlant
|
|||||||
private void AddButton_Click(object sender, EventArgs e)
|
private void AddButton_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
var service =
|
var service =
|
||||||
Program.ServiceProvider?.GetService(typeof(FormImplementer));
|
DependencyManager.Instance.Resolve<FormImplementer>();
|
||||||
if (service is FormImplementer form)
|
if (service is FormImplementer form)
|
||||||
{
|
{
|
||||||
if (form.ShowDialog() == DialogResult.OK)
|
if (form.ShowDialog() == DialogResult.OK)
|
||||||
@ -67,7 +61,7 @@ namespace AutomobilePlant
|
|||||||
if (DataGridView.SelectedRows.Count == 1)
|
if (DataGridView.SelectedRows.Count == 1)
|
||||||
{
|
{
|
||||||
var service =
|
var service =
|
||||||
Program.ServiceProvider?.GetService(typeof(FormImplementer));
|
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);
|
||||||
|
24
AutomobilePlant/AutomobilePlant/FormMain.Designer.cs
generated
24
AutomobilePlant/AutomobilePlant/FormMain.Designer.cs
generated
@ -39,11 +39,12 @@
|
|||||||
this.клиентыToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
this.клиентыToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
this.исполнителиToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
this.исполнителиToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
this.начатьРаботуToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
this.начатьРаботуToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
|
this.письмаToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
this.DataGridView = new System.Windows.Forms.DataGridView();
|
this.DataGridView = new System.Windows.Forms.DataGridView();
|
||||||
this.CreateOrderButton = new System.Windows.Forms.Button();
|
this.CreateOrderButton = new System.Windows.Forms.Button();
|
||||||
this.IssuedOrderButton = new System.Windows.Forms.Button();
|
this.IssuedOrderButton = new System.Windows.Forms.Button();
|
||||||
this.UpdateListButton = new System.Windows.Forms.Button();
|
this.UpdateListButton = new System.Windows.Forms.Button();
|
||||||
this.письмаToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
this.бекапToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
this.MenuStrip.SuspendLayout();
|
this.MenuStrip.SuspendLayout();
|
||||||
((System.ComponentModel.ISupportInitialize)(this.DataGridView)).BeginInit();
|
((System.ComponentModel.ISupportInitialize)(this.DataGridView)).BeginInit();
|
||||||
this.SuspendLayout();
|
this.SuspendLayout();
|
||||||
@ -57,7 +58,8 @@
|
|||||||
this.клиентыToolStripMenuItem,
|
this.клиентыToolStripMenuItem,
|
||||||
this.исполнителиToolStripMenuItem,
|
this.исполнителиToolStripMenuItem,
|
||||||
this.начатьРаботуToolStripMenuItem,
|
this.начатьРаботуToolStripMenuItem,
|
||||||
this.письмаToolStripMenuItem});
|
this.письмаToolStripMenuItem,
|
||||||
|
this.бекапToolStripMenuItem});
|
||||||
this.MenuStrip.Location = new System.Drawing.Point(0, 0);
|
this.MenuStrip.Location = new System.Drawing.Point(0, 0);
|
||||||
this.MenuStrip.Name = "MenuStrip";
|
this.MenuStrip.Name = "MenuStrip";
|
||||||
this.MenuStrip.Padding = new System.Windows.Forms.Padding(7, 3, 0, 3);
|
this.MenuStrip.Padding = new System.Windows.Forms.Padding(7, 3, 0, 3);
|
||||||
@ -140,6 +142,13 @@
|
|||||||
this.начатьРаботуToolStripMenuItem.Text = "Начать работу";
|
this.начатьРаботуToolStripMenuItem.Text = "Начать работу";
|
||||||
this.начатьРаботуToolStripMenuItem.Click += new System.EventHandler(this.начатьРаботуToolStripMenuItem_Click);
|
this.начатьРаботуToolStripMenuItem.Click += new System.EventHandler(this.начатьРаботуToolStripMenuItem_Click);
|
||||||
//
|
//
|
||||||
|
// письмаToolStripMenuItem
|
||||||
|
//
|
||||||
|
this.письмаToolStripMenuItem.Name = "письмаToolStripMenuItem";
|
||||||
|
this.письмаToolStripMenuItem.Size = new System.Drawing.Size(77, 24);
|
||||||
|
this.письмаToolStripMenuItem.Text = "Письма";
|
||||||
|
this.письмаToolStripMenuItem.Click += new System.EventHandler(this.письмаToolStripMenuItem_Click);
|
||||||
|
//
|
||||||
// DataGridView
|
// DataGridView
|
||||||
//
|
//
|
||||||
this.DataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
this.DataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||||
@ -184,12 +193,12 @@
|
|||||||
this.UpdateListButton.UseVisualStyleBackColor = true;
|
this.UpdateListButton.UseVisualStyleBackColor = true;
|
||||||
this.UpdateListButton.Click += new System.EventHandler(this.UpdateListButton_Click);
|
this.UpdateListButton.Click += new System.EventHandler(this.UpdateListButton_Click);
|
||||||
//
|
//
|
||||||
// письмаToolStripMenuItem
|
// бекапToolStripMenuItem
|
||||||
//
|
//
|
||||||
this.письмаToolStripMenuItem.Name = "письмаToolStripMenuItem";
|
this.бекапToolStripMenuItem.Name = "бекапToolStripMenuItem";
|
||||||
this.письмаToolStripMenuItem.Size = new System.Drawing.Size(77, 24);
|
this.бекапToolStripMenuItem.Size = new System.Drawing.Size(64, 24);
|
||||||
this.письмаToolStripMenuItem.Text = "Письма";
|
this.бекапToolStripMenuItem.Text = "Бекап";
|
||||||
this.письмаToolStripMenuItem.Click += new System.EventHandler(this.письмаToolStripMenuItem_Click);
|
this.бекапToolStripMenuItem.Click += new System.EventHandler(this.бекапToolStripMenuItem_Click);
|
||||||
//
|
//
|
||||||
// FormMain
|
// FormMain
|
||||||
//
|
//
|
||||||
@ -232,5 +241,6 @@
|
|||||||
private ToolStripMenuItem исполнителиToolStripMenuItem;
|
private ToolStripMenuItem исполнителиToolStripMenuItem;
|
||||||
private ToolStripMenuItem начатьРаботуToolStripMenuItem;
|
private ToolStripMenuItem начатьРаботуToolStripMenuItem;
|
||||||
private ToolStripMenuItem письмаToolStripMenuItem;
|
private ToolStripMenuItem письмаToolStripMenuItem;
|
||||||
|
private ToolStripMenuItem бекапToolStripMenuItem;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,7 +1,9 @@
|
|||||||
using AbstractShopView;
|
using AbstractShopView;
|
||||||
using AutomobilePlantBusinessLogic.BusinessLogics;
|
using AutomobilePlantBusinessLogic.BusinessLogics;
|
||||||
|
using AutomobilePlantBusinessLogic.MailWorker;
|
||||||
using AutomobilePlantContracts.BindingModels;
|
using AutomobilePlantContracts.BindingModels;
|
||||||
using AutomobilePlantContracts.BusinessLogicsContracts;
|
using AutomobilePlantContracts.BusinessLogicsContracts;
|
||||||
|
using AutomobilePlantContracts.DI;
|
||||||
using AutomobilePlantDataModels.Enums;
|
using AutomobilePlantDataModels.Enums;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using System;
|
using System;
|
||||||
@ -22,14 +24,16 @@ namespace AutomobilePlant
|
|||||||
private readonly IOrderLogic _orderLogic;
|
private readonly IOrderLogic _orderLogic;
|
||||||
private readonly IReportLogic _reportLogic;
|
private readonly IReportLogic _reportLogic;
|
||||||
private readonly IWorkProcess _workProcess;
|
private readonly IWorkProcess _workProcess;
|
||||||
|
private readonly IBackUpLogic _backUpLogic;
|
||||||
|
|
||||||
public FormMain(ILogger<FormMain> logger, IOrderLogic orderLogic, IReportLogic reportLogic, IWorkProcess workProcess)
|
public FormMain(ILogger<FormMain> logger, IOrderLogic orderLogic, IReportLogic reportLogic, IWorkProcess workProcess, IBackUpLogic backUpLogic)
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
_orderLogic = orderLogic;
|
_orderLogic = orderLogic;
|
||||||
_reportLogic = reportLogic;
|
_reportLogic = reportLogic;
|
||||||
_workProcess = workProcess;
|
_workProcess = workProcess;
|
||||||
|
_backUpLogic = backUpLogic;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void FormMain_Load(object sender, EventArgs e)
|
private void FormMain_Load(object sender, EventArgs e)
|
||||||
@ -43,15 +47,7 @@ namespace AutomobilePlant
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var list = _orderLogic.ReadList(null);
|
DataGridView.FillAndConfigGrid(_orderLogic.ReadList(null));
|
||||||
|
|
||||||
if (list != null)
|
|
||||||
{
|
|
||||||
DataGridView.DataSource = list;
|
|
||||||
DataGridView.Columns["CarId"].Visible = false;
|
|
||||||
DataGridView.Columns["ClientId"].Visible = false;
|
|
||||||
DataGridView.Columns["ImplementerId"].Visible = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
_logger.LogInformation("Загрузка заказов");
|
_logger.LogInformation("Загрузка заказов");
|
||||||
}
|
}
|
||||||
@ -64,7 +60,7 @@ namespace AutomobilePlant
|
|||||||
|
|
||||||
private void КомпонентыToolStripMenuItem_Click(object sender, EventArgs e)
|
private void КомпонентыToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
var service = Program.ServiceProvider?.GetService(typeof(FormComponents));
|
var service = DependencyManager.Instance.Resolve<FormComponents>();
|
||||||
|
|
||||||
if (service is FormComponents form)
|
if (service is FormComponents form)
|
||||||
{
|
{
|
||||||
@ -74,7 +70,7 @@ namespace AutomobilePlant
|
|||||||
|
|
||||||
private void ИзделияToolStripMenuItem_Click(object sender, EventArgs e)
|
private void ИзделияToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
var service = Program.ServiceProvider?.GetService(typeof(FormCars));
|
var service = DependencyManager.Instance.Resolve<FormCars>();
|
||||||
|
|
||||||
if (service is FormCars form)
|
if (service is FormCars form)
|
||||||
{
|
{
|
||||||
@ -84,7 +80,7 @@ namespace AutomobilePlant
|
|||||||
|
|
||||||
private void CreateOrderButton_Click(object sender, EventArgs e)
|
private void CreateOrderButton_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)
|
||||||
{
|
{
|
||||||
@ -216,7 +212,7 @@ namespace AutomobilePlant
|
|||||||
|
|
||||||
private void ComponentCarsToolStripMenuItem_Click(object sender, EventArgs e)
|
private void ComponentCarsToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
var service = Program.ServiceProvider?.GetService(typeof(FormReportCarComponents));
|
var service = DependencyManager.Instance.Resolve<FormReportCarComponents>();
|
||||||
if (service is FormReportCarComponents form)
|
if (service is FormReportCarComponents form)
|
||||||
{
|
{
|
||||||
form.ShowDialog();
|
form.ShowDialog();
|
||||||
@ -225,7 +221,7 @@ namespace AutomobilePlant
|
|||||||
|
|
||||||
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();
|
||||||
@ -234,7 +230,7 @@ namespace AutomobilePlant
|
|||||||
|
|
||||||
private void клиентыToolStripMenuItem_Click(object sender, EventArgs e)
|
private void клиентыToolStripMenuItem_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();
|
||||||
@ -243,7 +239,7 @@ namespace AutomobilePlant
|
|||||||
|
|
||||||
private void исполнителиToolStripMenuItem_Click(object sender, EventArgs e)
|
private void исполнителиToolStripMenuItem_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();
|
||||||
@ -252,18 +248,28 @@ namespace AutomobilePlant
|
|||||||
|
|
||||||
private void начатьРаботуToolStripMenuItem_Click(object sender, EventArgs e)
|
private void начатьРаботуToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
_workProcess.DoWork((Program.ServiceProvider?.GetService(typeof(IImplementerLogic)) as IImplementerLogic)!, _orderLogic);
|
_workProcess.DoWork(DependencyManager.Instance.Resolve<IImplementerLogic>(), _orderLogic);
|
||||||
MessageBox.Show("Процесс обработки запущен", "Сообщение",
|
MessageBox.Show("Процесс обработки запущен", "Сообщение",
|
||||||
MessageBoxButtons.OK, MessageBoxIcon.Information);
|
MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void письмаToolStripMenuItem_Click(object sender, EventArgs e)
|
private void письмаToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
var service = Program.ServiceProvider?.GetService(typeof(FormMessages));
|
var service = DependencyManager.Instance.Resolve<FormMessages>();
|
||||||
if (service is FormMessages form)
|
if (service is FormMessages form)
|
||||||
{
|
{
|
||||||
form.ShowDialog();
|
form.ShowDialog();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void бекапToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
using var dialog = new FolderBrowserDialog();
|
||||||
|
if (dialog.ShowDialog() == DialogResult.OK)
|
||||||
|
{
|
||||||
|
_backUpLogic.CreateBackUp(new BackUpSaveBinidngModel { FolderName = dialog.SelectedPath});
|
||||||
|
MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
using AbstractShopView;
|
using AbstractShopView;
|
||||||
|
using AutomobilePlantBusinessLogic.BusinessLogics;
|
||||||
using AutomobilePlantContracts.BindingModels;
|
using AutomobilePlantContracts.BindingModels;
|
||||||
using AutomobilePlantContracts.BusinessLogicsContracts;
|
using AutomobilePlantContracts.BusinessLogicsContracts;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
@ -36,14 +37,7 @@ namespace AutomobilePlant
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var list = _logic.ReadList(null);
|
dataGridView.FillAndConfigGrid(_logic.ReadList(null));
|
||||||
if (list != null)
|
|
||||||
{
|
|
||||||
dataGridView.DataSource = list;
|
|
||||||
dataGridView.Columns["MessageId"].Visible = false;
|
|
||||||
dataGridView.Columns["ClientId"].Visible = false;
|
|
||||||
dataGridView.Columns["SenderName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
|
||||||
}
|
|
||||||
_logger.LogInformation("Загрузка клиентов");
|
_logger.LogInformation("Загрузка клиентов");
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
|
@ -12,13 +12,13 @@ using AbstractShopView;
|
|||||||
using AbstractShopContracts.StoragesContracts;
|
using AbstractShopContracts.StoragesContracts;
|
||||||
using AutomobilePlantBusinessLogic.MailWorker;
|
using AutomobilePlantBusinessLogic.MailWorker;
|
||||||
using AutomobilePlantContracts.BindingModels;
|
using AutomobilePlantContracts.BindingModels;
|
||||||
|
using AutomobilePlantContracts.DI;
|
||||||
|
|
||||||
namespace AutomobilePlant
|
namespace AutomobilePlant
|
||||||
{
|
{
|
||||||
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>
|
||||||
@ -28,13 +28,12 @@ namespace AutomobilePlant
|
|||||||
// 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,
|
||||||
@ -50,56 +49,53 @@ namespace AutomobilePlant
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
var logger = _serviceProvider.GetService<ILogger>();
|
var logger = DependencyManager.Instance.Resolve<ILogger>();
|
||||||
logger?.LogError(ex, "Îøèáêà ðàáîòû ñ ïî÷òîé");
|
logger?.LogError(ex, "Îøèáêà ðàáîòû ñ ïî÷òîé");
|
||||||
}
|
}
|
||||||
|
|
||||||
Application.Run(_serviceProvider.GetRequiredService<FormMain>());
|
Application.Run(DependencyManager.Instance.Resolve<FormMain>());
|
||||||
}
|
}
|
||||||
private static void ConfigureServices(ServiceCollection services)
|
private static void InitDependency()
|
||||||
{
|
{
|
||||||
services.AddLogging(option =>
|
DependencyManager.InitDependency();
|
||||||
|
|
||||||
|
DependencyManager.Instance.AddLogging(option =>
|
||||||
{
|
{
|
||||||
option.SetMinimumLevel(LogLevel.Information);
|
option.SetMinimumLevel(LogLevel.Information);
|
||||||
option.AddNLog("nlog.config");
|
option.AddNLog("nlog.config");
|
||||||
});
|
});
|
||||||
services.AddTransient<IComponentStorage, ComponentStorage>();
|
|
||||||
services.AddTransient<IOrderStorage, OrderStorage>();
|
DependencyManager.Instance.RegisterType<IComponentLogic, ComponentLogic>();
|
||||||
services.AddTransient<ICarStorage, CarStorage>();
|
DependencyManager.Instance.RegisterType<IOrderLogic, OrderLogic>();
|
||||||
services.AddTransient<IClientStorage, ClientStorage>();
|
DependencyManager.Instance.RegisterType<ICarLogic, CarLogic>();
|
||||||
services.AddTransient<IImplementerStorage, ImplementerStorage>();
|
DependencyManager.Instance.RegisterType<IReportLogic, ReportLogic>();
|
||||||
services.AddTransient<IMessageInfoStorage, MessageStorage>();
|
DependencyManager.Instance.RegisterType<IMessageInfoLogic, MessageLogic>();
|
||||||
|
DependencyManager.Instance.RegisterType<IClientLogic, ClientLogic>();
|
||||||
|
DependencyManager.Instance.RegisterType<IImplementerLogic, ImplementerLogic>();
|
||||||
|
DependencyManager.Instance.RegisterType<IBackUpLogic, BackUpLogic>();
|
||||||
|
|
||||||
services.AddTransient<IComponentLogic, ComponentLogic>();
|
DependencyManager.Instance.RegisterType<AbstractMailWorker, MailKitWorker>(true);
|
||||||
services.AddTransient<IOrderLogic, OrderLogic>();
|
DependencyManager.Instance.RegisterType<IWorkProcess, WorkModeling>();
|
||||||
services.AddTransient<ICarLogic, CarLogic>();
|
|
||||||
services.AddTransient<IReportLogic, ReportLogic>();
|
|
||||||
services.AddTransient<IMessageInfoLogic, MessageLogic>();
|
|
||||||
services.AddTransient<IClientLogic, ClientLogic>();
|
|
||||||
services.AddTransient<IImplementerLogic, ImplementerLogic>();
|
|
||||||
|
|
||||||
services.AddSingleton<AbstractMailWorker, MailKitWorker>();
|
DependencyManager.Instance.RegisterType<AbstractSaveToExcel, SaveToExcel>();
|
||||||
services.AddTransient<IWorkProcess, WorkModeling>();
|
DependencyManager.Instance.RegisterType<AbstractSaveToWord, SaveToWord>();
|
||||||
|
DependencyManager.Instance.RegisterType<AbstractSaveToPdf, SaveToPdf>();
|
||||||
|
|
||||||
services.AddTransient<AbstractSaveToExcel, SaveToExcel>();
|
DependencyManager.Instance.RegisterType<FormMain>();
|
||||||
services.AddTransient<AbstractSaveToWord, SaveToWord>();
|
DependencyManager.Instance.RegisterType<FormComponent>();
|
||||||
services.AddTransient<AbstractSaveToPdf, SaveToPdf>();
|
DependencyManager.Instance.RegisterType<FormComponents>();
|
||||||
|
DependencyManager.Instance.RegisterType<FormCreateOrder>();
|
||||||
services.AddTransient<FormMain>();
|
DependencyManager.Instance.RegisterType<FormCar>();
|
||||||
services.AddTransient<FormComponent>();
|
DependencyManager.Instance.RegisterType<FormCarComponent>();
|
||||||
services.AddTransient<FormComponents>();
|
DependencyManager.Instance.RegisterType<FormCars>();
|
||||||
services.AddTransient<FormCreateOrder>();
|
DependencyManager.Instance.RegisterType<FormReportCarComponents>();
|
||||||
services.AddTransient<FormCar>();
|
DependencyManager.Instance.RegisterType<FormReportOrders>();
|
||||||
services.AddTransient<FormCarComponent>();
|
DependencyManager.Instance.RegisterType<FormClients>();
|
||||||
services.AddTransient<FormCars>();
|
DependencyManager.Instance.RegisterType<FormImplementer>();
|
||||||
services.AddTransient<FormReportCarComponents>();
|
DependencyManager.Instance.RegisterType<FormImplementers>();
|
||||||
services.AddTransient<FormReportOrders>();
|
DependencyManager.Instance.RegisterType<FormMessages>();
|
||||||
services.AddTransient<FormClients>();
|
|
||||||
services.AddTransient<FormImplementer>();
|
|
||||||
services.AddTransient<FormImplementers>();
|
|
||||||
services.AddTransient<FormMessages>();
|
|
||||||
}
|
}
|
||||||
private static void MailCheck(object obj) => ServiceProvider?.GetService<AbstractMailWorker>()?.MailCheck();
|
private static void MailCheck(object obj) => DependencyManager.Instance.Resolve<AbstractMailWorker>()?.MailCheck();
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -19,4 +19,8 @@
|
|||||||
<ProjectReference Include="..\AbstractAutoContracts\AutomobilePlantContracts.csproj" />
|
<ProjectReference Include="..\AbstractAutoContracts\AutomobilePlantContracts.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
|
||||||
|
<Exec Command="copy /Y "$(TargetDir)*.dll" "$(SolutionDir)ImplementationExtensions\*.dll"" />
|
||||||
|
</Target>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
@ -0,0 +1,28 @@
|
|||||||
|
using AbstractShopContracts.StoragesContracts;
|
||||||
|
using AutomobilePlantContracts.DI;
|
||||||
|
using AutomobilePlantContracts.StoragesContracts;
|
||||||
|
using AutomobilePlantDataBaseImplements.Implements;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace AutomobilePlantDataBaseImplements
|
||||||
|
{
|
||||||
|
public class DBImplementationExtension : IImplementationExtension
|
||||||
|
{
|
||||||
|
public int Priority => 2;
|
||||||
|
|
||||||
|
public void RegisterServices()
|
||||||
|
{
|
||||||
|
DependencyManager.Instance.RegisterType<IClientStorage, ClientStorage>();
|
||||||
|
DependencyManager.Instance.RegisterType<IComponentStorage, ComponentStorage>();
|
||||||
|
DependencyManager.Instance.RegisterType<IImplementerStorage, ImplementerStorage>();
|
||||||
|
DependencyManager.Instance.RegisterType<IMessageInfoStorage, MessageStorage>();
|
||||||
|
DependencyManager.Instance.RegisterType<IOrderStorage, OrderStorage>();
|
||||||
|
DependencyManager.Instance.RegisterType<ICarStorage, CarStorage>();
|
||||||
|
DependencyManager.Instance.RegisterType<IBackUpInfo, BackUpInfo>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,32 @@
|
|||||||
|
using AutomobilePlantContracts.StoragesContracts;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace AutomobilePlantDataBaseImplements.Implements
|
||||||
|
{
|
||||||
|
public class BackUpInfo : IBackUpInfo
|
||||||
|
{
|
||||||
|
public List<T>? GetList<T>() where T : class, new()
|
||||||
|
{
|
||||||
|
using var context = new AutoPlantDataBase();
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -8,17 +8,22 @@ using System.Text;
|
|||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using AutomobilePlantContracts.BindingModels;
|
using AutomobilePlantContracts.BindingModels;
|
||||||
using AutomobilePlantContracts.ViewModel;
|
using AutomobilePlantContracts.ViewModel;
|
||||||
|
using System.Runtime.Serialization;
|
||||||
|
|
||||||
namespace AutomobilePlantDataBaseImplements.Models
|
namespace AutomobilePlantDataBaseImplements.Models
|
||||||
{
|
{
|
||||||
|
[DataContract]
|
||||||
public class Car : ICarModel
|
public class Car : ICarModel
|
||||||
{
|
{
|
||||||
|
[DataMember]
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
|
|
||||||
[Required]
|
[Required]
|
||||||
|
[DataMember]
|
||||||
public string CarName { get; set; } = string.Empty;
|
public string CarName { get; set; } = string.Empty;
|
||||||
|
|
||||||
[Required]
|
[Required]
|
||||||
|
[DataMember]
|
||||||
public double Price { get; set; }
|
public double Price { get; set; }
|
||||||
|
|
||||||
private Dictionary<int, (IComponentModel, int)>? _carComponents = null;
|
private Dictionary<int, (IComponentModel, int)>? _carComponents = null;
|
||||||
|
@ -2,22 +2,28 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Runtime.Serialization;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace AutomobilePlantDataBaseImplements.Models
|
namespace AutomobilePlantDataBaseImplements.Models
|
||||||
{
|
{
|
||||||
|
|
||||||
public class CarComponent
|
public class CarComponent
|
||||||
{
|
{
|
||||||
|
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
|
|
||||||
[Required]
|
[Required]
|
||||||
|
|
||||||
public int CarId { get; set; }
|
public int CarId { get; set; }
|
||||||
|
|
||||||
[Required]
|
[Required]
|
||||||
|
|
||||||
public int ComponentId { get; set; }
|
public int ComponentId { get; set; }
|
||||||
|
|
||||||
[Required]
|
[Required]
|
||||||
|
|
||||||
public int Count { get; set; }
|
public int Count { get; set; }
|
||||||
|
|
||||||
public virtual Component Component { get; set; } = new();
|
public virtual Component Component { get; set; } = new();
|
||||||
|
@ -10,20 +10,26 @@ using System.ComponentModel.DataAnnotations;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using System.Runtime.Serialization;
|
||||||
|
|
||||||
namespace AutomobilePlantDataBaseImplements.Models
|
namespace AutomobilePlantDataBaseImplements.Models
|
||||||
{
|
{
|
||||||
|
[DataContract]
|
||||||
public class Client : IClientModel
|
public class Client : IClientModel
|
||||||
{
|
{
|
||||||
|
[DataMember]
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
|
|
||||||
[Required]
|
[Required]
|
||||||
|
[DataMember]
|
||||||
public string ClientFIO { get; set; } = string.Empty;
|
public string ClientFIO { get; set; } = string.Empty;
|
||||||
|
|
||||||
[Required]
|
[Required]
|
||||||
|
[DataMember]
|
||||||
public string Email { get; set; } = string.Empty;
|
public string Email { get; set; } = string.Empty;
|
||||||
|
|
||||||
[Required]
|
[Required]
|
||||||
|
[DataMember]
|
||||||
public string Password { get; set; } = string.Empty;
|
public string Password { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
|
||||||
|
@ -8,17 +8,22 @@ using System.ComponentModel.DataAnnotations;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using System.Runtime.Serialization;
|
||||||
|
|
||||||
namespace AutomobilePlantDataBaseImplements.Models
|
namespace AutomobilePlantDataBaseImplements.Models
|
||||||
{
|
{
|
||||||
|
[DataContract]
|
||||||
public class Component : IComponentModel
|
public class Component : IComponentModel
|
||||||
{
|
{
|
||||||
|
[DataMember]
|
||||||
public int Id { get; private set; }
|
public int Id { get; private set; }
|
||||||
|
|
||||||
[Required]
|
[Required]
|
||||||
|
[DataMember]
|
||||||
public string ComponentName { get; private set; } = string.Empty;
|
public string ComponentName { get; private set; } = string.Empty;
|
||||||
|
|
||||||
[Required]
|
[Required]
|
||||||
|
[DataMember]
|
||||||
public double Cost { get; set; }
|
public double Cost { get; set; }
|
||||||
|
|
||||||
[ForeignKey("ComponentId")]
|
[ForeignKey("ComponentId")]
|
||||||
|
@ -8,22 +8,29 @@ using System.ComponentModel.DataAnnotations;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using System.Runtime.Serialization;
|
||||||
|
|
||||||
namespace AutomobilePlantDataBaseImplements.Models
|
namespace AutomobilePlantDataBaseImplements.Models
|
||||||
{
|
{
|
||||||
|
[DataContract]
|
||||||
public class Implementer : IImplementerModel
|
public class Implementer : IImplementerModel
|
||||||
{
|
{
|
||||||
|
[DataMember]
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
|
|
||||||
[Required]
|
[Required]
|
||||||
|
[DataMember]
|
||||||
public string ImplementerFIO { get; set; } = string.Empty;
|
public string ImplementerFIO { get; set; } = string.Empty;
|
||||||
|
|
||||||
[Required]
|
[Required]
|
||||||
|
[DataMember]
|
||||||
public int WorkExperience { get; set; }
|
public int WorkExperience { get; set; }
|
||||||
[Required]
|
[Required]
|
||||||
|
[DataMember]
|
||||||
public int Qualification { get; set; }
|
public int Qualification { get; set; }
|
||||||
|
|
||||||
[Required]
|
[Required]
|
||||||
|
[DataMember]
|
||||||
public string Password { get; set; } = string.Empty;
|
public string Password { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
|
||||||
|
@ -7,24 +7,28 @@ using System.Collections.Generic;
|
|||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
using System.ComponentModel.DataAnnotations.Schema;
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Runtime.Serialization;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace AutomobilePlantDataBaseImplements.Models
|
namespace AutomobilePlantDataBaseImplements.Models
|
||||||
{
|
{
|
||||||
|
[DataContract]
|
||||||
public class MessageInfo : IMessageInfoModel
|
public class MessageInfo : IMessageInfoModel
|
||||||
{
|
{
|
||||||
[Key]
|
[Key]
|
||||||
|
[DataMember]
|
||||||
public string MessageId { get; set; } = string.Empty;
|
public string MessageId { get; set; } = string.Empty;
|
||||||
|
[DataMember]
|
||||||
public int? ClientId { get; set; }
|
public int? ClientId { get; set; }
|
||||||
public Client? client { get; private set; }
|
public Client? client { get; private set; }
|
||||||
|
[DataMember]
|
||||||
public string SenderName { get; set; } = string.Empty;
|
public string SenderName { get; set; } = string.Empty;
|
||||||
|
[DataMember]
|
||||||
public DateTime DateDelivery { get; set; }
|
public DateTime DateDelivery { get; set; }
|
||||||
|
[DataMember]
|
||||||
public string Subject { get; set; } = string.Empty;
|
public string Subject { get; set; } = string.Empty;
|
||||||
|
[DataMember]
|
||||||
public string Body { get; set; } = string.Empty;
|
public string Body { get; set; } = string.Empty;
|
||||||
public static MessageInfo? Create(MessageInfoBindingModel? model)
|
public static MessageInfo? Create(MessageInfoBindingModel? model)
|
||||||
{
|
{
|
||||||
@ -33,7 +37,7 @@ namespace AutomobilePlantDataBaseImplements.Models
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return new MessageInfo()
|
return new MessageInfo()
|
||||||
{
|
{ Id = model.Id,
|
||||||
MessageId = model.MessageId,
|
MessageId = model.MessageId,
|
||||||
ClientId = model.ClientId,
|
ClientId = model.ClientId,
|
||||||
SenderName = model.SenderName,
|
SenderName = model.SenderName,
|
||||||
@ -43,7 +47,7 @@ namespace AutomobilePlantDataBaseImplements.Models
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
public MessageInfoViewModel GetViewModel => new()
|
public MessageInfoViewModel GetViewModel => new()
|
||||||
{
|
{ Id = Id,
|
||||||
MessageId = MessageId,
|
MessageId = MessageId,
|
||||||
ClientId = ClientId,
|
ClientId = ClientId,
|
||||||
SenderName = SenderName,
|
SenderName = SenderName,
|
||||||
@ -51,5 +55,7 @@ namespace AutomobilePlantDataBaseImplements.Models
|
|||||||
Subject = Subject,
|
Subject = Subject,
|
||||||
Body = Body,
|
Body = Body,
|
||||||
};
|
};
|
||||||
|
[NotMapped]
|
||||||
|
public int Id {get; set;}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,33 +8,48 @@ using System.ComponentModel.DataAnnotations;
|
|||||||
using System.ComponentModel.DataAnnotations.Schema;
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
using System.Diagnostics.CodeAnalysis;
|
using System.Diagnostics.CodeAnalysis;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Runtime.Serialization;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace AutomobilePlantDataBaseImplements.Models
|
namespace AutomobilePlantDataBaseImplements.Models
|
||||||
{
|
{
|
||||||
|
[DataContract]
|
||||||
public class Order : IOrderModel
|
public class Order : IOrderModel
|
||||||
{
|
{
|
||||||
|
[DataMember]
|
||||||
public int Id { get; private set; }
|
public int Id { get; private set; }
|
||||||
[Required]
|
[Required]
|
||||||
|
[DataMember]
|
||||||
public int CarId { get; private set; }
|
public int CarId { get; private set; }
|
||||||
[Required]
|
[Required]
|
||||||
|
[DataMember]
|
||||||
public int ClientId { get; private set; }
|
public int ClientId { get; private set; }
|
||||||
|
[DataMember]
|
||||||
public string ClientName { get; private set; } = string.Empty;
|
public string ClientName { get; private set; } = string.Empty;
|
||||||
|
[DataMember]
|
||||||
public int? ImplementerId { get; private set; }
|
public int? ImplementerId { get; private set; }
|
||||||
|
[DataMember]
|
||||||
public string? ImplementerName { get; private set; } = string.Empty;
|
public string? ImplementerName { get; private set; } = string.Empty;
|
||||||
|
[DataMember]
|
||||||
public string CarName { get; private set; } = string.Empty;
|
public string CarName { get; private set; } = string.Empty;
|
||||||
|
|
||||||
public Client client { get; private set; }
|
public Client client { get; private set; }
|
||||||
public Car car { get; private set; }
|
public Car car { get; private set; }
|
||||||
public Implementer? implementer { get; private set; }
|
public Implementer? implementer { get; private set; }
|
||||||
[Required]
|
[Required]
|
||||||
|
[DataMember]
|
||||||
public int Count { get; private set; }
|
public int Count { get; private set; }
|
||||||
[Required]
|
[Required]
|
||||||
|
[DataMember]
|
||||||
public double Sum { get; private set; }
|
public double Sum { get; private set; }
|
||||||
[Required]
|
[Required]
|
||||||
|
[DataMember]
|
||||||
public OrderStatus Status { get; private set; } = OrderStatus.Неизвестен;
|
public OrderStatus Status { get; private set; } = OrderStatus.Неизвестен;
|
||||||
[Required]
|
[Required]
|
||||||
|
[DataMember]
|
||||||
public DateTime DateCreate { get; private set; } = DateTime.SpecifyKind(DateTime.Now, DateTimeKind.Utc);
|
public DateTime DateCreate { get; private set; } = DateTime.SpecifyKind(DateTime.Now, DateTimeKind.Utc);
|
||||||
|
[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)
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>net6.0</TargetFramework>
|
<TargetFramework>net6.0</TargetFramework>
|
||||||
@ -11,4 +11,8 @@
|
|||||||
<ProjectReference Include="..\AbstractAutoDataModels\AutomobilePlantDataModels.csproj" />
|
<ProjectReference Include="..\AbstractAutoDataModels\AutomobilePlantDataModels.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
|
||||||
|
<Exec Command="copy /Y "$(TargetDir)*.dll" "$(SolutionDir)ImplementationExtensions\*.dll"" />
|
||||||
|
</Target>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
@ -0,0 +1,28 @@
|
|||||||
|
using AbstractShopContracts.StoragesContracts;
|
||||||
|
using AutomobilePlantContracts.DI;
|
||||||
|
using AutomobilePlantContracts.StoragesContracts;
|
||||||
|
using AutomomilePlantFileImplement.Implements;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace AutomomilePlantFileImplement
|
||||||
|
{
|
||||||
|
public class FileImplementationExtension : IImplementationExtension
|
||||||
|
{
|
||||||
|
public int Priority => 1;
|
||||||
|
|
||||||
|
public void RegisterServices()
|
||||||
|
{
|
||||||
|
DependencyManager.Instance.RegisterType<IClientStorage, ClientStorage>();
|
||||||
|
DependencyManager.Instance.RegisterType<IComponentStorage, ComponentStorage>();
|
||||||
|
DependencyManager.Instance.RegisterType<IImplementerStorage, ImplementerStorage>();
|
||||||
|
DependencyManager.Instance.RegisterType<IMessageInfoStorage, MessageStorage>();
|
||||||
|
DependencyManager.Instance.RegisterType<IOrderStorage, OrderStorage>();
|
||||||
|
DependencyManager.Instance.RegisterType<ICarStorage, CarStorage>();
|
||||||
|
DependencyManager.Instance.RegisterType<IBackUpInfo, BackUpInfo>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,47 @@
|
|||||||
|
using AutomobilePlantContracts.StoragesContracts;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Reflection;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace AutomomilePlantFileImplement.Implements
|
||||||
|
{
|
||||||
|
public class BackUpInfo : IBackUpInfo
|
||||||
|
{
|
||||||
|
public List<T>? GetList<T>() where T : class, new()
|
||||||
|
{
|
||||||
|
var context = DataFileSingleton.GetInstance();
|
||||||
|
Type myType = typeof(DataFileSingleton);
|
||||||
|
string property = $"{typeof(T).FullName}";
|
||||||
|
string nameList = "";
|
||||||
|
foreach (PropertyInfo prop in myType.GetProperties(
|
||||||
|
BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Static))
|
||||||
|
{
|
||||||
|
var list = prop.GetValue(context);
|
||||||
|
var typeList = list.GetType().GetGenericArguments().Single();
|
||||||
|
if (property.Equals($"{typeList.FullName}"))
|
||||||
|
{ nameList = prop.Name; break; }
|
||||||
|
}
|
||||||
|
var propertyInfo = myType.GetProperty(nameList);
|
||||||
|
var values = (List<T>)propertyInfo.GetValue(context);
|
||||||
|
return values;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public Type? GetTypeByModelInterface(string modelInterfaceName)
|
||||||
|
{
|
||||||
|
var assembly = typeof(BackUpInfo).Assembly;
|
||||||
|
var types = assembly.GetTypes();
|
||||||
|
foreach (var type in types)
|
||||||
|
{
|
||||||
|
if (type.IsClass && type.GetInterface(modelInterfaceName) != null)
|
||||||
|
{
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -4,16 +4,21 @@ using AutomobilePlantDataModels.Models;
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Runtime.Serialization;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Xml.Linq;
|
using System.Xml.Linq;
|
||||||
|
|
||||||
namespace AutomomilePlantFileImplement.Models
|
namespace AutomomilePlantFileImplement.Models
|
||||||
{
|
{
|
||||||
|
[DataContract]
|
||||||
public class Car : ICarModel
|
public class Car : ICarModel
|
||||||
{
|
{
|
||||||
|
[DataMember]
|
||||||
public int Id { get; private set; }
|
public int Id { get; private set; }
|
||||||
|
[DataMember]
|
||||||
public string CarName { get; private set; } = string.Empty;
|
public string CarName { get; private set; } = string.Empty;
|
||||||
|
[DataMember]
|
||||||
public double Price { get; private set; }
|
public double Price { get; private set; }
|
||||||
public Dictionary<int, int> Components { get; private set; } = new();
|
public Dictionary<int, int> Components { get; private set; } = new();
|
||||||
private Dictionary<int, (IComponentModel, int)>? _carComponents =
|
private Dictionary<int, (IComponentModel, int)>? _carComponents =
|
||||||
|
@ -5,17 +5,23 @@ using System;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
|
using System.Runtime.Serialization;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Xml.Linq;
|
using System.Xml.Linq;
|
||||||
|
|
||||||
namespace AutomomilePlantFileImplement.Models
|
namespace AutomomilePlantFileImplement.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; private set; } = string.Empty;
|
public string Email { get; private set; } = string.Empty;
|
||||||
|
[DataMember]
|
||||||
public string Password { get; private set; } = string.Empty;
|
public string Password { get; private set; } = string.Empty;
|
||||||
public static Client? Create(ClientBindingModel model)
|
public static Client? Create(ClientBindingModel model)
|
||||||
{
|
{
|
||||||
|
@ -4,16 +4,21 @@ using AutomobilePlantDataModels.Models;
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Runtime.Serialization;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Xml.Linq;
|
using System.Xml.Linq;
|
||||||
|
|
||||||
namespace AutomomilePlantFileImplement.Models
|
namespace AutomomilePlantFileImplement.Models
|
||||||
{
|
{
|
||||||
|
[DataContract]
|
||||||
public class Component : IComponentModel
|
public class Component : IComponentModel
|
||||||
{
|
{
|
||||||
|
[DataMember]
|
||||||
public int Id { get; private set; }
|
public int Id { get; private set; }
|
||||||
|
[DataMember]
|
||||||
public string ComponentName { get; private set; } = string.Empty;
|
public string ComponentName { get; private set; } = string.Empty;
|
||||||
|
[DataMember]
|
||||||
public double Cost { get; set; }
|
public double Cost { get; set; }
|
||||||
public static Component? Create(ComponentBindingModel model)
|
public static Component? Create(ComponentBindingModel model)
|
||||||
{
|
{
|
||||||
|
@ -4,18 +4,25 @@ using AutomobilePlantDataModels.Models;
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Runtime.Serialization;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Xml.Linq;
|
using System.Xml.Linq;
|
||||||
|
|
||||||
namespace AutomomilePlantFileImplement.Models
|
namespace AutomomilePlantFileImplement.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 int WorkExperience { get; set; }
|
public int WorkExperience { get; set; }
|
||||||
|
[DataMember]
|
||||||
public int Qualification { get; set; }
|
public int Qualification { get; set; }
|
||||||
|
[DataMember]
|
||||||
public string Password { get; private set; } = string.Empty;
|
public string Password { get; private set; } = string.Empty;
|
||||||
public static Implementer? Create(ImplementerBindingModel model)
|
public static Implementer? Create(ImplementerBindingModel model)
|
||||||
{
|
{
|
||||||
|
@ -4,24 +4,27 @@ using AutomobilePlantDataModels.Models;
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Runtime.Serialization;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Xml.Linq;
|
using System.Xml.Linq;
|
||||||
|
|
||||||
namespace AutomomilePlantFileImplement.Models
|
namespace AutomomilePlantFileImplement.Models
|
||||||
{
|
{
|
||||||
|
[DataContract]
|
||||||
public class MessageInfo : IMessageInfoModel
|
public class MessageInfo : IMessageInfoModel
|
||||||
{
|
{
|
||||||
|
[DataMember]
|
||||||
public string MessageId {get;set;} = string.Empty;
|
public string MessageId {get;set;} = string.Empty;
|
||||||
|
|
||||||
public int? ClientId { get; set; }
|
public int? ClientId { get; set; }
|
||||||
|
[DataMember]
|
||||||
public string SenderName { get; set; } = string.Empty;
|
public string SenderName { get; set; } = string.Empty;
|
||||||
|
[DataMember]
|
||||||
public DateTime DateDelivery { get; set; }
|
public DateTime DateDelivery { get; set; }
|
||||||
|
[DataMember]
|
||||||
public string Subject { get; set; } = string.Empty;
|
public string Subject { get; set; } = string.Empty;
|
||||||
|
[DataMember]
|
||||||
public string Body { get; set;} = string.Empty;
|
public string Body { get; set;} = string.Empty;
|
||||||
public static MessageInfo? Create(MessageInfoBindingModel model)
|
public static MessageInfo? Create(MessageInfoBindingModel model)
|
||||||
{
|
{
|
||||||
@ -31,6 +34,7 @@ namespace AutomomilePlantFileImplement.Models
|
|||||||
}
|
}
|
||||||
return new MessageInfo()
|
return new MessageInfo()
|
||||||
{
|
{
|
||||||
|
Id = model.Id,
|
||||||
MessageId = model.MessageId,
|
MessageId = model.MessageId,
|
||||||
ClientId = model.ClientId,
|
ClientId = model.ClientId,
|
||||||
SenderName = model.SenderName,
|
SenderName = model.SenderName,
|
||||||
@ -47,6 +51,7 @@ namespace AutomomilePlantFileImplement.Models
|
|||||||
}
|
}
|
||||||
return new MessageInfo()
|
return new MessageInfo()
|
||||||
{
|
{
|
||||||
|
Id = Convert.ToInt32(element.Attribute("Id")!.Value),
|
||||||
MessageId =element.Attribute("MessageId")!.Value,
|
MessageId =element.Attribute("MessageId")!.Value,
|
||||||
ClientId = Convert.ToInt32(element.Attribute("ClientId")!.Value),
|
ClientId = Convert.ToInt32(element.Attribute("ClientId")!.Value),
|
||||||
SenderName = element.Attribute("SenderName")!.Value,
|
SenderName = element.Attribute("SenderName")!.Value,
|
||||||
@ -58,6 +63,7 @@ namespace AutomomilePlantFileImplement.Models
|
|||||||
|
|
||||||
public MessageInfoViewModel GetViewModel => new()
|
public MessageInfoViewModel GetViewModel => new()
|
||||||
{
|
{
|
||||||
|
Id = Id,
|
||||||
MessageId = MessageId,
|
MessageId = MessageId,
|
||||||
ClientId = ClientId,
|
ClientId = ClientId,
|
||||||
SenderName = SenderName,
|
SenderName = SenderName,
|
||||||
@ -67,11 +73,14 @@ namespace AutomomilePlantFileImplement.Models
|
|||||||
};
|
};
|
||||||
public XElement GetXElement => new("MessageInfo",
|
public XElement GetXElement => new("MessageInfo",
|
||||||
new XAttribute("MessageId", MessageId),
|
new XAttribute("MessageId", MessageId),
|
||||||
|
new XAttribute("Id", Id),
|
||||||
new XElement("ClientId", ClientId.ToString()),
|
new XElement("ClientId", ClientId.ToString()),
|
||||||
new XElement("SenderName", SenderName),
|
new XElement("SenderName", SenderName),
|
||||||
new XElement("DateDelivery", DateDelivery.ToString()),
|
new XElement("DateDelivery", DateDelivery.ToString()),
|
||||||
new XElement("Subject", Subject),
|
new XElement("Subject", Subject),
|
||||||
new XElement("Body", Body)
|
new XElement("Body", Body)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
public int Id { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,29 +5,43 @@ using AutomobilePlantDataModels.Models;
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Runtime.Serialization;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Xml.Linq;
|
using System.Xml.Linq;
|
||||||
|
|
||||||
namespace AutomomilePlantFileImplement.Models
|
namespace AutomomilePlantFileImplement.Models
|
||||||
{
|
{
|
||||||
|
[DataContract]
|
||||||
public class Order : IOrderModel
|
public class Order : IOrderModel
|
||||||
{
|
{
|
||||||
|
[DataMember]
|
||||||
public int CarId { get; private set; }
|
public int CarId { get; private set; }
|
||||||
|
[DataMember]
|
||||||
public int ClientId { get; private set; }
|
public int ClientId { get; private set; }
|
||||||
|
[DataMember]
|
||||||
public string ClientName { get; private set; } = string.Empty;
|
public string ClientName { get; private set; } = string.Empty;
|
||||||
public string CarName { get; private set; } = string.Empty;
|
[DataMember]
|
||||||
|
public string CarName { get; private set; } = string.Empty;
|
||||||
|
[DataMember]
|
||||||
public int? ImplementerId { get; private set; }
|
public int? ImplementerId { get; private set; }
|
||||||
|
[DataMember]
|
||||||
public string? ImplementerName { get; private set; } = string.Empty;
|
public string? ImplementerName { get; private set; } = string.Empty;
|
||||||
|
[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.SpecifyKind(DateTime.Now, DateTimeKind.Utc);
|
public DateTime DateCreate { get; private set; } = DateTime.SpecifyKind(DateTime.Now, DateTimeKind.Utc);
|
||||||
|
[DataMember]
|
||||||
|
|
||||||
public DateTime? DateImplement { get; private set; } = null;
|
public DateTime? DateImplement { get; private set; } = null;
|
||||||
|
[DataMember]
|
||||||
|
|
||||||
public int Id { get; private set; }
|
public int Id { get; private set; }
|
||||||
public static Order? Create(OrderBindingModel model)
|
public static Order? Create(OrderBindingModel model)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user