LabWork08_Basic
This commit is contained in:
parent
bc9e6e4979
commit
5281c2d59c
2
.gitignore
vendored
2
.gitignore
vendored
@ -13,6 +13,8 @@
|
|||||||
|
|
||||||
# User-specific files (MonoDevelop/Xamarin Studio)
|
# User-specific files (MonoDevelop/Xamarin Studio)
|
||||||
*.userprefs
|
*.userprefs
|
||||||
|
ImplementationExtensions
|
||||||
|
BusinessLogicExtensions
|
||||||
|
|
||||||
# Mono auto generated files
|
# Mono auto generated files
|
||||||
mono_crash.*
|
mono_crash.*
|
||||||
|
@ -1,41 +0,0 @@
|
|||||||
2024-04-21 02:01:49,249 INFO Microsoft.Hosting.Lifetime.? [?] - MESSAGE: Now listening on: https://localhost:7122
|
|
||||||
2024-04-21 02:01:49,313 INFO Microsoft.Hosting.Lifetime.? [?] - MESSAGE: Now listening on: http://localhost:5092
|
|
||||||
2024-04-21 02:01:49,318 INFO Microsoft.Hosting.Lifetime.OnApplicationStarted [0] - MESSAGE: Application started. Press Ctrl+C to shut down.
|
|
||||||
2024-04-21 02:01:49,321 INFO Microsoft.Hosting.Lifetime.OnApplicationStarted [0] - MESSAGE: Hosting environment: Development
|
|
||||||
2024-04-21 02:01:49,322 INFO Microsoft.Hosting.Lifetime.OnApplicationStarted [0] - MESSAGE: Content root path: D:\ULSTU\Семестр 4\РПП\AircraftPlant\AircraftPlantRestApi\
|
|
||||||
2024-04-21 02:20:52,936 INFO Microsoft.Hosting.Lifetime.? [?] - MESSAGE: Now listening on: https://localhost:7122
|
|
||||||
2024-04-21 02:20:52,958 INFO Microsoft.Hosting.Lifetime.? [?] - MESSAGE: Now listening on: http://localhost:5092
|
|
||||||
2024-04-21 02:20:52,964 INFO Microsoft.Hosting.Lifetime.OnApplicationStarted [0] - MESSAGE: Application started. Press Ctrl+C to shut down.
|
|
||||||
2024-04-21 02:20:52,966 INFO Microsoft.Hosting.Lifetime.OnApplicationStarted [0] - MESSAGE: Hosting environment: Development
|
|
||||||
2024-04-21 02:20:52,967 INFO Microsoft.Hosting.Lifetime.OnApplicationStarted [0] - MESSAGE: Content root path: D:\ULSTU\Семестр 4\РПП\AircraftPlant\AircraftPlantRestApi\
|
|
||||||
2024-04-21 02:21:14,577 INFO AircraftPlantBusinessLogic.BusinessLogics.ShopLogic.ReadList [49] - MESSAGE: ReadList. ShopName:(null).Id:(null)
|
|
||||||
2024-04-21 02:21:16,912 INFO AircraftPlantBusinessLogic.BusinessLogics.ShopLogic.ReadList [58] - MESSAGE: ReadList. Count:2
|
|
||||||
2024-04-21 02:21:40,373 INFO AircraftPlantBusinessLogic.BusinessLogics.ShopLogic.ReadList [49] - MESSAGE: ReadList. ShopName:(null).Id:(null)
|
|
||||||
2024-04-21 02:21:40,397 INFO AircraftPlantBusinessLogic.BusinessLogics.ShopLogic.ReadList [58] - MESSAGE: ReadList. Count:2
|
|
||||||
2024-04-21 02:21:40,453 INFO AircraftPlantBusinessLogic.BusinessLogics.ShopLogic.ReadElement [75] - MESSAGE: ReadElement. ShopName:(null).Id:4
|
|
||||||
2024-04-21 02:21:40,562 INFO AircraftPlantBusinessLogic.BusinessLogics.ShopLogic.ReadElement [84] - MESSAGE: ReadElement find. Id:4
|
|
||||||
2024-04-21 02:21:45,409 INFO AircraftPlantBusinessLogic.BusinessLogics.ShopLogic.ReadElement [75] - MESSAGE: ReadElement. ShopName:(null).Id:5
|
|
||||||
2024-04-21 02:21:45,412 INFO AircraftPlantBusinessLogic.BusinessLogics.ShopLogic.ReadElement [84] - MESSAGE: ReadElement find. Id:5
|
|
||||||
2024-04-21 02:21:47,533 INFO AircraftPlantBusinessLogic.BusinessLogics.ShopLogic.ReadElement [75] - MESSAGE: ReadElement. ShopName:(null).Id:4
|
|
||||||
2024-04-21 02:21:47,535 INFO AircraftPlantBusinessLogic.BusinessLogics.ShopLogic.ReadElement [84] - MESSAGE: ReadElement find. Id:4
|
|
||||||
2024-04-21 02:23:50,172 INFO Microsoft.Hosting.Lifetime.? [?] - MESSAGE: Now listening on: https://localhost:7122
|
|
||||||
2024-04-21 02:23:50,194 INFO Microsoft.Hosting.Lifetime.? [?] - MESSAGE: Now listening on: http://localhost:5092
|
|
||||||
2024-04-21 02:23:50,198 INFO Microsoft.Hosting.Lifetime.OnApplicationStarted [0] - MESSAGE: Application started. Press Ctrl+C to shut down.
|
|
||||||
2024-04-21 02:23:50,201 INFO Microsoft.Hosting.Lifetime.OnApplicationStarted [0] - MESSAGE: Hosting environment: Development
|
|
||||||
2024-04-21 02:23:50,201 INFO Microsoft.Hosting.Lifetime.OnApplicationStarted [0] - MESSAGE: Content root path: D:\ULSTU\Семестр 4\РПП\AircraftPlant\AircraftPlantRestApi\
|
|
||||||
2024-04-21 02:24:06,733 INFO AircraftPlantBusinessLogic.BusinessLogics.ShopLogic.ReadList [49] - MESSAGE: ReadList. ShopName:(null).Id:(null)
|
|
||||||
2024-04-21 02:24:08,724 INFO AircraftPlantBusinessLogic.BusinessLogics.ShopLogic.ReadList [58] - MESSAGE: ReadList. Count:2
|
|
||||||
2024-04-21 02:24:10,746 INFO AircraftPlantBusinessLogic.BusinessLogics.ShopLogic.ReadList [49] - MESSAGE: ReadList. ShopName:(null).Id:(null)
|
|
||||||
2024-04-21 02:24:10,764 INFO AircraftPlantBusinessLogic.BusinessLogics.ShopLogic.ReadList [58] - MESSAGE: ReadList. Count:2
|
|
||||||
2024-04-21 02:26:31,564 INFO Microsoft.Hosting.Lifetime.? [?] - MESSAGE: Now listening on: https://localhost:7122
|
|
||||||
2024-04-21 02:26:31,586 INFO Microsoft.Hosting.Lifetime.? [?] - MESSAGE: Now listening on: http://localhost:5092
|
|
||||||
2024-04-21 02:26:31,592 INFO Microsoft.Hosting.Lifetime.OnApplicationStarted [0] - MESSAGE: Application started. Press Ctrl+C to shut down.
|
|
||||||
2024-04-21 02:26:31,594 INFO Microsoft.Hosting.Lifetime.OnApplicationStarted [0] - MESSAGE: Hosting environment: Development
|
|
||||||
2024-04-21 02:26:31,595 INFO Microsoft.Hosting.Lifetime.OnApplicationStarted [0] - MESSAGE: Content root path: D:\ULSTU\Семестр 4\РПП\AircraftPlant\AircraftPlantRestApi\
|
|
||||||
2024-04-21 02:26:50,068 INFO AircraftPlantBusinessLogic.BusinessLogics.ShopLogic.ReadList [49] - MESSAGE: ReadList. ShopName:(null).Id:(null)
|
|
||||||
2024-04-21 02:26:52,105 INFO AircraftPlantBusinessLogic.BusinessLogics.ShopLogic.ReadList [58] - MESSAGE: ReadList. Count:2
|
|
||||||
2024-04-21 02:26:53,568 INFO AircraftPlantBusinessLogic.BusinessLogics.ShopLogic.ReadList [49] - MESSAGE: ReadList. ShopName:(null).Id:(null)
|
|
||||||
2024-04-21 02:26:53,583 INFO AircraftPlantBusinessLogic.BusinessLogics.ShopLogic.ReadList [58] - MESSAGE: ReadList. Count:2
|
|
||||||
2024-04-21 02:26:53,599 INFO AircraftPlantBusinessLogic.BusinessLogics.PlaneLogic.ReadList [48] - MESSAGE: ReadList. PlaneName:(null).Id:(null)
|
|
||||||
2024-04-21 02:26:53,668 INFO AircraftPlantBusinessLogic.BusinessLogics.PlaneLogic.ReadList [57] - MESSAGE: ReadList. Count:2
|
|
||||||
|
|
@ -1,65 +0,0 @@
|
|||||||
2024-04-22 01:54:32,867 INFO Microsoft.Hosting.Lifetime.? [?] - MESSAGE: Now listening on: https://localhost:7122
|
|
||||||
2024-04-22 01:54:32,897 INFO Microsoft.Hosting.Lifetime.? [?] - MESSAGE: Now listening on: http://localhost:5092
|
|
||||||
2024-04-22 01:54:32,904 INFO Microsoft.Hosting.Lifetime.OnApplicationStarted [0] - MESSAGE: Application started. Press Ctrl+C to shut down.
|
|
||||||
2024-04-22 01:54:32,906 INFO Microsoft.Hosting.Lifetime.OnApplicationStarted [0] - MESSAGE: Hosting environment: Development
|
|
||||||
2024-04-22 01:54:32,907 INFO Microsoft.Hosting.Lifetime.OnApplicationStarted [0] - MESSAGE: Content root path: D:\ULSTU\Семестр 4\РПП\AircraftPlant\AircraftPlantRestApi\
|
|
||||||
2024-04-22 01:54:46,181 INFO AircraftPlantBusinessLogic.BusinessLogics.ShopLogic.ReadList [49] - MESSAGE: ReadList. ShopName:(null).Id:(null)
|
|
||||||
2024-04-22 01:54:48,412 INFO AircraftPlantBusinessLogic.BusinessLogics.ShopLogic.ReadList [58] - MESSAGE: ReadList. Count:2
|
|
||||||
2024-04-22 01:55:30,608 INFO AircraftPlantBusinessLogic.BusinessLogics.ShopLogic.ReadList [49] - MESSAGE: ReadList. ShopName:(null).Id:(null)
|
|
||||||
2024-04-22 01:55:30,634 INFO AircraftPlantBusinessLogic.BusinessLogics.ShopLogic.ReadList [58] - MESSAGE: ReadList. Count:2
|
|
||||||
2024-04-22 01:56:13,348 INFO AircraftPlantBusinessLogic.BusinessLogics.ShopLogic.CheckModel [247] - MESSAGE: Shop. ShopName:Магазин 3.Address:Улица 3. Id:0
|
|
||||||
2024-04-22 01:56:13,576 INFO AircraftPlantBusinessLogic.BusinessLogics.ShopLogic.ReadList [49] - MESSAGE: ReadList. ShopName:(null).Id:(null)
|
|
||||||
2024-04-22 01:56:13,581 INFO AircraftPlantBusinessLogic.BusinessLogics.ShopLogic.ReadList [58] - MESSAGE: ReadList. Count:3
|
|
||||||
2024-04-22 01:56:21,121 INFO AircraftPlantBusinessLogic.BusinessLogics.ShopLogic.ReadList [49] - MESSAGE: ReadList. ShopName:(null).Id:(null)
|
|
||||||
2024-04-22 01:56:21,124 INFO AircraftPlantBusinessLogic.BusinessLogics.ShopLogic.ReadList [58] - MESSAGE: ReadList. Count:3
|
|
||||||
2024-04-22 01:56:21,142 INFO AircraftPlantBusinessLogic.BusinessLogics.PlaneLogic.ReadList [48] - MESSAGE: ReadList. PlaneName:(null).Id:(null)
|
|
||||||
2024-04-22 01:56:21,160 INFO AircraftPlantBusinessLogic.BusinessLogics.PlaneLogic.ReadList [57] - MESSAGE: ReadList. Count:2
|
|
||||||
2024-04-22 01:56:34,923 INFO AircraftPlantBusinessLogic.BusinessLogics.ShopLogic.AddPlaneInShop [159] - MESSAGE: AddPlaneInShop. ShopName:(null).Id:6
|
|
||||||
2024-04-22 01:56:34,931 INFO AircraftPlantBusinessLogic.BusinessLogics.ShopLogic.AddPlaneInShop [166] - MESSAGE: AddPlaneInShop find. Id:6
|
|
||||||
2024-04-22 01:56:34,935 INFO AircraftPlantBusinessLogic.BusinessLogics.ShopLogic.AddPlaneInShop [183] - MESSAGE: AddPlaneInShop. Added 5 new plane to 'Магазин 3' shop
|
|
||||||
2024-04-22 01:56:34,989 INFO AircraftPlantBusinessLogic.BusinessLogics.ShopLogic.ReadList [49] - MESSAGE: ReadList. ShopName:(null).Id:(null)
|
|
||||||
2024-04-22 01:56:34,991 INFO AircraftPlantBusinessLogic.BusinessLogics.ShopLogic.ReadList [58] - MESSAGE: ReadList. Count:3
|
|
||||||
2024-04-22 01:56:45,267 INFO AircraftPlantBusinessLogic.BusinessLogics.ShopLogic.ReadList [49] - MESSAGE: ReadList. ShopName:(null).Id:(null)
|
|
||||||
2024-04-22 01:56:45,269 INFO AircraftPlantBusinessLogic.BusinessLogics.ShopLogic.ReadList [58] - MESSAGE: ReadList. Count:3
|
|
||||||
2024-04-22 01:56:45,301 INFO AircraftPlantBusinessLogic.BusinessLogics.ShopLogic.ReadElement [75] - MESSAGE: ReadElement. ShopName:(null).Id:4
|
|
||||||
2024-04-22 01:56:45,303 INFO AircraftPlantBusinessLogic.BusinessLogics.ShopLogic.ReadElement [84] - MESSAGE: ReadElement find. Id:4
|
|
||||||
2024-04-22 01:56:49,512 INFO AircraftPlantBusinessLogic.BusinessLogics.ShopLogic.ReadElement [75] - MESSAGE: ReadElement. ShopName:(null).Id:6
|
|
||||||
2024-04-22 01:56:49,515 INFO AircraftPlantBusinessLogic.BusinessLogics.ShopLogic.ReadElement [84] - MESSAGE: ReadElement find. Id:6
|
|
||||||
2024-04-22 10:34:20,669 INFO Microsoft.Hosting.Lifetime.? [?] - MESSAGE: Now listening on: https://localhost:7122
|
|
||||||
2024-04-22 10:34:20,716 INFO Microsoft.Hosting.Lifetime.? [?] - MESSAGE: Now listening on: http://localhost:5092
|
|
||||||
2024-04-22 10:34:20,721 INFO Microsoft.Hosting.Lifetime.OnApplicationStarted [0] - MESSAGE: Application started. Press Ctrl+C to shut down.
|
|
||||||
2024-04-22 10:34:20,724 INFO Microsoft.Hosting.Lifetime.OnApplicationStarted [0] - MESSAGE: Hosting environment: Development
|
|
||||||
2024-04-22 10:34:20,725 INFO Microsoft.Hosting.Lifetime.OnApplicationStarted [0] - MESSAGE: Content root path: D:\ULSTU\Семестр 4\РПП\AircraftPlant\AircraftPlantRestApi\
|
|
||||||
2024-04-22 10:42:07,542 INFO Microsoft.Hosting.Lifetime.? [?] - MESSAGE: Now listening on: https://localhost:7122
|
|
||||||
2024-04-22 10:42:07,564 INFO Microsoft.Hosting.Lifetime.? [?] - MESSAGE: Now listening on: http://localhost:5092
|
|
||||||
2024-04-22 10:42:07,570 INFO Microsoft.Hosting.Lifetime.OnApplicationStarted [0] - MESSAGE: Application started. Press Ctrl+C to shut down.
|
|
||||||
2024-04-22 10:42:07,572 INFO Microsoft.Hosting.Lifetime.OnApplicationStarted [0] - MESSAGE: Hosting environment: Development
|
|
||||||
2024-04-22 10:42:07,573 INFO Microsoft.Hosting.Lifetime.OnApplicationStarted [0] - MESSAGE: Content root path: D:\ULSTU\Семестр 4\РПП\AircraftPlant\AircraftPlantRestApi\
|
|
||||||
2024-04-22 10:42:26,255 INFO AircraftPlantBusinessLogic.BusinessLogics.ShopLogic.ReadList [49] - MESSAGE: ReadList. ShopName:(null).Id:(null)
|
|
||||||
2024-04-22 10:42:28,411 INFO AircraftPlantBusinessLogic.BusinessLogics.ShopLogic.ReadList [58] - MESSAGE: ReadList. Count:3
|
|
||||||
2024-04-22 10:43:50,297 INFO Microsoft.Hosting.Lifetime.? [?] - MESSAGE: Now listening on: https://localhost:7122
|
|
||||||
2024-04-22 10:43:50,324 INFO Microsoft.Hosting.Lifetime.? [?] - MESSAGE: Now listening on: http://localhost:5092
|
|
||||||
2024-04-22 10:43:50,329 INFO Microsoft.Hosting.Lifetime.OnApplicationStarted [0] - MESSAGE: Application started. Press Ctrl+C to shut down.
|
|
||||||
2024-04-22 10:43:50,331 INFO Microsoft.Hosting.Lifetime.OnApplicationStarted [0] - MESSAGE: Hosting environment: Development
|
|
||||||
2024-04-22 10:43:50,333 INFO Microsoft.Hosting.Lifetime.OnApplicationStarted [0] - MESSAGE: Content root path: D:\ULSTU\Семестр 4\РПП\AircraftPlant\AircraftPlantRestApi\
|
|
||||||
2024-04-22 10:48:54,048 INFO AircraftPlantBusinessLogic.BusinessLogics.ShopLogic.ReadList [49] - MESSAGE: ReadList. ShopName:(null).Id:(null)
|
|
||||||
2024-04-22 10:48:56,110 INFO AircraftPlantBusinessLogic.BusinessLogics.ShopLogic.ReadList [58] - MESSAGE: ReadList. Count:3
|
|
||||||
2024-04-22 10:49:15,718 INFO AircraftPlantBusinessLogic.BusinessLogics.ShopLogic.CheckModel [247] - MESSAGE: Shop. ShopName:shop.Address:street. Id:0
|
|
||||||
2024-04-22 10:49:16,089 INFO AircraftPlantBusinessLogic.BusinessLogics.ShopLogic.ReadList [49] - MESSAGE: ReadList. ShopName:(null).Id:(null)
|
|
||||||
2024-04-22 10:49:16,094 INFO AircraftPlantBusinessLogic.BusinessLogics.ShopLogic.ReadList [58] - MESSAGE: ReadList. Count:4
|
|
||||||
2024-04-22 10:49:20,397 INFO AircraftPlantBusinessLogic.BusinessLogics.ShopLogic.ReadList [49] - MESSAGE: ReadList. ShopName:(null).Id:(null)
|
|
||||||
2024-04-22 10:49:20,400 INFO AircraftPlantBusinessLogic.BusinessLogics.ShopLogic.ReadList [58] - MESSAGE: ReadList. Count:4
|
|
||||||
2024-04-22 10:49:20,417 INFO AircraftPlantBusinessLogic.BusinessLogics.PlaneLogic.ReadList [48] - MESSAGE: ReadList. PlaneName:(null).Id:(null)
|
|
||||||
2024-04-22 10:49:20,446 INFO AircraftPlantBusinessLogic.BusinessLogics.PlaneLogic.ReadList [57] - MESSAGE: ReadList. Count:2
|
|
||||||
2024-04-22 10:49:26,177 INFO AircraftPlantBusinessLogic.BusinessLogics.ShopLogic.AddPlaneInShop [159] - MESSAGE: AddPlaneInShop. ShopName:(null).Id:7
|
|
||||||
2024-04-22 10:49:26,189 INFO AircraftPlantBusinessLogic.BusinessLogics.ShopLogic.AddPlaneInShop [166] - MESSAGE: AddPlaneInShop find. Id:7
|
|
||||||
2024-04-22 10:49:26,204 INFO AircraftPlantBusinessLogic.BusinessLogics.ShopLogic.AddPlaneInShop [183] - MESSAGE: AddPlaneInShop. Added 3 new plane to 'shop' shop
|
|
||||||
2024-04-22 10:49:26,300 INFO AircraftPlantBusinessLogic.BusinessLogics.ShopLogic.ReadList [49] - MESSAGE: ReadList. ShopName:(null).Id:(null)
|
|
||||||
2024-04-22 10:49:26,303 INFO AircraftPlantBusinessLogic.BusinessLogics.ShopLogic.ReadList [58] - MESSAGE: ReadList. Count:4
|
|
||||||
2024-04-22 10:49:29,404 INFO AircraftPlantBusinessLogic.BusinessLogics.ShopLogic.ReadList [49] - MESSAGE: ReadList. ShopName:(null).Id:(null)
|
|
||||||
2024-04-22 10:49:29,407 INFO AircraftPlantBusinessLogic.BusinessLogics.ShopLogic.ReadList [58] - MESSAGE: ReadList. Count:4
|
|
||||||
2024-04-22 10:49:29,437 INFO AircraftPlantBusinessLogic.BusinessLogics.ShopLogic.ReadElement [75] - MESSAGE: ReadElement. ShopName:(null).Id:4
|
|
||||||
2024-04-22 10:49:29,440 INFO AircraftPlantBusinessLogic.BusinessLogics.ShopLogic.ReadElement [84] - MESSAGE: ReadElement find. Id:4
|
|
||||||
2024-04-22 10:49:31,043 INFO AircraftPlantBusinessLogic.BusinessLogics.ShopLogic.ReadElement [75] - MESSAGE: ReadElement. ShopName:(null).Id:7
|
|
||||||
2024-04-22 10:49:31,046 INFO AircraftPlantBusinessLogic.BusinessLogics.ShopLogic.ReadElement [84] - MESSAGE: ReadElement find. Id:7
|
|
||||||
|
|
@ -0,0 +1,131 @@
|
|||||||
|
using AircraftPlantContracts.BindingModels;
|
||||||
|
using AircraftPlantContracts.BusinessLogicsContracts;
|
||||||
|
using AircraftPlantContracts.StoragesContracts;
|
||||||
|
using AircraftPlantDataModels.Models;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO.Compression;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Reflection;
|
||||||
|
using System.Runtime.Serialization.Json;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace AircraftPlantBusinessLogic.BusinessLogics
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Реализация интерфейса бизнес-логики для создания бэкапа
|
||||||
|
/// </summary>
|
||||||
|
public class BackUpLogic : IBackUpLogic
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Логгер
|
||||||
|
/// </summary>
|
||||||
|
private readonly ILogger _logger;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Получение данных из хранилища
|
||||||
|
/// </summary>
|
||||||
|
private readonly IBackUpInfo _backUpInfo;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Конструктор
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="logger"></param>
|
||||||
|
/// <param name="backUpInfo"></param>
|
||||||
|
public BackUpLogic(ILogger<BackUpLogic> logger, IBackUpInfo backUpInfo)
|
||||||
|
{
|
||||||
|
_logger = logger;
|
||||||
|
_backUpInfo = backUpInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Создать бэкап
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="model"></param>
|
||||||
|
public void CreateBackUp(BackUpSaveBindingModel model)
|
||||||
|
{
|
||||||
|
if (_backUpInfo == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_logger.LogDebug("Clear folder");
|
||||||
|
// Зачистка папки и удаление старого архива
|
||||||
|
var dirInfo = new DirectoryInfo(model.FolderName);
|
||||||
|
if (dirInfo.Exists)
|
||||||
|
{
|
||||||
|
foreach (var file in dirInfo.GetFiles())
|
||||||
|
{
|
||||||
|
file.Delete();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
_logger.LogDebug("Delete archive");
|
||||||
|
string fileName = $"{model.FolderName}.zip";
|
||||||
|
if (File.Exists(fileName))
|
||||||
|
{
|
||||||
|
File.Delete(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Берем метод для сохранения
|
||||||
|
_logger.LogDebug("Get assembly");
|
||||||
|
var typeIId = typeof(IId);
|
||||||
|
var assembly = typeIId.Assembly;
|
||||||
|
if (assembly == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException("Сборка не найдена", nameof(assembly));
|
||||||
|
}
|
||||||
|
|
||||||
|
var types = assembly.GetTypes();
|
||||||
|
var method = GetType().GetMethod("SaveToFile", BindingFlags.NonPublic | BindingFlags.Instance);
|
||||||
|
_logger.LogDebug("Find {count} types", types.Length);
|
||||||
|
foreach (var type in types)
|
||||||
|
{
|
||||||
|
if (type.IsInterface && type.GetInterface(typeIId.Name) != null)
|
||||||
|
{
|
||||||
|
var modelType = _backUpInfo.GetTypeByModelInterface(type.Name);
|
||||||
|
if (modelType == null)
|
||||||
|
{
|
||||||
|
throw new InvalidOperationException($"Не найден класс-модель для {type.Name}");
|
||||||
|
}
|
||||||
|
_logger.LogDebug("Call SaveToFile method for {name} type", type.Name);
|
||||||
|
// Вызываем метод на выполнение
|
||||||
|
method?.MakeGenericMethod(modelType).Invoke(this, new object[] { model.FolderName });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
_logger.LogDebug("Create zip and remove folder");
|
||||||
|
// Архивируем
|
||||||
|
ZipFile.CreateFromDirectory(model.FolderName, fileName);
|
||||||
|
// Удаляем папку
|
||||||
|
dirInfo.Delete(true);
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Сохранить в файл
|
||||||
|
/// </summary>
|
||||||
|
/// <typeparam name="T"></typeparam>
|
||||||
|
/// <param name="folderName"></param>
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -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="..\AircraftPlantDataModels\AircraftPlantDataModels.csproj" />
|
<ProjectReference Include="..\AircraftPlantDataModels\AircraftPlantDataModels.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
@ -0,0 +1,57 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace AircraftPlantContracts.Attributes
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Класс-атрибут для конифгурации колонки DataGridView
|
||||||
|
/// </summary>
|
||||||
|
[AttributeUsage(AttributeTargets.Property)]
|
||||||
|
public class ColumnAttribute : Attribute
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Заголовок колонки
|
||||||
|
/// </summary>
|
||||||
|
public string Title { get; private set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Признак видмости колонки
|
||||||
|
/// </summary>
|
||||||
|
public bool Visible { get; private set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Ширина колонки
|
||||||
|
/// </summary>
|
||||||
|
public int Width { get; private set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Автоширина колонки
|
||||||
|
/// </summary>
|
||||||
|
public GridViewAutoSize GridViewAutoSize { get; private set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Признак использования автоширины колонки
|
||||||
|
/// </summary>
|
||||||
|
public bool IsUseAutoSize { get; private set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Конструктор
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="title"></param>
|
||||||
|
/// <param name="visible"></param>
|
||||||
|
/// <param name="width"></param>
|
||||||
|
/// <param name="gridViewAutoSize"></param>
|
||||||
|
/// <param name="isUseAutoSize"></param>
|
||||||
|
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,30 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace AircraftPlantContracts.Attributes
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Автоширина колонки DataGridView
|
||||||
|
/// </summary>
|
||||||
|
public enum GridViewAutoSize
|
||||||
|
{
|
||||||
|
NotSet = 0,
|
||||||
|
|
||||||
|
None = 1,
|
||||||
|
|
||||||
|
ColumnHeader = 2,
|
||||||
|
|
||||||
|
AllCellsExceptHeader = 4,
|
||||||
|
|
||||||
|
AllCells = 6,
|
||||||
|
|
||||||
|
DisplayedCellsExceptHeader = 8,
|
||||||
|
|
||||||
|
DisplayedCells = 10,
|
||||||
|
|
||||||
|
Fill = 16
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,19 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace AircraftPlantContracts.BindingModels
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Модель привязки для создания бэкапа
|
||||||
|
/// </summary>
|
||||||
|
public class BackUpSaveBindingModel
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Путь и имя файла
|
||||||
|
/// </summary>
|
||||||
|
public string FolderName { get; set; } = string.Empty;
|
||||||
|
}
|
||||||
|
}
|
@ -42,5 +42,7 @@ namespace AircraftPlantContracts.BindingModels
|
|||||||
/// Тело письма
|
/// Тело письма
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string Body { get; set; } = string.Empty;
|
public string Body { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
public int Id => throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,21 @@
|
|||||||
|
using AircraftPlantContracts.BindingModels;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace AircraftPlantContracts.BusinessLogicsContracts
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Интерфейс бизнес-логики для создания бэкапа
|
||||||
|
/// </summary>
|
||||||
|
public interface IBackUpLogic
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Создать бэкап
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="model"></param>
|
||||||
|
void CreateBackUp(BackUpSaveBindingModel model);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,84 @@
|
|||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace AircraftPlantContracts.DependencyInjections
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Менеджер для работы с зависимостями
|
||||||
|
/// </summary>
|
||||||
|
public class DependencyManager
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Установка зависимостей
|
||||||
|
/// </summary>
|
||||||
|
private readonly IDependencyContainer _dependencyManager;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Менеджер для работы с зависимостями
|
||||||
|
/// </summary>
|
||||||
|
private static DependencyManager? _manager;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Блокировка
|
||||||
|
/// </summary>
|
||||||
|
private static readonly object _locjObject = new();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Конструктор
|
||||||
|
/// </summary>
|
||||||
|
private DependencyManager()
|
||||||
|
{
|
||||||
|
_dependencyManager = new UnityDependencyContainer();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Получить ссылку
|
||||||
|
/// </summary>
|
||||||
|
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,43 @@
|
|||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace AircraftPlantContracts.DependencyInjections
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Интерфейс установки зависмости между элементами
|
||||||
|
/// </summary>
|
||||||
|
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,24 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace AircraftPlantContracts.DependencyInjections
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Интерфейс для регистрации зависимостей в модулях
|
||||||
|
/// </summary>
|
||||||
|
public interface IImplementationExtension
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Приоритет
|
||||||
|
/// </summary>
|
||||||
|
public int Priority { get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Регистрация сервисов
|
||||||
|
/// </summary>
|
||||||
|
public void RegisterServices();
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,94 @@
|
|||||||
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace AircraftPlantContracts.DependencyInjections
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Реализация интерфейса установки зависимости между элементами
|
||||||
|
/// </summary>
|
||||||
|
public class ServiceDependencyContainer : IDependencyContainer
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Провайдер сервисов для разрешения зависимостей
|
||||||
|
/// </summary>
|
||||||
|
private ServiceProvider? _serviceProvider;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Коллекция сервисов для регистрации зависимостей
|
||||||
|
/// </summary>
|
||||||
|
private readonly ServiceCollection _serviceCollection;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Конструктор
|
||||||
|
/// </summary>
|
||||||
|
public ServiceDependencyContainer()
|
||||||
|
{
|
||||||
|
_serviceCollection = new ServiceCollection();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Регистрация логгера
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="configure"></param>
|
||||||
|
public void AddLogging(Action<ILoggingBuilder> configure)
|
||||||
|
{
|
||||||
|
_serviceCollection.AddLogging(configure);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Добавление зависимости
|
||||||
|
/// </summary>
|
||||||
|
/// <typeparam name="T"></typeparam>
|
||||||
|
/// <typeparam name="U"></typeparam>
|
||||||
|
/// <param name="isSingle"></param>
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Добавление зависимости
|
||||||
|
/// </summary>
|
||||||
|
/// <typeparam name="T"></typeparam>
|
||||||
|
/// <param name="isSingle"></param>
|
||||||
|
public void RegisterType<T>(bool isSingle) where T : class
|
||||||
|
{
|
||||||
|
if (isSingle)
|
||||||
|
{
|
||||||
|
_serviceCollection.AddSingleton<T>();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_serviceCollection.AddTransient<T>();
|
||||||
|
}
|
||||||
|
_serviceProvider = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Получение класса со всеми зависимостями
|
||||||
|
/// </summary>
|
||||||
|
/// <typeparam name="T"></typeparam>
|
||||||
|
/// <returns></returns>
|
||||||
|
public T Resolve<T>()
|
||||||
|
{
|
||||||
|
if (_serviceProvider == null)
|
||||||
|
{
|
||||||
|
_serviceProvider = _serviceCollection.BuildServiceProvider();
|
||||||
|
}
|
||||||
|
return _serviceProvider.GetService<T>()!;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,62 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Reflection;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace AircraftPlantContracts.DependencyInjections
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Загрузка данных
|
||||||
|
/// </summary>
|
||||||
|
public static partial 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Получить ImplementationExtensions
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
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,84 @@
|
|||||||
|
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 AircraftPlantContracts.DependencyInjections
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Реализация интерфейса установки зависимости между элементами
|
||||||
|
/// </summary>
|
||||||
|
public class UnityDependencyContainer : IDependencyContainer
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Контейнер сервисов для регистрации зависимостей
|
||||||
|
/// </summary>
|
||||||
|
private readonly UnityContainer _container;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Конструктор
|
||||||
|
/// </summary>
|
||||||
|
public UnityDependencyContainer()
|
||||||
|
{
|
||||||
|
_container = new UnityContainer();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Регистрация логгера
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="configure"></param>
|
||||||
|
public void AddLogging(Action<ILoggingBuilder> configure)
|
||||||
|
{
|
||||||
|
_container.AddExtension(new LoggingExtension(LoggerFactory.Create(configure)));
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Добавление зависимости
|
||||||
|
/// </summary>
|
||||||
|
/// <typeparam name="T"></typeparam>
|
||||||
|
/// <typeparam name="U"></typeparam>
|
||||||
|
/// <param name="isSingle"></param>
|
||||||
|
public void RegisterType<T, U>(bool isSingle) where U : class, T where T : class
|
||||||
|
{
|
||||||
|
if (isSingle)
|
||||||
|
{
|
||||||
|
_container.RegisterSingleton<T, U>();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_container.RegisterType<T, U>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Добавление зависимости
|
||||||
|
/// </summary>
|
||||||
|
/// <typeparam name="T"></typeparam>
|
||||||
|
/// <param name="isSingle"></param>
|
||||||
|
public void RegisterType<T>(bool isSingle) where T : class
|
||||||
|
{
|
||||||
|
if (isSingle)
|
||||||
|
{
|
||||||
|
_container.RegisterSingleton<T>();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_container.RegisterType<T>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Получение класса со всеми зависимостями
|
||||||
|
/// </summary>
|
||||||
|
/// <typeparam name="T"></typeparam>
|
||||||
|
/// <returns></returns>
|
||||||
|
public T Resolve<T>()
|
||||||
|
{
|
||||||
|
return _container.Resolve<T>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,28 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace AircraftPlantContracts.StoragesContracts
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Интерфейс для получения данных из хранилища
|
||||||
|
/// </summary>
|
||||||
|
public interface IBackUpInfo
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Получить список объектов
|
||||||
|
/// </summary>
|
||||||
|
/// <typeparam name="T"></typeparam>
|
||||||
|
/// <returns></returns>
|
||||||
|
List<T>? GetList<T>() where T : class, new();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Получить тип
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="modelInterfaceName"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
Type? GetTypeByModelInterface(string modelInterfaceName);
|
||||||
|
}
|
||||||
|
}
|
@ -1,4 +1,5 @@
|
|||||||
using AircraftPlantDataModels.Models;
|
using AircraftPlantContracts.Attributes;
|
||||||
|
using AircraftPlantDataModels.Models;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
@ -17,24 +18,25 @@ namespace AircraftPlantContracts.ViewModels
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Идентификатор
|
/// Идентификатор
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
[Column(visible: false)]
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// ФИО клиента
|
/// ФИО клиента
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[DisplayName("ФИО клиента")]
|
[Column(title: "ФИО клиента", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)]
|
||||||
public string ClientFIO { get; set; } = string.Empty;
|
public string ClientFIO { get; set; } = string.Empty;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Логин (электронная почта)
|
/// Логин (электронная почта)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[DisplayName("Логин (эл. почта)")]
|
[Column(title: "Логин (эл. почта)", width: 150)]
|
||||||
public string Email { get; set; } = string.Empty;
|
public string Email { get; set; } = string.Empty;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Пароль
|
/// Пароль
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[DisplayName("Пароль")]
|
[Column(title: "Пароль", width: 150)]
|
||||||
public string Password { get; set; } = string.Empty;
|
public string Password { get; set; } = string.Empty;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
using AircraftPlantDataModels.Models;
|
using AircraftPlantContracts.Attributes;
|
||||||
|
using AircraftPlantDataModels.Models;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
@ -17,18 +18,19 @@ namespace AircraftPlantContracts.ViewModels
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Идентификатор
|
/// Идентификатор
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
[Column(visible: false)]
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Название компонента
|
/// Название компонента
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[DisplayName("Название компонента")]
|
[Column(title: "Название компонента", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)]
|
||||||
public string ComponentName { get; set; } = string.Empty;
|
public string ComponentName { get; set; } = string.Empty;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Стоимость компонента
|
/// Стоимость компонента
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[DisplayName("Цена")]
|
[Column(title: "Цена", width: 150)]
|
||||||
public double Cost { get; set; }
|
public double Cost { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
using AircraftPlantDataModels.Models;
|
using AircraftPlantContracts.Attributes;
|
||||||
|
using AircraftPlantDataModels.Models;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
@ -17,30 +18,31 @@ namespace AircraftPlantContracts.ViewModels
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Идентификатор
|
/// Идентификатор
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
[Column(visible: false)]
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// ФИО исполнителя
|
/// ФИО исполнителя
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[DisplayName("ФИО исполнителя")]
|
[Column(title: "ФИО исполнителя", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)]
|
||||||
public string ImplementerFIO { get; set; } = string.Empty;
|
public string ImplementerFIO { get; set; } = string.Empty;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Пароль
|
/// Пароль
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[DisplayName("Пароль")]
|
[Column(title: "Пароль", width: 150)]
|
||||||
public string Password { get; set; } = string.Empty;
|
public string Password { get; set; } = string.Empty;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Опыт работы
|
/// Опыт работы
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[DisplayName("Опыт работы")]
|
[Column(title: "Опыт работы", width: 100)]
|
||||||
public int WorkExperience { get; set; }
|
public int WorkExperience { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Квалификация
|
/// Квалификация
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[DisplayName("Квалификация")]
|
[Column(title: "Квалификация", width: 100)]
|
||||||
public int Qualification { get; set; }
|
public int Qualification { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
using AircraftPlantDataModels.Models;
|
using AircraftPlantContracts.Attributes;
|
||||||
|
using AircraftPlantDataModels.Models;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
@ -17,35 +18,40 @@ namespace AircraftPlantContracts.ViewModels
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Идентификатор
|
/// Идентификатор
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
[Column(visible: false)]
|
||||||
public string MessageId { get; set; } = string.Empty;
|
public string MessageId { get; set; } = string.Empty;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Идентификатор клиента
|
/// Идентификатор клиента
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
[Column(visible: false)]
|
||||||
public int? ClientId { get; set; }
|
public int? ClientId { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Адрес электронной почты отправителя
|
/// Адрес электронной почты отправителя
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[DisplayName("Отправитель")]
|
[Column(title: "Отправитель", width: 150)]
|
||||||
public string SenderName { get; set; } = string.Empty;
|
public string SenderName { get; set; } = string.Empty;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Дата получения письма
|
/// Дата получения письма
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[DisplayName("Дата письма")]
|
[Column(title: "Дата письма", width: 150)]
|
||||||
public DateTime DateDelivery { get; set; }
|
public DateTime DateDelivery { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Заголовок письма
|
/// Заголовок письма
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[DisplayName("Заголовок")]
|
[Column(title: "Заголовок", width: 150)]
|
||||||
public string Subject { get; set; } = string.Empty;
|
public string Subject { get; set; } = string.Empty;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Тело письма
|
/// Тело письма
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[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; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
using AircraftPlantDataModels.Enums;
|
using AircraftPlantContracts.Attributes;
|
||||||
|
using AircraftPlantDataModels.Enums;
|
||||||
using AircraftPlantDataModels.Models;
|
using AircraftPlantDataModels.Models;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
@ -18,70 +19,73 @@ namespace AircraftPlantContracts.ViewModels
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Идентификатор
|
/// Идентификатор
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[DisplayName("Номер")]
|
[Column(title: "Номер", width: 50)]
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Идентификатор изделия
|
/// Идентификатор изделия
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
[Column(visible: false)]
|
||||||
public int PlaneId { get; set; }
|
public int PlaneId { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Название изделия
|
/// Название изделия
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[DisplayName("Изделие")]
|
[Column(title: "Изделие", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)]
|
||||||
public string PlaneName { get; set; } = string.Empty;
|
public string PlaneName { get; set; } = string.Empty;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Идентификатор клиента
|
/// Идентификатор клиента
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
[Column(visible: false)]
|
||||||
public int ClientId { get; set; }
|
public int ClientId { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// ФИО клиента
|
/// ФИО клиента
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[DisplayName("ФИО клиента")]
|
[Column(title: "ФИО клиента", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)]
|
||||||
public string ClientFIO { get; set; } = string.Empty;
|
public string ClientFIO { get; set; } = string.Empty;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Идентификатор исполнителя
|
/// Идентификатор исполнителя
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
[Column(visible: false)]
|
||||||
public int? ImplementerId { get; set; }
|
public int? ImplementerId { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// ФИО клиента
|
/// ФИО клиента
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[DisplayName("ФИО исполнителя")]
|
[Column(title: "ФИО исполнителя", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)]
|
||||||
public string ImplementerFIO { get; set; } = string.Empty;
|
public string ImplementerFIO { get; set; } = string.Empty;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Количество изделий
|
/// Количество изделий
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[DisplayName("Количество")]
|
[Column(title: "Количество", width: 100)]
|
||||||
public int Count { get; set; }
|
public int Count { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Сумма заказа
|
/// Сумма заказа
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[DisplayName("Сумма")]
|
[Column(title: "Сумма", width: 100)]
|
||||||
public double Sum { get; set; }
|
public double Sum { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Статус заказа
|
/// Статус заказа
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[DisplayName("Статус")]
|
[Column(title: "Статус", width: 70)]
|
||||||
public OrderStatus Status { get; set; } = OrderStatus.Неизвестен;
|
public OrderStatus Status { get; set; } = OrderStatus.Неизвестен;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Дата создания заказа
|
/// Дата создания заказа
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[DisplayName("Дата создания")]
|
[Column(title: "Дата создания", width: 100)]
|
||||||
public DateTime DateCreate { get; set; } = DateTime.Now;
|
public DateTime DateCreate { get; set; } = DateTime.Now;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Дата выполнения заказа
|
/// Дата выполнения заказа
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[DisplayName("Дата выполнения")]
|
[Column(title: "Дата выполнения", width: 100)]
|
||||||
public DateTime? DateImplement { get; set; }
|
public DateTime? DateImplement { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
using AircraftPlantDataModels.Models;
|
using AircraftPlantContracts.Attributes;
|
||||||
|
using AircraftPlantDataModels.Models;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
@ -17,23 +18,25 @@ namespace AircraftPlantContracts.ViewModels
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Идентификатор
|
/// Идентификатор
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
[Column(visible: false)]
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Название изделия
|
/// Название изделия
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[DisplayName("Название изделия")]
|
[Column(title: "Название изделия", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)]
|
||||||
public string PlaneName { get; set; } = string.Empty;
|
public string PlaneName { get; set; } = string.Empty;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Стоимость изделия
|
/// Стоимость изделия
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[DisplayName("Цена")]
|
[Column(title: "Цена", width: 150)]
|
||||||
public double Price { get; set; }
|
public double Price { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Коллекция компонентов изделия
|
/// Коллекция компонентов изделия
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
[Column(visible: false)]
|
||||||
public Dictionary<int, (IComponentModel, int)> PlaneComponents
|
public Dictionary<int, (IComponentModel, int)> PlaneComponents
|
||||||
{
|
{
|
||||||
get;
|
get;
|
||||||
|
@ -19,6 +19,8 @@ namespace AircraftPlantDataModels.Enums
|
|||||||
|
|
||||||
Готов = 2,
|
Готов = 2,
|
||||||
|
|
||||||
Выдан = 3
|
Выдан = 3,
|
||||||
|
|
||||||
|
Ожидание = 4 // Иначе возникает исключение ArgumentException
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,7 @@ namespace AircraftPlantDataModels.Models
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Интерфейс для модели письма
|
/// Интерфейс для модели письма
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public interface IMessageInfoModel
|
public interface IMessageInfoModel : IId
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Идентификатор
|
/// Идентификатор
|
||||||
|
@ -20,4 +20,8 @@
|
|||||||
<ProjectReference Include="..\AircraftPlantDataModels\AircraftPlantDataModels.csproj" />
|
<ProjectReference Include="..\AircraftPlantDataModels\AircraftPlantDataModels.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
|
||||||
|
<Exec Command="copy /Y "$(TargetDir)*.dll" "$(SolutionDir)ImplementationExtensions\*.dll"" />
|
||||||
|
</Target>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
@ -0,0 +1,36 @@
|
|||||||
|
using AircraftPlantContracts.DependencyInjections;
|
||||||
|
using AircraftPlantContracts.StoragesContracts;
|
||||||
|
using AircraftPlantDatabaseImplement.Implements;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace AircraftPlantDatabaseImplement
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Реализация интерфейса для регистрации зависимостей
|
||||||
|
/// </summary>
|
||||||
|
public class DatabaseImplementationExtension : IImplementationExtension
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Приоритет
|
||||||
|
/// </summary>
|
||||||
|
public int Priority => 2;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Регистрация сервисов
|
||||||
|
/// </summary>
|
||||||
|
public void RegisterServices()
|
||||||
|
{
|
||||||
|
DependencyManager.Instance.RegisterType<IClientStorage, ClientStorage>();
|
||||||
|
DependencyManager.Instance.RegisterType<IImplementerStorage, ImplementerStorage>();
|
||||||
|
DependencyManager.Instance.RegisterType<IComponentStorage, ComponentStorage>();
|
||||||
|
DependencyManager.Instance.RegisterType<IPlaneStorage, PlaneStorage>();
|
||||||
|
DependencyManager.Instance.RegisterType<IOrderStorage, OrderStorage>();
|
||||||
|
DependencyManager.Instance.RegisterType<IMessageInfoStorage, MessageInfoStorage>();
|
||||||
|
DependencyManager.Instance.RegisterType<IBackUpInfo, BackUpInfo>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,45 @@
|
|||||||
|
using AircraftPlantContracts.StoragesContracts;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace AircraftPlantDatabaseImplement.Implements
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Реализация интерфейса получения данных из хранилища
|
||||||
|
/// </summary>
|
||||||
|
public class BackUpInfo : IBackUpInfo
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Получить список объектов
|
||||||
|
/// </summary>
|
||||||
|
/// <typeparam name="T"></typeparam>
|
||||||
|
/// <returns></returns>
|
||||||
|
public List<T>? GetList<T>() where T : class, new()
|
||||||
|
{
|
||||||
|
using var context = new AircraftPlantDatabase();
|
||||||
|
return context.Set<T>().ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Получить тип
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="modelInterfaceName"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
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,6 +4,7 @@ using AircraftPlantDataModels.Models;
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
@ -55,6 +56,9 @@ namespace AircraftPlantDatabaseImplement.Models
|
|||||||
[Required]
|
[Required]
|
||||||
public string Body { get; set; } = string.Empty;
|
public string Body { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
[NotMapped]
|
||||||
|
public int Id { get; private set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Создание модели письма
|
/// Создание модели письма
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -11,4 +11,8 @@
|
|||||||
<ProjectReference Include="..\AircraftPlantDataModels\AircraftPlantDataModels.csproj" />
|
<ProjectReference Include="..\AircraftPlantDataModels\AircraftPlantDataModels.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
|
||||||
|
<Exec Command="copy /Y "$(TargetDir)*.dll" "$(SolutionDir)ImplementationExtensions\*.dll"" />
|
||||||
|
</Target>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
@ -0,0 +1,36 @@
|
|||||||
|
using AircraftPlantContracts.DependencyInjections;
|
||||||
|
using AircraftPlantContracts.StoragesContracts;
|
||||||
|
using AircraftPlantFileImplement.Implements;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace AircraftPlantFileImplement
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Реализация интерфейса для регистрации зависимостей
|
||||||
|
/// </summary>
|
||||||
|
public class FileImplementationExtension : IImplementationExtension
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Приоритет
|
||||||
|
/// </summary>
|
||||||
|
public int Priority => 1;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Регистрация сервисов
|
||||||
|
/// </summary>
|
||||||
|
public void RegisterServices()
|
||||||
|
{
|
||||||
|
DependencyManager.Instance.RegisterType<IClientStorage, ClientStorage>();
|
||||||
|
DependencyManager.Instance.RegisterType<IImplementerStorage, ImplementerStorage>();
|
||||||
|
DependencyManager.Instance.RegisterType<IComponentStorage, ComponentStorage>();
|
||||||
|
DependencyManager.Instance.RegisterType<IPlaneStorage, PlaneStorage>();
|
||||||
|
DependencyManager.Instance.RegisterType<IOrderStorage, OrderStorage>();
|
||||||
|
DependencyManager.Instance.RegisterType<IMessageInfoStorage, MessageInfoStorage>();
|
||||||
|
DependencyManager.Instance.RegisterType<IBackUpInfo, BackUpInfo>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,48 @@
|
|||||||
|
using AircraftPlantContracts.StoragesContracts;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace AircraftPlantFileImplement.Implements
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Реализация интерфейса получения данных из хранилища
|
||||||
|
/// </summary>
|
||||||
|
public class BackUpInfo : IBackUpInfo
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Получить список объектов
|
||||||
|
/// </summary>
|
||||||
|
/// <typeparam name="T"></typeparam>
|
||||||
|
/// <returns></returns>
|
||||||
|
public List<T>? GetList<T>() where T : class, new()
|
||||||
|
{
|
||||||
|
var source = DataFileSingleton.GetInstance();
|
||||||
|
return (List<T>?)source.GetType()
|
||||||
|
.GetProperties()
|
||||||
|
.FirstOrDefault(x => x.PropertyType.IsGenericType && x.PropertyType.GetGenericArguments()[0] == typeof(T))
|
||||||
|
?.GetValue(source);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Получить тип
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="modelInterfaceName"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -45,6 +45,8 @@ namespace AircraftPlantFileImplement.Models
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public string Body { get; set; } = string.Empty;
|
public string Body { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
public int Id => throw new NotImplementedException();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Создание модели письма
|
/// Создание модели письма
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -11,4 +11,8 @@
|
|||||||
<ProjectReference Include="..\AircraftPlantDataModels\AircraftPlantDataModels.csproj" />
|
<ProjectReference Include="..\AircraftPlantDataModels\AircraftPlantDataModels.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
|
||||||
|
<Exec Command="copy /Y "$(TargetDir)*.dll" "$(SolutionDir)ImplementationExtensions\*.dll"" />
|
||||||
|
</Target>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
@ -0,0 +1,35 @@
|
|||||||
|
using AircraftPlantContracts.StoragesContracts;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace AircraftPlantListImplement.Implements
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Реализация интерфейса получения данных из хранилища
|
||||||
|
/// </summary>
|
||||||
|
public class BackUpInfo : IBackUpInfo
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Получить список объектов
|
||||||
|
/// </summary>
|
||||||
|
/// <typeparam name="T"></typeparam>
|
||||||
|
/// <returns></returns>
|
||||||
|
public List<T>? GetList<T>() where T : class, new()
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Получить тип
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="modelInterfaceName"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public Type? GetTypeByModelInterface(string modelInterfaceName)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,36 @@
|
|||||||
|
using AircraftPlantContracts.DependencyInjections;
|
||||||
|
using AircraftPlantContracts.StoragesContracts;
|
||||||
|
using AircraftPlantListImplement.Implements;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace AircraftPlantListImplement
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Реализация интерфейса для регистрации зависимостей
|
||||||
|
/// </summary>
|
||||||
|
public class ListImplementationExtension : IImplementationExtension
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Приоритет
|
||||||
|
/// </summary>
|
||||||
|
public int Priority => 0;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Регистрация сервисов
|
||||||
|
/// </summary>
|
||||||
|
public void RegisterServices()
|
||||||
|
{
|
||||||
|
DependencyManager.Instance.RegisterType<IClientStorage, ClientStorage>();
|
||||||
|
DependencyManager.Instance.RegisterType<IImplementerStorage, ImplementerStorage>();
|
||||||
|
DependencyManager.Instance.RegisterType<IComponentStorage, ComponentStorage>();
|
||||||
|
DependencyManager.Instance.RegisterType<IPlaneStorage, PlaneStorage>();
|
||||||
|
DependencyManager.Instance.RegisterType<IOrderStorage, OrderStorage>();
|
||||||
|
DependencyManager.Instance.RegisterType<IMessageInfoStorage, MessageInfoStorage>();
|
||||||
|
DependencyManager.Instance.RegisterType<IBackUpInfo, BackUpInfo>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -44,6 +44,8 @@ namespace AircraftPlantListImplement.Models
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public string Body { get; set; } = string.Empty;
|
public string Body { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
public int Id => throw new NotImplementedException();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Создание модели письма
|
/// Создание модели письма
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
63
AircraftPlant/AircraftPlantView/DataGridViewExtension.cs
Normal file
63
AircraftPlant/AircraftPlantView/DataGridViewExtension.cs
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
using AircraftPlantContracts.Attributes;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace AircraftPlantView
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Класс-расширение для DataGridView
|
||||||
|
/// </summary>
|
||||||
|
public static class DataGridViewExtension
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Настройка и заполнение DataGridView
|
||||||
|
/// </summary>
|
||||||
|
/// <typeparam name="T"></typeparam>
|
||||||
|
/// <param name="grid"></param>
|
||||||
|
/// <param name="data"></param>
|
||||||
|
/// <exception cref="InvalidOperationException"></exception>
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -97,14 +97,7 @@ namespace AircraftPlantView
|
|||||||
{
|
{
|
||||||
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;
|
|
||||||
dataGridView.Columns["Email"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
|
||||||
}
|
|
||||||
_logger.LogInformation("Загрузка клиентов");
|
_logger.LogInformation("Загрузка клиентов");
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
using AircraftPlantContracts.BindingModels;
|
using AircraftPlantContracts.BindingModels;
|
||||||
using AircraftPlantContracts.BusinessLogicsContracts;
|
using AircraftPlantContracts.BusinessLogicsContracts;
|
||||||
|
using AircraftPlantContracts.DependencyInjections;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
@ -57,15 +58,12 @@ namespace AircraftPlantView
|
|||||||
/// <param name="e"></param>
|
/// <param name="e"></param>
|
||||||
private void buttonAdd_Click(object sender, EventArgs e)
|
private void buttonAdd_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
var service = Program.ServiceProvider?.GetService(typeof(FormComponent));
|
var form = DependencyManager.Instance.Resolve<FormComponent>();
|
||||||
if (service is FormComponent form)
|
|
||||||
{
|
|
||||||
if (form.ShowDialog() == DialogResult.OK)
|
if (form.ShowDialog() == DialogResult.OK)
|
||||||
{
|
{
|
||||||
LoadData();
|
LoadData();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Кнопка "Изменить"
|
/// Кнопка "Изменить"
|
||||||
@ -76,9 +74,7 @@ namespace AircraftPlantView
|
|||||||
{
|
{
|
||||||
if (dataGridView.SelectedRows.Count == 1)
|
if (dataGridView.SelectedRows.Count == 1)
|
||||||
{
|
{
|
||||||
var service = Program.ServiceProvider?.GetService(typeof(FormComponent));
|
var form = DependencyManager.Instance.Resolve<FormComponent>();
|
||||||
if (service is FormComponent form)
|
|
||||||
{
|
|
||||||
form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||||
if (form.ShowDialog() == DialogResult.OK)
|
if (form.ShowDialog() == DialogResult.OK)
|
||||||
{
|
{
|
||||||
@ -86,7 +82,6 @@ namespace AircraftPlantView
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Кнопка "Удалить"
|
/// Кнопка "Удалить"
|
||||||
@ -135,13 +130,7 @@ namespace AircraftPlantView
|
|||||||
{
|
{
|
||||||
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)
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
using AircraftPlantContracts.BindingModels;
|
using AircraftPlantContracts.BindingModels;
|
||||||
using AircraftPlantContracts.BusinessLogicsContracts;
|
using AircraftPlantContracts.BusinessLogicsContracts;
|
||||||
|
using AircraftPlantContracts.DependencyInjections;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
@ -57,15 +58,12 @@ namespace AircraftPlantView
|
|||||||
/// <param name="e"></param>
|
/// <param name="e"></param>
|
||||||
private void buttonAdd_Click(object sender, EventArgs e)
|
private void buttonAdd_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
var service = Program.ServiceProvider?.GetService(typeof(FormImplementer));
|
var form = DependencyManager.Instance.Resolve<FormImplementer>();
|
||||||
if (service is FormImplementer form)
|
|
||||||
{
|
|
||||||
if (form.ShowDialog() == DialogResult.OK)
|
if (form.ShowDialog() == DialogResult.OK)
|
||||||
{
|
{
|
||||||
LoadData();
|
LoadData();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Кнопка "Изменить"
|
/// Кнопка "Изменить"
|
||||||
@ -76,9 +74,7 @@ namespace AircraftPlantView
|
|||||||
{
|
{
|
||||||
if (dataGridView.SelectedRows.Count == 1)
|
if (dataGridView.SelectedRows.Count == 1)
|
||||||
{
|
{
|
||||||
var service = Program.ServiceProvider?.GetService(typeof(FormImplementer));
|
var form = DependencyManager.Instance.Resolve<FormImplementer>();
|
||||||
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);
|
||||||
if (form.ShowDialog() == DialogResult.OK)
|
if (form.ShowDialog() == DialogResult.OK)
|
||||||
{
|
{
|
||||||
@ -86,7 +82,6 @@ namespace AircraftPlantView
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Кнопка "Удалить"
|
/// Кнопка "Удалить"
|
||||||
@ -135,13 +130,7 @@ namespace AircraftPlantView
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var list = _logic.ReadList(null);
|
dataGridView.FillAndConfigGrid(_logic.ReadList(null));
|
||||||
if (list != null)
|
|
||||||
{
|
|
||||||
dataGridView.DataSource = list;
|
|
||||||
dataGridView.Columns["Id"].Visible = false;
|
|
||||||
dataGridView.Columns["ImplementerFIO"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
|
||||||
}
|
|
||||||
_logger.LogInformation("Загрузка списка исполнителей");
|
_logger.LogInformation("Загрузка списка исполнителей");
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
|
@ -57,14 +57,7 @@ namespace AircraftPlantView
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var list = _logic.ReadList(null);
|
dataGridView.FillAndConfigGrid(_logic.ReadList(null));
|
||||||
if (list != null)
|
|
||||||
{
|
|
||||||
dataGridView.DataSource = list;
|
|
||||||
dataGridView.Columns["MessageId"].Visible = false;
|
|
||||||
dataGridView.Columns["ClientId"].Visible = false;
|
|
||||||
dataGridView.Columns["Body"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
|
||||||
}
|
|
||||||
_logger.LogInformation("Загрузка писем");
|
_logger.LogInformation("Загрузка писем");
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
|
11
AircraftPlant/AircraftPlantView/FormMain.Designer.cs
generated
11
AircraftPlant/AircraftPlantView/FormMain.Designer.cs
generated
@ -44,6 +44,7 @@
|
|||||||
списокЗаказовToolStripMenuItem = new ToolStripMenuItem();
|
списокЗаказовToolStripMenuItem = new ToolStripMenuItem();
|
||||||
запускРаботToolStripMenuItem = new ToolStripMenuItem();
|
запускРаботToolStripMenuItem = new ToolStripMenuItem();
|
||||||
почтаToolStripMenuItem = new ToolStripMenuItem();
|
почтаToolStripMenuItem = new ToolStripMenuItem();
|
||||||
|
создатьБэкапToolStripMenuItem = new ToolStripMenuItem();
|
||||||
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
|
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
|
||||||
menuStrip.SuspendLayout();
|
menuStrip.SuspendLayout();
|
||||||
SuspendLayout();
|
SuspendLayout();
|
||||||
@ -98,7 +99,7 @@
|
|||||||
//
|
//
|
||||||
// menuStrip
|
// menuStrip
|
||||||
//
|
//
|
||||||
menuStrip.Items.AddRange(new ToolStripItem[] { справочникиToolStripMenuItem, отчетыToolStripMenuItem, запускРаботToolStripMenuItem, почтаToolStripMenuItem });
|
menuStrip.Items.AddRange(new ToolStripItem[] { справочникиToolStripMenuItem, отчетыToolStripMenuItem, запускРаботToolStripMenuItem, почтаToolStripMenuItem, создатьБэкапToolStripMenuItem });
|
||||||
menuStrip.Location = new Point(0, 0);
|
menuStrip.Location = new Point(0, 0);
|
||||||
menuStrip.Name = "menuStrip";
|
menuStrip.Name = "menuStrip";
|
||||||
menuStrip.Size = new Size(984, 24);
|
menuStrip.Size = new Size(984, 24);
|
||||||
@ -182,6 +183,13 @@
|
|||||||
почтаToolStripMenuItem.Text = "Почта";
|
почтаToolStripMenuItem.Text = "Почта";
|
||||||
почтаToolStripMenuItem.Click += почтаToolStripMenuItem_Click;
|
почтаToolStripMenuItem.Click += почтаToolStripMenuItem_Click;
|
||||||
//
|
//
|
||||||
|
// создатьБэкапToolStripMenuItem
|
||||||
|
//
|
||||||
|
создатьБэкапToolStripMenuItem.Name = "создатьБэкапToolStripMenuItem";
|
||||||
|
создатьБэкапToolStripMenuItem.Size = new Size(97, 20);
|
||||||
|
создатьБэкапToolStripMenuItem.Text = "Создать бэкап";
|
||||||
|
создатьБэкапToolStripMenuItem.Click += создатьБэкапToolStripMenuItem_Click;
|
||||||
|
//
|
||||||
// FormMain
|
// FormMain
|
||||||
//
|
//
|
||||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||||
@ -221,5 +229,6 @@
|
|||||||
private ToolStripMenuItem запускРаботToolStripMenuItem;
|
private ToolStripMenuItem запускРаботToolStripMenuItem;
|
||||||
private ToolStripMenuItem исполнителиToolStripMenuItem;
|
private ToolStripMenuItem исполнителиToolStripMenuItem;
|
||||||
private ToolStripMenuItem почтаToolStripMenuItem;
|
private ToolStripMenuItem почтаToolStripMenuItem;
|
||||||
|
private ToolStripMenuItem создатьБэкапToolStripMenuItem;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,6 +1,7 @@
|
|||||||
using AircraftPlantBusinessLogic.BusinessLogics;
|
using AircraftPlantBusinessLogic.BusinessLogics;
|
||||||
using AircraftPlantContracts.BindingModels;
|
using AircraftPlantContracts.BindingModels;
|
||||||
using AircraftPlantContracts.BusinessLogicsContracts;
|
using AircraftPlantContracts.BusinessLogicsContracts;
|
||||||
|
using AircraftPlantContracts.DependencyInjections;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
@ -39,18 +40,24 @@ namespace AircraftPlantView
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private readonly IWorkProcess _workProcess;
|
private readonly IWorkProcess _workProcess;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Бизнес-логика для создания бэкапа
|
||||||
|
/// </summary>
|
||||||
|
private readonly IBackUpLogic _backUpLogic;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Конструктор
|
/// Конструктор
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="logger"></param>
|
/// <param name="logger"></param>
|
||||||
/// <param name="logic"></param>
|
/// <param name="logic"></param>
|
||||||
public FormMain(ILogger<FormMain> logger, IOrderLogic orderLogic, IReportLogic reportLogic, IWorkProcess workProcess)
|
public FormMain(ILogger<FormMain> logger, IOrderLogic orderLogic, IReportLogic reportLogic, IWorkProcess workProcess, IBackUpLogic backUpLogic)
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
_orderLogic = orderLogic;
|
_orderLogic = orderLogic;
|
||||||
_reportLogic = reportLogic;
|
_reportLogic = reportLogic;
|
||||||
_workProcess = workProcess;
|
_workProcess = workProcess;
|
||||||
|
_backUpLogic = backUpLogic;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -70,12 +77,9 @@ namespace AircraftPlantView
|
|||||||
/// <param name="e"></param>
|
/// <param name="e"></param>
|
||||||
private void компонентыToolStripMenuItem_Click(object sender, EventArgs e)
|
private void компонентыToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
var service = Program.ServiceProvider?.GetService(typeof(FormComponents));
|
var form = DependencyManager.Instance.Resolve<FormComponents>();
|
||||||
if (service is FormComponents form)
|
|
||||||
{
|
|
||||||
form.ShowDialog();
|
form.ShowDialog();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Показать список всех изделий
|
/// Показать список всех изделий
|
||||||
@ -84,12 +88,9 @@ namespace AircraftPlantView
|
|||||||
/// <param name="e"></param>
|
/// <param name="e"></param>
|
||||||
private void изделияToolStripMenuItem_Click(object sender, EventArgs e)
|
private void изделияToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
var service = Program.ServiceProvider?.GetService(typeof(FormPlanes));
|
var form = DependencyManager.Instance.Resolve<FormPlanes>();
|
||||||
if (service is FormPlanes form)
|
|
||||||
{
|
|
||||||
form.ShowDialog();
|
form.ShowDialog();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Вывести список всех клиентов
|
/// Вывести список всех клиентов
|
||||||
@ -98,12 +99,9 @@ namespace AircraftPlantView
|
|||||||
/// <param name="e"></param>
|
/// <param name="e"></param>
|
||||||
private void клиентыToolStripMenuItem_Click(object sender, EventArgs e)
|
private void клиентыToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
var service = Program.ServiceProvider?.GetService(typeof(FormClients));
|
var form = DependencyManager.Instance.Resolve<FormClients>();
|
||||||
if (service is FormClients form)
|
|
||||||
{
|
|
||||||
form.ShowDialog();
|
form.ShowDialog();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Вывести список всех исполнителей
|
/// Вывести список всех исполнителей
|
||||||
@ -112,12 +110,9 @@ namespace AircraftPlantView
|
|||||||
/// <param name="e"></param>
|
/// <param name="e"></param>
|
||||||
private void исполнителиToolStripMenuItem_Click(object sender, EventArgs e)
|
private void исполнителиToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
var service = Program.ServiceProvider?.GetService(typeof(FormImplementers));
|
var form = DependencyManager.Instance.Resolve<FormImplementers>();
|
||||||
if (service is FormImplementers form)
|
|
||||||
{
|
|
||||||
form.ShowDialog();
|
form.ShowDialog();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Вывести отчет по изделиям
|
/// Вывести отчет по изделиям
|
||||||
@ -141,12 +136,9 @@ namespace AircraftPlantView
|
|||||||
/// <param name="e"></param>
|
/// <param name="e"></param>
|
||||||
private void изделияСКомпонентамиToolStripMenuItem_Click(object sender, EventArgs e)
|
private void изделияСКомпонентамиToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
var service = Program.ServiceProvider?.GetService(typeof(FormReportPlaneComponents));
|
var form = DependencyManager.Instance.Resolve<FormReportPlaneComponents>();
|
||||||
if (service is FormReportPlaneComponents form)
|
|
||||||
{
|
|
||||||
form.ShowDialog();
|
form.ShowDialog();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Получить отчет по заказам
|
/// Получить отчет по заказам
|
||||||
@ -155,12 +147,9 @@ namespace AircraftPlantView
|
|||||||
/// <param name="e"></param>
|
/// <param name="e"></param>
|
||||||
private void списокЗаказовToolStripMenuItem_Click(object sender, EventArgs e)
|
private void списокЗаказовToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
var service = Program.ServiceProvider?.GetService(typeof(FormReportOrders));
|
var form = DependencyManager.Instance.Resolve<FormReportOrders>();
|
||||||
if (service is FormReportOrders form)
|
|
||||||
{
|
|
||||||
form.ShowDialog();
|
form.ShowDialog();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Запуск имитации работы исполнителей
|
/// Запуск имитации работы исполнителей
|
||||||
@ -170,7 +159,7 @@ namespace AircraftPlantView
|
|||||||
private void запускРаботToolStripMenuItem_Click(object sender, EventArgs e)
|
private void запускРаботToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
_workProcess.DoWork((
|
_workProcess.DoWork((
|
||||||
Program.ServiceProvider?.GetService(typeof(IImplementerLogic)) as IImplementerLogic)!,
|
DependencyManager.Instance.Resolve<IImplementerLogic>() as IImplementerLogic)!,
|
||||||
_orderLogic);
|
_orderLogic);
|
||||||
MessageBox.Show("Процесс обработки запущен", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
MessageBox.Show("Процесс обработки запущен", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||||
}
|
}
|
||||||
@ -182,11 +171,36 @@ namespace AircraftPlantView
|
|||||||
/// <param name="e"></param>
|
/// <param name="e"></param>
|
||||||
private void почтаToolStripMenuItem_Click(object sender, EventArgs e)
|
private void почтаToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
var service = Program.ServiceProvider?.GetService(typeof(FormMail));
|
var form = DependencyManager.Instance.Resolve<FormMail>();
|
||||||
if (service is FormMail form)
|
|
||||||
{
|
|
||||||
form.ShowDialog();
|
form.ShowDialog();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Создать бэкап
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sender"></param>
|
||||||
|
/// <param name="e"></param>
|
||||||
|
private void создатьБэкапToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (_backUpLogic != null)
|
||||||
|
{
|
||||||
|
var fbd = new FolderBrowserDialog();
|
||||||
|
if (fbd.ShowDialog() == DialogResult.OK)
|
||||||
|
{
|
||||||
|
_backUpLogic.CreateBackUp(new BackUpSaveBindingModel
|
||||||
|
{
|
||||||
|
FolderName = fbd.SelectedPath
|
||||||
|
});
|
||||||
|
MessageBox.Show("Бекап создан", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -196,13 +210,10 @@ namespace AircraftPlantView
|
|||||||
/// <param name="e"></param>
|
/// <param name="e"></param>
|
||||||
private void buttonCreateOrder_Click(object sender, EventArgs e)
|
private void buttonCreateOrder_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
var service = Program.ServiceProvider?.GetService(typeof(FormCreateOrder));
|
var form = DependencyManager.Instance.Resolve<FormCreateOrder>();
|
||||||
if (service is FormCreateOrder form)
|
|
||||||
{
|
|
||||||
form.ShowDialog();
|
form.ShowDialog();
|
||||||
LoadData();
|
LoadData();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Кнопка "Заказ выдан"
|
/// Кнопка "Заказ выдан"
|
||||||
@ -251,14 +262,7 @@ namespace AircraftPlantView
|
|||||||
_logger.LogInformation("Загрузка заказов");
|
_logger.LogInformation("Загрузка заказов");
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var list = _orderLogic.ReadList(null);
|
dataGridView.FillAndConfigGrid(_orderLogic.ReadList(null));
|
||||||
if (list != null)
|
|
||||||
{
|
|
||||||
dataGridView.DataSource = list;
|
|
||||||
dataGridView.Columns["PlaneId"].Visible = false;
|
|
||||||
dataGridView.Columns["ClientId"].Visible = false;
|
|
||||||
dataGridView.Columns["ImplementerId"].Visible = false;
|
|
||||||
}
|
|
||||||
_logger.LogInformation("Загрузка заказов");
|
_logger.LogInformation("Загрузка заказов");
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
using AircraftPlantContracts.BindingModels;
|
using AircraftPlantContracts.BindingModels;
|
||||||
using AircraftPlantContracts.BusinessLogicsContracts;
|
using AircraftPlantContracts.BusinessLogicsContracts;
|
||||||
|
using AircraftPlantContracts.DependencyInjections;
|
||||||
using AircraftPlantContracts.SearchModels;
|
using AircraftPlantContracts.SearchModels;
|
||||||
using AircraftPlantDataModels.Models;
|
using AircraftPlantDataModels.Models;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
@ -90,9 +91,7 @@ namespace AircraftPlantView
|
|||||||
/// <param name="e"></param>
|
/// <param name="e"></param>
|
||||||
private void buttonAdd_Click(object sender, EventArgs e)
|
private void buttonAdd_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
var service = Program.ServiceProvider?.GetService(typeof(FormPlaneComponent));
|
var form = DependencyManager.Instance.Resolve<FormPlaneComponent>();
|
||||||
if (service is FormPlaneComponent form)
|
|
||||||
{
|
|
||||||
if (form.ShowDialog() == DialogResult.OK)
|
if (form.ShowDialog() == DialogResult.OK)
|
||||||
{
|
{
|
||||||
if (form.ComponentModel == null)
|
if (form.ComponentModel == null)
|
||||||
@ -111,7 +110,6 @@ namespace AircraftPlantView
|
|||||||
LoadData();
|
LoadData();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Кнопка "Изменить"
|
/// Кнопка "Изменить"
|
||||||
@ -122,9 +120,7 @@ namespace AircraftPlantView
|
|||||||
{
|
{
|
||||||
if (dataGridView.SelectedRows.Count == 1)
|
if (dataGridView.SelectedRows.Count == 1)
|
||||||
{
|
{
|
||||||
var service = Program.ServiceProvider?.GetService(typeof(FormPlaneComponent));
|
var form = DependencyManager.Instance.Resolve<FormPlaneComponent>();
|
||||||
if (service is FormPlaneComponent form)
|
|
||||||
{
|
|
||||||
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells[0].Value);
|
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells[0].Value);
|
||||||
form.Id = id;
|
form.Id = id;
|
||||||
form.Count = _planeComponents[id].Item2;
|
form.Count = _planeComponents[id].Item2;
|
||||||
@ -140,7 +136,6 @@ namespace AircraftPlantView
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Кнопка "Удалить"
|
/// Кнопка "Удалить"
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
using AircraftPlantContracts.BindingModels;
|
using AircraftPlantContracts.BindingModels;
|
||||||
using AircraftPlantContracts.BusinessLogicsContracts;
|
using AircraftPlantContracts.BusinessLogicsContracts;
|
||||||
|
using AircraftPlantContracts.DependencyInjections;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
@ -57,15 +58,12 @@ namespace AircraftPlantView
|
|||||||
/// <param name="e"></param>
|
/// <param name="e"></param>
|
||||||
private void buttonAdd_Click(object sender, EventArgs e)
|
private void buttonAdd_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
var service = Program.ServiceProvider?.GetService(typeof(FormPlane));
|
var form = DependencyManager.Instance.Resolve<FormPlane>();
|
||||||
if (service is FormPlane form)
|
|
||||||
{
|
|
||||||
if (form.ShowDialog() == DialogResult.OK)
|
if (form.ShowDialog() == DialogResult.OK)
|
||||||
{
|
{
|
||||||
LoadData();
|
LoadData();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Кнопка "Изменить"
|
/// Кнопка "Изменить"
|
||||||
@ -76,9 +74,7 @@ namespace AircraftPlantView
|
|||||||
{
|
{
|
||||||
if (dataGridView.SelectedRows.Count == 1)
|
if (dataGridView.SelectedRows.Count == 1)
|
||||||
{
|
{
|
||||||
var service = Program.ServiceProvider?.GetService(typeof(FormPlane));
|
var form = DependencyManager.Instance.Resolve<FormPlane>();
|
||||||
if (service is FormPlane form)
|
|
||||||
{
|
|
||||||
form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||||
if (form.ShowDialog() == DialogResult.OK)
|
if (form.ShowDialog() == DialogResult.OK)
|
||||||
{
|
{
|
||||||
@ -86,7 +82,6 @@ namespace AircraftPlantView
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Кнопка "Удалить"
|
/// Кнопка "Удалить"
|
||||||
@ -138,14 +133,7 @@ namespace AircraftPlantView
|
|||||||
{
|
{
|
||||||
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["PlaneName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
|
||||||
dataGridView.Columns["PlaneComponents"].Visible = false;
|
|
||||||
}
|
|
||||||
_logger.LogInformation("Загрузка изделий");
|
_logger.LogInformation("Загрузка изделий");
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
|
@ -10,17 +10,12 @@ using NLog.Extensions.Logging;
|
|||||||
using System;
|
using System;
|
||||||
using AircraftPlantBusinessLogic.MailWorker;
|
using AircraftPlantBusinessLogic.MailWorker;
|
||||||
using AircraftPlantContracts.BindingModels;
|
using AircraftPlantContracts.BindingModels;
|
||||||
|
using AircraftPlantContracts.DependencyInjections;
|
||||||
|
|
||||||
namespace AircraftPlantView
|
namespace AircraftPlantView
|
||||||
{
|
{
|
||||||
internal static class Program
|
internal static class Program
|
||||||
{
|
{
|
||||||
/// <summary>
|
|
||||||
/// IoC-êîíòåéíåð
|
|
||||||
/// </summary>
|
|
||||||
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>
|
||||||
@ -30,15 +25,12 @@ namespace AircraftPlantView
|
|||||||
// To customize application configuration such as set high DPI settings or default font,
|
// To customize application configuration such as set high DPI settings or default font,
|
||||||
// see https://aka.ms/applicationconfiguration.
|
// see https://aka.ms/applicationconfiguration.
|
||||||
ApplicationConfiguration.Initialize();
|
ApplicationConfiguration.Initialize();
|
||||||
|
InitDependency();
|
||||||
var services = new ServiceCollection();
|
|
||||||
ConfigureServices(services);
|
|
||||||
_serviceProvider = services.BuildServiceProvider();
|
|
||||||
|
|
||||||
// Íàñòðîéêà äëÿ îòïðàâêè ïèñåì
|
// Íàñòðîéêà äëÿ îòïðàâêè ïèñåì
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var mailSender = _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,
|
||||||
@ -54,66 +46,62 @@ namespace AircraftPlantView
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
var logger = _serviceProvider.GetService<ILogger>();
|
var logger = DependencyManager.Instance.Resolve<ILogger>();
|
||||||
logger?.LogError(ex, "Îøèáêà ðàáîòû ñ ïî÷òîé");
|
logger?.LogError(ex, "Îøèáêà ðàáîòû ñ ïî÷òîé");
|
||||||
}
|
}
|
||||||
|
|
||||||
Application.Run(_serviceProvider.GetRequiredService<FormMain>());
|
Application.Run(DependencyManager.Instance.Resolve<FormMain>());
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Íàñòðîéêà IoC-êîíòåéíåðà è ëîããåðà
|
/// Èíèöèàëèçàöèÿ çàâèñèìîñòåé
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="services"></param>
|
/// <param name="services"></param>
|
||||||
private static void ConfigureServices(ServiceCollection services)
|
private static void InitDependency()
|
||||||
{
|
{
|
||||||
services.AddLogging(option =>
|
DependencyManager.InitDependency();
|
||||||
|
|
||||||
|
DependencyManager.Instance.AddLogging(option =>
|
||||||
{
|
{
|
||||||
option.SetMinimumLevel(LogLevel.Information);
|
option.SetMinimumLevel(LogLevel.Information);
|
||||||
option.AddNLog("nlog.config");
|
option.AddNLog("nlog.config");
|
||||||
});
|
});
|
||||||
|
|
||||||
services.AddTransient<IClientStorage, ClientStorage>();
|
DependencyManager.Instance.RegisterType<IClientLogic, ClientLogic>();
|
||||||
services.AddTransient<IImplementerStorage, ImplementerStorage>();
|
DependencyManager.Instance.RegisterType<IImplementerLogic, ImplementerLogic>();
|
||||||
services.AddTransient<IComponentStorage, ComponentStorage>();
|
DependencyManager.Instance.RegisterType<IComponentLogic, ComponentLogic>();
|
||||||
services.AddTransient<IOrderStorage, OrderStorage>();
|
DependencyManager.Instance.RegisterType<IOrderLogic, OrderLogic>();
|
||||||
services.AddTransient<IPlaneStorage, PlaneStorage>();
|
DependencyManager.Instance.RegisterType<IPlaneLogic, PlaneLogic>();
|
||||||
services.AddTransient<IMessageInfoStorage, MessageInfoStorage>();
|
DependencyManager.Instance.RegisterType<IReportLogic, ReportLogic>();
|
||||||
|
DependencyManager.Instance.RegisterType<IMessageInfoLogic, MessageInfoLogic>();
|
||||||
|
DependencyManager.Instance.RegisterType<IBackUpLogic, BackUpLogic>();
|
||||||
|
|
||||||
services.AddTransient<IClientLogic, ClientLogic>();
|
DependencyManager.Instance.RegisterType<IWorkProcess, WorkModeling>();
|
||||||
services.AddTransient<IImplementerLogic, ImplementerLogic>();
|
DependencyManager.Instance.RegisterType<AbstractMailWorker, MailKitWorker>(true);
|
||||||
services.AddTransient<IComponentLogic, ComponentLogic>();
|
|
||||||
services.AddTransient<IOrderLogic, OrderLogic>();
|
|
||||||
services.AddTransient<IPlaneLogic, PlaneLogic>();
|
|
||||||
services.AddTransient<IReportLogic, ReportLogic>();
|
|
||||||
services.AddTransient<IMessageInfoLogic, MessageInfoLogic>();
|
|
||||||
|
|
||||||
services.AddTransient<IWorkProcess, WorkModeling>();
|
DependencyManager.Instance.RegisterType<AbstractSaveToWord, SaveToWord>();
|
||||||
services.AddSingleton<AbstractMailWorker, MailKitWorker>();
|
DependencyManager.Instance.RegisterType<AbstractSaveToExcel, SaveToExcel>();
|
||||||
|
DependencyManager.Instance.RegisterType<AbstractSaveToPdf, SaveToPdf>();
|
||||||
|
|
||||||
services.AddTransient<AbstractSaveToWord, SaveToWord>();
|
DependencyManager.Instance.RegisterType<FormMain>();
|
||||||
services.AddTransient<AbstractSaveToExcel, SaveToExcel>();
|
DependencyManager.Instance.RegisterType<FormClients>();
|
||||||
services.AddTransient<AbstractSaveToPdf, SaveToPdf>();
|
DependencyManager.Instance.RegisterType<FormImplementers>();
|
||||||
|
DependencyManager.Instance.RegisterType<FormImplementer>();
|
||||||
services.AddTransient<FormMain>();
|
DependencyManager.Instance.RegisterType<FormComponent>();
|
||||||
services.AddTransient<FormClients>();
|
DependencyManager.Instance.RegisterType<FormComponents>();
|
||||||
services.AddTransient<FormImplementers>();
|
DependencyManager.Instance.RegisterType<FormCreateOrder>();
|
||||||
services.AddTransient<FormImplementer>();
|
DependencyManager.Instance.RegisterType<FormPlane>();
|
||||||
services.AddTransient<FormComponent>();
|
DependencyManager.Instance.RegisterType<FormPlaneComponent>();
|
||||||
services.AddTransient<FormComponents>();
|
DependencyManager.Instance.RegisterType<FormPlanes>();
|
||||||
services.AddTransient<FormCreateOrder>();
|
DependencyManager.Instance.RegisterType<FormReportPlaneComponents>();
|
||||||
services.AddTransient<FormPlane>();
|
DependencyManager.Instance.RegisterType<FormReportOrders>();
|
||||||
services.AddTransient<FormPlaneComponent>();
|
DependencyManager.Instance.RegisterType<FormMail>();
|
||||||
services.AddTransient<FormPlanes>();
|
|
||||||
services.AddTransient<FormReportPlaneComponents>();
|
|
||||||
services.AddTransient<FormReportOrders>();
|
|
||||||
services.AddTransient<FormMail>();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Ïðîâåðêà ïî÷òû
|
/// Ïðîâåðêà ïî÷òû
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="obj"></param>
|
/// <param name="obj"></param>
|
||||||
private static void MailCheck(object obj) => ServiceProvider?.GetService<AbstractMailWorker>()?.MailCheck();
|
private static void MailCheck(object obj) => DependencyManager.Instance.Resolve<AbstractMailWorker>()?.MailCheck();
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user