ISEbd-21.Fedotov.I.A.LabWork08 #8
1
.gitignore
vendored
1
.gitignore
vendored
@ -398,3 +398,4 @@ FodyWeavers.xsd
|
|||||||
# JetBrains Rider
|
# JetBrains Rider
|
||||||
*.sln.iml
|
*.sln.iml
|
||||||
|
|
||||||
|
Diner/ImplementationExtensions/*
|
||||||
|
25
Diner/DinerContracts/Attributes/ColumnAttribute.cs
Normal file
25
Diner/DinerContracts/Attributes/ColumnAttribute.cs
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace DinerContracts.Attributes {
|
||||||
|
[AttributeUsage(AttributeTargets.Property)]
|
||||||
|
public class ColumnAttribute : Attribute {
|
||||||
|
public string Title { get; private set; }
|
||||||
|
public bool Visible { get; private set; }
|
||||||
|
public int Width { get; private set; }
|
||||||
|
public GridViewAutoSize _GridViewAutoSize { get; private set; }
|
||||||
|
public bool IsUseAutoSize { get; private set; }
|
||||||
|
|
||||||
|
public ColumnAttribute(string title = "", bool visible = true, int width = 0, GridViewAutoSize gridViewAutoSize = GridViewAutoSize.None,
|
||||||
|
bool isUseAutoSize = false) {
|
||||||
|
Title = title;
|
||||||
|
Visible = visible;
|
||||||
|
Width = width;
|
||||||
|
_GridViewAutoSize = gridViewAutoSize;
|
||||||
|
IsUseAutoSize = isUseAutoSize;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
18
Diner/DinerContracts/Attributes/GridViewAutoSize.cs
Normal file
18
Diner/DinerContracts/Attributes/GridViewAutoSize.cs
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace DinerContracts.Attributes {
|
||||||
|
public enum GridViewAutoSize {
|
||||||
|
NotSet = 0,
|
||||||
|
None = 1,
|
||||||
|
ColumnHeader = 2,
|
||||||
|
AllCellsExceptHeader = 4,
|
||||||
|
AllCells = 6,
|
||||||
|
DisplayedCellsExceptHeader = 8,
|
||||||
|
DisplayedCells = 10,
|
||||||
|
Fill = 16
|
||||||
|
}
|
||||||
|
}
|
11
Diner/DinerContracts/BindingModels/BackUpSaveBindingModel.cs
Normal file
11
Diner/DinerContracts/BindingModels/BackUpSaveBindingModel.cs
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace DinerContracts.BindingModels {
|
||||||
|
public class BackUpSaveBindingModel {
|
||||||
|
public string FolderName { get; set; } = string.Empty;
|
||||||
|
}
|
||||||
|
}
|
@ -18,5 +18,7 @@ namespace DinerContracts.BindingModels {
|
|||||||
public string Subject { get; set; } = string.Empty;
|
public string Subject { get; set; } = string.Empty;
|
||||||
|
|
||||||
public string Body { get; set; } = string.Empty;
|
public string Body { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
public int ID { get; private set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
12
Diner/DinerContracts/BusinessLogicsContracts/IBackUpLogic.cs
Normal file
12
Diner/DinerContracts/BusinessLogicsContracts/IBackUpLogic.cs
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
using DinerContracts.BindingModels;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace DinerContracts.BusinessLogicsContracts {
|
||||||
|
public interface IBackUpLogic {
|
||||||
|
void CreateBackUp(BackUpSaveBindingModel model);
|
||||||
|
}
|
||||||
|
}
|
56
Diner/DinerContracts/DI/DependencyManager.cs
Normal file
56
Diner/DinerContracts/DI/DependencyManager.cs
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace DinerContracts.DI {
|
||||||
|
public class DependencyManager {
|
||||||
|
|
||||||
|
private readonly IDependencyContainer _dependencyManager;
|
||||||
|
|
||||||
|
private static DependencyManager? _manager;
|
||||||
|
|
||||||
|
private static readonly object _locjObject = new();
|
||||||
|
|
||||||
|
private DependencyManager() {
|
||||||
|
_dependencyManager = new UnityDependencyContainer();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static DependencyManager Instance {
|
||||||
|
get {
|
||||||
|
if (_manager == null) {
|
||||||
|
lock (_locjObject) {
|
||||||
|
_manager = new DependencyManager();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return _manager;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Инициализация библиотек, в которых идут установки зависимостей
|
||||||
|
|
||||||
|
public static void InitDependency() {
|
||||||
|
var ext = ServiceProviderLoader.GetImplmentationExternsion();
|
||||||
|
if (ext == null) {
|
||||||
|
throw new ArgumentNullException("Отсутствуют компоненты для загрузки зависимостей по модулям");
|
||||||
|
}
|
||||||
|
ext.RegisterServices();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Регистрация логгера
|
||||||
|
|
||||||
|
public void AddLogging(Action<ILoggingBuilder> configure) => _dependencyManager.AddLogging(configure);
|
||||||
|
|
||||||
|
// Добавление зависимостей
|
||||||
|
public void RegisterType<T, U>(bool isSingle = false) where U : class,
|
||||||
|
T where T : class => _dependencyManager.RegisterType<T, U>(isSingle);
|
||||||
|
|
||||||
|
// Добавление зависимостей
|
||||||
|
public void RegisterType<T>(bool isSingle = false) where T : class => _dependencyManager.RegisterType<T>(isSingle);
|
||||||
|
|
||||||
|
// Получение класса со всеми зависимостями
|
||||||
|
public T Resolve<T>() => _dependencyManager.Resolve<T>();
|
||||||
|
}
|
||||||
|
}
|
22
Diner/DinerContracts/DI/IDependencyContainer.cs
Normal file
22
Diner/DinerContracts/DI/IDependencyContainer.cs
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace DinerContracts.DI {
|
||||||
|
public interface IDependencyContainer {
|
||||||
|
// Регистрация логгера
|
||||||
|
void AddLogging(Action<ILoggingBuilder> configure);
|
||||||
|
|
||||||
|
// Добавление зависимости
|
||||||
|
void RegisterType<T, U>(bool isSingle) where U : class, T where T : class;
|
||||||
|
|
||||||
|
// Добавление зависимости
|
||||||
|
void RegisterType<T>(bool isSingle) where T : class;
|
||||||
|
|
||||||
|
// Получение класса со всеми зависимостями
|
||||||
|
T Resolve<T>();
|
||||||
|
}
|
||||||
|
}
|
14
Diner/DinerContracts/DI/IImplmentationExtension.cs
Normal file
14
Diner/DinerContracts/DI/IImplmentationExtension.cs
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace DinerContracts.DI {
|
||||||
|
public interface IImplmentationExtension {
|
||||||
|
public int Priority { get; }
|
||||||
|
|
||||||
|
// Регистрация сервиса
|
||||||
|
public void RegisterServices();
|
||||||
|
}
|
||||||
|
}
|
51
Diner/DinerContracts/DI/ServiceDependencyContainer.cs
Normal file
51
Diner/DinerContracts/DI/ServiceDependencyContainer.cs
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
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 DinerContracts.DI {
|
||||||
|
public class ServiceDependencyContainer : IDependencyContainer {
|
||||||
|
|
||||||
|
private ServiceProvider? _serviceProvider;
|
||||||
|
|
||||||
|
private readonly ServiceCollection _serviceCollection;
|
||||||
|
|
||||||
|
public ServiceDependencyContainer() {
|
||||||
|
_serviceCollection = new ServiceCollection();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void AddLogging(Action<ILoggingBuilder> configure) {
|
||||||
|
_serviceCollection.AddLogging(configure);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void RegisterType<T>(bool isSingle) where T : class {
|
||||||
|
if (isSingle) {
|
||||||
|
_serviceCollection.AddSingleton<T>();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
_serviceCollection.AddTransient<T>();
|
||||||
|
}
|
||||||
|
_serviceProvider = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public T Resolve<T>() {
|
||||||
|
if (_serviceProvider == null) {
|
||||||
|
_serviceProvider = _serviceCollection.BuildServiceProvider();
|
||||||
|
}
|
||||||
|
return _serviceProvider.GetService<T>()!;
|
||||||
|
}
|
||||||
|
|
||||||
|
void IDependencyContainer.RegisterType<T, U>(bool isSingle) {
|
||||||
|
if (isSingle) {
|
||||||
|
_serviceCollection.AddSingleton<T, U>();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
_serviceCollection.AddTransient<T, U>();
|
||||||
|
}
|
||||||
|
_serviceProvider = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
44
Diner/DinerContracts/DI/ServiceProviderLoader.cs
Normal file
44
Diner/DinerContracts/DI/ServiceProviderLoader.cs
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Reflection;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace DinerContracts.DI {
|
||||||
|
public class ServiceProviderLoader {
|
||||||
|
|
||||||
|
// Загрузка всех классов-реализация IImplementationExtension
|
||||||
|
|
||||||
|
public static IImplmentationExtension? GetImplmentationExternsion() {
|
||||||
|
IImplmentationExtension? 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(IImplmentationExtension).IsAssignableFrom(t)) {
|
||||||
|
if (source == null) {
|
||||||
|
source = (IImplmentationExtension)Activator.CreateInstance(t)!;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
var newSource = (IImplmentationExtension)Activator.CreateInstance(t)!;
|
||||||
|
if (newSource.Priority > source.Priority) {
|
||||||
|
source = newSource;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return source;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static string TryGetImplementationExtensionsFolder() {
|
||||||
|
var directory = new DirectoryInfo(Directory.GetCurrentDirectory());
|
||||||
|
while (directory != null && !directory.GetDirectories("ImplementationExtensions", SearchOption.AllDirectories)
|
||||||
|
.Any(x => x.Name == "ImplementationExtensions")) {
|
||||||
|
directory = directory.Parent;
|
||||||
|
}
|
||||||
|
return $"{directory?.FullName}\\ImplementationExtensions";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
35
Diner/DinerContracts/DI/UnityDependencyContainer.cs
Normal file
35
Diner/DinerContracts/DI/UnityDependencyContainer.cs
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
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 DinerContracts.DI {
|
||||||
|
public class UnityDependencyContainer : IDependencyContainer {
|
||||||
|
|
||||||
|
private readonly IUnityContainer _container;
|
||||||
|
|
||||||
|
public UnityDependencyContainer() {
|
||||||
|
_container = new UnityContainer();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void AddLogging(Action<ILoggingBuilder> configure) {
|
||||||
|
_container.AddExtension(new LoggingExtension(LoggerFactory.Create(configure)));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void RegisterType<T>(bool isSingle) where T : class {
|
||||||
|
_container.RegisterType<T>(isSingle ? TypeLifetime.Singleton : TypeLifetime.Transient);
|
||||||
|
}
|
||||||
|
|
||||||
|
public T Resolve<T>() {
|
||||||
|
return _container.Resolve<T>();
|
||||||
|
}
|
||||||
|
|
||||||
|
void IDependencyContainer.RegisterType<T, U>(bool isSingle) {
|
||||||
|
_container.RegisterType<T, U>(isSingle ? TypeLifetime.Singleton : TypeLifetime.Transient);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -6,6 +6,12 @@
|
|||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Microsoft.Extensions.Logging" Version="8.0.0" />
|
||||||
|
<PackageReference Include="Unity" Version="5.11.10" />
|
||||||
|
<PackageReference Include="Unity.Microsoft.Logging" Version="5.11.1" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\DinerDataModels\DinerDataModels.csproj" />
|
<ProjectReference Include="..\DinerDataModels\DinerDataModels.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
@ -1,17 +0,0 @@
|
|||||||
using DinerContracts.BindingModels;
|
|
||||||
using DinerContracts.ViewModels;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace DinerContracts.SearchModels {
|
|
||||||
public interface IMessageInfoStorage {
|
|
||||||
List<MessageInfoViewModel> GetFullList();
|
|
||||||
List<MessageInfoViewModel> GetFilteredList(MessageInfoSearchModel model);
|
|
||||||
|
|
||||||
MessageInfoViewModel? GetElement(MessageInfoSearchModel model);
|
|
||||||
MessageInfoViewModel? Insert(MessageInfoBindingModel model);
|
|
||||||
}
|
|
||||||
}
|
|
13
Diner/DinerContracts/StoragesContracts/IBackUpInfo.cs
Normal file
13
Diner/DinerContracts/StoragesContracts/IBackUpInfo.cs
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace DinerContracts.StoragesContracts {
|
||||||
|
public interface IBackUpInfo {
|
||||||
|
List<T>? GetList<T>() where T: class, new();
|
||||||
|
|
||||||
|
Type? GetTypeModelInterface(string modelInterfaceName);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,20 @@
|
|||||||
|
using DinerContracts.BindingModels;
|
||||||
|
using DinerContracts.SearchModels;
|
||||||
|
using DinerContracts.ViewModels;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace DinerContracts.StoragesContracts
|
||||||
|
{
|
||||||
|
public interface IMessageInfoStorage
|
||||||
|
{
|
||||||
|
List<MessageInfoViewModel> GetFullList();
|
||||||
|
List<MessageInfoViewModel> GetFilteredList(MessageInfoSearchModel model);
|
||||||
|
|
||||||
|
MessageInfoViewModel? GetElement(MessageInfoSearchModel model);
|
||||||
|
MessageInfoViewModel? Insert(MessageInfoBindingModel model);
|
||||||
|
}
|
||||||
|
}
|
@ -1,4 +1,5 @@
|
|||||||
using DinerDataModels.Models;
|
using DinerContracts.Attributes;
|
||||||
|
using DinerDataModels.Models;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
@ -10,15 +11,16 @@ using System.Threading.Tasks;
|
|||||||
namespace DinerContracts.ViewModels {
|
namespace DinerContracts.ViewModels {
|
||||||
public class ClientViewModel : IClientModel {
|
public class ClientViewModel : IClientModel {
|
||||||
|
|
||||||
[DisplayName("ФИО клиента")]
|
[Column(title: "ФИО клиента", width:150)]
|
||||||
public string ClientFIO { get; set; } = string.Empty;
|
public string ClientFIO { get; set; } = string.Empty;
|
||||||
|
|
||||||
[DisplayName("Логин (эл.почта)")]
|
[Column(title: "Логин (эл.почта)", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)]
|
||||||
public string Email { get; set; } = string.Empty;
|
public string Email { get; set; } = string.Empty;
|
||||||
|
|
||||||
[DisplayName("Пароль")]
|
[Column(title: "Пароль", width: 150)]
|
||||||
public string Password { get; set; } = string.Empty;
|
public string Password { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
[Column(visible: false)]
|
||||||
public int ID { get; set; }
|
public int ID { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
using DinerDataModels.Models;
|
using DinerContracts.Attributes;
|
||||||
|
using DinerDataModels.Models;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
@ -11,12 +12,13 @@ namespace DinerContracts.ViewModels
|
|||||||
{
|
{
|
||||||
public class FoodViewModel : IFoodModel
|
public class FoodViewModel : IFoodModel
|
||||||
{
|
{
|
||||||
|
[Column(visible: false)]
|
||||||
public int ID { get; set; }
|
public int ID { get; set; }
|
||||||
|
|
||||||
[DisplayName("Название еды для изготовления")]
|
[Column(title: "Название еды для изготовления", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)]
|
||||||
public string ComponentName { get; set; } = string.Empty;
|
public string ComponentName { get; set; } = string.Empty;
|
||||||
|
|
||||||
[DisplayName("Цена")]
|
[Column(title: "Цена", width: 150)]
|
||||||
public double Price { get; set; }
|
public double Price { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
using DinerDataModels.Models;
|
using DinerContracts.Attributes;
|
||||||
|
using DinerDataModels.Models;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
@ -9,18 +10,19 @@ using System.Threading.Tasks;
|
|||||||
namespace DinerContracts.ViewModels {
|
namespace DinerContracts.ViewModels {
|
||||||
public class ImplementerViewModel : IImplementerModel {
|
public class ImplementerViewModel : IImplementerModel {
|
||||||
|
|
||||||
[DisplayName("ФИО исполнителя")]
|
[Column(title: "ФИО исполнителя", width: 150)]
|
||||||
public string ImplementerFIO { get; set; } = string.Empty;
|
public string ImplementerFIO { get; set; } = string.Empty;
|
||||||
|
|
||||||
[DisplayName("Пароль")]
|
[Column(title: "Пароль", width: 150)]
|
||||||
public string Password { get; set; } = string.Empty;
|
public string Password { get; set; } = string.Empty;
|
||||||
|
|
||||||
[DisplayName("Стаж работы")]
|
[Column(title: "Стаж работы", width: 150)]
|
||||||
public int WorkExperience { get; set; }
|
public int WorkExperience { get; set; }
|
||||||
|
|
||||||
[DisplayName("Квалификация")]
|
[Column(title: "Квалификация", width: 150)]
|
||||||
public int Qualification { get; set; }
|
public int Qualification { get; set; }
|
||||||
|
|
||||||
|
[Column(visible: false)]
|
||||||
public int ID { get; set; }
|
public int ID { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
using DinerDataModels.Models;
|
using DinerContracts.Attributes;
|
||||||
|
using DinerDataModels.Models;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
@ -8,20 +9,28 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace DinerContracts.ViewModels {
|
namespace DinerContracts.ViewModels {
|
||||||
public class MessageInfoViewModel : IMessageInfoModel {
|
public class MessageInfoViewModel : IMessageInfoModel {
|
||||||
|
|
||||||
|
[Column(visible: false)]
|
||||||
public string MessageID { get; set; } = string.Empty;
|
public string MessageID { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
[Column(visible: false)]
|
||||||
public int? ClientID { get; set; }
|
public int? ClientID { get; set; }
|
||||||
|
|
||||||
[DisplayName("Отправитель")]
|
[Column(visible: false)]
|
||||||
|
public int ID { get; private set; }
|
||||||
|
|
||||||
|
[Column(title: "Отправитель", width: 150)]
|
||||||
public string SenderName { get; set; } = string.Empty;
|
public string SenderName { get; set; } = string.Empty;
|
||||||
|
|
||||||
[DisplayName("Дата письма")]
|
[Column(title: "Дата письма", width: 150)]
|
||||||
public DateTime DateDelivery { get; set; }
|
public DateTime DateDelivery { get; set; }
|
||||||
|
|
||||||
[DisplayName("Заголовоск")]
|
[Column(title: "Заголовоск", width: 170)]
|
||||||
public string Subject { get; set; } = string.Empty;
|
public string Subject { get; set; } = string.Empty;
|
||||||
|
|
||||||
[DisplayName("Текст")]
|
[Column(title: "Текст", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)]
|
||||||
public string Body { get; set; } = string.Empty;
|
public string Body { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
using DinerDataModels.Enums;
|
using DinerContracts.Attributes;
|
||||||
|
using DinerDataModels.Enums;
|
||||||
using DinerDataModels.Models;
|
using DinerDataModels.Models;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
@ -11,36 +12,41 @@ namespace DinerContracts.ViewModels
|
|||||||
{
|
{
|
||||||
public class OrderViewModel : IOrderModel {
|
public class OrderViewModel : IOrderModel {
|
||||||
|
|
||||||
|
[Column(visible: false)]
|
||||||
public int ClientID { get; set; }
|
public int ClientID { get; set; }
|
||||||
|
|
||||||
|
[Column(visible: false)]
|
||||||
public int SnackID { get; set; }
|
public int SnackID { get; set; }
|
||||||
|
|
||||||
|
[Column(visible: false)]
|
||||||
public int? ImplementerID { get; set; }
|
public int? ImplementerID { get; set; }
|
||||||
|
|
||||||
[DisplayName("Количество")]
|
[Column(title: "Количество", width: 150)]
|
||||||
public int Count { get; set; }
|
public int Count { get; set; }
|
||||||
|
|
||||||
[DisplayName("Сумма")]
|
[Column(title: "Сумма", width: 150)]
|
||||||
public double Sum { get; set; }
|
public double Sum { get; set; }
|
||||||
|
|
||||||
[DisplayName("Статус")]
|
[Column(title: "Статус", width: 150)]
|
||||||
public OrderStatus Status { get; set; } = OrderStatus.Неизвестен;
|
public OrderStatus Status { get; set; } = OrderStatus.Неизвестен;
|
||||||
|
|
||||||
[DisplayName("Дата создания")]
|
[Column(title: "Дата создания", width: 150)]
|
||||||
public DateTime DateCreate { get; set; } = DateTime.Now;
|
public DateTime DateCreate { get; set; } = DateTime.Now;
|
||||||
|
|
||||||
[DisplayName("Дата выполнения")]
|
[Column(title: "Дата выполнения", width: 150)]
|
||||||
public DateTime? DateImplement { get; set; }
|
public DateTime? DateImplement { get; set; }
|
||||||
|
|
||||||
[DisplayName("Номер")]
|
[Column(title: "Номер", width: 150)]
|
||||||
public int ID { get; set; }
|
public int ID { get; set; }
|
||||||
|
|
||||||
// какой снэк изготавливается в рамках заказа
|
// какой снэк изготавливается в рамках заказа
|
||||||
[DisplayName("Снэк")]
|
[Column(title: "Снэк", width: 150)]
|
||||||
public string ProductName { get; set; } = string.Empty;
|
public string ProductName { get; set; } = string.Empty;
|
||||||
|
|
||||||
[DisplayName("Клиент")]
|
[Column(title: "Клиент", width: 150)]
|
||||||
public string ClientFIO { get; set; } = string.Empty;
|
public string ClientFIO { get; set; } = string.Empty;
|
||||||
|
|
||||||
[DisplayName("Исполнитель")]
|
[Column(title: "Исполнитель", width: 150)]
|
||||||
public string? ImplementerFIO { get; set; } = string.Empty;
|
public string? ImplementerFIO { get; set; } = string.Empty;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
using DinerDataModels.Models;
|
using DinerContracts.Attributes;
|
||||||
|
using DinerDataModels.Models;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
@ -10,14 +11,16 @@ namespace DinerContracts.ViewModels
|
|||||||
{
|
{
|
||||||
public class SnackViewModel : ISnackModel
|
public class SnackViewModel : ISnackModel
|
||||||
{
|
{
|
||||||
[DisplayName("Название снэка")]
|
[Column(title: "Название снэка", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)]
|
||||||
public string ProductName { get; set; } = string.Empty;
|
public string ProductName { get; set; } = string.Empty;
|
||||||
|
|
||||||
[DisplayName("Цена")]
|
[Column(title: "Цена", width: 150)]
|
||||||
public double Price { get; set; }
|
public double Price { get; set; }
|
||||||
|
|
||||||
|
[Column(visible: false)]
|
||||||
public Dictionary<int, (IFoodModel, int)> ProductComponents { get; set; } = new();
|
public Dictionary<int, (IFoodModel, int)> ProductComponents { get; set; } = new();
|
||||||
|
|
||||||
public int ID { get; set; }
|
[Column(visible: false)]
|
||||||
|
public int ID { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,24 @@
|
|||||||
|
using DinerContracts.DI;
|
||||||
|
using DinerContracts.StoragesContracts;
|
||||||
|
using DinerDataBaseImplement.Implements;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace DinerDataBaseImplement {
|
||||||
|
public class DataBaseImplementationExtension : IImplmentationExtension{
|
||||||
|
public int Priority => 2;
|
||||||
|
|
||||||
|
public void RegisterServices() {
|
||||||
|
DependencyManager.Instance.RegisterType<IClientStorage, ClientStorage>();
|
||||||
|
DependencyManager.Instance.RegisterType<IFoodStorage, FoodStorage>();
|
||||||
|
DependencyManager.Instance.RegisterType<IImplementerStorage, ImplementerStorage>();
|
||||||
|
DependencyManager.Instance.RegisterType<IMessageInfoStorage, MessageInfoStorage>();
|
||||||
|
DependencyManager.Instance.RegisterType<IOrderStorage, OrderStorage>();
|
||||||
|
DependencyManager.Instance.RegisterType<ISnackStorage, SnackStorage>();
|
||||||
|
DependencyManager.Instance.RegisterType<IBackUpInfo, BackUpInfo>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -3,6 +3,7 @@
|
|||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>net8.0</TargetFramework>
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<GenerateRuntimeConfigurationFiles>True</GenerateRuntimeConfigurationFiles>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
@ -20,4 +21,8 @@
|
|||||||
<ProjectReference Include="..\DinerDataModels\DinerDataModels.csproj" />
|
<ProjectReference Include="..\DinerDataModels\DinerDataModels.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
|
||||||
|
<Exec Command="copy /Y "$(targetDir)*.dll" "$(SolutionDir)ImplementationExtensions\*.dll"" />
|
||||||
|
</Target>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
26
Diner/DinerDataBaseImplement/Implements/BackUpInfo.cs
Normal file
26
Diner/DinerDataBaseImplement/Implements/BackUpInfo.cs
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
using DinerContracts.StoragesContracts;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace DinerDataBaseImplement.Implements {
|
||||||
|
public class BackUpInfo : IBackUpInfo {
|
||||||
|
public List<T>? GetList<T>() where T : class, new() {
|
||||||
|
using var context = new DinerDatabaseBy7Work();
|
||||||
|
return context.Set<T>().ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Type? GetTypeModelInterface(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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,4 +1,4 @@
|
|||||||
using DinerContracts.BindingModels;
|
using DinerContracts.BindingModels;
|
||||||
using DinerContracts.SearchModels;
|
using DinerContracts.SearchModels;
|
||||||
using DinerContracts.StoragesContracts;
|
using DinerContracts.StoragesContracts;
|
||||||
using DinerContracts.ViewModels;
|
using DinerContracts.ViewModels;
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
using DinerContracts.BindingModels;
|
using DinerContracts.BindingModels;
|
||||||
using DinerContracts.SearchModels;
|
using DinerContracts.SearchModels;
|
||||||
|
using DinerContracts.StoragesContracts;
|
||||||
using DinerContracts.ViewModels;
|
using DinerContracts.ViewModels;
|
||||||
using DinerDataBaseImplement.Models;
|
using DinerDataBaseImplement.Models;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
@ -9,8 +10,9 @@ using System.Linq;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace DinerDataBaseImplement.Implements {
|
namespace DinerDataBaseImplement.Implements
|
||||||
public class MessageInfoStorage : IMessageInfoStorage {
|
{
|
||||||
|
public class MessageInfoStorage : IMessageInfoStorage {
|
||||||
|
|
||||||
public MessageInfoViewModel? Insert(MessageInfoBindingModel model) {
|
public MessageInfoViewModel? Insert(MessageInfoBindingModel model) {
|
||||||
using var context = new DinerDatabaseBy7Work();
|
using var context = new DinerDatabaseBy7Work();
|
||||||
|
@ -7,21 +7,28 @@ using System.Collections.Generic;
|
|||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
using System.ComponentModel.DataAnnotations.Schema;
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Runtime.Serialization;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace DinerDataBaseImplement.Models {
|
namespace DinerDataBaseImplement.Models {
|
||||||
|
|
||||||
|
[DataContract]
|
||||||
public class Client : IClientModel {
|
public class Client : IClientModel {
|
||||||
|
|
||||||
[Required]
|
[Required]
|
||||||
|
[DataMember]
|
||||||
public string ClientFIO { get; set; } = string.Empty;
|
public string ClientFIO { get; set; } = string.Empty;
|
||||||
|
|
||||||
[Required]
|
[Required]
|
||||||
|
[DataMember]
|
||||||
public string Email { get; set; } = string.Empty;
|
public string Email { get; set; } = string.Empty;
|
||||||
|
|
||||||
[Required]
|
[Required]
|
||||||
|
[DataMember]
|
||||||
public string Password { get; set; } = string.Empty;
|
public string Password { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
[DataMember]
|
||||||
public int ID { get; private set; }
|
public int ID { get; private set; }
|
||||||
|
|
||||||
[ForeignKey("ClientID")]
|
[ForeignKey("ClientID")]
|
||||||
|
@ -6,20 +6,24 @@ using System.Collections.Generic;
|
|||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
using System.ComponentModel.DataAnnotations.Schema;
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Runtime.Serialization;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Xml.Linq;
|
|
||||||
|
|
||||||
namespace DinerDataBaseImplement.Models
|
namespace DinerDataBaseImplement.Models
|
||||||
{
|
{
|
||||||
|
[DataContract]
|
||||||
public class Food : IFoodModel
|
public class Food : IFoodModel
|
||||||
{
|
{
|
||||||
[Required]
|
[Required]
|
||||||
|
[DataMember]
|
||||||
public string ComponentName { get; set; } = string.Empty;
|
public string ComponentName { get; set; } = string.Empty;
|
||||||
|
|
||||||
[Required]
|
[Required]
|
||||||
|
[DataMember]
|
||||||
public double Price { get; set; }
|
public double Price { get; set; }
|
||||||
|
|
||||||
|
[DataMember]
|
||||||
public int ID { get; set; }
|
public int ID { get; set; }
|
||||||
|
|
||||||
[ForeignKey("ComponentID")]
|
[ForeignKey("ComponentID")]
|
||||||
|
@ -6,24 +6,32 @@ using System.Collections.Generic;
|
|||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
using System.ComponentModel.DataAnnotations.Schema;
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Runtime.Serialization;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace DinerDataBaseImplement.Models {
|
namespace DinerDataBaseImplement.Models {
|
||||||
|
|
||||||
|
[DataContract]
|
||||||
public class Implementer : IImplementerModel {
|
public class Implementer : IImplementerModel {
|
||||||
|
|
||||||
[Required]
|
[Required]
|
||||||
|
[DataMember]
|
||||||
public string ImplementerFIO { get; set; } = string.Empty;
|
public string ImplementerFIO { get; set; } = string.Empty;
|
||||||
|
|
||||||
[Required]
|
[Required]
|
||||||
|
[DataMember]
|
||||||
public string Password { get; set; } = string.Empty;
|
public string Password { get; set; } = string.Empty;
|
||||||
|
|
||||||
[Required]
|
[Required]
|
||||||
|
[DataMember]
|
||||||
public int WorkExperience { get; set; }
|
public int WorkExperience { get; set; }
|
||||||
|
|
||||||
[Required]
|
[Required]
|
||||||
|
[DataMember]
|
||||||
public int Qualification { get; set; }
|
public int Qualification { get; set; }
|
||||||
|
|
||||||
|
[DataMember]
|
||||||
public int ID { get; set; }
|
public int ID { get; set; }
|
||||||
|
|
||||||
[ForeignKey("ImplementerID")]
|
[ForeignKey("ImplementerID")]
|
||||||
|
@ -6,23 +6,35 @@ using System.Collections.Generic;
|
|||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
using System.ComponentModel.DataAnnotations.Schema;
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Runtime.Serialization;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace DinerDataBaseImplement.Models {
|
namespace DinerDataBaseImplement.Models {
|
||||||
|
|
||||||
|
[DataContract]
|
||||||
public class MessageInfo : IMessageInfoModel {
|
public class MessageInfo : IMessageInfoModel {
|
||||||
|
|
||||||
|
[NotMapped]
|
||||||
|
public int ID { get; private set; }
|
||||||
|
|
||||||
[Key]
|
[Key]
|
||||||
|
[DataMember]
|
||||||
public string MessageID { get; set; } = string.Empty;
|
public string MessageID { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
[DataMember]
|
||||||
public int? ClientID { get; set; }
|
public int? ClientID { get; set; }
|
||||||
|
|
||||||
|
[DataMember]
|
||||||
public string SenderName { get; set; } = string.Empty;
|
public string SenderName { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
[DataMember]
|
||||||
public DateTime DateDelivery { get; set; }
|
public DateTime DateDelivery { get; set; }
|
||||||
|
|
||||||
|
[DataMember]
|
||||||
public string Subject { get; set; } = string.Empty;
|
public string Subject { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
[DataMember]
|
||||||
public string Body { get; set; } = string.Empty;
|
public string Body { get; set; } = string.Empty;
|
||||||
|
|
||||||
public virtual Client? Client { get; set; }
|
public virtual Client? Client { get; set; }
|
||||||
|
@ -6,33 +6,45 @@ using DinerDataModels.Models;
|
|||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
using System.ComponentModel.DataAnnotations.Schema;
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
using System.Net.Http.Headers;
|
using System.Net.Http.Headers;
|
||||||
|
using System.Runtime.Serialization;
|
||||||
using System.Xml.Linq;
|
using System.Xml.Linq;
|
||||||
|
|
||||||
namespace DinerDataBaseImplement.Models
|
namespace DinerDataBaseImplement.Models
|
||||||
{
|
{
|
||||||
|
[DataContract]
|
||||||
public class Order : IOrderModel
|
public class Order : IOrderModel
|
||||||
{
|
{
|
||||||
[ForeignKey("SnackID")]
|
[ForeignKey("SnackID")]
|
||||||
|
[DataMember]
|
||||||
public int SnackID { get; set; }
|
public int SnackID { get; set; }
|
||||||
|
|
||||||
[Required]
|
[Required]
|
||||||
|
[DataMember]
|
||||||
public int ClientID { get; set; }
|
public int ClientID { get; set; }
|
||||||
|
|
||||||
|
[DataMember]
|
||||||
public int? ImplementerID { get; set; }
|
public int? ImplementerID { get; set; }
|
||||||
|
|
||||||
[Required]
|
[Required]
|
||||||
|
[DataMember]
|
||||||
public int Count { get; set; }
|
public int Count { get; set; }
|
||||||
|
|
||||||
[Required]
|
[Required]
|
||||||
|
[DataMember]
|
||||||
public double Sum { get; private set; }
|
public double Sum { get; private set; }
|
||||||
|
|
||||||
[Required]
|
[Required]
|
||||||
|
[DataMember]
|
||||||
public OrderStatus Status { get; set; }
|
public OrderStatus Status { get; set; }
|
||||||
|
|
||||||
[Required]
|
[Required]
|
||||||
|
[DataMember]
|
||||||
public DateTime DateCreate { get; private set; }
|
public DateTime DateCreate { get; private set; }
|
||||||
|
|
||||||
|
[DataMember]
|
||||||
public DateTime? DateImplement { get; set; }
|
public DateTime? DateImplement { get; set; }
|
||||||
|
|
||||||
|
[DataMember]
|
||||||
public int ID { get; private set; }
|
public int ID { get; private set; }
|
||||||
|
|
||||||
public virtual Snack Snack { get; set; }
|
public virtual Snack Snack { get; set; }
|
||||||
|
@ -8,25 +8,31 @@ using System.ComponentModel;
|
|||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
using System.ComponentModel.DataAnnotations.Schema;
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Runtime.Serialization;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Xml.Linq;
|
using System.Xml.Linq;
|
||||||
|
|
||||||
namespace DinerDataBaseImplement.Models
|
namespace DinerDataBaseImplement.Models
|
||||||
{
|
{
|
||||||
|
[DataContract]
|
||||||
public class Snack : ISnackModel
|
public class Snack : ISnackModel
|
||||||
{
|
{
|
||||||
[Required]
|
[Required]
|
||||||
|
[DataMember]
|
||||||
public string ProductName { get; set; } = string.Empty;
|
public string ProductName { get; set; } = string.Empty;
|
||||||
|
|
||||||
[Required]
|
[Required]
|
||||||
|
[DataMember]
|
||||||
public double Price { get; set; }
|
public double Price { get; set; }
|
||||||
|
|
||||||
|
[DataMember]
|
||||||
public int ID { get; set; }
|
public int ID { get; set; }
|
||||||
|
|
||||||
private Dictionary<int, (IFoodModel, int)>? _productComponents = null;
|
private Dictionary<int, (IFoodModel, int)>? _productComponents = null;
|
||||||
|
|
||||||
[NotMapped]
|
[NotMapped]
|
||||||
|
[DataMember]
|
||||||
public Dictionary<int, (IFoodModel, int)> ProductComponents
|
public Dictionary<int, (IFoodModel, int)> ProductComponents
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
|
@ -1,18 +1,24 @@
|
|||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using System.Runtime.Serialization;
|
||||||
|
|
||||||
namespace DinerDataBaseImplement.Models
|
namespace DinerDataBaseImplement.Models
|
||||||
{
|
{
|
||||||
|
[DataContract]
|
||||||
public class SnackFood
|
public class SnackFood
|
||||||
{
|
{
|
||||||
|
[DataMember]
|
||||||
public int ID { get; set; }
|
public int ID { get; set; }
|
||||||
|
|
||||||
[Required]
|
[Required]
|
||||||
|
[DataMember]
|
||||||
public int SnackID { get; set; }
|
public int SnackID { get; set; }
|
||||||
|
|
||||||
[Required]
|
[Required]
|
||||||
|
[DataMember]
|
||||||
public int ComponentID { get; set; }
|
public int ComponentID { get; set; }
|
||||||
|
|
||||||
[Required]
|
[Required]
|
||||||
|
[DataMember]
|
||||||
public int Count { get; set; }
|
public int Count { get; set; }
|
||||||
|
|
||||||
public virtual Food Component { get; set; } = new();
|
public virtual Food Component { get; set; } = new();
|
||||||
|
@ -5,7 +5,7 @@ using System.Text;
|
|||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace DinerDataModels.Models {
|
namespace DinerDataModels.Models {
|
||||||
public interface IMessageInfoModel {
|
public interface IMessageInfoModel : IID{
|
||||||
string MessageID { get; }
|
string MessageID { get; }
|
||||||
int? ClientID { get; }
|
int? ClientID { get; }
|
||||||
string SenderName { get; }
|
string SenderName { get; }
|
||||||
|
@ -11,4 +11,8 @@
|
|||||||
<ProjectReference Include="..\DinerDataModels\DinerDataModels.csproj" />
|
<ProjectReference Include="..\DinerDataModels\DinerDataModels.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
|
||||||
|
<Exec Command="copy /Y "$(targetDir)*.dll" "$(SolutionDir)ImplementationExtensions\*.dll"" />
|
||||||
|
</Target>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
18
Diner/DinerListImplement/Implements/BackUpInfo.cs
Normal file
18
Diner/DinerListImplement/Implements/BackUpInfo.cs
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
using DinerContracts.StoragesContracts;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace DinerListImplement.Implements {
|
||||||
|
public class BackUpInfo : IBackUpInfo {
|
||||||
|
public List<T>? GetList<T>() where T : class, new() {
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Type? GetTypeModelInterface(string modelInterfaceName) {
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,5 +1,6 @@
|
|||||||
using DinerContracts.BindingModels;
|
using DinerContracts.BindingModels;
|
||||||
using DinerContracts.SearchModels;
|
using DinerContracts.SearchModels;
|
||||||
|
using DinerContracts.StoragesContracts;
|
||||||
using DinerContracts.ViewModels;
|
using DinerContracts.ViewModels;
|
||||||
using DinerListImplement.Models;
|
using DinerListImplement.Models;
|
||||||
using System;
|
using System;
|
||||||
@ -9,8 +10,9 @@ using System.Net.Http.Headers;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace DinerListImplement.Implements {
|
namespace DinerListImplement.Implements
|
||||||
public class MessageInfoStorage : IMessageInfoStorage {
|
{
|
||||||
|
public class MessageInfoStorage : IMessageInfoStorage {
|
||||||
|
|
||||||
private readonly DataListSingleton _source;
|
private readonly DataListSingleton _source;
|
||||||
|
|
||||||
|
25
Diner/DinerListImplement/ListImplementationExtension.cs
Normal file
25
Diner/DinerListImplement/ListImplementationExtension.cs
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
using DinerContracts.DI;
|
||||||
|
using DinerContracts.StoragesContracts;
|
||||||
|
using DinerListImplement.Implements;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace DinerListImplement
|
||||||
|
{
|
||||||
|
public class ListImplementationExtension {
|
||||||
|
public int Priority => 0;
|
||||||
|
|
||||||
|
public void RegisterServices() {
|
||||||
|
DependencyManager.Instance.RegisterType<IClientStorage, ClientStorage>();
|
||||||
|
DependencyManager.Instance.RegisterType<IFoodStorage, FoodStorage>();
|
||||||
|
DependencyManager.Instance.RegisterType<IImplementerStorage, ImplementerStorage>();
|
||||||
|
DependencyManager.Instance.RegisterType<IMessageInfoStorage, MessageInfoStorage>();
|
||||||
|
DependencyManager.Instance.RegisterType<IOrderStorage, OrderStorage>();
|
||||||
|
DependencyManager.Instance.RegisterType<ISnackStorage, SnackStorage>();
|
||||||
|
DependencyManager.Instance.RegisterType<IBackUpInfo, BackUpInfo>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -9,6 +9,9 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace DinerListImplement.Models {
|
namespace DinerListImplement.Models {
|
||||||
public class MessageInfo : IMessageInfoModel {
|
public class MessageInfo : IMessageInfoModel {
|
||||||
|
|
||||||
|
public int ID { get; private set; }
|
||||||
|
|
||||||
public string MessageID { get; private set; } = string.Empty;
|
public string MessageID { get; private set; } = string.Empty;
|
||||||
|
|
||||||
public int? ClientID { get; set; }
|
public int? ClientID { get; set; }
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
using DinerContracts.BindingModels;
|
using DinerContracts.BindingModels;
|
||||||
using DinerContracts.BusinessLogicsContacts;
|
using DinerContracts.BusinessLogicsContacts;
|
||||||
using DinerContracts.BusinessLogicsContracts;
|
using DinerContracts.BusinessLogicsContracts;
|
||||||
using DinerContracts.SearchModels;
|
|
||||||
using DinerContracts.StoragesContracts;
|
using DinerContracts.StoragesContracts;
|
||||||
using DinerDataBaseImplement.Implements;
|
using DinerDataBaseImplement.Implements;
|
||||||
using DineryBusinessLogic.BusinessLogic;
|
using DineryBusinessLogic.BusinessLogic;
|
||||||
@ -10,8 +9,9 @@ using DineryBusinessLogic.MailWorker;
|
|||||||
using DocumentFormat.OpenXml.VariantTypes;
|
using DocumentFormat.OpenXml.VariantTypes;
|
||||||
using Microsoft.OpenApi.Models;
|
using Microsoft.OpenApi.Models;
|
||||||
|
|
||||||
namespace DinerRestAPI {
|
namespace DinerRestAPI
|
||||||
public class Program {
|
{
|
||||||
|
public class Program {
|
||||||
public static void Main(string[] args) {
|
public static void Main(string[] args) {
|
||||||
var builder = WebApplication.CreateBuilder(args);
|
var builder = WebApplication.CreateBuilder(args);
|
||||||
|
|
||||||
|
@ -11,4 +11,8 @@
|
|||||||
<ProjectReference Include="..\DinerDataModels\DinerDataModels.csproj" />
|
<ProjectReference Include="..\DinerDataModels\DinerDataModels.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
|
||||||
|
<Exec Command="copy /Y "$(targetDir)*.dll" "$(SolutionDir)ImplementationExtensions\*.dll"" />
|
||||||
|
</Target>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
24
Diner/DinerShopImplement/FileImplementationExtension.cs
Normal file
24
Diner/DinerShopImplement/FileImplementationExtension.cs
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
using DinerContracts.DI;
|
||||||
|
using DinerContracts.StoragesContracts;
|
||||||
|
using DinerFileImplement.Implements;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace DinerFileImplement {
|
||||||
|
public class FileImplementationExtension : IImplmentationExtension {
|
||||||
|
public int Priority => 1;
|
||||||
|
|
||||||
|
public void RegisterServices() {
|
||||||
|
DependencyManager.Instance.RegisterType<IClientStorage, ClientStorage>();
|
||||||
|
DependencyManager.Instance.RegisterType<IFoodStorage, FoodStorage>();
|
||||||
|
DependencyManager.Instance.RegisterType<IImplementerStorage, ImplementerStorage>();
|
||||||
|
DependencyManager.Instance.RegisterType<IMessageInfoStorage, MessageInfoStorage>();
|
||||||
|
DependencyManager.Instance.RegisterType<IOrderStorage, OrderStorage>();
|
||||||
|
DependencyManager.Instance.RegisterType<ISnackStorage, SnackStorage>();
|
||||||
|
DependencyManager.Instance.RegisterType<IBackUpInfo, BackUpInfo>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
28
Diner/DinerShopImplement/Implements/BackUpInfo.cs
Normal file
28
Diner/DinerShopImplement/Implements/BackUpInfo.cs
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
using DinerContracts.StoragesContracts;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace DinerFileImplement.Implements {
|
||||||
|
public class BackUpInfo : IBackUpInfo {
|
||||||
|
public List<T>? GetList<T>() where T : class, new() {
|
||||||
|
DataFileSingleton dataFileSingleton = DataFileSingleton.GetInstance();
|
||||||
|
return (List<T>?)dataFileSingleton.GetType().GetProperties()
|
||||||
|
.FirstOrDefault(x => x.PropertyType.IsGenericType && x.PropertyType.GetGenericArguments()[0] == typeof(T))?
|
||||||
|
.GetValue(dataFileSingleton);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Type? GetTypeModelInterface(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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -14,7 +14,7 @@ namespace DinerFileImplement.Implements {
|
|||||||
|
|
||||||
private readonly DataFileSingleton _source;
|
private readonly DataFileSingleton _source;
|
||||||
|
|
||||||
private ImplementerStorage() {
|
public ImplementerStorage() {
|
||||||
_source = DataFileSingleton.GetInstance();
|
_source = DataFileSingleton.GetInstance();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
using DinerContracts.BindingModels;
|
using DinerContracts.BindingModels;
|
||||||
using DinerContracts.SearchModels;
|
using DinerContracts.SearchModels;
|
||||||
|
using DinerContracts.StoragesContracts;
|
||||||
using DinerContracts.ViewModels;
|
using DinerContracts.ViewModels;
|
||||||
using DinerFileImplement.Models;
|
using DinerFileImplement.Models;
|
||||||
using System;
|
using System;
|
||||||
@ -9,12 +10,13 @@ using System.Linq;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace DinerFileImplement.Implements {
|
namespace DinerFileImplement.Implements
|
||||||
public class MessageInfoStorage : IMessageInfoStorage {
|
{
|
||||||
|
public class MessageInfoStorage : IMessageInfoStorage {
|
||||||
|
|
||||||
private readonly DataFileSingleton _source;
|
private readonly DataFileSingleton _source;
|
||||||
|
|
||||||
private MessageInfoStorage() {
|
public MessageInfoStorage() {
|
||||||
_source = DataFileSingleton.GetInstance();
|
_source = DataFileSingleton.GetInstance();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,18 +4,25 @@ using DinerDataModels.Models;
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Runtime.Serialization;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Xml.Linq;
|
using System.Xml.Linq;
|
||||||
|
|
||||||
namespace DinerFileImplement.Models {
|
namespace DinerFileImplement.Models {
|
||||||
|
[DataContract]
|
||||||
public class Client : IClientModel {
|
public class Client : IClientModel {
|
||||||
|
|
||||||
|
[DataMember]
|
||||||
public string ClientFIO { get; set; } = string.Empty;
|
public string ClientFIO { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
[DataMember]
|
||||||
public string Email { get; set; } = string.Empty;
|
public string Email { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
[DataMember]
|
||||||
public string Password { get; set; } = string.Empty;
|
public string Password { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
[DataMember]
|
||||||
public int ID { get; set; }
|
public int ID { get; set; }
|
||||||
|
|
||||||
public static Client? Create(ClientBindingModel? model) {
|
public static Client? Create(ClientBindingModel? model) {
|
||||||
|
@ -4,18 +4,23 @@ using DinerDataModels.Models;
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Runtime.Serialization;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Xml.Linq;
|
using System.Xml.Linq;
|
||||||
|
|
||||||
namespace DinerFileImplement.Models
|
namespace DinerFileImplement.Models
|
||||||
{
|
{
|
||||||
|
[DataContract]
|
||||||
internal class Food : IFoodModel
|
internal class Food : IFoodModel
|
||||||
{
|
{
|
||||||
|
[DataMember]
|
||||||
public string ComponentName { get; set; } = string.Empty;
|
public string ComponentName { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
[DataMember]
|
||||||
public double Price { get; set; }
|
public double Price { get; set; }
|
||||||
|
|
||||||
|
[DataMember]
|
||||||
public int ID { get; set; }
|
public int ID { get; set; }
|
||||||
|
|
||||||
public static Food? Create(FoodBindingModel? model)
|
public static Food? Create(FoodBindingModel? model)
|
||||||
@ -33,7 +38,7 @@ namespace DinerFileImplement.Models
|
|||||||
return new Food()
|
return new Food()
|
||||||
{
|
{
|
||||||
ID = Convert.ToInt32(element.Attribute("ID")!.Value),
|
ID = Convert.ToInt32(element.Attribute("ID")!.Value),
|
||||||
ComponentName = element.Element("ProductName")!.Value,
|
ComponentName = element.Element("ComponentName")!.Value,
|
||||||
Price = Convert.ToDouble(element.Element("Price")!.Value)
|
Price = Convert.ToDouble(element.Element("Price")!.Value)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -4,19 +4,29 @@ using DinerDataModels.Models;
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Runtime.Serialization;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Xml.Linq;
|
using System.Xml.Linq;
|
||||||
|
|
||||||
namespace DinerFileImplement.Models {
|
namespace DinerFileImplement.Models {
|
||||||
|
|
||||||
|
[DataContract]
|
||||||
public class Implementer : IImplementerModel {
|
public class Implementer : IImplementerModel {
|
||||||
|
|
||||||
|
[DataMember]
|
||||||
public string ImplementerFIO { get; set; } = string.Empty;
|
public string ImplementerFIO { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
[DataMember]
|
||||||
public string Password { get; set; } = string.Empty;
|
public string Password { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
[DataMember]
|
||||||
public int WorkExperience { get; set; }
|
public int WorkExperience { get; set; }
|
||||||
|
|
||||||
|
[DataMember]
|
||||||
public int Qualification { get; set; }
|
public int Qualification { get; set; }
|
||||||
|
|
||||||
|
[DataMember]
|
||||||
public int ID { get; set; }
|
public int ID { get; set; }
|
||||||
|
|
||||||
public static Implementer? Create(ImplementerBindingModel? model) {
|
public static Implementer? Create(ImplementerBindingModel? model) {
|
||||||
|
@ -4,22 +4,34 @@ using DinerDataModels.Models;
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Runtime.Serialization;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Xml.Linq;
|
using System.Xml.Linq;
|
||||||
|
|
||||||
namespace DinerFileImplement.Models {
|
namespace DinerFileImplement.Models {
|
||||||
|
[DataContract]
|
||||||
public class MessageInfo : IMessageInfoModel {
|
public class MessageInfo : IMessageInfoModel {
|
||||||
|
|
||||||
|
[DataMember]
|
||||||
|
public int ID { get; private set; }
|
||||||
|
|
||||||
|
[DataMember]
|
||||||
public string MessageID { get; set; } = string.Empty;
|
public string MessageID { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
[DataMember]
|
||||||
public int? ClientID { get; set; }
|
public int? ClientID { get; set; }
|
||||||
|
|
||||||
|
[DataMember]
|
||||||
public string SenderName { get; set; } = string.Empty;
|
public string SenderName { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
[DataMember]
|
||||||
public DateTime DateDelivery { get; set; }
|
public DateTime DateDelivery { get; set; }
|
||||||
|
|
||||||
|
[DataMember]
|
||||||
public string Subject { get; set; } = string.Empty;
|
public string Subject { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
[DataMember]
|
||||||
public string Body { get; set; } = string.Empty;
|
public string Body { get; set; } = string.Empty;
|
||||||
|
|
||||||
public static MessageInfo? Create(MessageInfoBindingModel? model) {
|
public static MessageInfo? Create(MessageInfoBindingModel? model) {
|
||||||
@ -65,5 +77,6 @@ namespace DinerFileImplement.Models {
|
|||||||
new XElement("DateDelivery", DateDelivery.ToString()),
|
new XElement("DateDelivery", DateDelivery.ToString()),
|
||||||
new XElement("Subject", Subject),
|
new XElement("Subject", Subject),
|
||||||
new XElement("Body", Body));
|
new XElement("Body", Body));
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@ using DinerDataModels.Models;
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Runtime.Serialization;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Xml.Linq;
|
using System.Xml.Linq;
|
||||||
@ -12,29 +13,43 @@ using System.Xml.Schema;
|
|||||||
|
|
||||||
namespace DinerFileImplement.Models
|
namespace DinerFileImplement.Models
|
||||||
{
|
{
|
||||||
|
[DataContract]
|
||||||
internal class Order : IOrderModel {
|
internal class Order : IOrderModel {
|
||||||
|
|
||||||
|
[DataMember]
|
||||||
public int SnackID { get; private set; }
|
public int SnackID { get; private set; }
|
||||||
|
|
||||||
|
[DataMember]
|
||||||
public int ClientID { get; private set; }
|
public int ClientID { get; private set; }
|
||||||
|
|
||||||
|
[DataMember]
|
||||||
public int? ImplementerID { get; set; }
|
public int? ImplementerID { get; set; }
|
||||||
|
|
||||||
|
[DataMember]
|
||||||
public int Count { get; set; }
|
public int Count { get; set; }
|
||||||
|
|
||||||
|
[DataMember]
|
||||||
public double Sum { get; private set; }
|
public double Sum { get; private set; }
|
||||||
|
|
||||||
|
[DataMember]
|
||||||
public OrderStatus Status { get; set; }
|
public OrderStatus Status { get; set; }
|
||||||
|
|
||||||
|
[DataMember]
|
||||||
public DateTime DateCreate { get; private set; }
|
public DateTime DateCreate { get; private set; }
|
||||||
|
|
||||||
|
[DataMember]
|
||||||
public DateTime? DateImplement { get; set; }
|
public DateTime? DateImplement { get; set; }
|
||||||
|
|
||||||
|
[DataMember]
|
||||||
public int ID { get; private set; }
|
public int ID { get; private set; }
|
||||||
|
|
||||||
|
[DataMember]
|
||||||
public string? ProductName { get; private set; }
|
public string? ProductName { get; private set; }
|
||||||
|
|
||||||
|
[DataMember]
|
||||||
public string ClientFIO { get; private set; }
|
public string ClientFIO { get; private set; }
|
||||||
|
|
||||||
|
[DataMember]
|
||||||
public string ImplementerFIO { get; private set; }
|
public string ImplementerFIO { get; private set; }
|
||||||
|
|
||||||
public static Order? Create(OrderBindingModel? model)
|
public static Order? Create(OrderBindingModel? model)
|
||||||
|
@ -5,6 +5,7 @@ using System;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
|
using System.Runtime.Serialization;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Xml.Linq;
|
using System.Xml.Linq;
|
||||||
@ -12,15 +13,21 @@ using System.Xml.XPath;
|
|||||||
|
|
||||||
namespace DinerFileImplement.Models
|
namespace DinerFileImplement.Models
|
||||||
{
|
{
|
||||||
|
[DataContract]
|
||||||
internal class Snack : ISnackModel
|
internal class Snack : ISnackModel
|
||||||
{
|
{
|
||||||
|
[DataMember]
|
||||||
public string ProductName { get; private set; } = string.Empty;
|
public string ProductName { get; private set; } = string.Empty;
|
||||||
|
|
||||||
|
[DataMember]
|
||||||
public double Price { get; private set; }
|
public double Price { get; private set; }
|
||||||
|
|
||||||
|
[DataMember]
|
||||||
public int ID { get; private set; }
|
public int ID { get; private set; }
|
||||||
|
|
||||||
public Dictionary<int, int> Components { get; private set; } = new();
|
public Dictionary<int, int> Components { get; private set; } = new();
|
||||||
|
|
||||||
|
[DataMember]
|
||||||
private Dictionary<int, (IFoodModel, int)>? _productComponents = null;
|
private Dictionary<int, (IFoodModel, int)>? _productComponents = null;
|
||||||
public Dictionary<int, (IFoodModel, int)> ProductComponents
|
public Dictionary<int, (IFoodModel, int)> ProductComponents
|
||||||
{
|
{
|
||||||
|
43
Diner/DinerView/DataGridViewExtension.cs
Normal file
43
Diner/DinerView/DataGridViewExtension.cs
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
using DinerContracts.Attributes;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace DinerView {
|
||||||
|
internal static class DataGridViewExtension {
|
||||||
|
public static void FillAndConfigGrid<T>(this DataGridView grid, List<T>? data) {
|
||||||
|
if (data == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
grid.DataSource = data;
|
||||||
|
|
||||||
|
var type = typeof(T);
|
||||||
|
var properties = type.GetProperties();
|
||||||
|
foreach (DataGridViewColumn column in grid.Columns) {
|
||||||
|
var property = properties.FirstOrDefault(x => x.Name == column.Name);
|
||||||
|
if (property == null) {
|
||||||
|
throw new InvalidOperationException($"В типе {type.Name} не найдено свойств с именем {column.Name}");
|
||||||
|
}
|
||||||
|
var attribute = property.GetCustomAttributes(typeof(ColumnAttribute), true)?.SingleOrDefault();
|
||||||
|
if (attribute == null) {
|
||||||
|
throw new InvalidOperationException($"Не найден атрибут типа ColumnAttribute для свойства {property.Name}");
|
||||||
|
}
|
||||||
|
|
||||||
|
// ищем нужный атрибут
|
||||||
|
if (attribute is ColumnAttribute columnAttr) {
|
||||||
|
column.HeaderText = columnAttr.Title;
|
||||||
|
column.Visible = columnAttr.Visible;
|
||||||
|
if (columnAttr.IsUseAutoSize) {
|
||||||
|
column.AutoSizeMode = (DataGridViewAutoSizeColumnMode)Enum.Parse(typeof(DataGridViewAutoSizeColumnMode),
|
||||||
|
columnAttr._GridViewAutoSize.ToString());
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
column.Width = columnAttr.Width;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -21,10 +21,15 @@
|
|||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.5.0" />
|
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.5.0" />
|
||||||
<PackageReference Include="Microsoft.CodeAnalysis.VisualBasic" Version="4.5.0" />
|
<PackageReference Include="Microsoft.CodeAnalysis.VisualBasic" Version="4.5.0" />
|
||||||
|
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.6" />
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.3">
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.3">
|
||||||
<PrivateAssets>all</PrivateAssets>
|
<PrivateAssets>all</PrivateAssets>
|
||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="8.0.3">
|
||||||
|
<PrivateAssets>all</PrivateAssets>
|
||||||
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
|
</PackageReference>
|
||||||
<PackageReference Include="Microsoft.Extensions.Configuration" Version="8.0.0" />
|
<PackageReference Include="Microsoft.Extensions.Configuration" Version="8.0.0" />
|
||||||
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="8.0.0" />
|
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="8.0.0" />
|
||||||
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.1" />
|
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.1" />
|
||||||
|
@ -25,12 +25,7 @@ namespace DinerView {
|
|||||||
|
|
||||||
private void LoadData() {
|
private void LoadData() {
|
||||||
try {
|
try {
|
||||||
var list = _logic.ReadList(null);
|
dataGridView.FillAndConfigGrid(_logic.ReadList(null));
|
||||||
if (list != null) {
|
|
||||||
dataGridView.DataSource = list;
|
|
||||||
dataGridView.Columns["ID"].Visible = false;
|
|
||||||
dataGridView.Columns["ClientFIO"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
|
||||||
}
|
|
||||||
_logger.LogInformation("Загрузка клиентов");
|
_logger.LogInformation("Загрузка клиентов");
|
||||||
}
|
}
|
||||||
catch (Exception ex) {
|
catch (Exception ex) {
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
using DinerContracts.BindingModels;
|
using DinerContracts.BindingModels;
|
||||||
using DinerContracts.BusinessLogicsContacts;
|
using DinerContracts.BusinessLogicsContacts;
|
||||||
|
using DinerContracts.DI;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
@ -29,13 +30,7 @@ namespace DinerView
|
|||||||
{
|
{
|
||||||
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)
|
||||||
@ -47,7 +42,7 @@ namespace DinerView
|
|||||||
|
|
||||||
private void buttonAdd_Click(object sender, EventArgs e)
|
private void buttonAdd_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
var service = Program.ServiceProvider?.GetService(typeof(FormFood));
|
var service = DependencyManager.Instance.Resolve<FormFood>();
|
||||||
if (service is FormFood form) {
|
if (service is FormFood form) {
|
||||||
if (form.ShowDialog() == DialogResult.OK) LoadData();
|
if (form.ShowDialog() == DialogResult.OK) LoadData();
|
||||||
}
|
}
|
||||||
@ -87,7 +82,7 @@ namespace DinerView
|
|||||||
{
|
{
|
||||||
if (dataGridView.SelectedRows.Count == 1)
|
if (dataGridView.SelectedRows.Count == 1)
|
||||||
{
|
{
|
||||||
var service = Program.ServiceProvider?.GetService(typeof(FormFood));
|
var service = DependencyManager.Instance.Resolve<FormFood>();
|
||||||
if (service is FormFood form)
|
if (service is FormFood form)
|
||||||
{
|
{
|
||||||
form.ID = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["ID"].Value);
|
form.ID = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["ID"].Value);
|
||||||
|
6
Diner/DinerView/FormImplementers.Designer.cs
generated
6
Diner/DinerView/FormImplementers.Designer.cs
generated
@ -35,10 +35,10 @@
|
|||||||
//
|
//
|
||||||
dataGridView.AllowUserToAddRows = false;
|
dataGridView.AllowUserToAddRows = false;
|
||||||
dataGridView.AllowUserToDeleteRows = false;
|
dataGridView.AllowUserToDeleteRows = false;
|
||||||
|
dataGridView.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
|
||||||
dataGridView.BackgroundColor = SystemColors.ButtonHighlight;
|
dataGridView.BackgroundColor = SystemColors.ButtonHighlight;
|
||||||
dataGridView.BorderStyle = BorderStyle.None;
|
dataGridView.BorderStyle = BorderStyle.None;
|
||||||
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||||
dataGridView.Dock = DockStyle.Left;
|
|
||||||
dataGridView.Location = new Point(0, 0);
|
dataGridView.Location = new Point(0, 0);
|
||||||
dataGridView.Name = "dataGridView";
|
dataGridView.Name = "dataGridView";
|
||||||
dataGridView.RowHeadersVisible = false;
|
dataGridView.RowHeadersVisible = false;
|
||||||
@ -48,6 +48,7 @@
|
|||||||
//
|
//
|
||||||
// buttonAdd
|
// buttonAdd
|
||||||
//
|
//
|
||||||
|
buttonAdd.Anchor = AnchorStyles.Top | AnchorStyles.Right;
|
||||||
buttonAdd.Location = new Point(509, 12);
|
buttonAdd.Location = new Point(509, 12);
|
||||||
buttonAdd.Name = "buttonAdd";
|
buttonAdd.Name = "buttonAdd";
|
||||||
buttonAdd.Size = new Size(95, 35);
|
buttonAdd.Size = new Size(95, 35);
|
||||||
@ -58,6 +59,7 @@
|
|||||||
//
|
//
|
||||||
// buttonCange
|
// buttonCange
|
||||||
//
|
//
|
||||||
|
buttonCange.Anchor = AnchorStyles.Top | AnchorStyles.Right;
|
||||||
buttonCange.Location = new Point(509, 53);
|
buttonCange.Location = new Point(509, 53);
|
||||||
buttonCange.Name = "buttonCange";
|
buttonCange.Name = "buttonCange";
|
||||||
buttonCange.Size = new Size(95, 35);
|
buttonCange.Size = new Size(95, 35);
|
||||||
@ -68,6 +70,7 @@
|
|||||||
//
|
//
|
||||||
// buttonDelete
|
// buttonDelete
|
||||||
//
|
//
|
||||||
|
buttonDelete.Anchor = AnchorStyles.Top | AnchorStyles.Right;
|
||||||
buttonDelete.Location = new Point(509, 94);
|
buttonDelete.Location = new Point(509, 94);
|
||||||
buttonDelete.Name = "buttonDelete";
|
buttonDelete.Name = "buttonDelete";
|
||||||
buttonDelete.Size = new Size(95, 35);
|
buttonDelete.Size = new Size(95, 35);
|
||||||
@ -78,6 +81,7 @@
|
|||||||
//
|
//
|
||||||
// buttonUpdate
|
// buttonUpdate
|
||||||
//
|
//
|
||||||
|
buttonUpdate.Anchor = AnchorStyles.Top | AnchorStyles.Right;
|
||||||
buttonUpdate.Location = new Point(509, 135);
|
buttonUpdate.Location = new Point(509, 135);
|
||||||
buttonUpdate.Name = "buttonUpdate";
|
buttonUpdate.Name = "buttonUpdate";
|
||||||
buttonUpdate.Size = new Size(95, 35);
|
buttonUpdate.Size = new Size(95, 35);
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
using DinerContracts.BindingModels;
|
using DinerContracts.BindingModels;
|
||||||
using DinerContracts.BusinessLogicsContracts;
|
using DinerContracts.BusinessLogicsContracts;
|
||||||
|
using DinerContracts.DI;
|
||||||
using Microsoft.EntityFrameworkCore.Diagnostics;
|
using Microsoft.EntityFrameworkCore.Diagnostics;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using System;
|
using System;
|
||||||
@ -30,12 +31,7 @@ namespace DinerView {
|
|||||||
|
|
||||||
private void LoadData() {
|
private void LoadData() {
|
||||||
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) {
|
||||||
@ -49,7 +45,7 @@ namespace DinerView {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void buttonAdd_Click(object sender, EventArgs e) {
|
private void buttonAdd_Click(object sender, EventArgs e) {
|
||||||
var service = Program.ServiceProvider?.GetService(typeof(FormImplementer));
|
var service = DependencyManager.Instance.Resolve<FormImplementer>();
|
||||||
if (service is FormImplementer form) {
|
if (service is FormImplementer form) {
|
||||||
if (form.ShowDialog() == DialogResult.OK) {
|
if (form.ShowDialog() == DialogResult.OK) {
|
||||||
LoadData();
|
LoadData();
|
||||||
@ -59,7 +55,7 @@ namespace DinerView {
|
|||||||
|
|
||||||
private void buttonCange_Click(object sender, EventArgs e) {
|
private void buttonCange_Click(object sender, EventArgs e) {
|
||||||
if (dataGridView.SelectedRows.Count == 1) {
|
if (dataGridView.SelectedRows.Count == 1) {
|
||||||
var service = Program.ServiceProvider?.GetService(typeof(FormImplementer));
|
var service = DependencyManager.Instance.Resolve<FormImplementer>();
|
||||||
if (service is FormImplementer form) {
|
if (service is FormImplementer form) {
|
||||||
form.ID = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["ID"].Value);
|
form.ID = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["ID"].Value);
|
||||||
if (form.ShowDialog() == DialogResult.OK) {
|
if (form.ShowDialog() == DialogResult.OK) {
|
||||||
|
@ -24,13 +24,7 @@ namespace DinerView {
|
|||||||
|
|
||||||
private void FormMail_Load(object sender, EventArgs e) {
|
private void FormMail_Load(object sender, EventArgs e) {
|
||||||
try {
|
try {
|
||||||
var list = _logic.ReadList(null);
|
dataGridView.FillAndConfigGrid(_logic.ReadList(null));
|
||||||
if (list != null) {
|
|
||||||
dataGridView.DataSource = list;
|
|
||||||
dataGridView.Columns["ClientID"].Visible = false;
|
|
||||||
dataGridView.Columns["MessageID"].Visible = false;
|
|
||||||
dataGridView.Columns["Body"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
|
||||||
}
|
|
||||||
_logger.LogInformation("Загрузка списка писем");
|
_logger.LogInformation("Загрузка списка писем");
|
||||||
}
|
}
|
||||||
catch (Exception ex) {
|
catch (Exception ex) {
|
||||||
|
27
Diner/DinerView/FormMain.Designer.cs
generated
27
Diner/DinerView/FormMain.Designer.cs
generated
@ -38,11 +38,12 @@
|
|||||||
FoodSnacksToolStripMenuItem = new ToolStripMenuItem();
|
FoodSnacksToolStripMenuItem = new ToolStripMenuItem();
|
||||||
ordersToolStripMenuItem = new ToolStripMenuItem();
|
ordersToolStripMenuItem = new ToolStripMenuItem();
|
||||||
toolStripMenuItemStartOfWork = new ToolStripMenuItem();
|
toolStripMenuItemStartOfWork = new ToolStripMenuItem();
|
||||||
|
toolStripMenuItemMail = new ToolStripMenuItem();
|
||||||
dataGridView = new DataGridView();
|
dataGridView = new DataGridView();
|
||||||
buttonCreateOrder = new Button();
|
buttonCreateOrder = new Button();
|
||||||
buttonIsDelivery = new Button();
|
buttonIsDelivery = new Button();
|
||||||
buttonUpdateList = new Button();
|
buttonUpdateList = new Button();
|
||||||
toolStripMenuItemMail = new ToolStripMenuItem();
|
toolStripMenuCreateBackUp = new ToolStripMenuItem();
|
||||||
menuStrip.SuspendLayout();
|
menuStrip.SuspendLayout();
|
||||||
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
|
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
|
||||||
SuspendLayout();
|
SuspendLayout();
|
||||||
@ -50,7 +51,7 @@
|
|||||||
// menuStrip
|
// menuStrip
|
||||||
//
|
//
|
||||||
menuStrip.BackColor = SystemColors.Control;
|
menuStrip.BackColor = SystemColors.Control;
|
||||||
menuStrip.Items.AddRange(new ToolStripItem[] { toolStripMenuItemMenu, toolStripMenuItemReport, toolStripMenuItemStartOfWork, toolStripMenuItemMail });
|
menuStrip.Items.AddRange(new ToolStripItem[] { toolStripMenuItemMenu, toolStripMenuItemReport, toolStripMenuItemStartOfWork, toolStripMenuItemMail, toolStripMenuCreateBackUp });
|
||||||
menuStrip.Location = new Point(0, 0);
|
menuStrip.Location = new Point(0, 0);
|
||||||
menuStrip.Name = "menuStrip";
|
menuStrip.Name = "menuStrip";
|
||||||
menuStrip.Size = new Size(1114, 24);
|
menuStrip.Size = new Size(1114, 24);
|
||||||
@ -127,6 +128,13 @@
|
|||||||
toolStripMenuItemStartOfWork.Text = "Запуск работ";
|
toolStripMenuItemStartOfWork.Text = "Запуск работ";
|
||||||
toolStripMenuItemStartOfWork.Click += toolStripMenuItemStartOfWork_Click;
|
toolStripMenuItemStartOfWork.Click += toolStripMenuItemStartOfWork_Click;
|
||||||
//
|
//
|
||||||
|
// toolStripMenuItemMail
|
||||||
|
//
|
||||||
|
toolStripMenuItemMail.Name = "toolStripMenuItemMail";
|
||||||
|
toolStripMenuItemMail.Size = new Size(53, 20);
|
||||||
|
toolStripMenuItemMail.Text = "Почта";
|
||||||
|
toolStripMenuItemMail.Click += toolStripMenuItemMail_Click;
|
||||||
|
//
|
||||||
// dataGridView
|
// dataGridView
|
||||||
//
|
//
|
||||||
dataGridView.AllowUserToAddRows = false;
|
dataGridView.AllowUserToAddRows = false;
|
||||||
@ -146,6 +154,7 @@
|
|||||||
//
|
//
|
||||||
// buttonCreateOrder
|
// buttonCreateOrder
|
||||||
//
|
//
|
||||||
|
buttonCreateOrder.Anchor = AnchorStyles.Top | AnchorStyles.Right;
|
||||||
buttonCreateOrder.Location = new Point(895, 40);
|
buttonCreateOrder.Location = new Point(895, 40);
|
||||||
buttonCreateOrder.Name = "buttonCreateOrder";
|
buttonCreateOrder.Name = "buttonCreateOrder";
|
||||||
buttonCreateOrder.Size = new Size(212, 39);
|
buttonCreateOrder.Size = new Size(212, 39);
|
||||||
@ -156,6 +165,7 @@
|
|||||||
//
|
//
|
||||||
// buttonIsDelivery
|
// buttonIsDelivery
|
||||||
//
|
//
|
||||||
|
buttonIsDelivery.Anchor = AnchorStyles.Top | AnchorStyles.Right;
|
||||||
buttonIsDelivery.Location = new Point(895, 100);
|
buttonIsDelivery.Location = new Point(895, 100);
|
||||||
buttonIsDelivery.Name = "buttonIsDelivery";
|
buttonIsDelivery.Name = "buttonIsDelivery";
|
||||||
buttonIsDelivery.Size = new Size(212, 39);
|
buttonIsDelivery.Size = new Size(212, 39);
|
||||||
@ -166,6 +176,8 @@
|
|||||||
//
|
//
|
||||||
// buttonUpdateList
|
// buttonUpdateList
|
||||||
//
|
//
|
||||||
|
buttonUpdateList.Anchor = AnchorStyles.Top | AnchorStyles.Right;
|
||||||
|
buttonUpdateList.AutoSize = true;
|
||||||
buttonUpdateList.Location = new Point(895, 159);
|
buttonUpdateList.Location = new Point(895, 159);
|
||||||
buttonUpdateList.Name = "buttonUpdateList";
|
buttonUpdateList.Name = "buttonUpdateList";
|
||||||
buttonUpdateList.Size = new Size(212, 39);
|
buttonUpdateList.Size = new Size(212, 39);
|
||||||
@ -174,12 +186,12 @@
|
|||||||
buttonUpdateList.UseVisualStyleBackColor = true;
|
buttonUpdateList.UseVisualStyleBackColor = true;
|
||||||
buttonUpdateList.Click += buttonUpdateList_Click;
|
buttonUpdateList.Click += buttonUpdateList_Click;
|
||||||
//
|
//
|
||||||
// toolStripMenuItemMail
|
// toolStripMenuCreateBackUp
|
||||||
//
|
//
|
||||||
toolStripMenuItemMail.Name = "toolStripMenuItemMail";
|
toolStripMenuCreateBackUp.Name = "toolStripMenuCreateBackUp";
|
||||||
toolStripMenuItemMail.Size = new Size(53, 20);
|
toolStripMenuCreateBackUp.Size = new Size(97, 20);
|
||||||
toolStripMenuItemMail.Text = "Почта";
|
toolStripMenuCreateBackUp.Text = "Создать бекап";
|
||||||
toolStripMenuItemMail.Click += toolStripMenuItemMail_Click;
|
toolStripMenuCreateBackUp.Click += toolStripMenuCreateBackUp_Click;
|
||||||
//
|
//
|
||||||
// FormMain
|
// FormMain
|
||||||
//
|
//
|
||||||
@ -221,5 +233,6 @@
|
|||||||
private ToolStripMenuItem toolStripMenuItemStartOfWork;
|
private ToolStripMenuItem toolStripMenuItemStartOfWork;
|
||||||
private ToolStripMenuItem toolStripMenuItemImplementer;
|
private ToolStripMenuItem toolStripMenuItemImplementer;
|
||||||
private ToolStripMenuItem toolStripMenuItemMail;
|
private ToolStripMenuItem toolStripMenuItemMail;
|
||||||
|
private ToolStripMenuItem toolStripMenuCreateBackUp;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,6 +1,7 @@
|
|||||||
using DinerContracts.BindingModels;
|
using DinerContracts.BindingModels;
|
||||||
using DinerContracts.BusinessLogicsContacts;
|
using DinerContracts.BusinessLogicsContacts;
|
||||||
using DinerContracts.BusinessLogicsContracts;
|
using DinerContracts.BusinessLogicsContracts;
|
||||||
|
using DinerContracts.DI;
|
||||||
using DinerDataBaseImplement.Models;
|
using DinerDataBaseImplement.Models;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using System;
|
using System;
|
||||||
@ -21,12 +22,14 @@ namespace DinerView
|
|||||||
private readonly IOrderLogic _orderLogic;
|
private readonly IOrderLogic _orderLogic;
|
||||||
private readonly IReportLogic _reportLogic;
|
private readonly IReportLogic _reportLogic;
|
||||||
private readonly IWorkProcess _workProcess;
|
private readonly IWorkProcess _workProcess;
|
||||||
public FormMain(ILogger<FormMain> logger, IOrderLogic orderLogic, IReportLogic reportLogic, IWorkProcess workProcess) {
|
private readonly IBackUpLogic _backUpLogic;
|
||||||
|
public FormMain(ILogger<FormMain> logger, IOrderLogic orderLogic, IReportLogic reportLogic, IWorkProcess workProcess, IBackUpLogic backUpLogic) {
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
_orderLogic = orderLogic;
|
_orderLogic = orderLogic;
|
||||||
_reportLogic = reportLogic;
|
_reportLogic = reportLogic;
|
||||||
_workProcess = workProcess;
|
_workProcess = workProcess;
|
||||||
|
_backUpLogic = backUpLogic;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void FormMain_Load(object sender, EventArgs e) {
|
private void FormMain_Load(object sender, EventArgs e) {
|
||||||
@ -36,16 +39,7 @@ namespace DinerView
|
|||||||
private void LoadData() {
|
private void LoadData() {
|
||||||
_logger.LogInformation("Загрузка заказов");
|
_logger.LogInformation("Загрузка заказов");
|
||||||
try {
|
try {
|
||||||
var list = _orderLogic.ReadList(null);
|
dataGridView.FillAndConfigGrid(_orderLogic.ReadList(null));
|
||||||
if (list != null) {
|
|
||||||
dataGridView.DataSource = list;
|
|
||||||
dataGridView.Columns["SnackID"].Visible = false;
|
|
||||||
dataGridView.Columns["ClientID"].Visible = false;
|
|
||||||
dataGridView.Columns["ImplementerID"].Visible = false;
|
|
||||||
dataGridView.Columns["ID"].AutoSizeMode = DataGridViewAutoSizeColumnMode.ColumnHeader;
|
|
||||||
dataGridView.Columns["Sum"].AutoSizeMode = DataGridViewAutoSizeColumnMode.ColumnHeader;
|
|
||||||
dataGridView.Columns["ImplementerFIO"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
|
||||||
}
|
|
||||||
_logger.LogInformation("Загрузка заказов");
|
_logger.LogInformation("Загрузка заказов");
|
||||||
}
|
}
|
||||||
catch (Exception ex) {
|
catch (Exception ex) {
|
||||||
@ -55,7 +49,7 @@ namespace DinerView
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void toolStripMenuItemFoods_Click(object sender, EventArgs e) {
|
private void toolStripMenuItemFoods_Click(object sender, EventArgs e) {
|
||||||
var service = Program.ServiceProvider?.GetService(typeof(FormFoods));
|
var service = DependencyManager.Instance.Resolve<FormFoods>();
|
||||||
if (service is FormFoods form) {
|
if (service is FormFoods form) {
|
||||||
form.ShowDialog();
|
form.ShowDialog();
|
||||||
LoadData();
|
LoadData();
|
||||||
@ -63,7 +57,7 @@ namespace DinerView
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void toolStripMenuItemSnacks_Click(object sender, EventArgs e) {
|
private void toolStripMenuItemSnacks_Click(object sender, EventArgs e) {
|
||||||
var service = Program.ServiceProvider?.GetService(typeof(FormSnacks));
|
var service = DependencyManager.Instance.Resolve<FormSnacks>();
|
||||||
if (service is FormSnacks form) {
|
if (service is FormSnacks form) {
|
||||||
form.ShowDialog();
|
form.ShowDialog();
|
||||||
LoadData();
|
LoadData();
|
||||||
@ -71,7 +65,7 @@ namespace DinerView
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void buttonCreateOrder_Click(object sender, EventArgs e) {
|
private void buttonCreateOrder_Click(object sender, EventArgs e) {
|
||||||
var service = Program.ServiceProvider?.GetService(typeof(FormCreateOrder));
|
var service = DependencyManager.Instance.Resolve<FormCreateOrder>();
|
||||||
if (service is FormCreateOrder form) {
|
if (service is FormCreateOrder form) {
|
||||||
form.ShowDialog();
|
form.ShowDialog();
|
||||||
LoadData();
|
LoadData();
|
||||||
@ -146,44 +140,57 @@ namespace DinerView
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void FoodSnacksToolStripMenuItem_Click(object sender, EventArgs e) {
|
private void FoodSnacksToolStripMenuItem_Click(object sender, EventArgs e) {
|
||||||
var service = Program.ServiceProvider?.GetService(typeof(FormReportSnackFoods));
|
var service = DependencyManager.Instance.Resolve<FormReportSnackFoods>();
|
||||||
if (service is FormReportSnackFoods form) {
|
if (service is FormReportSnackFoods form) {
|
||||||
form.ShowDialog();
|
form.ShowDialog();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ordersToolStripMenuItem_Click(object sender, EventArgs e) {
|
private void ordersToolStripMenuItem_Click(object sender, EventArgs e) {
|
||||||
var service = Program.ServiceProvider?.GetService(typeof(FormReportOrders));
|
var service = DependencyManager.Instance.Resolve<FormReportOrders>();
|
||||||
if (service is FormReportOrders form) {
|
if (service is FormReportOrders form) {
|
||||||
form.ShowDialog();
|
form.ShowDialog();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void toolStripMenuItemClient_Click(object sender, EventArgs e) {
|
private void toolStripMenuItemClient_Click(object sender, EventArgs e) {
|
||||||
var service = Program.ServiceProvider?.GetService(typeof(FormClient));
|
var service = DependencyManager.Instance.Resolve<FormClient>();
|
||||||
if (service is FormClient form) {
|
if (service is FormClient form) {
|
||||||
form.ShowDialog();
|
form.ShowDialog();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void toolStripMenuItemImplementer_Click(object sender, EventArgs e) {
|
private void toolStripMenuItemImplementer_Click(object sender, EventArgs e) {
|
||||||
var service = Program.ServiceProvider?.GetService(typeof(FormImplementers));
|
var service = DependencyManager.Instance.Resolve<FormImplementers>();
|
||||||
if (service is FormImplementers form) {
|
if (service is FormImplementers form) {
|
||||||
form.ShowDialog();
|
form.ShowDialog();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void toolStripMenuItemStartOfWork_Click(object sender, EventArgs e) {
|
private void toolStripMenuItemStartOfWork_Click(object sender, EventArgs e) {
|
||||||
_workProcess.Work((Program.ServiceProvider?.GetService(typeof(IImplementerLogic)) as IImplementerLogic)!, _orderLogic);
|
_workProcess.Work((DependencyManager.Instance.Resolve<IImplementerLogic>() as IImplementerLogic)!, _orderLogic);
|
||||||
MessageBox.Show("Процесс обработки запущен", "Сообщение",
|
MessageBox.Show("Процесс обработки запущен", "Сообщение",
|
||||||
MessageBoxButtons.OK, MessageBoxIcon.Information);
|
MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void toolStripMenuItemMail_Click(object sender, EventArgs e) {
|
private void toolStripMenuItemMail_Click(object sender, EventArgs e) {
|
||||||
var service = Program.ServiceProvider?.GetService(typeof(FormMail));
|
var service = DependencyManager.Instance.Resolve<FormMail>();
|
||||||
if (service is FormMail form) {
|
if (service is FormMail form) {
|
||||||
form.ShowDialog();
|
form.ShowDialog();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void toolStripMenuCreateBackUp_Click(object sender, EventArgs e) {
|
||||||
|
try {
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
using DinerContracts.BindingModels;
|
using DinerContracts.BindingModels;
|
||||||
using DinerContracts.BusinessLogicsContacts;
|
using DinerContracts.BusinessLogicsContacts;
|
||||||
|
using DinerContracts.DI;
|
||||||
using DinerContracts.SearchModels;
|
using DinerContracts.SearchModels;
|
||||||
using DinerDataModels.Models;
|
using DinerDataModels.Models;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
@ -87,7 +88,7 @@ namespace DinerView
|
|||||||
|
|
||||||
private void buttonAdd_Click(object sender, EventArgs e)
|
private void buttonAdd_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
var service = Program.ServiceProvider?.GetService(typeof(FormSnackFood));
|
var service = DependencyManager.Instance.Resolve<FormSnackFood>();
|
||||||
if (service is FormSnackFood form)
|
if (service is FormSnackFood form)
|
||||||
{
|
{
|
||||||
if (form.ShowDialog() == DialogResult.OK)
|
if (form.ShowDialog() == DialogResult.OK)
|
||||||
@ -111,7 +112,7 @@ namespace DinerView
|
|||||||
{
|
{
|
||||||
if (dataGridView.SelectedRows.Count == 1)
|
if (dataGridView.SelectedRows.Count == 1)
|
||||||
{
|
{
|
||||||
var service = Program.ServiceProvider?.GetService(typeof(FormSnackFood));
|
var service = DependencyManager.Instance.Resolve<FormSnackFood>();
|
||||||
if (service is FormSnackFood form)
|
if (service is FormSnackFood form)
|
||||||
{
|
{
|
||||||
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells[0].Value);
|
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells[0].Value);
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
using DinerContracts.BindingModels;
|
using DinerContracts.BindingModels;
|
||||||
using DinerContracts.BusinessLogicsContacts;
|
using DinerContracts.BusinessLogicsContacts;
|
||||||
|
using DinerContracts.DI;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
@ -27,14 +28,7 @@ namespace DinerView
|
|||||||
{
|
{
|
||||||
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["ProductComponents"].Visible = false;
|
|
||||||
dataGridView.Columns["ProductName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
|
||||||
}
|
|
||||||
_logger.LogInformation("Загрузка снэков");
|
_logger.LogInformation("Загрузка снэков");
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
@ -46,7 +40,7 @@ namespace DinerView
|
|||||||
|
|
||||||
private void buttonAdd_Click(object sender, EventArgs e)
|
private void buttonAdd_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
var service = Program.ServiceProvider?.GetService(typeof(FormSnack));
|
var service = DependencyManager.Instance.Resolve<FormSnack>();
|
||||||
if (service is FormSnack form) {
|
if (service is FormSnack form) {
|
||||||
if (form.ShowDialog() == DialogResult.OK) LoadData();
|
if (form.ShowDialog() == DialogResult.OK) LoadData();
|
||||||
}
|
}
|
||||||
@ -81,7 +75,7 @@ namespace DinerView
|
|||||||
{
|
{
|
||||||
if (dataGridView.SelectedRows.Count == 1)
|
if (dataGridView.SelectedRows.Count == 1)
|
||||||
{
|
{
|
||||||
var service = Program.ServiceProvider?.GetService(typeof(FormSnack));
|
var service = DependencyManager.Instance.Resolve<FormSnack>();
|
||||||
if (service is FormSnack form)
|
if (service is FormSnack form)
|
||||||
{
|
{
|
||||||
form.ID = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["ID"].Value);
|
form.ID = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["ID"].Value);
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
using DinerContracts.BindingModels;
|
using DinerContracts.BindingModels;
|
||||||
using DinerContracts.BusinessLogicsContacts;
|
using DinerContracts.BusinessLogicsContacts;
|
||||||
using DinerContracts.BusinessLogicsContracts;
|
using DinerContracts.BusinessLogicsContracts;
|
||||||
using DinerContracts.SearchModels;
|
using DinerContracts.DI;
|
||||||
using DinerContracts.StoragesContracts;
|
using DinerContracts.StoragesContracts;
|
||||||
using DinerDataBaseImplement.Implements;
|
using DinerDataBaseImplement.Implements;
|
||||||
using DineryBusinessLogic.BusinessLogic;
|
using DineryBusinessLogic.BusinessLogic;
|
||||||
@ -16,8 +16,7 @@ namespace DinerView
|
|||||||
{
|
{
|
||||||
internal static class Program
|
internal static class Program
|
||||||
{
|
{
|
||||||
private static ServiceProvider? _serviceProvider;
|
|
||||||
public static ServiceProvider? ServiceProvider => _serviceProvider;
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The main entry point for the application.
|
/// The main entry point for the application.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -27,12 +26,10 @@ namespace DinerView
|
|||||||
// To customize application configuration such as set high DPI settings or default font,
|
// To customize application configuration such as set high DPI settings or default font,
|
||||||
// see https://aka.ms/applicationconfiguration.
|
// see https://aka.ms/applicationconfiguration.
|
||||||
ApplicationConfiguration.Initialize();
|
ApplicationConfiguration.Initialize();
|
||||||
var services = new ServiceCollection();
|
InitDependency();
|
||||||
ConfigureServices(services);
|
|
||||||
_serviceProvider = services.BuildServiceProvider();
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
var mailSender = _serviceProvider.GetService<AbstractMailWorker>();
|
var mailSender = DependencyManager.Instance.Resolve<AbstractMailWorker>();
|
||||||
mailSender?.MailConfig(new MailConfigBindingModel {
|
mailSender?.MailConfig(new MailConfigBindingModel {
|
||||||
MailLogin = System.Configuration.ConfigurationManager.AppSettings["MailLogin"] ?? string.Empty,
|
MailLogin = System.Configuration.ConfigurationManager.AppSettings["MailLogin"] ?? string.Empty,
|
||||||
MailPassword = System.Configuration.ConfigurationManager.AppSettings["MailPassword"] ?? string.Empty,
|
MailPassword = System.Configuration.ConfigurationManager.AppSettings["MailPassword"] ?? string.Empty,
|
||||||
@ -46,58 +43,55 @@ namespace DinerView
|
|||||||
var timer = new System.Threading.Timer(new TimerCallback(MailCheck!), null, 0, 100000);
|
var timer = new System.Threading.Timer(new TimerCallback(MailCheck!), null, 0, 100000);
|
||||||
}
|
}
|
||||||
catch (Exception ex) {
|
catch (Exception ex) {
|
||||||
var logger = _serviceProvider.GetService<ILogger>();
|
var logger = DependencyManager.Instance.Resolve<ILogger>();
|
||||||
logger?.LogError(ex, "Îøèþêà ðàáîòû ñ ïî÷òîé");
|
logger?.LogError(ex, "Îøèþêà ðàáîòû ñ ïî÷òîé");
|
||||||
}
|
}
|
||||||
|
|
||||||
Application.Run(_serviceProvider.GetRequiredService<FormMain>());
|
Application.Run(DependencyManager.Instance.Resolve<FormMain>());
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void ConfigureServices(ServiceCollection services)
|
private static void InitDependency()
|
||||||
{
|
{
|
||||||
services.AddLogging(option =>
|
DependencyManager.InitDependency();
|
||||||
|
|
||||||
|
DependencyManager.Instance.AddLogging(option =>
|
||||||
{
|
{
|
||||||
option.SetMinimumLevel(LogLevel.Information);
|
option.SetMinimumLevel(LogLevel.Information);
|
||||||
option.AddNLog("nlog.config");
|
option.AddNLog("nlog.config");
|
||||||
});
|
});
|
||||||
services.AddTransient<IFoodStorage, FoodStorage>();
|
|
||||||
services.AddTransient<IOrderStorage, OrderStorage>();
|
|
||||||
services.AddTransient<IImplementerStorage, ImplementerStorage>();
|
|
||||||
services.AddTransient<ISnackStorage, SnackStorage>();
|
|
||||||
services.AddTransient<IClientStorage, ClientStorage>();
|
|
||||||
services.AddTransient<IMessageInfoStorage, MessageInfoStorage>();
|
|
||||||
|
|
||||||
services.AddTransient<IClientLogic, ClientLogic>();
|
DependencyManager.Instance.RegisterType<IClientLogic, ClientLogic>();
|
||||||
services.AddTransient<IFoodLogic, FoodLogic>();
|
DependencyManager.Instance.RegisterType<IFoodLogic, FoodLogic>();
|
||||||
services.AddTransient<IOrderLogic, OrderLogic>();
|
DependencyManager.Instance.RegisterType<IOrderLogic, OrderLogic>();
|
||||||
services.AddTransient<IImplementerLogic, ImplementerLogic>();
|
DependencyManager.Instance.RegisterType<IImplementerLogic, ImplementerLogic>();
|
||||||
services.AddTransient<ISnackLogic, SnackLogic>();
|
DependencyManager.Instance.RegisterType<ISnackLogic, SnackLogic>();
|
||||||
services.AddTransient<IReportLogic, ReportLogic>();
|
DependencyManager.Instance.RegisterType<IReportLogic, ReportLogic>();
|
||||||
services.AddTransient<IWorkProcess, WorkModelling>();
|
DependencyManager.Instance.RegisterType<IWorkProcess, WorkModelling>();
|
||||||
services.AddTransient<IMessageInfoLogic, MessageInfoLogic>();
|
DependencyManager.Instance.RegisterType<IMessageInfoLogic, MessageInfoLogic>();
|
||||||
|
DependencyManager.Instance.RegisterType<IBackUpLogic, BackUpLogic>();
|
||||||
|
|
||||||
services.AddSingleton<AbstractMailWorker, MailKitWorker>();
|
DependencyManager.Instance.RegisterType<AbstractMailWorker, MailKitWorker>();
|
||||||
|
|
||||||
services.AddTransient<AbstractSaveToExcel, SaveToExcel>();
|
DependencyManager.Instance.RegisterType<AbstractSaveToExcel, SaveToExcel>();
|
||||||
services.AddTransient<AbstractSaveToWord, SaveToWord>();
|
DependencyManager.Instance.RegisterType<AbstractSaveToWord, SaveToWord>();
|
||||||
services.AddTransient<AbstractSaveToPdf, SaveToPdf>();
|
DependencyManager.Instance.RegisterType<AbstractSaveToPdf, SaveToPdf>();
|
||||||
|
|
||||||
services.AddTransient<FormMain>();
|
DependencyManager.Instance.RegisterType<FormMain>();
|
||||||
services.AddTransient<FormFood>();
|
DependencyManager.Instance.RegisterType<FormFood>();
|
||||||
services.AddTransient<FormFoods>();
|
DependencyManager.Instance.RegisterType<FormFoods>();
|
||||||
services.AddTransient<FormCreateOrder>();
|
DependencyManager.Instance.RegisterType<FormCreateOrder>();
|
||||||
services.AddTransient<FormSnack>();
|
DependencyManager.Instance.RegisterType<FormSnack>();
|
||||||
services.AddTransient<FormSnackFood>();
|
DependencyManager.Instance.RegisterType<FormSnackFood>();
|
||||||
services.AddTransient<FormSnacks>();
|
DependencyManager.Instance.RegisterType<FormSnacks>();
|
||||||
services.AddTransient<FormReportSnackFoods>();
|
DependencyManager.Instance.RegisterType<FormReportSnackFoods>();
|
||||||
services.AddTransient<FormReportOrders>();
|
DependencyManager.Instance.RegisterType<FormReportOrders>();
|
||||||
services.AddTransient<FormClient>();
|
DependencyManager.Instance.RegisterType<FormClient>();
|
||||||
services.AddTransient<FormImplementers>();
|
DependencyManager.Instance.RegisterType<FormImplementers>();
|
||||||
services.AddTransient<FormImplementer>();
|
DependencyManager.Instance.RegisterType<FormImplementer>();
|
||||||
services.AddTransient<FormMail>();
|
DependencyManager.Instance.RegisterType<FormMail>();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void MailCheck(object obj) => ServiceProvider?.GetService<AbstractMailWorker>()?.MailCheck();
|
private static void MailCheck(object obj) => DependencyManager.Instance.Resolve<AbstractMailWorker>()?.MailCheck();
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
91
Diner/DineryBusinessLogic/BusinessLogic/BackUpLogic.cs
Normal file
91
Diner/DineryBusinessLogic/BusinessLogic/BackUpLogic.cs
Normal file
@ -0,0 +1,91 @@
|
|||||||
|
using DinerContracts.BindingModels;
|
||||||
|
using DinerContracts.BusinessLogicsContracts;
|
||||||
|
using DinerContracts.StoragesContracts;
|
||||||
|
using DinerDataModels;
|
||||||
|
using DocumentFormat.OpenXml.Wordprocessing;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO.Compression;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Net.WebSockets;
|
||||||
|
using System.Reflection;
|
||||||
|
using System.Runtime.Serialization;
|
||||||
|
using System.Runtime.Serialization.Json;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace DineryBusinessLogic.BusinessLogic {
|
||||||
|
public class BackUpLogic : IBackUpLogic {
|
||||||
|
|
||||||
|
private readonly ILogger _logger;
|
||||||
|
|
||||||
|
private readonly IBackUpInfo _backUpInfo;
|
||||||
|
|
||||||
|
public BackUpLogic(ILogger<BackUpLogic> logger, IBackUpInfo backUpInfo) {
|
||||||
|
_logger = logger;
|
||||||
|
_backUpInfo = backUpInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void CreateBackUp(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 {types.Length} types");
|
||||||
|
foreach (var type in types) {
|
||||||
|
if (type.IsInterface && type.GetInterface(typeIID.Name) != null) {
|
||||||
|
var modelType = _backUpInfo.GetTypeModelInterface(type.Name);
|
||||||
|
if (modelType == null) {
|
||||||
|
throw new InvalidOperationException($"Не найден класс-модель для {type.Name}");
|
||||||
|
}
|
||||||
|
_logger.LogDebug($"Call SaveToFile method for {type.Name} type");
|
||||||
|
// вызываем метод на выполнение
|
||||||
|
method?.MakeGenericMethod(modelType).Invoke(this, new object[] { model.FolderName });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_logger.LogDebug("Create zip and remove folder");
|
||||||
|
// архивируем
|
||||||
|
ZipFile.CreateFromDirectory(model.FolderName, fileName);
|
||||||
|
// удаляем папку
|
||||||
|
dirInfo.Delete(true);
|
||||||
|
}
|
||||||
|
catch (Exception) {
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void SaveToFile<T>(string folderName) where T : class, new() {
|
||||||
|
var records = _backUpInfo.GetList<T>();
|
||||||
|
if (records == null) {
|
||||||
|
_logger.LogWarning($"{typeof(T).Name} type get null list");
|
||||||
|
}
|
||||||
|
var jsonFormatter = new DataContractJsonSerializer(typeof(List<T>));
|
||||||
|
|
||||||
|
using var fs = new FileStream(string.Format("{0}/{1}.json", folderName, typeof(T).Name), FileMode.OpenOrCreate);
|
||||||
|
jsonFormatter.WriteObject(fs, records);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,6 +1,7 @@
|
|||||||
using DinerContracts.BindingModels;
|
using DinerContracts.BindingModels;
|
||||||
using DinerContracts.BusinessLogicsContracts;
|
using DinerContracts.BusinessLogicsContracts;
|
||||||
using DinerContracts.SearchModels;
|
using DinerContracts.SearchModels;
|
||||||
|
using DinerContracts.StoragesContracts;
|
||||||
using DinerContracts.ViewModels;
|
using DinerContracts.ViewModels;
|
||||||
using DocumentFormat.OpenXml.Packaging;
|
using DocumentFormat.OpenXml.Packaging;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
@ -12,8 +13,9 @@ using System.Reflection.Metadata.Ecma335;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace DineryBusinessLogic.BusinessLogic {
|
namespace DineryBusinessLogic.BusinessLogic
|
||||||
public class MessageInfoLogic : IMessageInfoLogic {
|
{
|
||||||
|
public class MessageInfoLogic : IMessageInfoLogic {
|
||||||
|
|
||||||
private readonly ILogger _logger;
|
private readonly ILogger _logger;
|
||||||
private readonly IMessageInfoStorage _storage;
|
private readonly IMessageInfoStorage _storage;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user