не работает удаление бд
This commit is contained in:
parent
a7f5e9f99f
commit
46dc0fbc6d
2
.gitignore
vendored
2
.gitignore
vendored
@ -13,6 +13,8 @@
|
|||||||
|
|
||||||
# User-specific files (MonoDevelop/Xamarin Studio)
|
# User-specific files (MonoDevelop/Xamarin Studio)
|
||||||
*.userprefs
|
*.userprefs
|
||||||
|
ImplementationExtensions
|
||||||
|
BusinessLogicExtensions
|
||||||
|
|
||||||
# Mono auto generated files
|
# Mono auto generated files
|
||||||
mono_crash.*
|
mono_crash.*
|
||||||
|
@ -0,0 +1,98 @@
|
|||||||
|
using FishFactoryContracts.BindingModels;
|
||||||
|
using FishFactoryContracts.BusinessLogicsContracts;
|
||||||
|
using FishFactoryContracts.StoragesContracts;
|
||||||
|
using FishFactoryDataModels;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO.Compression;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Reflection;
|
||||||
|
using System.Runtime.Serialization.Json;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace FishFactoryBusinessLogic.BusinessLogics
|
||||||
|
{
|
||||||
|
public class BackUpLogic : IBackUpLogic
|
||||||
|
{
|
||||||
|
private readonly ILogger _logger;
|
||||||
|
|
||||||
|
private readonly IBackUpInfo _backUpInfo;
|
||||||
|
|
||||||
|
public BackUpLogic(ILogger<BackUpLogic> logger, IBackUpInfo backUpInfo)
|
||||||
|
{
|
||||||
|
_logger = logger;
|
||||||
|
_backUpInfo = backUpInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void CreateBackUp(BackUpSaveBindingModel model)
|
||||||
|
{
|
||||||
|
if (_backUpInfo == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_logger.LogDebug("Clear folder");
|
||||||
|
var dirInfo = new DirectoryInfo(model.FolderName);
|
||||||
|
if (dirInfo.Exists)
|
||||||
|
{
|
||||||
|
foreach (var file in dirInfo.GetFiles())
|
||||||
|
{
|
||||||
|
file.Delete();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_logger.LogDebug("Delete archive");
|
||||||
|
string fileName = $"{model.FolderName}.zip";
|
||||||
|
if (File.Exists(fileName))
|
||||||
|
{
|
||||||
|
File.Delete(fileName);
|
||||||
|
}
|
||||||
|
_logger.LogDebug("Get assembly");
|
||||||
|
var typeIId = typeof(IId);
|
||||||
|
var assembly = typeIId.Assembly;
|
||||||
|
if (assembly == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException("Сборка не найдена", nameof(assembly));
|
||||||
|
}
|
||||||
|
var types = assembly.GetTypes();
|
||||||
|
var method = GetType().GetMethod("SaveToFile", BindingFlags.NonPublic | BindingFlags.Instance);
|
||||||
|
_logger.LogDebug("Find {count} types", types.Length);
|
||||||
|
foreach (var type in types)
|
||||||
|
{
|
||||||
|
if (type.IsInterface && type.GetInterface(typeIId.Name) != null)
|
||||||
|
{
|
||||||
|
var modelType = _backUpInfo.GetTypeByModelInterface(type.Name);
|
||||||
|
if (modelType == null)
|
||||||
|
{
|
||||||
|
throw new InvalidOperationException($"Не найден класс-модель для {type.Name}");
|
||||||
|
}
|
||||||
|
_logger.LogDebug("Call SaveToFile method for {name} type", type.Name);
|
||||||
|
method?.MakeGenericMethod(modelType).Invoke(this, new object[] { model.FolderName });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_logger.LogDebug("Create zip and remove folder");
|
||||||
|
ZipFile.CreateFromDirectory(model.FolderName, fileName);
|
||||||
|
dirInfo.Delete(true);
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void SaveToFile<T>(string folderName) where T : class, new()
|
||||||
|
{
|
||||||
|
var records = _backUpInfo.GetList<T>();
|
||||||
|
if (records == null)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("{type} type get null list", typeof(T).Name);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var jsonFormatter = new DataContractJsonSerializer(typeof(List<T>));
|
||||||
|
using var fs = new FileStream(string.Format("{0}/{1}.json", folderName, typeof(T).Name), FileMode.OpenOrCreate);
|
||||||
|
jsonFormatter.WriteObject(fs, records);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,31 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace FishFactoryContracts.Attributes
|
||||||
|
{
|
||||||
|
[AttributeUsage(AttributeTargets.Property)]
|
||||||
|
public class ColumnAttribute : Attribute
|
||||||
|
{
|
||||||
|
public string Title { get; private set; }
|
||||||
|
|
||||||
|
public bool Visible { get; private set; }
|
||||||
|
|
||||||
|
public int Width { get; private set; }
|
||||||
|
|
||||||
|
public GridViewAutoSize GridViewAutoSize { get; private set; }
|
||||||
|
|
||||||
|
public bool IsUseAutoSize { get; private set; }
|
||||||
|
|
||||||
|
public ColumnAttribute(string title = "", bool visible = true, int width = 0, GridViewAutoSize gridViewAutoSize = GridViewAutoSize.None, bool isUseAutoSize = false)
|
||||||
|
{
|
||||||
|
Title = title;
|
||||||
|
Visible = visible;
|
||||||
|
Width = width;
|
||||||
|
GridViewAutoSize = gridViewAutoSize;
|
||||||
|
IsUseAutoSize = isUseAutoSize;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,20 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace FishFactoryContracts.Attributes
|
||||||
|
{
|
||||||
|
public enum GridViewAutoSize
|
||||||
|
{
|
||||||
|
NotSet = 0,
|
||||||
|
None = 1,
|
||||||
|
ColumnHeader = 2,
|
||||||
|
AllCellsExceptHeader = 4,
|
||||||
|
AllCells = 6,
|
||||||
|
DisplayedCellsExceptHeader = 8,
|
||||||
|
DisplayedCells = 10,
|
||||||
|
Fill = 16
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,13 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace FishFactoryContracts.BindingModels
|
||||||
|
{
|
||||||
|
public class BackUpSaveBindingModel
|
||||||
|
{
|
||||||
|
public string FolderName { get; set; } = string.Empty;
|
||||||
|
}
|
||||||
|
}
|
@ -15,5 +15,7 @@ namespace FishFactoryContracts.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 DateTime DateDelivery { get; set; }
|
public DateTime DateDelivery { get; set; }
|
||||||
}
|
|
||||||
|
public int Id => throw new NotImplementedException();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,14 @@
|
|||||||
|
using FishFactoryContracts.BindingModels;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace FishFactoryContracts.BusinessLogicsContracts
|
||||||
|
{
|
||||||
|
public interface IBackUpLogic
|
||||||
|
{
|
||||||
|
void CreateBackUp(BackUpSaveBindingModel model);
|
||||||
|
}
|
||||||
|
}
|
38
FishFactory/FishFactoryContracts/DI/DependencyManager.cs
Normal file
38
FishFactory/FishFactoryContracts/DI/DependencyManager.cs
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace FishFactoryContracts.DI
|
||||||
|
{
|
||||||
|
public class DependencyManager
|
||||||
|
{
|
||||||
|
private readonly IDependencyContainer _dependencyManager;
|
||||||
|
|
||||||
|
private static DependencyManager? _manager;
|
||||||
|
|
||||||
|
private static readonly object _locjObject = new();
|
||||||
|
|
||||||
|
private DependencyManager()
|
||||||
|
{
|
||||||
|
_dependencyManager = new ServiceDependencyContainer();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static DependencyManager Instance { get { if (_manager == null) { lock (_locjObject) { _manager = new DependencyManager(); } } return _manager; } }
|
||||||
|
public static void InitDependency()
|
||||||
|
{
|
||||||
|
var ext = ServiceProviderLoader.GetImplementationExtensions();
|
||||||
|
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>();
|
||||||
|
}
|
||||||
|
}
|
17
FishFactory/FishFactoryContracts/DI/IDependencyContainer.cs
Normal file
17
FishFactory/FishFactoryContracts/DI/IDependencyContainer.cs
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace FishFactoryContracts.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>();
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,14 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace FishFactoryContracts.DI
|
||||||
|
{
|
||||||
|
public interface IImplementationExtension
|
||||||
|
{
|
||||||
|
public int Priority { get; }
|
||||||
|
public void RegisterServices();
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,51 @@
|
|||||||
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
|
||||||
|
namespace FishFactoryContracts.DI
|
||||||
|
{
|
||||||
|
public class ServiceDependencyContainer : IDependencyContainer
|
||||||
|
{
|
||||||
|
private ServiceProvider? _serviceProvider;
|
||||||
|
private readonly ServiceCollection _serviceCollection;
|
||||||
|
public ServiceDependencyContainer()
|
||||||
|
{
|
||||||
|
_serviceCollection = new ServiceCollection();
|
||||||
|
}
|
||||||
|
public void AddLogging(Action<ILoggingBuilder> configure)
|
||||||
|
{
|
||||||
|
_serviceCollection.AddLogging(configure);
|
||||||
|
}
|
||||||
|
public void RegisterType<T, U>(bool isSingle) where U : class, T where T : class
|
||||||
|
{
|
||||||
|
if (isSingle)
|
||||||
|
{
|
||||||
|
_serviceCollection.AddSingleton<T, U>();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_serviceCollection.AddTransient<T, U>();
|
||||||
|
}
|
||||||
|
_serviceProvider = null;
|
||||||
|
}
|
||||||
|
public void RegisterType<T>(bool isSingle) where T : class
|
||||||
|
{
|
||||||
|
if (isSingle)
|
||||||
|
{
|
||||||
|
_serviceCollection.AddSingleton<T>();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_serviceCollection.AddTransient<T>();
|
||||||
|
}
|
||||||
|
_serviceProvider = null;
|
||||||
|
}
|
||||||
|
public T Resolve<T>()
|
||||||
|
{
|
||||||
|
if (_serviceProvider == null)
|
||||||
|
{
|
||||||
|
_serviceProvider = _serviceCollection.BuildServiceProvider();
|
||||||
|
}
|
||||||
|
return _serviceProvider.GetService<T>()!;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
53
FishFactory/FishFactoryContracts/DI/ServiceProviderLoader.cs
Normal file
53
FishFactory/FishFactoryContracts/DI/ServiceProviderLoader.cs
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Reflection;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace FishFactoryContracts.DI
|
||||||
|
{
|
||||||
|
public class ServiceProviderLoader
|
||||||
|
{
|
||||||
|
public static IImplementationExtension? GetImplementationExtensions()
|
||||||
|
{
|
||||||
|
IImplementationExtension? source = null;
|
||||||
|
var files = Directory.GetFiles(TryGetImplementationExtensionsFolder(), "*.dll", SearchOption.AllDirectories);
|
||||||
|
foreach (var file in files.Distinct())
|
||||||
|
{
|
||||||
|
Assembly asm = Assembly.LoadFrom(file);
|
||||||
|
foreach (var t in asm.GetExportedTypes())
|
||||||
|
{
|
||||||
|
if (t.IsClass &&
|
||||||
|
typeof(IImplementationExtension).IsAssignableFrom(t))
|
||||||
|
{
|
||||||
|
if (source == null)
|
||||||
|
{
|
||||||
|
source =
|
||||||
|
(IImplementationExtension)Activator.CreateInstance(t)!;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var newSource = (IImplementationExtension)Activator.CreateInstance(t)!;
|
||||||
|
if (newSource.Priority > source.Priority)
|
||||||
|
{
|
||||||
|
source = newSource;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return source;
|
||||||
|
}
|
||||||
|
private static string TryGetImplementationExtensionsFolder()
|
||||||
|
{
|
||||||
|
var directory = new
|
||||||
|
DirectoryInfo(Directory.GetCurrentDirectory());
|
||||||
|
while (directory != null && !directory.GetDirectories("ImplementationExtensions", SearchOption.AllDirectories).Any(x => x.Name == "ImplementationExtensions"))
|
||||||
|
{
|
||||||
|
directory = directory.Parent;
|
||||||
|
}
|
||||||
|
return $"{directory?.FullName}\\ImplementationExtensions";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,55 @@
|
|||||||
|
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 FishFactoryContracts.DI
|
||||||
|
{
|
||||||
|
public class UnityDependencyContainer : IDependencyContainer
|
||||||
|
{
|
||||||
|
private readonly UnityContainer _container;
|
||||||
|
|
||||||
|
public UnityDependencyContainer()
|
||||||
|
{
|
||||||
|
_container = new UnityContainer();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void AddLogging(Action<ILoggingBuilder> configure)
|
||||||
|
{
|
||||||
|
_container.AddExtension(new LoggingExtension(LoggerFactory.Create(configure)));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void RegisterType<T, U>(bool isSingle) where U : class, T where T : class
|
||||||
|
{
|
||||||
|
if (isSingle)
|
||||||
|
{
|
||||||
|
_container.RegisterSingleton<T, U>();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_container.RegisterType<T, U>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void RegisterType<T>(bool isSingle) where T : class
|
||||||
|
{
|
||||||
|
if (isSingle)
|
||||||
|
{
|
||||||
|
_container.RegisterSingleton<T>();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_container.RegisterType<T>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public T Resolve<T>()
|
||||||
|
{
|
||||||
|
return _container.Resolve<T>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -6,6 +6,14 @@
|
|||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="7.0.0" />
|
||||||
|
<PackageReference Include="Microsoft.Extensions.Logging" Version="7.0.0" />
|
||||||
|
<PackageReference Include="NLog.Extensions.Logging" Version="5.3.8" />
|
||||||
|
<PackageReference Include="Unity" Version="5.11.10" />
|
||||||
|
<PackageReference Include="Unity.Microsoft.Logging" Version="5.11.1" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\FishFactoryDataModels\FishFactoryDataModels.csproj" />
|
<ProjectReference Include="..\FishFactoryDataModels\FishFactoryDataModels.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
@ -0,0 +1,14 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace FishFactoryContracts.StoragesContracts
|
||||||
|
{
|
||||||
|
public interface IBackUpInfo
|
||||||
|
{
|
||||||
|
List<T>? GetList<T>() where T : class, new();
|
||||||
|
Type? GetTypeByModelInterface(string modelInterfaceName);
|
||||||
|
}
|
||||||
|
}
|
@ -1,4 +1,5 @@
|
|||||||
using FishFactoryDataModels.Models;
|
using FishFactoryContracts.Attributes;
|
||||||
|
using FishFactoryDataModels.Models;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
@ -10,11 +11,13 @@ namespace FishFactoryContracts.ViewModels
|
|||||||
{
|
{
|
||||||
public class CannedViewModel : ICannedModel
|
public class CannedViewModel : ICannedModel
|
||||||
{
|
{
|
||||||
public int Id { get; set; }
|
[Column(visible: false)]
|
||||||
[DisplayName("Название изделия")]
|
public int Id { get; set; }
|
||||||
public string CannedName { get; set; } = string.Empty;
|
[Column(title: "Консерва", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)]
|
||||||
[DisplayName("Цена")]
|
public string CannedName { get; set; } = string.Empty;
|
||||||
public double Price { get; set; }
|
[Column(title: "Цена", width: 150)]
|
||||||
public Dictionary<int, (IComponentModel, int)> CannedComponents { get; set; } = new();
|
public double Price { get; set; }
|
||||||
|
[Column(visible: false)]
|
||||||
|
public Dictionary<int, (IComponentModel, int)> CannedComponents { get; set; } = new();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
using FishFactoryDataModels.Models;
|
using FishFactoryContracts.Attributes;
|
||||||
|
using FishFactoryDataModels.Models;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
@ -10,12 +11,13 @@ namespace FishFactoryContracts.ViewModels
|
|||||||
{
|
{
|
||||||
public class ClientViewModel : IClientModel
|
public class ClientViewModel : IClientModel
|
||||||
{
|
{
|
||||||
public int Id { get; set; }
|
[Column(visible: false)]
|
||||||
[DisplayName("ФИО клиента")]
|
public int Id { get; set; }
|
||||||
public string ClientFIO { get; set; } = string.Empty;
|
[Column(title: "Клиент", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)]
|
||||||
[DisplayName("Логин (эл. почта)")]
|
public string ClientFIO { get; set; } = string.Empty;
|
||||||
public string Email { get; set; } = string.Empty;
|
[Column(title: "Логин (эл. почта)", width: 150)]
|
||||||
[DisplayName("Пароль")]
|
public string Email { get; set; } = string.Empty;
|
||||||
public string Password { get; set; } = string.Empty;
|
[Column(title: "Пароль", width: 150)]
|
||||||
|
public string Password { get; set; } = string.Empty;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
using FishFactoryDataModels.Models;
|
using FishFactoryContracts.Attributes;
|
||||||
|
using FishFactoryDataModels.Models;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
@ -10,10 +11,11 @@ namespace FishFactoryContracts.ViewModels
|
|||||||
{
|
{
|
||||||
public class ComponentViewModel : IComponentModel
|
public class ComponentViewModel : IComponentModel
|
||||||
{
|
{
|
||||||
public int Id { get; set; }
|
[Column(visible: false)]
|
||||||
[DisplayName("Название компонента")]
|
public int Id { get; set; }
|
||||||
public string ComponentName { get; set; } = string.Empty;
|
[Column(title: "Ингредиент", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)]
|
||||||
[DisplayName("Цена")]
|
public string ComponentName { get; set; } = string.Empty;
|
||||||
public double Cost { get; set; }
|
[Column(title: "Цена", width: 150)]
|
||||||
|
public double Cost { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
using FishFactoryDataModels.Models;
|
using FishFactoryContracts.Attributes;
|
||||||
|
using FishFactoryDataModels.Models;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
@ -10,14 +11,15 @@ namespace FishFactoryContracts.ViewModels
|
|||||||
{
|
{
|
||||||
public class ImplementerViewModel : IImplementerModel
|
public class ImplementerViewModel : IImplementerModel
|
||||||
{
|
{
|
||||||
|
[Column(visible: false)]
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
[DisplayName("ФИО исполнителя")]
|
[Column(title: "ФИО исполнителя", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)]
|
||||||
public string ImplementerFIO { get; set; } = string.Empty;
|
public string ImplementerFIO { get; set; } = string.Empty;
|
||||||
[DisplayName("Стаж работы")]
|
[Column(title: "Стаж работы", width: 50)]
|
||||||
public int WorkExperience { get; set; } = 0;
|
public int WorkExperience { get; set; } = 0;
|
||||||
[DisplayName("Квалификация")]
|
[Column(title: "Квалификация", width: 50)]
|
||||||
public int Qualification { get; set; } = 0;
|
public int Qualification { get; set; } = 0;
|
||||||
[DisplayName("Пароль")]
|
[Column(title: "Пароль", width: 100)]
|
||||||
public string Password { get; set; } = string.Empty;
|
public string Password { get; set; } = string.Empty;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
using FishFactoryDataModels.Models;
|
using FishFactoryContracts.Attributes;
|
||||||
|
using FishFactoryDataModels.Models;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
@ -10,15 +11,19 @@ namespace FishFactoryContracts.ViewModels
|
|||||||
{
|
{
|
||||||
public class MessageInfoViewModel : IMessageInfoModel
|
public class MessageInfoViewModel : IMessageInfoModel
|
||||||
{
|
{
|
||||||
public string MessageId { get; set; } = string.Empty;
|
[Column(visible: false)]
|
||||||
public int? ClientId { get; set; }
|
public string MessageId { get; set; } = string.Empty;
|
||||||
[DisplayName("Отправитель")]
|
[Column(visible: false)]
|
||||||
public string SenderName { get; set; } = string.Empty;
|
public int? ClientId { get; set; }
|
||||||
[DisplayName("Дата письма")]
|
[Column(title: "Отправитель", width: 150)]
|
||||||
public DateTime DateDelivery { get; set; }
|
public string SenderName { get; set; } = string.Empty;
|
||||||
[DisplayName("Заголовок")]
|
[Column(title: "Дата письма", width: 150)]
|
||||||
public string Subject { get; set; } = string.Empty;
|
public DateTime DateDelivery { get; set; }
|
||||||
[DisplayName("Текст")]
|
[Column(title: "Заголовок", width: 150)]
|
||||||
public string Body { get; set; } = string.Empty;
|
public string Subject { get; set; } = string.Empty;
|
||||||
}
|
[Column(title: "Текст", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)]
|
||||||
|
public string Body { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
public int Id => throw new NotImplementedException();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
using FishFactoryDataModels.Enums;
|
using FishFactoryContracts.Attributes;
|
||||||
|
using FishFactoryDataModels.Enums;
|
||||||
using FishFactoryDataModels.Models;
|
using FishFactoryDataModels.Models;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
@ -11,26 +12,29 @@ namespace FishFactoryContracts.ViewModels
|
|||||||
{
|
{
|
||||||
public class OrderViewModel : IOrderModel
|
public class OrderViewModel : IOrderModel
|
||||||
{
|
{
|
||||||
[DisplayName("Номер")]
|
[Column(title: "Номер", width: 50)]
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
public int ClientId { get; set; }
|
[Column(visible: false)]
|
||||||
public int? ImplementerId { get; set; }
|
public int ClientId { get; set; }
|
||||||
[DisplayName("ФИО клиента")]
|
[Column(visible: false)]
|
||||||
public string ClientFIO { get; set; } = string.Empty;
|
public int? ImplementerId { get; set; }
|
||||||
public int CannedId { get; set; }
|
[Column(title: "Клиент", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)]
|
||||||
[DisplayName("Консерва")]
|
public string ClientFIO { get; set; } = string.Empty;
|
||||||
public string CannedName { get; set; } = string.Empty;
|
[Column(visible: false)]
|
||||||
[DisplayName("Исполнитель")]
|
public int CannedId { get; set; }
|
||||||
|
[Column(title: "Консерва", width: 100)]
|
||||||
|
public string CannedName { get; set; } = string.Empty;
|
||||||
|
[Column(title: "Исполнитель", width: 130)]
|
||||||
public string ImplementerFIO { get; set; } = string.Empty;
|
public string ImplementerFIO { get; set; } = string.Empty;
|
||||||
[DisplayName("Количество")]
|
[Column(title: "Количество", width: 100)]
|
||||||
public int Count { get; set; }
|
public int Count { get; set; }
|
||||||
[DisplayName("Сумма")]
|
[Column(title: "Сумма", width: 50)]
|
||||||
public double Sum { get; set; }
|
public double Sum { get; set; }
|
||||||
[DisplayName("Статус")]
|
[Column(title: "Статус", width: 50)]
|
||||||
public OrderStatus Status { get; set; } = OrderStatus.Неизвестен;
|
public OrderStatus Status { get; set; } = OrderStatus.Неизвестен;
|
||||||
[DisplayName("Дата создания")]
|
[Column(title: "Дата создания", width: 100)]
|
||||||
public DateTime DateCreate { get; set; } = DateTime.Now;
|
public DateTime DateCreate { get; set; } = DateTime.Now;
|
||||||
[DisplayName("Дата выполнения")]
|
[Column(title: "Дата выполнения", width: 100)]
|
||||||
public DateTime? DateImplement { get; set; }
|
public DateTime? DateImplement { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,7 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace FishFactoryDataModels.Models
|
namespace FishFactoryDataModels.Models
|
||||||
{
|
{
|
||||||
public interface IMessageInfoModel
|
public interface IMessageInfoModel : IId
|
||||||
{
|
{
|
||||||
string MessageId { get; }
|
string MessageId { get; }
|
||||||
int? ClientId { get; }
|
int? ClientId { get; }
|
||||||
|
@ -0,0 +1,27 @@
|
|||||||
|
using FishFactoryContracts.DI;
|
||||||
|
using FishFactoryContracts.StoragesContracts;
|
||||||
|
using FishFactoryDatabaseImplement.Implements;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace FishFactoryDatabaseImplement
|
||||||
|
{
|
||||||
|
public class DatabaseImplementationExtension : IImplementationExtension
|
||||||
|
{
|
||||||
|
public int Priority => 2;
|
||||||
|
|
||||||
|
public void RegisterServices()
|
||||||
|
{
|
||||||
|
DependencyManager.Instance.RegisterType<IClientStorage, ClientStorage>();
|
||||||
|
DependencyManager.Instance.RegisterType<IComponentStorage, ComponentStorage>();
|
||||||
|
DependencyManager.Instance.RegisterType<IImplementerStorage, ImplementerStorage>();
|
||||||
|
DependencyManager.Instance.RegisterType<IMessageInfoStorage, MessageInfoStorage>();
|
||||||
|
DependencyManager.Instance.RegisterType<IOrderStorage, OrderStorage>();
|
||||||
|
DependencyManager.Instance.RegisterType<ICannedStorage, CannedStorage>();
|
||||||
|
DependencyManager.Instance.RegisterType<IBackUpInfo, BackUpInfo>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -20,4 +20,8 @@
|
|||||||
<ProjectReference Include="..\FishFactoryDataModels\FishFactoryDataModels.csproj" />
|
<ProjectReference Include="..\FishFactoryDataModels\FishFactoryDataModels.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
|
||||||
|
<Exec Command="copy /Y "$(TargetDir)*.dll" "$(SolutionDir)ImplementationExtensions\*.dll"" />
|
||||||
|
</Target>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
@ -0,0 +1,32 @@
|
|||||||
|
using FishFactoryContracts.StoragesContracts;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace FishFactoryDatabaseImplement.Implements
|
||||||
|
{
|
||||||
|
public class BackUpInfo : IBackUpInfo
|
||||||
|
{
|
||||||
|
public List<T>? GetList<T>() where T : class, new()
|
||||||
|
{
|
||||||
|
using var context = new FishFactoryDatabase();
|
||||||
|
return context.Set<T>().ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Type? GetTypeByModelInterface(string modelInterfaceName)
|
||||||
|
{
|
||||||
|
var assembly = typeof(BackUpInfo).Assembly;
|
||||||
|
var types = assembly.GetTypes();
|
||||||
|
foreach (var type in types)
|
||||||
|
{
|
||||||
|
if (type.IsClass && type.GetInterface(modelInterfaceName) != null)
|
||||||
|
{
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -8,19 +8,25 @@ using System.Text;
|
|||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using FishFactoryContracts.BindingModels;
|
using FishFactoryContracts.BindingModels;
|
||||||
using FishFactoryContracts.ViewModels;
|
using FishFactoryContracts.ViewModels;
|
||||||
|
using System.Runtime.Serialization;
|
||||||
|
|
||||||
namespace FishFactoryDatabaseImplement.Models
|
namespace FishFactoryDatabaseImplement.Models
|
||||||
{
|
{
|
||||||
public class Canned : ICannedModel
|
[DataContract]
|
||||||
|
public class Canned : ICannedModel
|
||||||
{
|
{
|
||||||
public int Id { get; set; }
|
[DataMember]
|
||||||
[Required]
|
public int Id { get; set; }
|
||||||
|
[DataMember]
|
||||||
|
[Required]
|
||||||
public string CannedName { get; set; } = string.Empty;
|
public string CannedName { get; set; } = string.Empty;
|
||||||
[Required]
|
[DataMember]
|
||||||
|
[Required]
|
||||||
public double Price { get; set; }
|
public double Price { get; set; }
|
||||||
private Dictionary<int, (IComponentModel, int)>? _cannedComponents =
|
private Dictionary<int, (IComponentModel, int)>? _cannedComponents =
|
||||||
null;
|
null;
|
||||||
[NotMapped]
|
[DataMember]
|
||||||
|
[NotMapped]
|
||||||
public Dictionary<int, (IComponentModel, int)> CannedComponents
|
public Dictionary<int, (IComponentModel, int)> CannedComponents
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
|
@ -8,20 +8,24 @@ using System.ComponentModel.DataAnnotations;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using System.Runtime.Serialization;
|
||||||
|
|
||||||
namespace FishFactoryDatabaseImplement.Models
|
namespace FishFactoryDatabaseImplement.Models
|
||||||
{
|
{
|
||||||
public class Client : IClientModel
|
[DataContract]
|
||||||
|
public class Client : IClientModel
|
||||||
{
|
{
|
||||||
public int Id { get; private set; }
|
[DataMember]
|
||||||
|
public int Id { get; private set; }
|
||||||
[Required]
|
[DataMember]
|
||||||
|
[Required]
|
||||||
public string ClientFIO { get; set; } = string.Empty;
|
public string ClientFIO { get; set; } = string.Empty;
|
||||||
[Required]
|
[DataMember]
|
||||||
|
[Required]
|
||||||
public string Email { get; set; } = string.Empty;
|
public string Email { get; set; } = string.Empty;
|
||||||
[Required]
|
[DataMember]
|
||||||
|
[Required]
|
||||||
public string Password { get; set; } = string.Empty;
|
public string Password { get; set; } = string.Empty;
|
||||||
|
|
||||||
[ForeignKey("ClientId")]
|
[ForeignKey("ClientId")]
|
||||||
public virtual List<Order> Orders { get; set; } = new();
|
public virtual List<Order> Orders { get; set; } = new();
|
||||||
[ForeignKey("ClientId")]
|
[ForeignKey("ClientId")]
|
||||||
|
@ -8,15 +8,20 @@ using System.Collections.Generic;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using System.Runtime.Serialization;
|
||||||
|
|
||||||
namespace FishFactoryDatabaseImplement.Models
|
namespace FishFactoryDatabaseImplement.Models
|
||||||
{
|
{
|
||||||
public class Component : IComponentModel
|
[DataContract]
|
||||||
|
public class Component : IComponentModel
|
||||||
{
|
{
|
||||||
public int Id { get; private set; }
|
[DataMember]
|
||||||
[Required]
|
public int Id { get; private set; }
|
||||||
|
[DataMember]
|
||||||
|
[Required]
|
||||||
public string ComponentName { get; private set; } = string.Empty;
|
public string ComponentName { get; private set; } = string.Empty;
|
||||||
[Required]
|
[DataMember]
|
||||||
|
[Required]
|
||||||
public double Cost { get; set; }
|
public double Cost { get; set; }
|
||||||
[ForeignKey("ComponentId")]
|
[ForeignKey("ComponentId")]
|
||||||
public virtual List<CannedComponent> CannedComponents { get; set; } =
|
public virtual List<CannedComponent> CannedComponents { get; set; } =
|
||||||
|
@ -8,18 +8,25 @@ using System.ComponentModel.DataAnnotations;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using System.Runtime.Serialization;
|
||||||
|
|
||||||
namespace FishFactoryDatabaseImplement.Models
|
namespace FishFactoryDatabaseImplement.Models
|
||||||
{
|
{
|
||||||
|
[DataContract]
|
||||||
public class Implementer : IImplementerModel
|
public class Implementer : IImplementerModel
|
||||||
{
|
{
|
||||||
|
[DataMember]
|
||||||
public int Id { get; private set; }
|
public int Id { get; private set; }
|
||||||
|
[DataMember]
|
||||||
[Required]
|
[Required]
|
||||||
public string ImplementerFIO { get; private set; } = string.Empty;
|
public string ImplementerFIO { get; private set; } = string.Empty;
|
||||||
|
[DataMember]
|
||||||
[Required]
|
[Required]
|
||||||
public string Password { get; set; } = string.Empty;
|
public string Password { get; set; } = string.Empty;
|
||||||
|
[DataMember]
|
||||||
[Required]
|
[Required]
|
||||||
public int Qualification { get; set; } = 0;
|
public int Qualification { get; set; } = 0;
|
||||||
|
[DataMember]
|
||||||
[Required]
|
[Required]
|
||||||
public int WorkExperience { get; set; } = 0;
|
public int WorkExperience { get; set; } = 0;
|
||||||
[ForeignKey("ImplementerId")]
|
[ForeignKey("ImplementerId")]
|
||||||
|
@ -5,19 +5,31 @@ using System;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Runtime.Serialization;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace FishFactoryDatabaseImplement.Models
|
namespace FishFactoryDatabaseImplement.Models
|
||||||
{
|
{
|
||||||
|
[DataContract]
|
||||||
public class MessageInfo : IMessageInfoModel
|
public class MessageInfo : IMessageInfoModel
|
||||||
{
|
{
|
||||||
|
[DataMember]
|
||||||
[Key]
|
[Key]
|
||||||
public string MessageId { get; private set; } = string.Empty;
|
public string MessageId { get; private set; } = string.Empty;
|
||||||
|
[DataMember]
|
||||||
public int? ClientId { get; private set; }
|
public int? ClientId { get; private set; }
|
||||||
|
[DataMember]
|
||||||
|
[Required]
|
||||||
public string SenderName { get; private set; } = string.Empty;
|
public string SenderName { get; private set; } = string.Empty;
|
||||||
|
[DataMember]
|
||||||
|
[Required]
|
||||||
public DateTime DateDelivery { get; private set; } = DateTime.Now;
|
public DateTime DateDelivery { get; private set; } = DateTime.Now;
|
||||||
|
[DataMember]
|
||||||
|
[Required]
|
||||||
public string Subject { get; private set; } = string.Empty;
|
public string Subject { get; private set; } = string.Empty;
|
||||||
|
[DataMember]
|
||||||
|
[Required]
|
||||||
public string Body { get; private set; } = string.Empty;
|
public string Body { get; private set; } = string.Empty;
|
||||||
public virtual Client? Client { get; private set; }
|
public virtual Client? Client { get; private set; }
|
||||||
public static MessageInfo? Create(MessageInfoBindingModel model)
|
public static MessageInfo? Create(MessageInfoBindingModel model)
|
||||||
@ -46,5 +58,6 @@ namespace FishFactoryDatabaseImplement.Models
|
|||||||
DateDelivery = DateDelivery,
|
DateDelivery = DateDelivery,
|
||||||
Subject = Subject,
|
Subject = Subject,
|
||||||
};
|
};
|
||||||
|
public int Id => throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,27 +6,38 @@ using System;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Runtime.Serialization;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace FishFactoryDatabaseImplement.Models
|
namespace FishFactoryDatabaseImplement.Models
|
||||||
{
|
{
|
||||||
public class Order : IOrderModel
|
[DataContract]
|
||||||
|
public class Order : IOrderModel
|
||||||
{
|
{
|
||||||
public int Id { get; private set; }
|
[DataMember]
|
||||||
[Required]
|
public int Id { get; private set; }
|
||||||
|
[DataMember]
|
||||||
|
[Required]
|
||||||
public int ClientId { get; private set; }
|
public int ClientId { get; private set; }
|
||||||
|
[DataMember]
|
||||||
public int? ImplementerId { get; private set; }
|
public int? ImplementerId { get; private set; }
|
||||||
|
[DataMember]
|
||||||
[Required]
|
[Required]
|
||||||
public int Count { get; private set; }
|
public int Count { get; private set; }
|
||||||
[Required]
|
[DataMember]
|
||||||
|
[Required]
|
||||||
public double Sum { get; private set; }
|
public double Sum { get; private set; }
|
||||||
[Required]
|
[DataMember]
|
||||||
|
[Required]
|
||||||
public OrderStatus Status { get; private set; }
|
public OrderStatus Status { get; private set; }
|
||||||
[Required]
|
[DataMember]
|
||||||
|
[Required]
|
||||||
public DateTime DateCreate { get; private set; } = DateTime.Now;
|
public DateTime DateCreate { get; private set; } = DateTime.Now;
|
||||||
public DateTime? DateImplement { get; private set; }
|
[DataMember]
|
||||||
[Required]
|
public DateTime? DateImplement { get; private set; }
|
||||||
|
[DataMember]
|
||||||
|
[Required]
|
||||||
public int CannedId { get; private set; }
|
public int CannedId { get; private set; }
|
||||||
public virtual Canned Canned { get; set; }
|
public virtual Canned Canned { get; set; }
|
||||||
public virtual Client Client { get; set; }
|
public virtual Client Client { get; set; }
|
||||||
|
@ -0,0 +1,27 @@
|
|||||||
|
using FishFactoryContracts.DI;
|
||||||
|
using FishFactoryContracts.StoragesContracts;
|
||||||
|
using FishFactoryFileImplement.Implements;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace FishFactoryFileImplement
|
||||||
|
{
|
||||||
|
public class FileImplementationExtension : IImplementationExtension
|
||||||
|
{
|
||||||
|
public int Priority => 1;
|
||||||
|
|
||||||
|
public void RegisterServices()
|
||||||
|
{
|
||||||
|
DependencyManager.Instance.RegisterType<IClientStorage, ClientStorage>();
|
||||||
|
DependencyManager.Instance.RegisterType<IComponentStorage, ComponentStorage>();
|
||||||
|
DependencyManager.Instance.RegisterType<IImplementerStorage, ImplementerStorage>();
|
||||||
|
DependencyManager.Instance.RegisterType<IMessageInfoStorage, MessageInfoStorage>();
|
||||||
|
DependencyManager.Instance.RegisterType<IOrderStorage, OrderStorage>();
|
||||||
|
DependencyManager.Instance.RegisterType<ICannedStorage, CannedStorage>();
|
||||||
|
DependencyManager.Instance.RegisterType<IBackUpInfo, BackUpInfo>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -12,4 +12,8 @@
|
|||||||
<ProjectReference Include="..\FishFactoryListImplement\FishFactoryListImplement.csproj" />
|
<ProjectReference Include="..\FishFactoryListImplement\FishFactoryListImplement.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
|
||||||
|
<Exec Command="copy /Y "$(TargetDir)*.dll" "$(SolutionDir)ImplementationExtensions\*.dll"" />
|
||||||
|
</Target>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
@ -0,0 +1,34 @@
|
|||||||
|
using FishFactoryContracts.StoragesContracts;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace FishFactoryFileImplement.Implements
|
||||||
|
{
|
||||||
|
public class BackUpInfo : IBackUpInfo
|
||||||
|
{
|
||||||
|
public List<T>? GetList<T>() where T : class, new()
|
||||||
|
{
|
||||||
|
var source = DataFileSingleton.GetInstance();
|
||||||
|
return (List<T>?)source.GetType().GetProperties()
|
||||||
|
.FirstOrDefault(x => x.PropertyType.IsGenericType && x.PropertyType.GetGenericArguments()[0] == typeof(T))
|
||||||
|
?.GetValue(source);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Type? GetTypeByModelInterface(string modelInterfaceName)
|
||||||
|
{
|
||||||
|
var assembly = typeof(BackUpInfo).Assembly;
|
||||||
|
var types = assembly.GetTypes();
|
||||||
|
foreach (var type in types)
|
||||||
|
{
|
||||||
|
if (type.IsClass && type.GetInterface(modelInterfaceName) != null)
|
||||||
|
{
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -7,17 +7,23 @@ using System.Collections.Generic;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using System.Runtime.Serialization;
|
||||||
|
|
||||||
namespace FishFactoryFileImplement.Models
|
namespace FishFactoryFileImplement.Models
|
||||||
{
|
{
|
||||||
public class Canned : ICannedModel
|
[DataContract]
|
||||||
|
public class Canned : ICannedModel
|
||||||
{
|
{
|
||||||
public int Id { get; private set; }
|
[DataMember]
|
||||||
public string CannedName { get; private set; } = string.Empty;
|
public int Id { get; private set; }
|
||||||
public double Price { get; private set; }
|
[DataMember]
|
||||||
|
public string CannedName { get; private set; } = string.Empty;
|
||||||
|
[DataMember]
|
||||||
|
public double Price { get; private set; }
|
||||||
public Dictionary<int, int> Components { get; private set; } = new();
|
public Dictionary<int, int> Components { get; private set; } = new();
|
||||||
private Dictionary<int, (IComponentModel, int)>? _cannedComponents = null;
|
private Dictionary<int, (IComponentModel, int)>? _cannedComponents = null;
|
||||||
public Dictionary<int, (IComponentModel, int)> CannedComponents
|
[DataMember]
|
||||||
|
public Dictionary<int, (IComponentModel, int)> CannedComponents
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
|
@ -4,18 +4,24 @@ using FishFactoryDataModels.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 FishFactoryFileImplement.Models
|
namespace FishFactoryFileImplement.Models
|
||||||
{
|
{
|
||||||
public class Client : IClientModel
|
[DataContract]
|
||||||
|
public class Client : IClientModel
|
||||||
{
|
{
|
||||||
public int Id { get; set; }
|
[DataMember]
|
||||||
public string ClientFIO { get; set; } = string.Empty;
|
public int Id { get; set; }
|
||||||
public string Email { get; set; } = string.Empty;
|
[DataMember]
|
||||||
public string Password { get; set; } = string.Empty;
|
public string ClientFIO { get; set; } = string.Empty;
|
||||||
|
[DataMember]
|
||||||
|
public string Email { get; set; } = string.Empty;
|
||||||
|
[DataMember]
|
||||||
|
public string Password { get; set; } = string.Empty;
|
||||||
public static Client? Create(ClientBindingModel? model)
|
public static Client? Create(ClientBindingModel? model)
|
||||||
{
|
{
|
||||||
if (model == null)
|
if (model == null)
|
||||||
|
@ -7,14 +7,19 @@ using System.Collections.Generic;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using System.Runtime.Serialization;
|
||||||
|
|
||||||
namespace FishFactoryFileImplement.Models
|
namespace FishFactoryFileImplement.Models
|
||||||
{
|
{
|
||||||
public class Component : IComponentModel
|
[DataContract]
|
||||||
|
public class Component : IComponentModel
|
||||||
{
|
{
|
||||||
public int Id { get; private set; }
|
[DataMember]
|
||||||
public string ComponentName { get; private set; } = string.Empty;
|
public int Id { get; private set; }
|
||||||
public double Cost { get; private set; }
|
[DataMember]
|
||||||
|
public string ComponentName { get; private set; } = string.Empty;
|
||||||
|
[DataMember]
|
||||||
|
public double Cost { get; private set; }
|
||||||
public static Component? Create(ComponentBindingModel model)
|
public static Component? Create(ComponentBindingModel model)
|
||||||
{
|
{
|
||||||
if (model == null)
|
if (model == null)
|
||||||
|
@ -4,18 +4,25 @@ using FishFactoryDataModels.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 FishFactoryFileImplement.Models
|
namespace FishFactoryFileImplement.Models
|
||||||
{
|
{
|
||||||
|
[DataContract]
|
||||||
public class Implementer : IImplementerModel
|
public class Implementer : IImplementerModel
|
||||||
{
|
{
|
||||||
|
[DataMember]
|
||||||
public int Id { get; private set; }
|
public int Id { get; private set; }
|
||||||
|
[DataMember]
|
||||||
public string ImplementerFIO { get; private set; } = string.Empty;
|
public string ImplementerFIO { get; private set; } = string.Empty;
|
||||||
|
[DataMember]
|
||||||
public string Password { get; set; } = string.Empty;
|
public string Password { get; set; } = string.Empty;
|
||||||
|
[DataMember]
|
||||||
public int Qualification { get; set; } = 0;
|
public int Qualification { get; set; } = 0;
|
||||||
|
[DataMember]
|
||||||
public int WorkExperience { get; set; } = 0;
|
public int WorkExperience { get; set; } = 0;
|
||||||
public static Implementer? Create(ImplementerBindingModel model)
|
public static Implementer? Create(ImplementerBindingModel model)
|
||||||
{
|
{
|
||||||
|
@ -4,24 +4,27 @@ using FishFactoryDataModels.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 FishFactoryFileImplement.Models
|
namespace FishFactoryFileImplement.Models
|
||||||
{
|
{
|
||||||
|
[DataContract]
|
||||||
public class MessageInfo : IMessageInfoModel
|
public class MessageInfo : IMessageInfoModel
|
||||||
{
|
{
|
||||||
|
[DataMember]
|
||||||
public string MessageId { get; private set; } = string.Empty;
|
public string MessageId { get; private set; } = string.Empty;
|
||||||
|
[DataMember]
|
||||||
public int? ClientId { get; private set; }
|
public int? ClientId { get; private set; }
|
||||||
|
[DataMember]
|
||||||
public string SenderName { get; private set; } = string.Empty;
|
public string SenderName { get; private set; } = string.Empty;
|
||||||
|
[DataMember]
|
||||||
public DateTime DateDelivery { get; private set; } = DateTime.Now;
|
public DateTime DateDelivery { get; private set; } = DateTime.Now;
|
||||||
|
[DataMember]
|
||||||
public string Subject { get; private set; } = string.Empty;
|
public string Subject { get; private set; } = string.Empty;
|
||||||
|
[DataMember]
|
||||||
public string Body { get; private set; } = string.Empty;
|
public string Body { get; private set; } = string.Empty;
|
||||||
|
|
||||||
public static MessageInfo? Create(MessageInfoBindingModel model)
|
public static MessageInfo? Create(MessageInfoBindingModel model)
|
||||||
@ -76,5 +79,6 @@ namespace FishFactoryFileImplement.Models
|
|||||||
new XAttribute("SenderName", SenderName),
|
new XAttribute("SenderName", SenderName),
|
||||||
new XAttribute("DateDelivery", DateDelivery)
|
new XAttribute("DateDelivery", DateDelivery)
|
||||||
);
|
);
|
||||||
|
public int Id => throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,20 +9,31 @@ using System.Collections.Generic;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using System.Runtime.Serialization;
|
||||||
|
|
||||||
namespace FishFactoryFileImplement.Models
|
namespace FishFactoryFileImplement.Models
|
||||||
{
|
{
|
||||||
public class Order : IOrderModel
|
[DataContract]
|
||||||
|
public class Order : IOrderModel
|
||||||
{
|
{
|
||||||
public int Id { get; private set; }
|
[DataMember]
|
||||||
public int CannedId { get; private set; }
|
public int Id { get; private set; }
|
||||||
public int ClientId { get; private set; }
|
[DataMember]
|
||||||
public int? ImplementerId { get; private set; }
|
public int CannedId { get; private set; }
|
||||||
public int Count { get; private set; }
|
[DataMember]
|
||||||
public double Sum { get; private set; }
|
public int ClientId { get; private set; }
|
||||||
public OrderStatus Status { get; private set; }
|
[DataMember]
|
||||||
public DateTime DateCreate { get; private set; } = DateTime.Now;
|
public int? ImplementerId { get; private set; }
|
||||||
public DateTime? DateImplement { get; private set; }
|
[DataMember]
|
||||||
|
public int Count { get; private set; }
|
||||||
|
[DataMember]
|
||||||
|
public double Sum { get; private set; }
|
||||||
|
[DataMember]
|
||||||
|
public OrderStatus Status { get; private set; }
|
||||||
|
[DataMember]
|
||||||
|
public DateTime DateCreate { get; private set; } = DateTime.Now;
|
||||||
|
[DataMember]
|
||||||
|
public DateTime? DateImplement { get; private set; }
|
||||||
|
|
||||||
public static Order? Create(OrderBindingModel model)
|
public static Order? Create(OrderBindingModel model)
|
||||||
{
|
{
|
||||||
|
@ -11,4 +11,8 @@
|
|||||||
<ProjectReference Include="..\FishFactoryDataModels\FishFactoryDataModels.csproj" />
|
<ProjectReference Include="..\FishFactoryDataModels\FishFactoryDataModels.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
|
||||||
|
<Exec Command="copy /Y "$(TargetDir)*.dll" "$(SolutionDir)ImplementationExtensions\*.dll"" />
|
||||||
|
</Target>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
@ -0,0 +1,22 @@
|
|||||||
|
using FishFactoryContracts.StoragesContracts;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace FishFactoryListImplement.Implements
|
||||||
|
{
|
||||||
|
public class BackUpInfo : IBackUpInfo
|
||||||
|
{
|
||||||
|
public List<T>? GetList<T>() where T : class, new()
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Type? GetTypeByModelInterface(string modelInterfaceName)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,27 @@
|
|||||||
|
using FishFactoryContracts.DI;
|
||||||
|
using FishFactoryContracts.StoragesContracts;
|
||||||
|
using FishFactoryListImplement.Implements;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace FishFactoryListImplement
|
||||||
|
{
|
||||||
|
public class ListImplementationExtension : IImplementationExtension
|
||||||
|
{
|
||||||
|
public int Priority => 0;
|
||||||
|
|
||||||
|
public void RegisterServices()
|
||||||
|
{
|
||||||
|
DependencyManager.Instance.RegisterType<IClientStorage, ClientStorage>();
|
||||||
|
DependencyManager.Instance.RegisterType<IComponentStorage, ComponentStorage>();
|
||||||
|
DependencyManager.Instance.RegisterType<IImplementerStorage, ImplementerStorage>();
|
||||||
|
DependencyManager.Instance.RegisterType<IMessageInfoStorage, MessageInfoStorage>();
|
||||||
|
DependencyManager.Instance.RegisterType<IOrderStorage, OrderStorage>();
|
||||||
|
DependencyManager.Instance.RegisterType<ICannedStorage, CannedStorage>();
|
||||||
|
DependencyManager.Instance.RegisterType<IBackUpInfo, BackUpInfo>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -47,6 +47,6 @@ namespace FishFactoryListImplement.Models
|
|||||||
SenderName = SenderName,
|
SenderName = SenderName,
|
||||||
DateDelivery = DateDelivery,
|
DateDelivery = DateDelivery,
|
||||||
};
|
};
|
||||||
|
public int Id => throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
50
FishFactory/FishFactoryView/DataGridViewExtension.cs
Normal file
50
FishFactory/FishFactoryView/DataGridViewExtension.cs
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
using FishFactoryContracts.Attributes;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace FishFactoryView
|
||||||
|
{
|
||||||
|
public 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,5 +1,6 @@
|
|||||||
using FishFactoryContracts.BindingModels;
|
using FishFactoryContracts.BindingModels;
|
||||||
using FishFactoryContracts.BusinessLogicsContracts;
|
using FishFactoryContracts.BusinessLogicsContracts;
|
||||||
|
using FishFactoryContracts.DI;
|
||||||
using FishFactoryContracts.SearchModels;
|
using FishFactoryContracts.SearchModels;
|
||||||
using FishFactoryDataModels.Models;
|
using FishFactoryDataModels.Models;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
@ -78,9 +79,8 @@ namespace FishFactoryView
|
|||||||
}
|
}
|
||||||
private void ButtonAdd_Click(object sender, EventArgs e)
|
private void ButtonAdd_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
var service =
|
var service = DependencyManager.Instance.Resolve<FormCannedComponent>();
|
||||||
Program.ServiceProvider?.GetService(typeof(FormCannedComponent));
|
if (service is FormCannedComponent form)
|
||||||
if (service is FormCannedComponent form)
|
|
||||||
{
|
{
|
||||||
if (form.ShowDialog() == DialogResult.OK)
|
if (form.ShowDialog() == DialogResult.OK)
|
||||||
{
|
{
|
||||||
@ -107,9 +107,8 @@ namespace FishFactoryView
|
|||||||
{
|
{
|
||||||
if (dataGridView.SelectedRows.Count == 1)
|
if (dataGridView.SelectedRows.Count == 1)
|
||||||
{
|
{
|
||||||
var service =
|
var service = DependencyManager.Instance.Resolve<FormCannedComponent>();
|
||||||
Program.ServiceProvider?.GetService(typeof(FormCannedComponent));
|
if (service is FormCannedComponent form)
|
||||||
if (service is FormCannedComponent form)
|
|
||||||
{
|
{
|
||||||
int id =
|
int id =
|
||||||
Convert.ToInt32(dataGridView.SelectedRows[0].Cells[0].Value);
|
Convert.ToInt32(dataGridView.SelectedRows[0].Cells[0].Value);
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
using FishFactoryContracts.BindingModels;
|
using FishFactoryContracts.BindingModels;
|
||||||
using FishFactoryContracts.BusinessLogicsContracts;
|
using FishFactoryContracts.BusinessLogicsContracts;
|
||||||
|
using FishFactoryContracts.DI;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
@ -31,15 +32,8 @@ namespace FishFactoryView
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var list = _logic.ReadList(null);
|
dataGridView.FillAndConfigGrid(_logic.ReadList(null));
|
||||||
if (list != null)
|
_logger.LogInformation("Загрузка консервы");
|
||||||
{
|
|
||||||
dataGridView.DataSource = list;
|
|
||||||
dataGridView.Columns["Id"].Visible = false;
|
|
||||||
dataGridView.Columns["CannedName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
|
||||||
dataGridView.Columns["CannedComponents"].Visible = false;
|
|
||||||
}
|
|
||||||
_logger.LogInformation("Загрузка консервы");
|
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
@ -49,7 +43,7 @@ namespace FishFactoryView
|
|||||||
}
|
}
|
||||||
private void AddButton_Click(object sender, EventArgs e)
|
private void AddButton_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
var service = Program.ServiceProvider?.GetService(typeof(FormCanned));
|
var service = DependencyManager.Instance.Resolve<FormCanned>();
|
||||||
if (service is FormCanned form)
|
if (service is FormCanned form)
|
||||||
{
|
{
|
||||||
if (form.ShowDialog() == DialogResult.OK)
|
if (form.ShowDialog() == DialogResult.OK)
|
||||||
@ -63,7 +57,7 @@ namespace FishFactoryView
|
|||||||
{
|
{
|
||||||
if (dataGridView.SelectedRows.Count == 1)
|
if (dataGridView.SelectedRows.Count == 1)
|
||||||
{
|
{
|
||||||
var service = Program.ServiceProvider?.GetService(typeof(FormCanned));
|
var service = DependencyManager.Instance.Resolve<FormCanned>();
|
||||||
if (service is FormCanned form)
|
if (service is FormCanned form)
|
||||||
{
|
{
|
||||||
var tmp = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
var tmp = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||||
|
@ -30,15 +30,8 @@ namespace FishFactoryView
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var list = _clientLogic.ReadList(null);
|
dataGridView.FillAndConfigGrid(_clientLogic.ReadList(null));
|
||||||
if (list != null)
|
_logger.LogInformation("Load clients");
|
||||||
{
|
|
||||||
dataGridView.DataSource = list;
|
|
||||||
dataGridView.Columns["Id"].Visible = false;
|
|
||||||
dataGridView.Columns["ClientFIO"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
|
||||||
dataGridView.Columns["Password"].Visible = false;
|
|
||||||
}
|
|
||||||
_logger.LogInformation("Load clients");
|
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
using FishFactoryContracts.BindingModels;
|
using FishFactoryContracts.BindingModels;
|
||||||
using FishFactoryContracts.BusinessLogicsContracts;
|
using FishFactoryContracts.BusinessLogicsContracts;
|
||||||
|
using FishFactoryContracts.DI;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
@ -32,15 +33,8 @@ namespace FishFactoryView
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var list = _logic.ReadList(null);
|
dataGridView.FillAndConfigGrid(_logic.ReadList(null));
|
||||||
if (list != null)
|
_logger.LogInformation("Загрузка компонентов");
|
||||||
{
|
|
||||||
dataGridView.DataSource = list;
|
|
||||||
dataGridView.Columns["Id"].Visible = false;
|
|
||||||
dataGridView.Columns["ComponentName"].AutoSizeMode =
|
|
||||||
DataGridViewAutoSizeColumnMode.Fill;
|
|
||||||
}
|
|
||||||
_logger.LogInformation("Загрузка компонентов");
|
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
@ -51,8 +45,7 @@ namespace FishFactoryView
|
|||||||
}
|
}
|
||||||
private void ButtonAdd_Click(object sender, EventArgs e)
|
private void ButtonAdd_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
var service =
|
var service = DependencyManager.Instance.Resolve<FormComponent>();
|
||||||
Program.ServiceProvider?.GetService(typeof(FormComponent));
|
|
||||||
if (service is FormComponent form)
|
if (service is FormComponent form)
|
||||||
{
|
{
|
||||||
if (form.ShowDialog() == DialogResult.OK)
|
if (form.ShowDialog() == DialogResult.OK)
|
||||||
@ -65,8 +58,7 @@ namespace FishFactoryView
|
|||||||
{
|
{
|
||||||
if (dataGridView.SelectedRows.Count == 1)
|
if (dataGridView.SelectedRows.Count == 1)
|
||||||
{
|
{
|
||||||
var service =
|
var service = DependencyManager.Instance.Resolve<FormComponent>();
|
||||||
Program.ServiceProvider?.GetService(typeof(FormComponent));
|
|
||||||
if (service is FormComponent form)
|
if (service is FormComponent form)
|
||||||
{
|
{
|
||||||
form.Id =
|
form.Id =
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
using FishFactoryContracts.BindingModels;
|
using FishFactoryContracts.BindingModels;
|
||||||
using FishFactoryContracts.BusinessLogicsContracts;
|
using FishFactoryContracts.BusinessLogicsContracts;
|
||||||
|
using FishFactoryContracts.DI;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
@ -33,20 +34,7 @@ namespace FishFactoryView
|
|||||||
{
|
{
|
||||||
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;
|
|
||||||
dataGridView.Columns["Password"].AutoSizeMode =
|
|
||||||
DataGridViewAutoSizeColumnMode.Fill;
|
|
||||||
dataGridView.Columns["Qualification"].AutoSizeMode =
|
|
||||||
DataGridViewAutoSizeColumnMode.Fill;
|
|
||||||
dataGridView.Columns["WorkExperience"].AutoSizeMode =
|
|
||||||
DataGridViewAutoSizeColumnMode.Fill;
|
|
||||||
}
|
|
||||||
_logger.LogInformation("Загрузка компонентов");
|
_logger.LogInformation("Загрузка компонентов");
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
@ -58,7 +46,7 @@ namespace FishFactoryView
|
|||||||
}
|
}
|
||||||
private void buttonCreate_Click(object sender, EventArgs e)
|
private void buttonCreate_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)
|
||||||
@ -72,8 +60,7 @@ namespace FishFactoryView
|
|||||||
{
|
{
|
||||||
if (dataGridView.SelectedRows.Count == 1)
|
if (dataGridView.SelectedRows.Count == 1)
|
||||||
{
|
{
|
||||||
var service =
|
var service = DependencyManager.Instance.Resolve<FormImplementer>();
|
||||||
Program.ServiceProvider?.GetService(typeof(FormImplementer));
|
|
||||||
if (service is FormImplementer form)
|
if (service is FormImplementer form)
|
||||||
{
|
{
|
||||||
form.Id =
|
form.Id =
|
||||||
|
@ -27,14 +27,7 @@ namespace FishFactoryView
|
|||||||
{
|
{
|
||||||
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)
|
||||||
|
62
FishFactory/FishFactoryView/MainForm.Designer.cs
generated
62
FishFactory/FishFactoryView/MainForm.Designer.cs
generated
@ -44,6 +44,7 @@
|
|||||||
OrdersToolStripMenuItem = new ToolStripMenuItem();
|
OrdersToolStripMenuItem = new ToolStripMenuItem();
|
||||||
StartingWorkToolStripMenuItem = new ToolStripMenuItem();
|
StartingWorkToolStripMenuItem = new ToolStripMenuItem();
|
||||||
mailToolStripMenuItem = new ToolStripMenuItem();
|
mailToolStripMenuItem = new ToolStripMenuItem();
|
||||||
|
CreateBackUpToolStripMenuItem = new ToolStripMenuItem();
|
||||||
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
|
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
|
||||||
menuStrip1.SuspendLayout();
|
menuStrip1.SuspendLayout();
|
||||||
SuspendLayout();
|
SuspendLayout();
|
||||||
@ -51,20 +52,18 @@
|
|||||||
// dataGridView
|
// dataGridView
|
||||||
//
|
//
|
||||||
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||||
dataGridView.Location = new Point(-1, 22);
|
dataGridView.Location = new Point(-1, 29);
|
||||||
dataGridView.Margin = new Padding(3, 2, 3, 2);
|
|
||||||
dataGridView.Name = "dataGridView";
|
dataGridView.Name = "dataGridView";
|
||||||
dataGridView.RowHeadersWidth = 51;
|
dataGridView.RowHeadersWidth = 51;
|
||||||
dataGridView.RowTemplate.Height = 29;
|
dataGridView.RowTemplate.Height = 29;
|
||||||
dataGridView.Size = new Size(762, 343);
|
dataGridView.Size = new Size(871, 457);
|
||||||
dataGridView.TabIndex = 1;
|
dataGridView.TabIndex = 1;
|
||||||
//
|
//
|
||||||
// button1
|
// button1
|
||||||
//
|
//
|
||||||
button1.Location = new Point(774, 41);
|
button1.Location = new Point(885, 55);
|
||||||
button1.Margin = new Padding(3, 2, 3, 2);
|
|
||||||
button1.Name = "button1";
|
button1.Name = "button1";
|
||||||
button1.Size = new Size(157, 22);
|
button1.Size = new Size(179, 29);
|
||||||
button1.TabIndex = 2;
|
button1.TabIndex = 2;
|
||||||
button1.Text = "Создать заказ";
|
button1.Text = "Создать заказ";
|
||||||
button1.UseVisualStyleBackColor = true;
|
button1.UseVisualStyleBackColor = true;
|
||||||
@ -72,10 +71,9 @@
|
|||||||
//
|
//
|
||||||
// button4
|
// button4
|
||||||
//
|
//
|
||||||
button4.Location = new Point(774, 100);
|
button4.Location = new Point(885, 133);
|
||||||
button4.Margin = new Padding(3, 2, 3, 2);
|
|
||||||
button4.Name = "button4";
|
button4.Name = "button4";
|
||||||
button4.Size = new Size(157, 22);
|
button4.Size = new Size(179, 29);
|
||||||
button4.TabIndex = 5;
|
button4.TabIndex = 5;
|
||||||
button4.Text = "Заказ выдан";
|
button4.Text = "Заказ выдан";
|
||||||
button4.UseVisualStyleBackColor = true;
|
button4.UseVisualStyleBackColor = true;
|
||||||
@ -83,10 +81,9 @@
|
|||||||
//
|
//
|
||||||
// button5
|
// button5
|
||||||
//
|
//
|
||||||
button5.Location = new Point(774, 154);
|
button5.Location = new Point(885, 205);
|
||||||
button5.Margin = new Padding(3, 2, 3, 2);
|
|
||||||
button5.Name = "button5";
|
button5.Name = "button5";
|
||||||
button5.Size = new Size(157, 22);
|
button5.Size = new Size(179, 29);
|
||||||
button5.TabIndex = 6;
|
button5.TabIndex = 6;
|
||||||
button5.Text = "Обновить список";
|
button5.Text = "Обновить список";
|
||||||
button5.UseVisualStyleBackColor = true;
|
button5.UseVisualStyleBackColor = true;
|
||||||
@ -95,11 +92,11 @@
|
|||||||
// menuStrip1
|
// menuStrip1
|
||||||
//
|
//
|
||||||
menuStrip1.ImageScalingSize = new Size(20, 20);
|
menuStrip1.ImageScalingSize = new Size(20, 20);
|
||||||
menuStrip1.Items.AddRange(new ToolStripItem[] { spravochnikToolStripMenuItem, otchetToolStripMenuItem, StartingWorkToolStripMenuItem, mailToolStripMenuItem });
|
menuStrip1.Items.AddRange(new ToolStripItem[] { spravochnikToolStripMenuItem, otchetToolStripMenuItem, StartingWorkToolStripMenuItem, mailToolStripMenuItem, CreateBackUpToolStripMenuItem });
|
||||||
menuStrip1.Location = new Point(0, 0);
|
menuStrip1.Location = new Point(0, 0);
|
||||||
menuStrip1.Name = "menuStrip1";
|
menuStrip1.Name = "menuStrip1";
|
||||||
menuStrip1.Padding = new Padding(5, 2, 0, 2);
|
menuStrip1.Padding = new Padding(6, 3, 0, 3);
|
||||||
menuStrip1.Size = new Size(942, 24);
|
menuStrip1.Size = new Size(1077, 30);
|
||||||
menuStrip1.TabIndex = 7;
|
menuStrip1.TabIndex = 7;
|
||||||
menuStrip1.Text = "menuStrip1";
|
menuStrip1.Text = "menuStrip1";
|
||||||
//
|
//
|
||||||
@ -107,34 +104,34 @@
|
|||||||
//
|
//
|
||||||
spravochnikToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { компонентыToolStripMenuItem, консервыToolStripMenuItem, ClientsToolStripMenuItem, ImplementerToolStripMenuItem });
|
spravochnikToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { компонентыToolStripMenuItem, консервыToolStripMenuItem, ClientsToolStripMenuItem, ImplementerToolStripMenuItem });
|
||||||
spravochnikToolStripMenuItem.Name = "spravochnikToolStripMenuItem";
|
spravochnikToolStripMenuItem.Name = "spravochnikToolStripMenuItem";
|
||||||
spravochnikToolStripMenuItem.Size = new Size(94, 20);
|
spravochnikToolStripMenuItem.Size = new Size(117, 24);
|
||||||
spravochnikToolStripMenuItem.Text = "Справочники";
|
spravochnikToolStripMenuItem.Text = "Справочники";
|
||||||
//
|
//
|
||||||
// компонентыToolStripMenuItem
|
// компонентыToolStripMenuItem
|
||||||
//
|
//
|
||||||
компонентыToolStripMenuItem.Name = "компонентыToolStripMenuItem";
|
компонентыToolStripMenuItem.Name = "компонентыToolStripMenuItem";
|
||||||
компонентыToolStripMenuItem.Size = new Size(149, 22);
|
компонентыToolStripMenuItem.Size = new Size(185, 26);
|
||||||
компонентыToolStripMenuItem.Text = "Компоненты";
|
компонентыToolStripMenuItem.Text = "Компоненты";
|
||||||
компонентыToolStripMenuItem.Click += ComponentToolStripMenuItem_Click;
|
компонентыToolStripMenuItem.Click += ComponentToolStripMenuItem_Click;
|
||||||
//
|
//
|
||||||
// консервыToolStripMenuItem
|
// консервыToolStripMenuItem
|
||||||
//
|
//
|
||||||
консервыToolStripMenuItem.Name = "консервыToolStripMenuItem";
|
консервыToolStripMenuItem.Name = "консервыToolStripMenuItem";
|
||||||
консервыToolStripMenuItem.Size = new Size(149, 22);
|
консервыToolStripMenuItem.Size = new Size(185, 26);
|
||||||
консервыToolStripMenuItem.Text = "Консервы";
|
консервыToolStripMenuItem.Text = "Консервы";
|
||||||
консервыToolStripMenuItem.Click += CannedToolStripMenuItem_Click;
|
консервыToolStripMenuItem.Click += CannedToolStripMenuItem_Click;
|
||||||
//
|
//
|
||||||
// ClientsToolStripMenuItem
|
// ClientsToolStripMenuItem
|
||||||
//
|
//
|
||||||
ClientsToolStripMenuItem.Name = "ClientsToolStripMenuItem";
|
ClientsToolStripMenuItem.Name = "ClientsToolStripMenuItem";
|
||||||
ClientsToolStripMenuItem.Size = new Size(149, 22);
|
ClientsToolStripMenuItem.Size = new Size(185, 26);
|
||||||
ClientsToolStripMenuItem.Text = "Клиенты";
|
ClientsToolStripMenuItem.Text = "Клиенты";
|
||||||
ClientsToolStripMenuItem.Click += ClientsToolStripMenuItem_Click;
|
ClientsToolStripMenuItem.Click += ClientsToolStripMenuItem_Click;
|
||||||
//
|
//
|
||||||
// ImplementerToolStripMenuItem
|
// ImplementerToolStripMenuItem
|
||||||
//
|
//
|
||||||
ImplementerToolStripMenuItem.Name = "ImplementerToolStripMenuItem";
|
ImplementerToolStripMenuItem.Name = "ImplementerToolStripMenuItem";
|
||||||
ImplementerToolStripMenuItem.Size = new Size(149, 22);
|
ImplementerToolStripMenuItem.Size = new Size(185, 26);
|
||||||
ImplementerToolStripMenuItem.Text = "Исполнители";
|
ImplementerToolStripMenuItem.Text = "Исполнители";
|
||||||
ImplementerToolStripMenuItem.Click += ImplementerToolStripMenuItem_Click;
|
ImplementerToolStripMenuItem.Click += ImplementerToolStripMenuItem_Click;
|
||||||
//
|
//
|
||||||
@ -142,56 +139,62 @@
|
|||||||
//
|
//
|
||||||
otchetToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { ComponentsToolStripMenuItem, ComponentCannedToolStripMenuItem, OrdersToolStripMenuItem });
|
otchetToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { ComponentsToolStripMenuItem, ComponentCannedToolStripMenuItem, OrdersToolStripMenuItem });
|
||||||
otchetToolStripMenuItem.Name = "otchetToolStripMenuItem";
|
otchetToolStripMenuItem.Name = "otchetToolStripMenuItem";
|
||||||
otchetToolStripMenuItem.Size = new Size(60, 20);
|
otchetToolStripMenuItem.Size = new Size(73, 24);
|
||||||
otchetToolStripMenuItem.Text = "Отчёты";
|
otchetToolStripMenuItem.Text = "Отчёты";
|
||||||
//
|
//
|
||||||
// ComponentsToolStripMenuItem
|
// ComponentsToolStripMenuItem
|
||||||
//
|
//
|
||||||
ComponentsToolStripMenuItem.Name = "ComponentsToolStripMenuItem";
|
ComponentsToolStripMenuItem.Name = "ComponentsToolStripMenuItem";
|
||||||
ComponentsToolStripMenuItem.Size = new Size(218, 22);
|
ComponentsToolStripMenuItem.Size = new Size(276, 26);
|
||||||
ComponentsToolStripMenuItem.Text = "Список компонентов";
|
ComponentsToolStripMenuItem.Text = "Список компонентов";
|
||||||
ComponentsToolStripMenuItem.Click += ComponentsToolStripMenuItem_Click;
|
ComponentsToolStripMenuItem.Click += ComponentsToolStripMenuItem_Click;
|
||||||
//
|
//
|
||||||
// ComponentCannedToolStripMenuItem
|
// ComponentCannedToolStripMenuItem
|
||||||
//
|
//
|
||||||
ComponentCannedToolStripMenuItem.Name = "ComponentCannedToolStripMenuItem";
|
ComponentCannedToolStripMenuItem.Name = "ComponentCannedToolStripMenuItem";
|
||||||
ComponentCannedToolStripMenuItem.Size = new Size(218, 22);
|
ComponentCannedToolStripMenuItem.Size = new Size(276, 26);
|
||||||
ComponentCannedToolStripMenuItem.Text = "Компоненты по изделиям";
|
ComponentCannedToolStripMenuItem.Text = "Компоненты по изделиям";
|
||||||
ComponentCannedToolStripMenuItem.Click += ComponentCannedToolStripMenuItem_Click;
|
ComponentCannedToolStripMenuItem.Click += ComponentCannedToolStripMenuItem_Click;
|
||||||
//
|
//
|
||||||
// OrdersToolStripMenuItem
|
// OrdersToolStripMenuItem
|
||||||
//
|
//
|
||||||
OrdersToolStripMenuItem.Name = "OrdersToolStripMenuItem";
|
OrdersToolStripMenuItem.Name = "OrdersToolStripMenuItem";
|
||||||
OrdersToolStripMenuItem.Size = new Size(218, 22);
|
OrdersToolStripMenuItem.Size = new Size(276, 26);
|
||||||
OrdersToolStripMenuItem.Text = "Список заказов";
|
OrdersToolStripMenuItem.Text = "Список заказов";
|
||||||
OrdersToolStripMenuItem.Click += OrdersToolStripMenuItem_Click;
|
OrdersToolStripMenuItem.Click += OrdersToolStripMenuItem_Click;
|
||||||
//
|
//
|
||||||
// StartingWorkToolStripMenuItem
|
// StartingWorkToolStripMenuItem
|
||||||
//
|
//
|
||||||
StartingWorkToolStripMenuItem.Name = "StartingWorkToolStripMenuItem";
|
StartingWorkToolStripMenuItem.Name = "StartingWorkToolStripMenuItem";
|
||||||
StartingWorkToolStripMenuItem.Size = new Size(92, 20);
|
StartingWorkToolStripMenuItem.Size = new Size(114, 24);
|
||||||
StartingWorkToolStripMenuItem.Text = "Запуск работ";
|
StartingWorkToolStripMenuItem.Text = "Запуск работ";
|
||||||
StartingWorkToolStripMenuItem.Click += StartingWorkToolStripMenuItem_Click;
|
StartingWorkToolStripMenuItem.Click += StartingWorkToolStripMenuItem_Click;
|
||||||
//
|
//
|
||||||
// mailToolStripMenuItem
|
// mailToolStripMenuItem
|
||||||
//
|
//
|
||||||
mailToolStripMenuItem.Name = "mailToolStripMenuItem";
|
mailToolStripMenuItem.Name = "mailToolStripMenuItem";
|
||||||
mailToolStripMenuItem.Size = new Size(102, 20);
|
mailToolStripMenuItem.Size = new Size(126, 24);
|
||||||
mailToolStripMenuItem.Text = "Отчет на почту";
|
mailToolStripMenuItem.Text = "Отчет на почту";
|
||||||
mailToolStripMenuItem.Click += mailToolStripMenuItem_Click;
|
mailToolStripMenuItem.Click += mailToolStripMenuItem_Click;
|
||||||
//
|
//
|
||||||
|
// CreateBackUpToolStripMenuItem
|
||||||
|
//
|
||||||
|
CreateBackUpToolStripMenuItem.Name = "CreateBackUpToolStripMenuItem";
|
||||||
|
CreateBackUpToolStripMenuItem.Size = new Size(63, 24);
|
||||||
|
CreateBackUpToolStripMenuItem.Text = "Бэкап";
|
||||||
|
CreateBackUpToolStripMenuItem.Click += CreateBackUpToolStripMenuItem_Click;
|
||||||
|
//
|
||||||
// MainForm
|
// MainForm
|
||||||
//
|
//
|
||||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||||
AutoScaleMode = AutoScaleMode.Font;
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
ClientSize = new Size(942, 365);
|
ClientSize = new Size(1077, 487);
|
||||||
Controls.Add(button5);
|
Controls.Add(button5);
|
||||||
Controls.Add(button4);
|
Controls.Add(button4);
|
||||||
Controls.Add(button1);
|
Controls.Add(button1);
|
||||||
Controls.Add(dataGridView);
|
Controls.Add(dataGridView);
|
||||||
Controls.Add(menuStrip1);
|
Controls.Add(menuStrip1);
|
||||||
MainMenuStrip = menuStrip1;
|
MainMenuStrip = menuStrip1;
|
||||||
Margin = new Padding(3, 2, 3, 2);
|
|
||||||
Name = "MainForm";
|
Name = "MainForm";
|
||||||
Text = "Рыбный завод";
|
Text = "Рыбный завод";
|
||||||
Load += FormMain_Load;
|
Load += FormMain_Load;
|
||||||
@ -219,5 +222,6 @@
|
|||||||
private ToolStripMenuItem StartingWorkToolStripMenuItem;
|
private ToolStripMenuItem StartingWorkToolStripMenuItem;
|
||||||
private ToolStripMenuItem ImplementerToolStripMenuItem;
|
private ToolStripMenuItem ImplementerToolStripMenuItem;
|
||||||
private ToolStripMenuItem mailToolStripMenuItem;
|
private ToolStripMenuItem mailToolStripMenuItem;
|
||||||
|
private ToolStripMenuItem CreateBackUpToolStripMenuItem;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -2,7 +2,7 @@ using FishFactoryContracts.BindingModels;
|
|||||||
using FishFactoryContracts.BusinessLogicsContracts;
|
using FishFactoryContracts.BusinessLogicsContracts;
|
||||||
using FishFactoryDataModels.Enums;
|
using FishFactoryDataModels.Enums;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using System.Windows.Forms;
|
using FishFactoryContracts.DI;
|
||||||
|
|
||||||
namespace FishFactoryView
|
namespace FishFactoryView
|
||||||
{
|
{
|
||||||
@ -12,13 +12,15 @@ namespace FishFactoryView
|
|||||||
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 MainForm(ILogger<MainForm> logger, IOrderLogic orderLogic, IReportLogic reportLogic, IWorkProcess workProcess)
|
private readonly IBackUpLogic _backUpLogic;
|
||||||
|
public MainForm(ILogger<MainForm> 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)
|
||||||
{
|
{
|
||||||
@ -29,14 +31,7 @@ namespace FishFactoryView
|
|||||||
_logger.LogInformation("Çàãðóçêà çàêàçîâ");
|
_logger.LogInformation("Çàãðóçêà çàêàçîâ");
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var list = _orderLogic.ReadList(null);
|
dataGridView.FillAndConfigGrid(_orderLogic.ReadList(null));
|
||||||
if (list != null)
|
|
||||||
{
|
|
||||||
dataGridView.DataSource = list;
|
|
||||||
dataGridView.Columns["CannedId"].Visible = false;
|
|
||||||
dataGridView.Columns["ClientId"].Visible = false;
|
|
||||||
dataGridView.Columns["ImplementerId"].Visible = false;
|
|
||||||
}
|
|
||||||
_logger.LogInformation("Çàãðóçêà çàêàçîâ");
|
_logger.LogInformation("Çàãðóçêà çàêàçîâ");
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
@ -48,8 +43,7 @@ namespace FishFactoryView
|
|||||||
private void ComponentToolStripMenuItem_Click(object sender, EventArgs
|
private void ComponentToolStripMenuItem_Click(object sender, EventArgs
|
||||||
e)
|
e)
|
||||||
{
|
{
|
||||||
var service =
|
var service = DependencyManager.Instance.Resolve<FormComponents>();
|
||||||
Program.ServiceProvider?.GetService(typeof(FormComponents));
|
|
||||||
if (service is FormComponents form)
|
if (service is FormComponents form)
|
||||||
{
|
{
|
||||||
form.ShowDialog();
|
form.ShowDialog();
|
||||||
@ -57,7 +51,7 @@ namespace FishFactoryView
|
|||||||
}
|
}
|
||||||
private void CannedToolStripMenuItem_Click(object sender, EventArgs e)
|
private void CannedToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
var service = Program.ServiceProvider?.GetService(typeof(FormCanneds));
|
var service = DependencyManager.Instance.Resolve<FormCanneds>();
|
||||||
if (service is FormCanneds form)
|
if (service is FormCanneds form)
|
||||||
{
|
{
|
||||||
form.ShowDialog();
|
form.ShowDialog();
|
||||||
@ -65,8 +59,7 @@ namespace FishFactoryView
|
|||||||
}
|
}
|
||||||
private void ButtonCreateOrder_Click(object sender, EventArgs e)
|
private void ButtonCreateOrder_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
var service =
|
var service = DependencyManager.Instance.Resolve<FormCreateOrder>();
|
||||||
Program.ServiceProvider?.GetService(typeof(FormCreateOrder));
|
|
||||||
if (service is FormCreateOrder form)
|
if (service is FormCreateOrder form)
|
||||||
{
|
{
|
||||||
form.ShowDialog();
|
form.ShowDialog();
|
||||||
@ -126,7 +119,7 @@ namespace FishFactoryView
|
|||||||
|
|
||||||
private void ComponentCannedToolStripMenuItem_Click(object sender, EventArgs e)
|
private void ComponentCannedToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
var service = Program.ServiceProvider?.GetService(typeof(FormReportCannedComponents));
|
var service = DependencyManager.Instance.Resolve<FormReportCannedComponents>();
|
||||||
if (service is FormReportCannedComponents form)
|
if (service is FormReportCannedComponents form)
|
||||||
{
|
{
|
||||||
form.ShowDialog();
|
form.ShowDialog();
|
||||||
@ -135,7 +128,7 @@ namespace FishFactoryView
|
|||||||
|
|
||||||
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();
|
||||||
@ -143,7 +136,7 @@ namespace FishFactoryView
|
|||||||
}
|
}
|
||||||
private void ClientsToolStripMenuItem_Click(object sender, EventArgs e)
|
private void ClientsToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
var service = Program.ServiceProvider?.GetService(typeof(FormClients));
|
var service = DependencyManager.Instance.Resolve<FormClients>();
|
||||||
if (service is FormClients form)
|
if (service is FormClients form)
|
||||||
{
|
{
|
||||||
form.ShowDialog();
|
form.ShowDialog();
|
||||||
@ -151,7 +144,7 @@ namespace FishFactoryView
|
|||||||
}
|
}
|
||||||
private void ImplementerToolStripMenuItem_Click(object sender, EventArgs e)
|
private void ImplementerToolStripMenuItem_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();
|
||||||
@ -159,18 +152,41 @@ namespace FishFactoryView
|
|||||||
}
|
}
|
||||||
private void StartingWorkToolStripMenuItem_Click(object sender, EventArgs e)
|
private void StartingWorkToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
_workProcess.DoWork((Program.ServiceProvider?.GetService(typeof(IImplementerLogic
|
_workProcess.DoWork((DependencyManager.Instance.Resolve<IImplementerLogic>() as IImplementerLogic)!, _orderLogic);
|
||||||
)) as IImplementerLogic)!, _orderLogic);
|
|
||||||
MessageBox.Show("Ïðîöåññ îáðàáîòêè çàïóùåí", "Ñîîáùåíèå",
|
MessageBox.Show("Ïðîöåññ îáðàáîòêè çàïóùåí", "Ñîîáùåíèå",
|
||||||
MessageBoxButtons.OK, MessageBoxIcon.Information);
|
MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||||
}
|
}
|
||||||
private void mailToolStripMenuItem_Click(object sender, EventArgs e)
|
private void mailToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
var service = Program.ServiceProvider?.GetService(typeof(FormViewMail));
|
var service = DependencyManager.Instance.Resolve<FormViewMail>();
|
||||||
if (service is FormViewMail form)
|
if (service is FormViewMail form)
|
||||||
{
|
{
|
||||||
form.ShowDialog();
|
form.ShowDialog();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
private void CreateBackUpToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (_backUpLogic != null)
|
||||||
|
{
|
||||||
|
var fbd = new FolderBrowserDialog();
|
||||||
|
if (fbd.ShowDialog() == DialogResult.OK)
|
||||||
|
{
|
||||||
|
_backUpLogic.CreateBackUp(new BackUpSaveBindingModel
|
||||||
|
{
|
||||||
|
FolderName = fbd.SelectedPath
|
||||||
|
});
|
||||||
|
MessageBox.Show("Áåêàï ñîçäàí", "Ñîîáùåíèå",
|
||||||
|
MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Îøèáêà", MessageBoxButtons.OK,
|
||||||
|
MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -9,28 +9,22 @@ using Microsoft.Extensions.Logging;
|
|||||||
using NLog.Extensions.Logging;
|
using NLog.Extensions.Logging;
|
||||||
using FishFactoryBusinessLogic.MailWorker;
|
using FishFactoryBusinessLogic.MailWorker;
|
||||||
using FishFactoryContracts.BindingModels;
|
using FishFactoryContracts.BindingModels;
|
||||||
|
using FishFactoryContracts.DI;
|
||||||
|
|
||||||
namespace FishFactoryView
|
namespace FishFactoryView
|
||||||
{
|
{
|
||||||
internal static class Program
|
internal static class Program
|
||||||
{
|
{
|
||||||
private static ServiceProvider? _serviceProvider;
|
|
||||||
public static ServiceProvider? ServiceProvider => _serviceProvider;
|
|
||||||
/// <summary>
|
|
||||||
/// The main entry point for the application.
|
|
||||||
/// </summary>
|
|
||||||
[STAThread]
|
[STAThread]
|
||||||
static void Main()
|
static void Main()
|
||||||
{
|
{
|
||||||
// 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,
|
||||||
@ -44,51 +38,49 @@ namespace FishFactoryView
|
|||||||
}
|
}
|
||||||
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<MainForm>());
|
Application.Run(DependencyManager.Instance.Resolve<MainForm>());
|
||||||
}
|
}
|
||||||
private static void ConfigureServices(ServiceCollection services)
|
private static void InitDependency()
|
||||||
{
|
{
|
||||||
services.AddLogging(option =>
|
DependencyManager.InitDependency();
|
||||||
{
|
DependencyManager.Instance.AddLogging(option =>
|
||||||
|
{
|
||||||
option.SetMinimumLevel(LogLevel.Information);
|
option.SetMinimumLevel(LogLevel.Information);
|
||||||
option.AddNLog("nlog.config");
|
option.AddNLog("nlog.config");
|
||||||
});
|
});
|
||||||
services.AddTransient<IComponentStorage, ComponentStorage>();
|
DependencyManager.Instance.RegisterType<IComponentLogic, ComponentLogic>();
|
||||||
services.AddTransient<IOrderStorage, OrderStorage>();
|
DependencyManager.Instance.RegisterType<IOrderLogic, OrderLogic>();
|
||||||
services.AddTransient<ICannedStorage, CannedStorage>();
|
DependencyManager.Instance.RegisterType<ICannedLogic, CannedLogic>();
|
||||||
services.AddTransient<IClientStorage, ClientStorage>();
|
DependencyManager.Instance.RegisterType<IReportLogic, ReportLogic>();
|
||||||
services.AddTransient<IMessageInfoStorage, MessageInfoStorage>();
|
DependencyManager.Instance.RegisterType<IClientLogic, ClientLogic>();
|
||||||
services.AddTransient<IComponentLogic, ComponentLogic>();
|
DependencyManager.Instance.RegisterType<IImplementerLogic, ImplementerLogic>();
|
||||||
services.AddTransient<IOrderLogic, OrderLogic>();
|
DependencyManager.Instance.RegisterType<IMessageInfoLogic, MessageInfoLogic>();
|
||||||
services.AddTransient<ICannedLogic, CannedLogic>();
|
|
||||||
services.AddTransient<IReportLogic, ReportLogic>();
|
DependencyManager.Instance.RegisterType<IWorkProcess, WorkModeling>();
|
||||||
services.AddTransient<IClientLogic, ClientLogic>();
|
DependencyManager.Instance.RegisterType<AbstractMailWorker, MailKitWorker>(true);
|
||||||
services.AddTransient<IImplementerLogic, ImplementerLogic>();
|
DependencyManager.Instance.RegisterType<AbstractSaveToExcel, SaveToExcel>();
|
||||||
services.AddTransient<IMessageInfoLogic, MessageInfoLogic>();
|
DependencyManager.Instance.RegisterType<AbstractSaveToWord, SaveToWord>();
|
||||||
services.AddTransient<IImplementerStorage, ImplementerStorage>();
|
DependencyManager.Instance.RegisterType<AbstractSaveToPdf, SaveToPdf>();
|
||||||
services.AddTransient<IWorkProcess, WorkModeling>();
|
DependencyManager.Instance.RegisterType<IBackUpLogic, BackUpLogic>();
|
||||||
services.AddSingleton<AbstractMailWorker, MailKitWorker>();
|
|
||||||
services.AddTransient<AbstractSaveToExcel, SaveToExcel>();
|
DependencyManager.Instance.RegisterType<MainForm>();
|
||||||
services.AddTransient<AbstractSaveToWord, SaveToWord>();
|
DependencyManager.Instance.RegisterType<FormComponent>();
|
||||||
services.AddTransient<AbstractSaveToPdf, SaveToPdf>();
|
DependencyManager.Instance.RegisterType<FormComponents>();
|
||||||
services.AddTransient<MainForm>();
|
DependencyManager.Instance.RegisterType<FormCreateOrder>();
|
||||||
services.AddTransient<FormComponent>();
|
DependencyManager.Instance.RegisterType<FormCanned>();
|
||||||
services.AddTransient<FormComponents>();
|
DependencyManager.Instance.RegisterType<FormCannedComponent>();
|
||||||
services.AddTransient<FormCreateOrder>();
|
DependencyManager.Instance.RegisterType<FormClients>();
|
||||||
services.AddTransient<FormCanned>();
|
DependencyManager.Instance.RegisterType<FormCanneds>();
|
||||||
services.AddTransient<FormCannedComponent>();
|
DependencyManager.Instance.RegisterType<FormReportCannedComponents>();
|
||||||
services.AddTransient<FormClients>();
|
DependencyManager.Instance.RegisterType<FormReportOrders>();
|
||||||
services.AddTransient<FormCanneds>();
|
DependencyManager.Instance.RegisterType<FormImplementer>();
|
||||||
services.AddTransient<FormReportCannedComponents>();
|
DependencyManager.Instance.RegisterType<FormImplementers>();
|
||||||
services.AddTransient<FormReportOrders>();
|
DependencyManager.Instance.RegisterType<FormViewMail>();
|
||||||
services.AddTransient<FormImplementer>();
|
|
||||||
services.AddTransient<FormImplementers>();
|
|
||||||
services.AddTransient<FormViewMail>();
|
|
||||||
}
|
}
|
||||||
private static void MailCheck(object obj) => ServiceProvider?.GetService<AbstractMailWorker>()?.MailCheck();
|
private static void MailCheck(object obj) => DependencyManager.Instance.Resolve<AbstractMailWorker>()?.MailCheck();
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user