PIbd-21_MasenkinMS_LabWork08_Basic #15
2
.gitignore
vendored
2
.gitignore
vendored
@ -13,6 +13,8 @@
|
||||
|
||||
# User-specific files (MonoDevelop/Xamarin Studio)
|
||||
*.userprefs
|
||||
ImplementationExtensions
|
||||
BusinessLogicExtensions
|
||||
|
||||
# Mono auto generated files
|
||||
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>
|
||||
</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>
|
||||
<ProjectReference Include="..\AircraftPlantDataModels\AircraftPlantDataModels.csproj" />
|
||||
</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>
|
||||
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.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
@ -17,25 +18,26 @@ namespace AircraftPlantContracts.ViewModels
|
||||
/// <summary>
|
||||
/// Идентификатор
|
||||
/// </summary>
|
||||
[Column(visible: false)]
|
||||
public int Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// ФИО клиента
|
||||
/// </summary>
|
||||
[DisplayName("ФИО клиента")]
|
||||
public string ClientFIO { get; set; } = string.Empty;
|
||||
/// <summary>
|
||||
/// ФИО клиента
|
||||
/// </summary>
|
||||
[Column(title: "ФИО клиента", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)]
|
||||
public string ClientFIO { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// Логин (электронная почта)
|
||||
/// </summary>
|
||||
[DisplayName("Логин (эл. почта)")]
|
||||
public string Email { get; set; } = string.Empty;
|
||||
/// <summary>
|
||||
/// Логин (электронная почта)
|
||||
/// </summary>
|
||||
[Column(title: "Логин (эл. почта)", width: 150)]
|
||||
public string Email { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// Пароль
|
||||
/// </summary>
|
||||
[DisplayName("Пароль")]
|
||||
public string Password { get; set; } = string.Empty;
|
||||
/// <summary>
|
||||
/// Пароль
|
||||
/// </summary>
|
||||
[Column(title: "Пароль", width: 150)]
|
||||
public string Password { get; set; } = string.Empty;
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
using AircraftPlantDataModels.Models;
|
||||
using AircraftPlantContracts.Attributes;
|
||||
using AircraftPlantDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
@ -17,18 +18,19 @@ namespace AircraftPlantContracts.ViewModels
|
||||
/// <summary>
|
||||
/// Идентификатор
|
||||
/// </summary>
|
||||
[Column(visible: false)]
|
||||
public int Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Название компонента
|
||||
/// </summary>
|
||||
[DisplayName("Название компонента")]
|
||||
public string ComponentName { get; set; } = string.Empty;
|
||||
/// <summary>
|
||||
/// Название компонента
|
||||
/// </summary>
|
||||
[Column(title: "Название компонента", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)]
|
||||
public string ComponentName { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// Стоимость компонента
|
||||
/// </summary>
|
||||
[DisplayName("Цена")]
|
||||
public double Cost { get; set; }
|
||||
/// <summary>
|
||||
/// Стоимость компонента
|
||||
/// </summary>
|
||||
[Column(title: "Цена", width: 150)]
|
||||
public double Cost { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
using AircraftPlantDataModels.Models;
|
||||
using AircraftPlantContracts.Attributes;
|
||||
using AircraftPlantDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
@ -14,33 +15,34 @@ namespace AircraftPlantContracts.ViewModels
|
||||
/// </summary>
|
||||
public class ImplementerViewModel : IImplementerModel
|
||||
{
|
||||
/// <summary>
|
||||
/// Идентификатор
|
||||
/// </summary>
|
||||
public int Id { get; set; }
|
||||
/// <summary>
|
||||
/// Идентификатор
|
||||
/// </summary>
|
||||
[Column(visible: false)]
|
||||
public int Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// ФИО исполнителя
|
||||
/// </summary>
|
||||
[DisplayName("ФИО исполнителя")]
|
||||
public string ImplementerFIO { get; set; } = string.Empty;
|
||||
/// <summary>
|
||||
/// ФИО исполнителя
|
||||
/// </summary>
|
||||
[Column(title: "ФИО исполнителя", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)]
|
||||
public string ImplementerFIO { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// Пароль
|
||||
/// </summary>
|
||||
[DisplayName("Пароль")]
|
||||
public string Password { get; set; } = string.Empty;
|
||||
/// <summary>
|
||||
/// Пароль
|
||||
/// </summary>
|
||||
[Column(title: "Пароль", width: 150)]
|
||||
public string Password { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// Опыт работы
|
||||
/// </summary>
|
||||
[DisplayName("Опыт работы")]
|
||||
public int WorkExperience { get; set; }
|
||||
/// <summary>
|
||||
/// Опыт работы
|
||||
/// </summary>
|
||||
[Column(title: "Опыт работы", width: 100)]
|
||||
public int WorkExperience { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Квалификация
|
||||
/// </summary>
|
||||
[DisplayName("Квалификация")]
|
||||
public int Qualification { get; set; }
|
||||
/// <summary>
|
||||
/// Квалификация
|
||||
/// </summary>
|
||||
[Column(title: "Квалификация", width: 100)]
|
||||
public int Qualification { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
using AircraftPlantDataModels.Models;
|
||||
using AircraftPlantContracts.Attributes;
|
||||
using AircraftPlantDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
@ -17,35 +18,40 @@ namespace AircraftPlantContracts.ViewModels
|
||||
/// <summary>
|
||||
/// Идентификатор
|
||||
/// </summary>
|
||||
[Column(visible: false)]
|
||||
public string MessageId { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// Идентификатор клиента
|
||||
/// </summary>
|
||||
[Column(visible: false)]
|
||||
public int? ClientId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Адрес электронной почты отправителя
|
||||
/// </summary>
|
||||
[DisplayName("Отправитель")]
|
||||
[Column(title: "Отправитель", width: 150)]
|
||||
public string SenderName { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// Дата получения письма
|
||||
/// </summary>
|
||||
[DisplayName("Дата письма")]
|
||||
[Column(title: "Дата письма", width: 150)]
|
||||
public DateTime DateDelivery { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Заголовок письма
|
||||
/// </summary>
|
||||
[DisplayName("Заголовок")]
|
||||
[Column(title: "Заголовок", width: 150)]
|
||||
public string Subject { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// Тело письма
|
||||
/// </summary>
|
||||
[DisplayName("Текст")]
|
||||
[Column(title: "Текст", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)]
|
||||
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 System;
|
||||
using System.Collections.Generic;
|
||||
@ -15,73 +16,76 @@ namespace AircraftPlantContracts.ViewModels
|
||||
/// </summary>
|
||||
public class OrderViewModel : IOrderModel
|
||||
{
|
||||
/// <summary>
|
||||
/// Идентификатор
|
||||
/// </summary>
|
||||
[DisplayName("Номер")]
|
||||
public int Id { get; set; }
|
||||
/// <summary>
|
||||
/// Идентификатор
|
||||
/// </summary>
|
||||
[Column(title: "Номер", width: 50)]
|
||||
public int Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Идентификатор изделия
|
||||
/// </summary>
|
||||
public int PlaneId { get; set; }
|
||||
/// <summary>
|
||||
/// Идентификатор изделия
|
||||
/// </summary>
|
||||
[Column(visible: false)]
|
||||
public int PlaneId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Название изделия
|
||||
/// </summary>
|
||||
[DisplayName("Изделие")]
|
||||
public string PlaneName { get; set; } = string.Empty;
|
||||
/// <summary>
|
||||
/// Название изделия
|
||||
/// </summary>
|
||||
[Column(title: "Изделие", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)]
|
||||
public string PlaneName { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// Идентификатор клиента
|
||||
/// </summary>
|
||||
public int ClientId { get; set; }
|
||||
/// <summary>
|
||||
/// Идентификатор клиента
|
||||
/// </summary>
|
||||
[Column(visible: false)]
|
||||
public int ClientId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// ФИО клиента
|
||||
/// </summary>
|
||||
[DisplayName("ФИО клиента")]
|
||||
public string ClientFIO { get; set; } = string.Empty;
|
||||
/// <summary>
|
||||
/// ФИО клиента
|
||||
/// </summary>
|
||||
[Column(title: "ФИО клиента", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)]
|
||||
public string ClientFIO { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// Идентификатор исполнителя
|
||||
/// </summary>
|
||||
public int? ImplementerId { get; set; }
|
||||
/// <summary>
|
||||
/// Идентификатор исполнителя
|
||||
/// </summary>
|
||||
[Column(visible: false)]
|
||||
public int? ImplementerId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// ФИО клиента
|
||||
/// </summary>
|
||||
[DisplayName("ФИО исполнителя")]
|
||||
public string ImplementerFIO { get; set; } = string.Empty;
|
||||
/// <summary>
|
||||
/// ФИО клиента
|
||||
/// </summary>
|
||||
[Column(title: "ФИО исполнителя", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)]
|
||||
public string ImplementerFIO { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// Количество изделий
|
||||
/// </summary>
|
||||
[DisplayName("Количество")]
|
||||
public int Count { get; set; }
|
||||
/// <summary>
|
||||
/// Количество изделий
|
||||
/// </summary>
|
||||
[Column(title: "Количество", width: 100)]
|
||||
public int Count { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Сумма заказа
|
||||
/// </summary>
|
||||
[DisplayName("Сумма")]
|
||||
public double Sum { get; set; }
|
||||
/// <summary>
|
||||
/// Сумма заказа
|
||||
/// </summary>
|
||||
[Column(title: "Сумма", width: 100)]
|
||||
public double Sum { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Статус заказа
|
||||
/// </summary>
|
||||
[DisplayName("Статус")]
|
||||
public OrderStatus Status { get; set; } = OrderStatus.Неизвестен;
|
||||
/// <summary>
|
||||
/// Статус заказа
|
||||
/// </summary>
|
||||
[Column(title: "Статус", width: 70)]
|
||||
public OrderStatus Status { get; set; } = OrderStatus.Неизвестен;
|
||||
|
||||
/// <summary>
|
||||
/// Дата создания заказа
|
||||
/// </summary>
|
||||
[DisplayName("Дата создания")]
|
||||
public DateTime DateCreate { get; set; } = DateTime.Now;
|
||||
/// <summary>
|
||||
/// Дата создания заказа
|
||||
/// </summary>
|
||||
[Column(title: "Дата создания", width: 100)]
|
||||
public DateTime DateCreate { get; set; } = DateTime.Now;
|
||||
|
||||
/// <summary>
|
||||
/// Дата выполнения заказа
|
||||
/// </summary>
|
||||
[DisplayName("Дата выполнения")]
|
||||
[Column(title: "Дата выполнения", width: 100)]
|
||||
public DateTime? DateImplement { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
using AircraftPlantDataModels.Models;
|
||||
using AircraftPlantContracts.Attributes;
|
||||
using AircraftPlantDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
@ -14,27 +15,29 @@ namespace AircraftPlantContracts.ViewModels
|
||||
/// </summary>
|
||||
public class PlaneViewModel : IPlaneModel
|
||||
{
|
||||
/// <summary>
|
||||
/// Идентификатор
|
||||
/// </summary>
|
||||
public int Id { get; set; }
|
||||
/// <summary>
|
||||
/// Идентификатор
|
||||
/// </summary>
|
||||
[Column(visible: false)]
|
||||
public int Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Название изделия
|
||||
/// </summary>
|
||||
[DisplayName("Название изделия")]
|
||||
public string PlaneName { get; set; } = string.Empty;
|
||||
/// <summary>
|
||||
/// Название изделия
|
||||
/// </summary>
|
||||
[Column(title: "Название изделия", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)]
|
||||
public string PlaneName { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// Стоимость изделия
|
||||
/// </summary>
|
||||
[DisplayName("Цена")]
|
||||
public double Price { get; set; }
|
||||
/// <summary>
|
||||
/// Стоимость изделия
|
||||
/// </summary>
|
||||
[Column(title: "Цена", width: 150)]
|
||||
public double Price { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Коллекция компонентов изделия
|
||||
/// </summary>
|
||||
public Dictionary<int, (IComponentModel, int)> PlaneComponents
|
||||
/// <summary>
|
||||
/// Коллекция компонентов изделия
|
||||
/// </summary>
|
||||
[Column(visible: false)]
|
||||
public Dictionary<int, (IComponentModel, int)> PlaneComponents
|
||||
{
|
||||
get;
|
||||
set;
|
||||
|
@ -19,6 +19,8 @@ namespace AircraftPlantDataModels.Enums
|
||||
|
||||
Готов = 2,
|
||||
|
||||
Выдан = 3
|
||||
Выдан = 3,
|
||||
|
||||
Ожидание = 4 // Иначе возникает исключение ArgumentException
|
||||
}
|
||||
}
|
||||
|
@ -9,7 +9,7 @@ namespace AircraftPlantDataModels.Models
|
||||
/// <summary>
|
||||
/// Интерфейс для модели письма
|
||||
/// </summary>
|
||||
public interface IMessageInfoModel
|
||||
public interface IMessageInfoModel : IId
|
||||
{
|
||||
/// <summary>
|
||||
/// Идентификатор
|
||||
|
@ -20,4 +20,8 @@
|
||||
<ProjectReference Include="..\AircraftPlantDataModels\AircraftPlantDataModels.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
|
||||
<Exec Command="copy /Y "$(TargetDir)*.dll" "$(SolutionDir)ImplementationExtensions\*.dll"" />
|
||||
</Target>
|
||||
|
||||
</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.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
@ -55,6 +56,9 @@ namespace AircraftPlantDatabaseImplement.Models
|
||||
[Required]
|
||||
public string Body { get; set; } = string.Empty;
|
||||
|
||||
[NotMapped]
|
||||
public int Id { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Создание модели письма
|
||||
/// </summary>
|
||||
|
@ -11,4 +11,8 @@
|
||||
<ProjectReference Include="..\AircraftPlantDataModels\AircraftPlantDataModels.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
|
||||
<Exec Command="copy /Y "$(TargetDir)*.dll" "$(SolutionDir)ImplementationExtensions\*.dll"" />
|
||||
</Target>
|
||||
|
||||
</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>
|
||||
public string Body { get; set; } = string.Empty;
|
||||
|
||||
public int Id => throw new NotImplementedException();
|
||||
|
||||
/// <summary>
|
||||
/// Создание модели письма
|
||||
/// </summary>
|
||||
|
@ -11,4 +11,8 @@
|
||||
<ProjectReference Include="..\AircraftPlantDataModels\AircraftPlantDataModels.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
|
||||
<Exec Command="copy /Y "$(TargetDir)*.dll" "$(SolutionDir)ImplementationExtensions\*.dll"" />
|
||||
</Target>
|
||||
|
||||
</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>
|
||||
public string Body { get; set; } = string.Empty;
|
||||
|
||||
public int Id => throw new NotImplementedException();
|
||||
|
||||
/// <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
|
||||
{
|
||||
var list = _logic.ReadList(null);
|
||||
if (list != null)
|
||||
{
|
||||
dataGridView.DataSource = list;
|
||||
dataGridView.Columns["Id"].Visible = false;
|
||||
dataGridView.Columns["ClientFIO"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||
dataGridView.Columns["Email"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||
}
|
||||
dataGridView.FillAndConfigGrid(_logic.ReadList(null));
|
||||
_logger.LogInformation("Загрузка клиентов");
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
@ -1,5 +1,6 @@
|
||||
using AircraftPlantContracts.BindingModels;
|
||||
using AircraftPlantContracts.BusinessLogicsContracts;
|
||||
using AircraftPlantContracts.DependencyInjections;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@ -57,13 +58,10 @@ namespace AircraftPlantView
|
||||
/// <param name="e"></param>
|
||||
private void buttonAdd_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormComponent));
|
||||
if (service is FormComponent form)
|
||||
var form = DependencyManager.Instance.Resolve<FormComponent>();
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
|
||||
@ -76,14 +74,11 @@ namespace AircraftPlantView
|
||||
{
|
||||
if (dataGridView.SelectedRows.Count == 1)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormComponent));
|
||||
if (service is FormComponent form)
|
||||
var form = DependencyManager.Instance.Resolve<FormComponent>();
|
||||
form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -135,14 +130,8 @@ namespace AircraftPlantView
|
||||
{
|
||||
try
|
||||
{
|
||||
var list = _logic.ReadList(null);
|
||||
if (list != null)
|
||||
{
|
||||
dataGridView.DataSource = list;
|
||||
dataGridView.Columns["Id"].Visible = false;
|
||||
dataGridView.Columns["ComponentName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||
}
|
||||
_logger.LogInformation("Загрузка компонентов");
|
||||
dataGridView.FillAndConfigGrid(_logic.ReadList(null));
|
||||
_logger.LogInformation("Загрузка компонентов");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
@ -1,5 +1,6 @@
|
||||
using AircraftPlantContracts.BindingModels;
|
||||
using AircraftPlantContracts.BusinessLogicsContracts;
|
||||
using AircraftPlantContracts.DependencyInjections;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@ -57,13 +58,10 @@ namespace AircraftPlantView
|
||||
/// <param name="e"></param>
|
||||
private void buttonAdd_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormImplementer));
|
||||
if (service is FormImplementer form)
|
||||
var form = DependencyManager.Instance.Resolve<FormImplementer>();
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
|
||||
@ -76,14 +74,11 @@ namespace AircraftPlantView
|
||||
{
|
||||
if (dataGridView.SelectedRows.Count == 1)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormImplementer));
|
||||
if (service is FormImplementer form)
|
||||
var form = DependencyManager.Instance.Resolve<FormImplementer>();
|
||||
form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -135,14 +130,8 @@ namespace AircraftPlantView
|
||||
{
|
||||
try
|
||||
{
|
||||
var list = _logic.ReadList(null);
|
||||
if (list != null)
|
||||
{
|
||||
dataGridView.DataSource = list;
|
||||
dataGridView.Columns["Id"].Visible = false;
|
||||
dataGridView.Columns["ImplementerFIO"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||
}
|
||||
_logger.LogInformation("Загрузка списка исполнителей");
|
||||
dataGridView.FillAndConfigGrid(_logic.ReadList(null));
|
||||
_logger.LogInformation("Загрузка списка исполнителей");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
@ -57,14 +57,7 @@ namespace AircraftPlantView
|
||||
{
|
||||
try
|
||||
{
|
||||
var list = _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;
|
||||
}
|
||||
dataGridView.FillAndConfigGrid(_logic.ReadList(null));
|
||||
_logger.LogInformation("Загрузка писем");
|
||||
}
|
||||
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();
|
||||
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
|
||||
menuStrip.SuspendLayout();
|
||||
SuspendLayout();
|
||||
@ -98,7 +99,7 @@
|
||||
//
|
||||
// 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.Name = "menuStrip";
|
||||
menuStrip.Size = new Size(984, 24);
|
||||
@ -182,6 +183,13 @@
|
||||
почтаToolStripMenuItem.Text = "Почта";
|
||||
почтаToolStripMenuItem.Click += почтаToolStripMenuItem_Click;
|
||||
//
|
||||
// создатьБэкапToolStripMenuItem
|
||||
//
|
||||
создатьБэкапToolStripMenuItem.Name = "создатьБэкапToolStripMenuItem";
|
||||
создатьБэкапToolStripMenuItem.Size = new Size(97, 20);
|
||||
создатьБэкапToolStripMenuItem.Text = "Создать бэкап";
|
||||
создатьБэкапToolStripMenuItem.Click += создатьБэкапToolStripMenuItem_Click;
|
||||
//
|
||||
// FormMain
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||
@ -221,5 +229,6 @@
|
||||
private ToolStripMenuItem запускРаботToolStripMenuItem;
|
||||
private ToolStripMenuItem исполнителиToolStripMenuItem;
|
||||
private ToolStripMenuItem почтаToolStripMenuItem;
|
||||
private ToolStripMenuItem создатьБэкапToolStripMenuItem;
|
||||
}
|
||||
}
|
@ -1,6 +1,7 @@
|
||||
using AircraftPlantBusinessLogic.BusinessLogics;
|
||||
using AircraftPlantContracts.BindingModels;
|
||||
using AircraftPlantContracts.BusinessLogicsContracts;
|
||||
using AircraftPlantContracts.DependencyInjections;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@ -39,18 +40,24 @@ namespace AircraftPlantView
|
||||
/// </summary>
|
||||
private readonly IWorkProcess _workProcess;
|
||||
|
||||
/// <summary>
|
||||
/// Бизнес-логика для создания бэкапа
|
||||
/// </summary>
|
||||
private readonly IBackUpLogic _backUpLogic;
|
||||
|
||||
/// <summary>
|
||||
/// Конструктор
|
||||
/// </summary>
|
||||
/// <param name="logger"></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();
|
||||
_logger = logger;
|
||||
_orderLogic = orderLogic;
|
||||
_reportLogic = reportLogic;
|
||||
_workProcess = workProcess;
|
||||
_backUpLogic = backUpLogic;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -70,11 +77,8 @@ namespace AircraftPlantView
|
||||
/// <param name="e"></param>
|
||||
private void компонентыToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormComponents));
|
||||
if (service is FormComponents form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
}
|
||||
var form = DependencyManager.Instance.Resolve<FormComponents>();
|
||||
form.ShowDialog();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -84,11 +88,8 @@ namespace AircraftPlantView
|
||||
/// <param name="e"></param>
|
||||
private void изделияToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormPlanes));
|
||||
if (service is FormPlanes form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
}
|
||||
var form = DependencyManager.Instance.Resolve<FormPlanes>();
|
||||
form.ShowDialog();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -98,11 +99,8 @@ namespace AircraftPlantView
|
||||
/// <param name="e"></param>
|
||||
private void клиентыToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormClients));
|
||||
if (service is FormClients form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
}
|
||||
var form = DependencyManager.Instance.Resolve<FormClients>();
|
||||
form.ShowDialog();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -112,11 +110,8 @@ namespace AircraftPlantView
|
||||
/// <param name="e"></param>
|
||||
private void исполнителиToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormImplementers));
|
||||
if (service is FormImplementers form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
}
|
||||
var form = DependencyManager.Instance.Resolve<FormImplementers>();
|
||||
form.ShowDialog();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -141,11 +136,8 @@ namespace AircraftPlantView
|
||||
/// <param name="e"></param>
|
||||
private void изделияСКомпонентамиToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormReportPlaneComponents));
|
||||
if (service is FormReportPlaneComponents form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
}
|
||||
var form = DependencyManager.Instance.Resolve<FormReportPlaneComponents>();
|
||||
form.ShowDialog();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -155,11 +147,8 @@ namespace AircraftPlantView
|
||||
/// <param name="e"></param>
|
||||
private void списокЗаказовToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormReportOrders));
|
||||
if (service is FormReportOrders form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
}
|
||||
var form = DependencyManager.Instance.Resolve<FormReportOrders>();
|
||||
form.ShowDialog();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -170,7 +159,7 @@ namespace AircraftPlantView
|
||||
private void запускРаботToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
_workProcess.DoWork((
|
||||
Program.ServiceProvider?.GetService(typeof(IImplementerLogic)) as IImplementerLogic)!,
|
||||
DependencyManager.Instance.Resolve<IImplementerLogic>() as IImplementerLogic)!,
|
||||
_orderLogic);
|
||||
MessageBox.Show("Процесс обработки запущен", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
}
|
||||
@ -182,10 +171,35 @@ namespace AircraftPlantView
|
||||
/// <param name="e"></param>
|
||||
private void почтаToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormMail));
|
||||
if (service is FormMail form)
|
||||
var form = DependencyManager.Instance.Resolve<FormMail>();
|
||||
form.ShowDialog();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Создать бэкап
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void создатьБэкапToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
form.ShowDialog();
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
@ -196,12 +210,9 @@ namespace AircraftPlantView
|
||||
/// <param name="e"></param>
|
||||
private void buttonCreateOrder_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormCreateOrder));
|
||||
if (service is FormCreateOrder form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
LoadData();
|
||||
}
|
||||
var form = DependencyManager.Instance.Resolve<FormCreateOrder>();
|
||||
form.ShowDialog();
|
||||
LoadData();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -251,14 +262,7 @@ namespace AircraftPlantView
|
||||
_logger.LogInformation("Загрузка заказов");
|
||||
try
|
||||
{
|
||||
var list = _orderLogic.ReadList(null);
|
||||
if (list != null)
|
||||
{
|
||||
dataGridView.DataSource = list;
|
||||
dataGridView.Columns["PlaneId"].Visible = false;
|
||||
dataGridView.Columns["ClientId"].Visible = false;
|
||||
dataGridView.Columns["ImplementerId"].Visible = false;
|
||||
}
|
||||
dataGridView.FillAndConfigGrid(_orderLogic.ReadList(null));
|
||||
_logger.LogInformation("Загрузка заказов");
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
@ -1,5 +1,6 @@
|
||||
using AircraftPlantContracts.BindingModels;
|
||||
using AircraftPlantContracts.BusinessLogicsContracts;
|
||||
using AircraftPlantContracts.DependencyInjections;
|
||||
using AircraftPlantContracts.SearchModels;
|
||||
using AircraftPlantDataModels.Models;
|
||||
using Microsoft.Extensions.Logging;
|
||||
@ -90,26 +91,23 @@ namespace AircraftPlantView
|
||||
/// <param name="e"></param>
|
||||
private void buttonAdd_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormPlaneComponent));
|
||||
if (service is FormPlaneComponent form)
|
||||
var form = DependencyManager.Instance.Resolve<FormPlaneComponent>();
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
if (form.ComponentModel == null)
|
||||
{
|
||||
if (form.ComponentModel == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_logger.LogInformation("Добавление нового компонента:{ ComponentName} - { Count}", form.ComponentModel.ComponentName, form.Count);
|
||||
if (_planeComponents.ContainsKey(form.Id))
|
||||
{
|
||||
_planeComponents[form.Id] = (form.ComponentModel, form.Count);
|
||||
}
|
||||
else
|
||||
{
|
||||
_planeComponents.Add(form.Id, (form.ComponentModel, form.Count));
|
||||
}
|
||||
LoadData();
|
||||
return;
|
||||
}
|
||||
_logger.LogInformation("Добавление нового компонента:{ ComponentName} - { Count}", form.ComponentModel.ComponentName, form.Count);
|
||||
if (_planeComponents.ContainsKey(form.Id))
|
||||
{
|
||||
_planeComponents[form.Id] = (form.ComponentModel, form.Count);
|
||||
}
|
||||
else
|
||||
{
|
||||
_planeComponents.Add(form.Id, (form.ComponentModel, form.Count));
|
||||
}
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
|
||||
@ -122,22 +120,19 @@ namespace AircraftPlantView
|
||||
{
|
||||
if (dataGridView.SelectedRows.Count == 1)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormPlaneComponent));
|
||||
if (service is FormPlaneComponent form)
|
||||
var form = DependencyManager.Instance.Resolve<FormPlaneComponent>();
|
||||
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells[0].Value);
|
||||
form.Id = id;
|
||||
form.Count = _planeComponents[id].Item2;
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells[0].Value);
|
||||
form.Id = id;
|
||||
form.Count = _planeComponents[id].Item2;
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
if (form.ComponentModel == null)
|
||||
{
|
||||
if (form.ComponentModel == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_logger.LogInformation("Изменение компонента:{ ComponentName} - { Count}", form.ComponentModel.ComponentName, form.Count);
|
||||
_planeComponents[form.Id] = (form.ComponentModel, form.Count);
|
||||
LoadData();
|
||||
return;
|
||||
}
|
||||
_logger.LogInformation("Изменение компонента:{ ComponentName} - { Count}", form.ComponentModel.ComponentName, form.Count);
|
||||
_planeComponents[form.Id] = (form.ComponentModel, form.Count);
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
using AircraftPlantContracts.BindingModels;
|
||||
using AircraftPlantContracts.BusinessLogicsContracts;
|
||||
using AircraftPlantContracts.DependencyInjections;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@ -57,13 +58,10 @@ namespace AircraftPlantView
|
||||
/// <param name="e"></param>
|
||||
private void buttonAdd_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormPlane));
|
||||
if (service is FormPlane form)
|
||||
var form = DependencyManager.Instance.Resolve<FormPlane>();
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
|
||||
@ -76,14 +74,11 @@ namespace AircraftPlantView
|
||||
{
|
||||
if (dataGridView.SelectedRows.Count == 1)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormPlane));
|
||||
if (service is FormPlane form)
|
||||
var form = DependencyManager.Instance.Resolve<FormPlane>();
|
||||
form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -138,15 +133,8 @@ namespace AircraftPlantView
|
||||
{
|
||||
try
|
||||
{
|
||||
var list = _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("Загрузка изделий");
|
||||
dataGridView.FillAndConfigGrid(_logic.ReadList(null));
|
||||
_logger.LogInformation("Загрузка изделий");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
@ -10,17 +10,12 @@ using NLog.Extensions.Logging;
|
||||
using System;
|
||||
using AircraftPlantBusinessLogic.MailWorker;
|
||||
using AircraftPlantContracts.BindingModels;
|
||||
using AircraftPlantContracts.DependencyInjections;
|
||||
|
||||
namespace AircraftPlantView
|
||||
{
|
||||
internal static class Program
|
||||
{
|
||||
/// <summary>
|
||||
/// IoC-êîíòåéíåð
|
||||
/// </summary>
|
||||
private static ServiceProvider? _serviceProvider;
|
||||
public static ServiceProvider? ServiceProvider => _serviceProvider;
|
||||
|
||||
/// <summary>
|
||||
/// The main entry point for the application.
|
||||
/// </summary>
|
||||
@ -30,15 +25,12 @@ namespace AircraftPlantView
|
||||
// To customize application configuration such as set high DPI settings or default font,
|
||||
// see https://aka.ms/applicationconfiguration.
|
||||
ApplicationConfiguration.Initialize();
|
||||
|
||||
var services = new ServiceCollection();
|
||||
ConfigureServices(services);
|
||||
_serviceProvider = services.BuildServiceProvider();
|
||||
InitDependency();
|
||||
|
||||
// Íàñòðîéêà äëÿ îòïðàâêè ïèñåì
|
||||
try
|
||||
{
|
||||
var mailSender = _serviceProvider.GetService<AbstractMailWorker>();
|
||||
var mailSender = DependencyManager.Instance.Resolve<AbstractMailWorker>();
|
||||
mailSender?.MailConfig(new MailConfigBindingModel
|
||||
{
|
||||
MailLogin = System.Configuration.ConfigurationManager.AppSettings["MailLogin"] ?? string.Empty,
|
||||
@ -54,66 +46,62 @@ namespace AircraftPlantView
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
var logger = _serviceProvider.GetService<ILogger>();
|
||||
var logger = DependencyManager.Instance.Resolve<ILogger>();
|
||||
logger?.LogError(ex, "Îøèáêà ðàáîòû ñ ïî÷òîé");
|
||||
}
|
||||
|
||||
Application.Run(_serviceProvider.GetRequiredService<FormMain>());
|
||||
Application.Run(DependencyManager.Instance.Resolve<FormMain>());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Íàñòðîéêà IoC-êîíòåéíåðà è ëîããåðà
|
||||
/// Èíèöèàëèçàöèÿ çàâèñèìîñòåé
|
||||
/// </summary>
|
||||
/// <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.AddNLog("nlog.config");
|
||||
});
|
||||
|
||||
services.AddTransient<IClientStorage, ClientStorage>();
|
||||
services.AddTransient<IImplementerStorage, ImplementerStorage>();
|
||||
services.AddTransient<IComponentStorage, ComponentStorage>();
|
||||
services.AddTransient<IOrderStorage, OrderStorage>();
|
||||
services.AddTransient<IPlaneStorage, PlaneStorage>();
|
||||
services.AddTransient<IMessageInfoStorage, MessageInfoStorage>();
|
||||
DependencyManager.Instance.RegisterType<IClientLogic, ClientLogic>();
|
||||
DependencyManager.Instance.RegisterType<IImplementerLogic, ImplementerLogic>();
|
||||
DependencyManager.Instance.RegisterType<IComponentLogic, ComponentLogic>();
|
||||
DependencyManager.Instance.RegisterType<IOrderLogic, OrderLogic>();
|
||||
DependencyManager.Instance.RegisterType<IPlaneLogic, PlaneLogic>();
|
||||
DependencyManager.Instance.RegisterType<IReportLogic, ReportLogic>();
|
||||
DependencyManager.Instance.RegisterType<IMessageInfoLogic, MessageInfoLogic>();
|
||||
DependencyManager.Instance.RegisterType<IBackUpLogic, BackUpLogic>();
|
||||
|
||||
services.AddTransient<IClientLogic, ClientLogic>();
|
||||
services.AddTransient<IImplementerLogic, ImplementerLogic>();
|
||||
services.AddTransient<IComponentLogic, ComponentLogic>();
|
||||
services.AddTransient<IOrderLogic, OrderLogic>();
|
||||
services.AddTransient<IPlaneLogic, PlaneLogic>();
|
||||
services.AddTransient<IReportLogic, ReportLogic>();
|
||||
services.AddTransient<IMessageInfoLogic, MessageInfoLogic>();
|
||||
DependencyManager.Instance.RegisterType<IWorkProcess, WorkModeling>();
|
||||
DependencyManager.Instance.RegisterType<AbstractMailWorker, MailKitWorker>(true);
|
||||
|
||||
services.AddTransient<IWorkProcess, WorkModeling>();
|
||||
services.AddSingleton<AbstractMailWorker, MailKitWorker>();
|
||||
DependencyManager.Instance.RegisterType<AbstractSaveToWord, SaveToWord>();
|
||||
DependencyManager.Instance.RegisterType<AbstractSaveToExcel, SaveToExcel>();
|
||||
DependencyManager.Instance.RegisterType<AbstractSaveToPdf, SaveToPdf>();
|
||||
|
||||
services.AddTransient<AbstractSaveToWord, SaveToWord>();
|
||||
services.AddTransient<AbstractSaveToExcel, SaveToExcel>();
|
||||
services.AddTransient<AbstractSaveToPdf, SaveToPdf>();
|
||||
|
||||
services.AddTransient<FormMain>();
|
||||
services.AddTransient<FormClients>();
|
||||
services.AddTransient<FormImplementers>();
|
||||
services.AddTransient<FormImplementer>();
|
||||
services.AddTransient<FormComponent>();
|
||||
services.AddTransient<FormComponents>();
|
||||
services.AddTransient<FormCreateOrder>();
|
||||
services.AddTransient<FormPlane>();
|
||||
services.AddTransient<FormPlaneComponent>();
|
||||
services.AddTransient<FormPlanes>();
|
||||
services.AddTransient<FormReportPlaneComponents>();
|
||||
services.AddTransient<FormReportOrders>();
|
||||
services.AddTransient<FormMail>();
|
||||
DependencyManager.Instance.RegisterType<FormMain>();
|
||||
DependencyManager.Instance.RegisterType<FormClients>();
|
||||
DependencyManager.Instance.RegisterType<FormImplementers>();
|
||||
DependencyManager.Instance.RegisterType<FormImplementer>();
|
||||
DependencyManager.Instance.RegisterType<FormComponent>();
|
||||
DependencyManager.Instance.RegisterType<FormComponents>();
|
||||
DependencyManager.Instance.RegisterType<FormCreateOrder>();
|
||||
DependencyManager.Instance.RegisterType<FormPlane>();
|
||||
DependencyManager.Instance.RegisterType<FormPlaneComponent>();
|
||||
DependencyManager.Instance.RegisterType<FormPlanes>();
|
||||
DependencyManager.Instance.RegisterType<FormReportPlaneComponents>();
|
||||
DependencyManager.Instance.RegisterType<FormReportOrders>();
|
||||
DependencyManager.Instance.RegisterType<FormMail>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Ïðîâåðêà ïî÷òû
|
||||
/// </summary>
|
||||
/// <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