Compare commits
No commits in common. "30d108205849cd40dc2cad8aa48bcd460b0e99f0" and "10df3ce42a73806d002447c4bea99c059c14cb7c" have entirely different histories.
30d1082058
...
10df3ce42a
1
.gitignore
vendored
1
.gitignore
vendored
@ -398,4 +398,3 @@ FodyWeavers.xsd
|
|||||||
# JetBrains Rider
|
# JetBrains Rider
|
||||||
*.sln.iml
|
*.sln.iml
|
||||||
|
|
||||||
*.dll
|
|
||||||
|
@ -1,103 +0,0 @@
|
|||||||
using ComputersShopContracts.BindingModels;
|
|
||||||
using ComputersShopContracts.BusinessLogicContracts;
|
|
||||||
using ComputersShopContracts.StoragesContracts;
|
|
||||||
using ComputersShopDataModels;
|
|
||||||
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 ComputersShopBusinessLogic.BusinessLogics
|
|
||||||
{
|
|
||||||
public class BackUpLogic : IBackUpLogic
|
|
||||||
{
|
|
||||||
private readonly ILogger _logger;
|
|
||||||
|
|
||||||
private readonly IBackUpInfo _backUpInfo;
|
|
||||||
|
|
||||||
public BackUpLogic(ILogger<BackUpLogic> logger, IBackUpInfo backUpInfo)
|
|
||||||
{
|
|
||||||
_logger = logger;
|
|
||||||
_backUpInfo = backUpInfo;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void CreateBackUp(BackUpSaveBinidngModel model)
|
|
||||||
{
|
|
||||||
if (_backUpInfo == null)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
try
|
|
||||||
{
|
|
||||||
_logger.LogDebug("Clear folder");
|
|
||||||
// зачистка папки и удаление старого архива
|
|
||||||
var dirInfo = new DirectoryInfo(model.FolderName);
|
|
||||||
if (dirInfo.Exists)
|
|
||||||
{
|
|
||||||
foreach (var file in dirInfo.GetFiles())
|
|
||||||
{
|
|
||||||
file.Delete();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
_logger.LogDebug("Delete archive");
|
|
||||||
string fileName = $"{model.FolderName}.zip";
|
|
||||||
if (File.Exists(fileName))
|
|
||||||
{
|
|
||||||
File.Delete(fileName);
|
|
||||||
}
|
|
||||||
// берем метод для сохранения
|
|
||||||
_logger.LogDebug("Get assembly");
|
|
||||||
var typeIId = typeof(IId);
|
|
||||||
var assembly = typeIId.Assembly;
|
|
||||||
if (assembly == null)
|
|
||||||
{
|
|
||||||
throw new ArgumentNullException("Сборка не найдена", nameof(assembly));
|
|
||||||
}
|
|
||||||
var types = assembly.GetTypes();
|
|
||||||
var method = GetType().GetMethod("SaveToFile", BindingFlags.NonPublic | BindingFlags.Instance);
|
|
||||||
_logger.LogDebug("Find {count} types", types.Length);
|
|
||||||
foreach (var type in types)
|
|
||||||
{
|
|
||||||
if (type.IsInterface && type.GetInterface(typeIId.Name) != null)
|
|
||||||
{
|
|
||||||
var modelType = _backUpInfo.GetTypeByModelInterface(type.Name);
|
|
||||||
if (modelType == null)
|
|
||||||
{
|
|
||||||
throw new InvalidOperationException($"Не найден класс-модель для {type.Name}");
|
|
||||||
}
|
|
||||||
_logger.LogDebug("Call SaveToFile method for {name} type", type.Name);
|
|
||||||
// вызываем метод на выполнение
|
|
||||||
method?.MakeGenericMethod(modelType).Invoke(this, new object[] { model.FolderName });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
_logger.LogDebug("Create zip and remove folder");
|
|
||||||
// архивируем
|
|
||||||
ZipFile.CreateFromDirectory(model.FolderName, fileName);
|
|
||||||
// удаляем папку
|
|
||||||
dirInfo.Delete(true);
|
|
||||||
}
|
|
||||||
catch (Exception)
|
|
||||||
{
|
|
||||||
throw;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void SaveToFile<T>(string folderName) where T : class, new()
|
|
||||||
{
|
|
||||||
var records = _backUpInfo.GetList<T>();
|
|
||||||
if (records == null)
|
|
||||||
{
|
|
||||||
_logger.LogWarning("{type} type get null list", typeof(T).Name);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
var jsonFormatter = new DataContractJsonSerializer(typeof(List<T>));
|
|
||||||
using var fs = new FileStream(string.Format("{0}/{1}.json", folderName, typeof(T).Name), FileMode.OpenOrCreate);
|
|
||||||
jsonFormatter.WriteObject(fs, records);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,26 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace ComputersShopContracts.Attributes
|
|
||||||
{
|
|
||||||
[AttributeUsage(AttributeTargets.Property)]
|
|
||||||
public class ColumnAttribute : Attribute
|
|
||||||
{
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
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; }
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,20 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace ComputersShopContracts.Attributes
|
|
||||||
{
|
|
||||||
public enum GridViewAutoSize
|
|
||||||
{
|
|
||||||
NotSet = 0,
|
|
||||||
None = 1,
|
|
||||||
ColumnHeader = 2,
|
|
||||||
AllCellsExceptHeader = 4,
|
|
||||||
AllCells = 6,
|
|
||||||
DisplayedCellsExceptHeader = 8,
|
|
||||||
DisplayedCells = 10,
|
|
||||||
Fill = 16
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,13 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace ComputersShopContracts.BindingModels
|
|
||||||
{
|
|
||||||
public class BackUpSaveBinidngModel
|
|
||||||
{
|
|
||||||
public string FolderName { get; set; } = string.Empty;
|
|
||||||
}
|
|
||||||
}
|
|
@ -20,7 +20,5 @@ namespace ComputersShopContracts.BindingModels
|
|||||||
public string Body { get; set; } = string.Empty;
|
public string Body { get; set; } = string.Empty;
|
||||||
|
|
||||||
public DateTime DateDelivery { get; set; }
|
public DateTime DateDelivery { get; set; }
|
||||||
|
|
||||||
public int Id => throw new NotImplementedException();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,14 +0,0 @@
|
|||||||
using ComputersShopContracts.BindingModels;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace ComputersShopContracts.BusinessLogicContracts
|
|
||||||
{
|
|
||||||
public interface IBackUpLogic
|
|
||||||
{
|
|
||||||
void CreateBackUp(BackUpSaveBinidngModel model);
|
|
||||||
}
|
|
||||||
}
|
|
@ -6,12 +6,6 @@
|
|||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<PackageReference Include="Microsoft.Extensions.Logging" Version="7.0.0" />
|
|
||||||
<PackageReference Include="Unity" Version="5.11.10" />
|
|
||||||
<PackageReference Include="Unity.Microsoft.Logging" Version="5.11.1" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\ComputersShopDataModels\ComputersShopDataModels.csproj" />
|
<ProjectReference Include="..\ComputersShopDataModels\ComputersShopDataModels.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
@ -1,44 +0,0 @@
|
|||||||
using Microsoft.Extensions.Logging;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace ComputersShopContracts.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>();
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,17 +0,0 @@
|
|||||||
using Microsoft.Extensions.Logging;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace ComputersShopContracts.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>();
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,14 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace ComputersShopContracts.DI
|
|
||||||
{
|
|
||||||
public interface IImplementationExtension
|
|
||||||
{
|
|
||||||
public int Priority { get; }
|
|
||||||
public void RegisterServices();
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,62 +0,0 @@
|
|||||||
using Microsoft.Extensions.DependencyInjection;
|
|
||||||
using Microsoft.Extensions.Logging;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace ComputersShopContracts.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>()!;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,59 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Reflection;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace ComputersShopContracts.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";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,43 +0,0 @@
|
|||||||
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 ComputersShopContracts.DI
|
|
||||||
{
|
|
||||||
public class UnityDependencyContainer : IDependencyContainer
|
|
||||||
{
|
|
||||||
private readonly IUnityContainer _container;
|
|
||||||
|
|
||||||
public UnityDependencyContainer()
|
|
||||||
{
|
|
||||||
_container = new UnityContainer();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void AddLogging(Action<ILoggingBuilder> configure)
|
|
||||||
{
|
|
||||||
var factory = LoggerFactory.Create(configure);
|
|
||||||
_container.AddExtension(new LoggingExtension(factory));
|
|
||||||
}
|
|
||||||
|
|
||||||
public void RegisterType<T>(bool isSingle) where T : class
|
|
||||||
{
|
|
||||||
_container.RegisterType<T>(isSingle ? TypeLifetime.Singleton : TypeLifetime.Transient);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public T Resolve<T>()
|
|
||||||
{
|
|
||||||
return _container.Resolve<T>();
|
|
||||||
}
|
|
||||||
|
|
||||||
void IDependencyContainer.RegisterType<T, U>(bool isSingle)
|
|
||||||
{
|
|
||||||
_container.RegisterType<T, U>(isSingle ? TypeLifetime.Singleton : TypeLifetime.Transient);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,14 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace ComputersShopContracts.StoragesContracts
|
|
||||||
{
|
|
||||||
public interface IBackUpInfo
|
|
||||||
{
|
|
||||||
List<T>? GetList<T>() where T : class, new();
|
|
||||||
Type? GetTypeByModelInterface(string modelInterfaceName);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,5 +1,4 @@
|
|||||||
using ComputersShopContracts.Attributes;
|
using ComputersShopDataModels.Models;
|
||||||
using ComputersShopDataModels.Models;
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
@ -11,13 +10,15 @@ namespace ComputersShopContracts.ViewModels
|
|||||||
{
|
{
|
||||||
public class ClientViewModel : IClientModel
|
public class ClientViewModel : IClientModel
|
||||||
{
|
{
|
||||||
[Column(visible: false)]
|
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
[Column("ФИО клиента", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)]
|
|
||||||
|
[DisplayName("ФИО клиента")]
|
||||||
public string ClientFIO { get; set; } = string.Empty;
|
public string ClientFIO { get; set; } = string.Empty;
|
||||||
[Column("Логин (эл. почта)", width: 150)]
|
|
||||||
|
[DisplayName("Логин (эл. почта)")]
|
||||||
public string Email { get; set; } = string.Empty;
|
public string Email { get; set; } = string.Empty;
|
||||||
[Column("Пароль", width: 150)]
|
|
||||||
|
[DisplayName("Пароль")]
|
||||||
public string Password { get; set; } = string.Empty;
|
public string Password { get; set; } = string.Empty;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
using ComputersShopContracts.Attributes;
|
using ComputersShopDataModels.Models;
|
||||||
using ComputersShopDataModels.Models;
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
@ -11,11 +10,10 @@ namespace ComputersShopContracts.ViewModels
|
|||||||
{
|
{
|
||||||
public class ComponentViewModel : IComponentModel
|
public class ComponentViewModel : IComponentModel
|
||||||
{
|
{
|
||||||
[Column(visible: false)]
|
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
[Column("Название комплектующего", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)]
|
[DisplayName("Название компонента")]
|
||||||
public string ComponentName { get; set; } = string.Empty;
|
public string ComponentName { get; set; } = string.Empty;
|
||||||
[Column("Цена", width: 80)]
|
[DisplayName("Цена")]
|
||||||
public double Cost { get; set; }
|
public double Cost { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
using ComputersShopContracts.Attributes;
|
using ComputersShopDataModels.Models;
|
||||||
using ComputersShopDataModels.Models;
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
@ -11,16 +10,14 @@ namespace ComputersShopContracts.ViewModels
|
|||||||
{
|
{
|
||||||
public class ComputerViewModel : IComputerModel
|
public class ComputerViewModel : IComputerModel
|
||||||
{
|
{
|
||||||
[Column(visible: false)]
|
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
|
|
||||||
[Column("Название компьютера", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)]
|
[DisplayName("Название компьютера")]
|
||||||
public string ComputerName { get; set; } = string.Empty;
|
public string ComputerName { get; set; } = string.Empty;
|
||||||
|
|
||||||
[Column("Цена", width: 100)]
|
[DisplayName("Цена")]
|
||||||
public double Price { get; set; }
|
public double Price { get; set; }
|
||||||
|
|
||||||
[Column(visible: false)]
|
|
||||||
public Dictionary<int, (IComponentModel, int)> ComputerComponents
|
public Dictionary<int, (IComponentModel, int)> ComputerComponents
|
||||||
{
|
{
|
||||||
get;
|
get;
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
using ComputersShopContracts.Attributes;
|
using ComputersShopDataModels.Models;
|
||||||
using ComputersShopDataModels.Models;
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
@ -11,19 +10,18 @@ namespace ComputersShopContracts.ViewModels
|
|||||||
{
|
{
|
||||||
public class ImplementerViewModel : IImplementerModel
|
public class ImplementerViewModel : IImplementerModel
|
||||||
{
|
{
|
||||||
[Column(visible: false)]
|
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
|
|
||||||
[Column("ФИО исполнителя", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)]
|
[DisplayName("ФИО исполнителя")]
|
||||||
public string ImplementerFIO { get; set; } = string.Empty;
|
public string ImplementerFIO { get; set; } = string.Empty;
|
||||||
|
|
||||||
[Column("Пароль", width: 150)]
|
[DisplayName("Пароль")]
|
||||||
public string Password { get; set; } = string.Empty;
|
public string Password { get; set; } = string.Empty;
|
||||||
|
|
||||||
[Column("Стаж работы", gridViewAutoSize: GridViewAutoSize.AllCells, isUseAutoSize: true)]
|
[DisplayName("Стаж работы")]
|
||||||
public int WorkExperience { get; set; }
|
public int WorkExperience { get; set; }
|
||||||
|
|
||||||
[Column("Квалификация", gridViewAutoSize: GridViewAutoSize.AllCells, isUseAutoSize: true)]
|
[DisplayName("Квалификация")]
|
||||||
public int Qualification { get; set; }
|
public int Qualification { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
using ComputersShopContracts.Attributes;
|
using ComputersShopDataModels.Models;
|
||||||
using ComputersShopDataModels.Models;
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
@ -11,23 +10,20 @@ namespace ComputersShopContracts.ViewModels
|
|||||||
{
|
{
|
||||||
public class MessageInfoViewModel : IMessageInfoModel
|
public class MessageInfoViewModel : IMessageInfoModel
|
||||||
{
|
{
|
||||||
[Column(visible: false)]
|
|
||||||
public string MessageId { get; set; } = string.Empty;
|
public string MessageId { get; set; } = string.Empty;
|
||||||
[Column(visible: false)]
|
|
||||||
public int? ClientId { get; set; }
|
public int? ClientId { get; set; }
|
||||||
|
|
||||||
[Column("Отправитель", gridViewAutoSize: GridViewAutoSize.DisplayedCells, isUseAutoSize: true)]
|
[DisplayName("Отправитель")]
|
||||||
public string SenderName { get; set; } = string.Empty;
|
public string SenderName { get; set; } = string.Empty;
|
||||||
|
|
||||||
[Column("Дата письма", width: 100)]
|
[DisplayName("Дата письма")]
|
||||||
public DateTime DateDelivery { get; set; }
|
public DateTime DateDelivery { get; set; }
|
||||||
|
|
||||||
[Column("Заголовок", gridViewAutoSize: GridViewAutoSize.AllCells, isUseAutoSize: true)]
|
[DisplayName("Заголовок")]
|
||||||
public string Subject { get; set; } = string.Empty;
|
public string Subject { get; set; } = string.Empty;
|
||||||
|
|
||||||
[Column("Текст", gridViewAutoSize: GridViewAutoSize.AllCells, isUseAutoSize: true)]
|
[DisplayName("Текст")]
|
||||||
public string Body { get; set; } = string.Empty;
|
public string Body { get; set; } = string.Empty;
|
||||||
[Column(visible: false)]
|
|
||||||
public int Id => throw new NotImplementedException();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
using ComputersShopContracts.Attributes;
|
using ComputersShopDataModels.Enums;
|
||||||
using ComputersShopDataModels.Enums;
|
|
||||||
using ComputersShopDataModels.Models;
|
using ComputersShopDataModels.Models;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
@ -12,29 +11,26 @@ namespace ComputersShopContracts.ViewModels
|
|||||||
{
|
{
|
||||||
public class OrderViewModel : IOrderModel
|
public class OrderViewModel : IOrderModel
|
||||||
{
|
{
|
||||||
[Column("Номер", gridViewAutoSize: GridViewAutoSize.AllCells, isUseAutoSize: true)]
|
[DisplayName("Номер")]
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
[Column(visible: false)]
|
|
||||||
public int ComputerId { get; set; }
|
public int ComputerId { get; set; }
|
||||||
[Column(visible: false)]
|
|
||||||
public int ClientId { get; set; }
|
public int ClientId { get; set; }
|
||||||
[Column("Данные клиента", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)]
|
[DisplayName("Фамилия клиента")]
|
||||||
public string ClientFIO { get; set; } = string.Empty;
|
public string ClientFIO { get; set; } = string.Empty;
|
||||||
[Column(visible: false)]
|
|
||||||
public int? ImplementerId { get; set; }
|
public int? ImplementerId { get; set; }
|
||||||
[Column("Данные исполнителя", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)]
|
[DisplayName("Исполнитель")]
|
||||||
public string ImplementerFIO { get; set; } = string.Empty;
|
public string ImplementerFIO { get; set; } = string.Empty;
|
||||||
[Column("Компьютер", gridViewAutoSize: GridViewAutoSize.AllCells, isUseAutoSize: true)]
|
[DisplayName("Компьютер")]
|
||||||
public string ComputerName { get; set; } = string.Empty;
|
public string ComputerName { get; set; } = string.Empty;
|
||||||
[Column("Количество", gridViewAutoSize: GridViewAutoSize.AllCells, isUseAutoSize: true)]
|
[DisplayName("Количество")]
|
||||||
public int Count { get; set; }
|
public int Count { get; set; }
|
||||||
[Column("Сумма", gridViewAutoSize: GridViewAutoSize.AllCells, isUseAutoSize: true)]
|
[DisplayName("Сумма")]
|
||||||
public double Sum { get; set; }
|
public double Sum { get; set; }
|
||||||
[Column("Статус", gridViewAutoSize: GridViewAutoSize.AllCells, isUseAutoSize: true)]
|
[DisplayName("Статус")]
|
||||||
public OrderStatus Status { get; set; } = OrderStatus.Неизвестен;
|
public OrderStatus Status { get; set; } = OrderStatus.Неизвестен;
|
||||||
[Column("Дата создания", width: 100)]
|
[DisplayName("Дата создания")]
|
||||||
public DateTime DateCreate { get; set; } = DateTime.Now;
|
public DateTime DateCreate { get; set; } = DateTime.Now;
|
||||||
[Column("Дата выполнения", width: 100)]
|
[DisplayName("Дата выполнения")]
|
||||||
public DateTime? DateImplement { get; set; }
|
public DateTime? DateImplement { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>net6.0</TargetFramework>
|
<TargetFramework>net6.0</TargetFramework>
|
||||||
@ -20,8 +20,4 @@
|
|||||||
<ProjectReference Include="..\ComputersShopDataModels\ComputersShopDataModels.csproj" />
|
<ProjectReference Include="..\ComputersShopDataModels\ComputersShopDataModels.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
|
|
||||||
<Exec Command="copy /Y "$(TargetDir)*.dll"; "$(SolutionDir)ImplementationExtensions\*.dll"" />
|
|
||||||
</Target>
|
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
@ -1,27 +0,0 @@
|
|||||||
using ComputersShopContracts.DI;
|
|
||||||
using ComputersShopContracts.StoragesContracts;
|
|
||||||
using ComputersShopDataBaseImplement.Implements;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace ComputersShopDataBaseImplement
|
|
||||||
{
|
|
||||||
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<IComputerStorage, ComputerStorage>();
|
|
||||||
DependencyManager.Instance.RegisterType<IBackUpInfo, BackUpInfo>();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,32 +0,0 @@
|
|||||||
using ComputersShopContracts.StoragesContracts;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace ComputersShopDataBaseImplement.Implements
|
|
||||||
{
|
|
||||||
public class BackUpInfo : IBackUpInfo
|
|
||||||
{
|
|
||||||
public List<T>? GetList<T>() where T : class, new()
|
|
||||||
{
|
|
||||||
using var context = new ComputersShopDataBase();
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -25,8 +25,6 @@ namespace ComputersShopDataBaseImplement.Models
|
|||||||
|
|
||||||
public string Body { get; private set; } = string.Empty;
|
public string Body { get; private set; } = string.Empty;
|
||||||
|
|
||||||
public int Id => throw new NotImplementedException();
|
|
||||||
|
|
||||||
public static Message? Create(MessageInfoBindingModel model)
|
public static Message? Create(MessageInfoBindingModel model)
|
||||||
{
|
{
|
||||||
if (model == null)
|
if (model == null)
|
||||||
|
@ -6,7 +6,7 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace ComputersShopDataModels.Models
|
namespace ComputersShopDataModels.Models
|
||||||
{
|
{
|
||||||
public interface IMessageInfoModel : IId
|
public interface IMessageInfoModel
|
||||||
{
|
{
|
||||||
string MessageId { get; }
|
string MessageId { get; }
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>net6.0</TargetFramework>
|
<TargetFramework>net6.0</TargetFramework>
|
||||||
@ -11,8 +11,4 @@
|
|||||||
<ProjectReference Include="..\ComputersShopDataModels\ComputersShopDataModels.csproj" />
|
<ProjectReference Include="..\ComputersShopDataModels\ComputersShopDataModels.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
|
|
||||||
<Exec Command="copy /Y "$(TargetDir)*.dll"; "$(SolutionDir)ImplementationExtensions\*.dll"" />
|
|
||||||
</Target>
|
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
@ -1,27 +0,0 @@
|
|||||||
using ComputersShopContracts.DI;
|
|
||||||
using ComputersShopContracts.StoragesContracts;
|
|
||||||
using ComputersShopFileImplement.Implements;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace ComputersShopFileImplement
|
|
||||||
{
|
|
||||||
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<IComputerStorage, ComputerStorage>();
|
|
||||||
DependencyManager.Instance.RegisterType<IBackUpInfo, BackUpInfo>();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,35 +0,0 @@
|
|||||||
using ComputersShopContracts.StoragesContracts;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace ComputersShopFileImplement.Implements
|
|
||||||
{
|
|
||||||
public class BackUpInfo : IBackUpInfo
|
|
||||||
{
|
|
||||||
public List<T>? GetList<T>() where T : class, new()
|
|
||||||
{
|
|
||||||
// Получаем значения из singleton-объекта универсального свойства содержащее тип T
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -24,8 +24,6 @@ namespace ComputersShopFileImplement.Models
|
|||||||
|
|
||||||
public string Body { get; private set; } = string.Empty;
|
public string Body { get; private set; } = string.Empty;
|
||||||
|
|
||||||
public int Id => throw new NotImplementedException();
|
|
||||||
|
|
||||||
public static Message? Create(MessageInfoBindingModel model)
|
public static Message? Create(MessageInfoBindingModel model)
|
||||||
{
|
{
|
||||||
if (model == null)
|
if (model == null)
|
||||||
|
@ -11,8 +11,4 @@
|
|||||||
<ProjectReference Include="..\ComputersShopDataModels\ComputersShopDataModels.csproj" />
|
<ProjectReference Include="..\ComputersShopDataModels\ComputersShopDataModels.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
|
|
||||||
<Exec Command="copy /Y "$(TargetDir)*.dll"; "$(SolutionDir)ImplementationExtensions\*.dll"" />
|
|
||||||
</Target>
|
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
@ -1,22 +0,0 @@
|
|||||||
using ComputersShopContracts.StoragesContracts;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace ComputersShopListImplement.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();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -10,7 +10,7 @@ using System.Linq;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace ComputersShopListImplement.Implements
|
namespace OrdersShopListImplement.Implements
|
||||||
{
|
{
|
||||||
public class OrderStorage : IOrderStorage
|
public class OrderStorage : IOrderStorage
|
||||||
{
|
{
|
||||||
|
@ -1,26 +0,0 @@
|
|||||||
using ComputersShopContracts.DI;
|
|
||||||
using ComputersShopContracts.StoragesContracts;
|
|
||||||
using ComputersShopListImplement.Implements;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace ComputersShopListImplement
|
|
||||||
{
|
|
||||||
public class ListImplementationExtension : IImplementationExtension
|
|
||||||
{
|
|
||||||
public int Priority => 0;
|
|
||||||
public void RegisterServices()
|
|
||||||
{
|
|
||||||
DependencyManager.Instance.RegisterType<IClientStorage, ClientStorage>();
|
|
||||||
DependencyManager.Instance.RegisterType<IComputerStorage, ComputerStorage>();
|
|
||||||
DependencyManager.Instance.RegisterType<IImplementerStorage, ImplementerStorage>();
|
|
||||||
DependencyManager.Instance.RegisterType<IMessageInfoStorage, MessageInfoStorage>();
|
|
||||||
DependencyManager.Instance.RegisterType<IOrderStorage, OrderStorage>();
|
|
||||||
DependencyManager.Instance.RegisterType<IComponentStorage, ComponentStorage>();
|
|
||||||
DependencyManager.Instance.RegisterType<IBackUpInfo, BackUpInfo>();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -23,8 +23,6 @@ namespace ComputersShopListImplement.Models
|
|||||||
|
|
||||||
public string Body { get; private set; } = string.Empty;
|
public string Body { get; private set; } = string.Empty;
|
||||||
|
|
||||||
public int Id => throw new NotImplementedException();
|
|
||||||
|
|
||||||
public static Message? Create(MessageInfoBindingModel model)
|
public static Message? Create(MessageInfoBindingModel model)
|
||||||
{
|
{
|
||||||
if (model == null)
|
if (model == null)
|
||||||
|
@ -1,52 +0,0 @@
|
|||||||
using ComputersShopContracts.Attributes;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace ComputersShopView
|
|
||||||
{
|
|
||||||
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,4 @@
|
|||||||
using ComputersShopBusinessLogic.BusinessLogics;
|
using ComputersShopContracts.BindingModels;
|
||||||
using ComputersShopContracts.BindingModels;
|
|
||||||
using ComputersShopContracts.BusinessLogicContracts;
|
using ComputersShopContracts.BusinessLogicContracts;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using System;
|
using System;
|
||||||
@ -36,7 +35,13 @@ namespace ComputersShopView
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
dataGridView.FillandConfigGrid(_logic.ReadList(null));
|
var list = _logic.ReadList(null);
|
||||||
|
if (list != null)
|
||||||
|
{
|
||||||
|
dataGridView.DataSource = list;
|
||||||
|
dataGridView.Columns["Id"].Visible = false;
|
||||||
|
dataGridView.Columns["ClientFIO"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||||
|
}
|
||||||
_logger.LogInformation("Загрузка клиентов");
|
_logger.LogInformation("Загрузка клиентов");
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
using ComputersShopBusinessLogic.BusinessLogics;
|
using ComputersShopContracts.BindingModels;
|
||||||
using ComputersShopContracts.BindingModels;
|
|
||||||
using ComputersShopContracts.BusinessLogicContracts;
|
using ComputersShopContracts.BusinessLogicContracts;
|
||||||
using ComputersShopContracts.DI;
|
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using Microsoft.VisualBasic.Logging;
|
using Microsoft.VisualBasic.Logging;
|
||||||
using System;
|
using System;
|
||||||
@ -38,7 +36,13 @@ namespace ComputersShopView
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
dataGridView.FillandConfigGrid(_logic.ReadList(null));
|
var list = _logic.ReadList(null);
|
||||||
|
if (list != null)
|
||||||
|
{
|
||||||
|
dataGridView.DataSource = list;
|
||||||
|
dataGridView.Columns["Id"].Visible = false;
|
||||||
|
dataGridView.Columns["ComponentName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||||
|
}
|
||||||
_logger.LogInformation("Загрузка компонентов");
|
_logger.LogInformation("Загрузка компонентов");
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
@ -50,7 +54,7 @@ namespace ComputersShopView
|
|||||||
|
|
||||||
private void ButtonAdd_Click(object sender, EventArgs e)
|
private void ButtonAdd_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
var service = DependencyManager.Instance.Resolve<FormComponent>();
|
var service = 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)
|
||||||
@ -64,7 +68,7 @@ namespace ComputersShopView
|
|||||||
{
|
{
|
||||||
if (dataGridView.SelectedRows.Count == 1)
|
if (dataGridView.SelectedRows.Count == 1)
|
||||||
{
|
{
|
||||||
var service = DependencyManager.Instance.Resolve<FormComponent>();
|
var service = Program.ServiceProvider?.GetService(typeof(FormComponent));
|
||||||
if (service is FormComponent form)
|
if (service is FormComponent form)
|
||||||
{
|
{
|
||||||
form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||||
|
@ -12,7 +12,6 @@ using System.Linq;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
using ComputersShopContracts.DI;
|
|
||||||
|
|
||||||
namespace ComputersShopView
|
namespace ComputersShopView
|
||||||
{
|
{
|
||||||
@ -82,7 +81,7 @@ namespace ComputersShopView
|
|||||||
}
|
}
|
||||||
private void ButtonAdd_Click(object sender, EventArgs e)
|
private void ButtonAdd_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
var service = DependencyManager.Instance.Resolve<FormComputerComponent>();
|
var service = Program.ServiceProvider?.GetService(typeof(FormComputerComponent));
|
||||||
if (service is FormComputerComponent form)
|
if (service is FormComputerComponent form)
|
||||||
{
|
{
|
||||||
if (form.ShowDialog() == DialogResult.OK)
|
if (form.ShowDialog() == DialogResult.OK)
|
||||||
@ -110,7 +109,7 @@ namespace ComputersShopView
|
|||||||
{
|
{
|
||||||
if (dataGridView.SelectedRows.Count == 1)
|
if (dataGridView.SelectedRows.Count == 1)
|
||||||
{
|
{
|
||||||
var service = DependencyManager.Instance.Resolve<FormComputerComponent>();
|
var service = Program.ServiceProvider?.GetService(typeof(FormComputerComponent));
|
||||||
if (service is FormComputerComponent form)
|
if (service is FormComputerComponent form)
|
||||||
{
|
{
|
||||||
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells[0].Value);
|
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells[0].Value);
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
using ComputersShopBusinessLogic.BusinessLogics;
|
using ComputersShopContracts.BindingModels;
|
||||||
using ComputersShopContracts.BindingModels;
|
|
||||||
using ComputersShopContracts.BusinessLogicContracts;
|
using ComputersShopContracts.BusinessLogicContracts;
|
||||||
using ComputersShopContracts.DI;
|
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
@ -36,7 +34,14 @@ namespace ComputersShopView
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
dataGridView.FillandConfigGrid(_logic.ReadList(null));
|
var list = _logic.ReadList(null);
|
||||||
|
if (list != null)
|
||||||
|
{
|
||||||
|
dataGridView.DataSource = list;
|
||||||
|
dataGridView.Columns["Id"].Visible = false;
|
||||||
|
dataGridView.Columns["ComputerName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||||
|
dataGridView.Columns["ComputerComponents"].Visible = false;
|
||||||
|
}
|
||||||
_logger.LogInformation("Загрузка компьютеров");
|
_logger.LogInformation("Загрузка компьютеров");
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
@ -48,7 +53,7 @@ namespace ComputersShopView
|
|||||||
|
|
||||||
private void ButtonAdd_Click(object sender, EventArgs e)
|
private void ButtonAdd_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
var service = DependencyManager.Instance.Resolve<FormComputer>();
|
var service = Program.ServiceProvider?.GetService(typeof(FormComputer));
|
||||||
if (service is FormComputer form)
|
if (service is FormComputer form)
|
||||||
{
|
{
|
||||||
if (form.ShowDialog() == DialogResult.OK)
|
if (form.ShowDialog() == DialogResult.OK)
|
||||||
@ -62,7 +67,7 @@ namespace ComputersShopView
|
|||||||
{
|
{
|
||||||
if (dataGridView.SelectedRows.Count == 1)
|
if (dataGridView.SelectedRows.Count == 1)
|
||||||
{
|
{
|
||||||
var service = DependencyManager.Instance.Resolve<FormComputer>();
|
var service = Program.ServiceProvider?.GetService(typeof(FormComputer));
|
||||||
if (service is FormComputer form)
|
if (service is FormComputer form)
|
||||||
{
|
{
|
||||||
form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
using ComputersShopBusinessLogic.BusinessLogics;
|
using ComputersShopContracts.BindingModels;
|
||||||
using ComputersShopContracts.BindingModels;
|
|
||||||
using ComputersShopContracts.BusinessLogicContracts;
|
using ComputersShopContracts.BusinessLogicContracts;
|
||||||
using ComputersShopContracts.DI;
|
|
||||||
using ComputersShopView;
|
using ComputersShopView;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using System;
|
using System;
|
||||||
@ -35,7 +33,16 @@ namespace ComputersShopView
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
dataGridView.FillandConfigGrid(_logic.ReadList(null));
|
var list = _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["WorkExperience"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||||
|
dataGridView.Columns["Qualification"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||||
|
}
|
||||||
_logger.LogInformation("Загрузка исполнителей");
|
_logger.LogInformation("Загрузка исполнителей");
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
@ -47,7 +54,7 @@ namespace ComputersShopView
|
|||||||
|
|
||||||
private void ButtonAdd_Click(object sender, EventArgs e)
|
private void ButtonAdd_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
var service = DependencyManager.Instance.Resolve<FormImplementer>();
|
var service = Program.ServiceProvider?.GetService(typeof(FormImplementer));
|
||||||
if (service is FormImplementer form)
|
if (service is FormImplementer form)
|
||||||
{
|
{
|
||||||
if (form.ShowDialog() == DialogResult.OK)
|
if (form.ShowDialog() == DialogResult.OK)
|
||||||
@ -61,7 +68,7 @@ namespace ComputersShopView
|
|||||||
{
|
{
|
||||||
if (dataGridView.SelectedRows.Count == 1)
|
if (dataGridView.SelectedRows.Count == 1)
|
||||||
{
|
{
|
||||||
var service = DependencyManager.Instance.Resolve<FormImplementer>();
|
var service = Program.ServiceProvider?.GetService(typeof(FormImplementer));
|
||||||
if (service is FormImplementer form)
|
if (service is FormImplementer form)
|
||||||
{
|
{
|
||||||
form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
using ComputersShopBusinessLogic.BusinessLogics;
|
using ComputersShopContracts.BusinessLogicContracts;
|
||||||
using ComputersShopContracts.BusinessLogicContracts;
|
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
@ -29,7 +28,14 @@ namespace ComputersShopView
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
dataGridView.FillandConfigGrid(_logic.ReadList(null));
|
var list = _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)
|
||||||
|
11
ComputersShop/ComputersShopView/FormMain.Designer.cs
generated
11
ComputersShop/ComputersShopView/FormMain.Designer.cs
generated
@ -40,7 +40,6 @@
|
|||||||
списокЗаказовToolStripMenuItem = new ToolStripMenuItem();
|
списокЗаказовToolStripMenuItem = new ToolStripMenuItem();
|
||||||
запускРаботToolStripMenuItem = new ToolStripMenuItem();
|
запускРаботToolStripMenuItem = new ToolStripMenuItem();
|
||||||
письмаToolStripMenuItem = new ToolStripMenuItem();
|
письмаToolStripMenuItem = new ToolStripMenuItem();
|
||||||
создатьBackupToolStripMenuItem = new ToolStripMenuItem();
|
|
||||||
dataGridView = new DataGridView();
|
dataGridView = new DataGridView();
|
||||||
buttonCreateOrder = new Button();
|
buttonCreateOrder = new Button();
|
||||||
buttonIssuedOrder = new Button();
|
buttonIssuedOrder = new Button();
|
||||||
@ -51,7 +50,7 @@
|
|||||||
//
|
//
|
||||||
// menuStrip
|
// menuStrip
|
||||||
//
|
//
|
||||||
menuStrip.Items.AddRange(new ToolStripItem[] { справочникToolStripMenuItem, отчётыToolStripMenuItem, запускРаботToolStripMenuItem, письмаToolStripMenuItem, создатьBackupToolStripMenuItem });
|
menuStrip.Items.AddRange(new ToolStripItem[] { справочникToolStripMenuItem, отчётыToolStripMenuItem, запускРаботToolStripMenuItem, письмаToolStripMenuItem });
|
||||||
menuStrip.Location = new Point(0, 0);
|
menuStrip.Location = new Point(0, 0);
|
||||||
menuStrip.Name = "menuStrip";
|
menuStrip.Name = "menuStrip";
|
||||||
menuStrip.Size = new Size(1047, 24);
|
menuStrip.Size = new Size(1047, 24);
|
||||||
@ -135,13 +134,6 @@
|
|||||||
письмаToolStripMenuItem.Text = "письма";
|
письмаToolStripMenuItem.Text = "письма";
|
||||||
письмаToolStripMenuItem.Click += MailToolStripMenuItem_Click;
|
письмаToolStripMenuItem.Click += MailToolStripMenuItem_Click;
|
||||||
//
|
//
|
||||||
// создатьBackupToolStripMenuItem
|
|
||||||
//
|
|
||||||
создатьBackupToolStripMenuItem.Name = "создатьBackupToolStripMenuItem";
|
|
||||||
создатьBackupToolStripMenuItem.Size = new Size(102, 20);
|
|
||||||
создатьBackupToolStripMenuItem.Text = "создать backup";
|
|
||||||
создатьBackupToolStripMenuItem.Click += CreateBackupToolStripMenuItem_Click;
|
|
||||||
//
|
|
||||||
// dataGridView
|
// dataGridView
|
||||||
//
|
//
|
||||||
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||||
@ -220,6 +212,5 @@
|
|||||||
private ToolStripMenuItem исполнителиToolStripMenuItem;
|
private ToolStripMenuItem исполнителиToolStripMenuItem;
|
||||||
private ToolStripMenuItem запускРаботToolStripMenuItem;
|
private ToolStripMenuItem запускРаботToolStripMenuItem;
|
||||||
private ToolStripMenuItem письмаToolStripMenuItem;
|
private ToolStripMenuItem письмаToolStripMenuItem;
|
||||||
private ToolStripMenuItem создатьBackupToolStripMenuItem;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,7 +1,6 @@
|
|||||||
using ComputersShopBusinessLogic.BusinessLogics;
|
using ComputersShopBusinessLogic.BusinessLogics;
|
||||||
using ComputersShopContracts.BindingModels;
|
using ComputersShopContracts.BindingModels;
|
||||||
using ComputersShopContracts.BusinessLogicContracts;
|
using ComputersShopContracts.BusinessLogicContracts;
|
||||||
using ComputersShopContracts.DI;
|
|
||||||
using ComputersShopDataModels.Enums;
|
using ComputersShopDataModels.Enums;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using System;
|
using System;
|
||||||
@ -22,16 +21,14 @@ namespace ComputersShopView
|
|||||||
private readonly IOrderLogic _orderLogic;
|
private readonly IOrderLogic _orderLogic;
|
||||||
private readonly IReportLogic _reportLogic;
|
private readonly IReportLogic _reportLogic;
|
||||||
private readonly IWorkProcess _workProcess;
|
private readonly IWorkProcess _workProcess;
|
||||||
private readonly IBackUpLogic _backUpLogic;
|
|
||||||
|
|
||||||
public FormMain(ILogger<FormMain> logger, IOrderLogic orderLogic, IReportLogic reportlogic, IWorkProcess workProcess, IBackUpLogic backUpLogic)
|
public FormMain(ILogger<FormMain> logger, IOrderLogic orderLogic, IReportLogic reportlogic, IWorkProcess workProcess)
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
_orderLogic = orderLogic;
|
_orderLogic = orderLogic;
|
||||||
_reportLogic = reportlogic;
|
_reportLogic = reportlogic;
|
||||||
_workProcess = workProcess;
|
_workProcess = workProcess;
|
||||||
_backUpLogic = backUpLogic;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void FormMain_Load(object sender, EventArgs e)
|
private void FormMain_Load(object sender, EventArgs e)
|
||||||
@ -43,7 +40,14 @@ namespace ComputersShopView
|
|||||||
_logger.LogInformation("Загрузка заказов");
|
_logger.LogInformation("Загрузка заказов");
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
dataGridView.FillandConfigGrid(_orderLogic.ReadList(null));
|
var list = _orderLogic.ReadList(null);
|
||||||
|
if (list != null)
|
||||||
|
{
|
||||||
|
dataGridView.DataSource = list;
|
||||||
|
dataGridView.Columns["ComputerId"].Visible = false;
|
||||||
|
dataGridView.Columns["ClientId"].Visible = false;
|
||||||
|
dataGridView.Columns["ImplementerId"].Visible = false;
|
||||||
|
}
|
||||||
_logger.LogInformation("Загрузка заказов");
|
_logger.LogInformation("Загрузка заказов");
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
@ -54,7 +58,7 @@ namespace ComputersShopView
|
|||||||
}
|
}
|
||||||
private void ComponentsToolStripMenuItem_Click(object sender, EventArgs e)
|
private void ComponentsToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
var service = DependencyManager.Instance.Resolve<FormComponents>();
|
var service = Program.ServiceProvider?.GetService(typeof(FormComponents));
|
||||||
if (service is FormComponents form)
|
if (service is FormComponents form)
|
||||||
{
|
{
|
||||||
form.ShowDialog();
|
form.ShowDialog();
|
||||||
@ -62,7 +66,7 @@ namespace ComputersShopView
|
|||||||
}
|
}
|
||||||
private void ComputersToolStripMenuItem_Click(object sender, EventArgs e)
|
private void ComputersToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
var service = DependencyManager.Instance.Resolve<FormComputers>();
|
var service = Program.ServiceProvider?.GetService(typeof(FormComputers));
|
||||||
if (service is FormComputers form)
|
if (service is FormComputers form)
|
||||||
{
|
{
|
||||||
form.ShowDialog();
|
form.ShowDialog();
|
||||||
@ -70,7 +74,7 @@ namespace ComputersShopView
|
|||||||
}
|
}
|
||||||
private void ButtonCreateOrder_Click(object sender, EventArgs e)
|
private void ButtonCreateOrder_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
var service = DependencyManager.Instance.Resolve<FormCreateOrder>();
|
var service = Program.ServiceProvider?.GetService(typeof(FormCreateOrder));
|
||||||
if (service is FormCreateOrder form)
|
if (service is FormCreateOrder form)
|
||||||
{
|
{
|
||||||
form.ShowDialog();
|
form.ShowDialog();
|
||||||
@ -182,7 +186,7 @@ namespace ComputersShopView
|
|||||||
|
|
||||||
private void ComputerComponentsToolStripMenuItem_Click(object sender, EventArgs e)
|
private void ComputerComponentsToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
var service = DependencyManager.Instance.Resolve<FormReportComputerComponents>();
|
var service = Program.ServiceProvider?.GetService(typeof(FormReportComputerComponents));
|
||||||
if (service is FormReportComputerComponents form)
|
if (service is FormReportComputerComponents form)
|
||||||
{
|
{
|
||||||
form.ShowDialog();
|
form.ShowDialog();
|
||||||
@ -191,7 +195,7 @@ namespace ComputersShopView
|
|||||||
|
|
||||||
private void OrdersToolStripMenuItem_Click(object sender, EventArgs e)
|
private void OrdersToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
var service = DependencyManager.Instance.Resolve<FormReportOrders>();
|
var service = Program.ServiceProvider?.GetService(typeof(FormReportOrders));
|
||||||
if (service is FormReportOrders form)
|
if (service is FormReportOrders form)
|
||||||
{
|
{
|
||||||
form.ShowDialog();
|
form.ShowDialog();
|
||||||
@ -200,7 +204,7 @@ namespace ComputersShopView
|
|||||||
|
|
||||||
private void ClientsToolStripMenuItem_Click(object sender, EventArgs e)
|
private void ClientsToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
var service = DependencyManager.Instance.Resolve<FormClients>();
|
var service = Program.ServiceProvider?.GetService(typeof(FormClients));
|
||||||
if (service is FormClients form)
|
if (service is FormClients form)
|
||||||
{
|
{
|
||||||
form.ShowDialog();
|
form.ShowDialog();
|
||||||
@ -209,7 +213,7 @@ namespace ComputersShopView
|
|||||||
|
|
||||||
private void ImplementersToolStripMenuItem_Click(object sender, EventArgs e)
|
private void ImplementersToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
var service = DependencyManager.Instance.Resolve<FormImplementers>();
|
var service = Program.ServiceProvider?.GetService(typeof(FormImplementers));
|
||||||
if (service is FormImplementers form)
|
if (service is FormImplementers form)
|
||||||
{
|
{
|
||||||
form.ShowDialog();
|
form.ShowDialog();
|
||||||
@ -218,8 +222,8 @@ namespace ComputersShopView
|
|||||||
|
|
||||||
private void DoWorkToolStripMenuItem_Click(object sender, EventArgs e)
|
private void DoWorkToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
_workProcess.DoWork(
|
_workProcess.DoWork((
|
||||||
DependencyManager.Instance.Resolve<IImplementerLogic>(),
|
Program.ServiceProvider?.GetService(typeof(IImplementerLogic)) as IImplementerLogic)!,
|
||||||
_orderLogic);
|
_orderLogic);
|
||||||
MessageBox.Show("Процесс обработки запущен", "Сообщение",
|
MessageBox.Show("Процесс обработки запущен", "Сообщение",
|
||||||
MessageBoxButtons.OK, MessageBoxIcon.Information);
|
MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||||
@ -227,7 +231,7 @@ namespace ComputersShopView
|
|||||||
|
|
||||||
private void MailToolStripMenuItem_Click(object sender, EventArgs e)
|
private void MailToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
var service = DependencyManager.Instance.Resolve<FormMails>();
|
var service = Program.ServiceProvider?.GetService(typeof(FormMails));
|
||||||
if (service is FormMails form)
|
if (service is FormMails form)
|
||||||
{
|
{
|
||||||
form.ShowDialog();
|
form.ShowDialog();
|
||||||
@ -238,31 +242,5 @@ namespace ComputersShopView
|
|||||||
{
|
{
|
||||||
LoadData();
|
LoadData();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void CreateBackupToolStripMenuItem_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
if (_backUpLogic != null)
|
|
||||||
{
|
|
||||||
var fbd = new FolderBrowserDialog();
|
|
||||||
if (fbd.ShowDialog() == DialogResult.OK)
|
|
||||||
{
|
|
||||||
_backUpLogic.CreateBackUp(new BackUpSaveBinidngModel
|
|
||||||
{
|
|
||||||
FolderName = fbd.SelectedPath
|
|
||||||
});
|
|
||||||
MessageBox.Show("Бекап создан", "Сообщение",
|
|
||||||
MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
|
|
||||||
MessageBoxIcon.Error);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,12 +9,13 @@ using Microsoft.Extensions.Logging;
|
|||||||
using NLog.Extensions.Logging;
|
using NLog.Extensions.Logging;
|
||||||
using ComputersShopBusinessLogic.MailWorker;
|
using ComputersShopBusinessLogic.MailWorker;
|
||||||
using ComputersShopContracts.BindingModels;
|
using ComputersShopContracts.BindingModels;
|
||||||
using ComputersShopContracts.DI;
|
|
||||||
|
|
||||||
namespace ComputersShopView
|
namespace ComputersShopView
|
||||||
{
|
{
|
||||||
internal static class Program
|
internal static class Program
|
||||||
{
|
{
|
||||||
|
private static ServiceProvider? _serviceProvider;
|
||||||
|
public static ServiceProvider? ServiceProvider => _serviceProvider;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The main entry point for the application.
|
/// The main entry point for the application.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -24,10 +25,12 @@ namespace ComputersShopView
|
|||||||
// To customize application configuration such as set high DPI settings or default font,
|
// To customize application configuration such as set high DPI settings or default font,
|
||||||
// see https://aka.ms/applicationconfiguration.
|
// see https://aka.ms/applicationconfiguration.
|
||||||
ApplicationConfiguration.Initialize();
|
ApplicationConfiguration.Initialize();
|
||||||
InitDependency();
|
var services = new ServiceCollection();
|
||||||
|
ConfigureServices(services);
|
||||||
|
_serviceProvider = services.BuildServiceProvider();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var mailSender = DependencyManager.Instance.Resolve<AbstractMailWorker>();
|
var mailSender = _serviceProvider.GetService<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,
|
||||||
@ -42,13 +45,13 @@ namespace ComputersShopView
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
var logger = DependencyManager.Instance.Resolve<ILogger>();
|
var logger = _serviceProvider.GetService<ILogger>();
|
||||||
logger?.LogError(ex, "Error");
|
logger?.LogError(ex, "Error");
|
||||||
}
|
}
|
||||||
Application.Run(DependencyManager.Instance.Resolve<FormMain>());
|
Application.Run(_serviceProvider.GetRequiredService<FormMain>());
|
||||||
}
|
}
|
||||||
|
|
||||||
/*private static void ConfigureServices(ServiceCollection services)
|
private static void ConfigureServices(ServiceCollection services)
|
||||||
{
|
{
|
||||||
services.AddLogging(option =>
|
services.AddLogging(option =>
|
||||||
{
|
{
|
||||||
@ -61,7 +64,6 @@ namespace ComputersShopView
|
|||||||
services.AddTransient<IClientStorage, ClientStorage>();
|
services.AddTransient<IClientStorage, ClientStorage>();
|
||||||
services.AddTransient<IImplementerStorage, ImplementerStorage>();
|
services.AddTransient<IImplementerStorage, ImplementerStorage>();
|
||||||
services.AddTransient<IMessageInfoStorage, MessageInfoStorage>();
|
services.AddTransient<IMessageInfoStorage, MessageInfoStorage>();
|
||||||
services.AddTransient<IBackUpInfo, BackUpInfo>();
|
|
||||||
|
|
||||||
services.AddTransient<IComponentLogic, ComponentLogic>();
|
services.AddTransient<IComponentLogic, ComponentLogic>();
|
||||||
services.AddTransient<IComputerLogic, ComputerLogic>();
|
services.AddTransient<IComputerLogic, ComputerLogic>();
|
||||||
@ -71,7 +73,6 @@ namespace ComputersShopView
|
|||||||
services.AddTransient<IImplementerLogic, ImplementerLogic>();
|
services.AddTransient<IImplementerLogic, ImplementerLogic>();
|
||||||
services.AddTransient<IWorkProcess, WorkModeling>();
|
services.AddTransient<IWorkProcess, WorkModeling>();
|
||||||
services.AddTransient<IMessageInfoLogic, MessageInfoLogic>();
|
services.AddTransient<IMessageInfoLogic, MessageInfoLogic>();
|
||||||
services.AddTransient<IBackUpLogic, BackUpLogic>();
|
|
||||||
|
|
||||||
services.AddTransient<AbstractSaveToWord, SaveToWord>();
|
services.AddTransient<AbstractSaveToWord, SaveToWord>();
|
||||||
services.AddTransient<AbstractSaveToExcel, SaveToExcel>();
|
services.AddTransient<AbstractSaveToExcel, SaveToExcel>();
|
||||||
@ -91,43 +92,7 @@ namespace ComputersShopView
|
|||||||
services.AddTransient<FormImplementer>();
|
services.AddTransient<FormImplementer>();
|
||||||
services.AddTransient<FormImplementers>();
|
services.AddTransient<FormImplementers>();
|
||||||
services.AddTransient<FormMails>();
|
services.AddTransient<FormMails>();
|
||||||
}*/
|
|
||||||
|
|
||||||
private static void InitDependency()
|
|
||||||
{
|
|
||||||
DependencyManager.InitDependency();
|
|
||||||
DependencyManager.Instance.AddLogging(option =>
|
|
||||||
{
|
|
||||||
option.SetMinimumLevel(LogLevel.Information);
|
|
||||||
option.AddNLog("nlog.config");
|
|
||||||
});
|
|
||||||
DependencyManager.Instance.RegisterType<IComponentLogic, ComponentLogic>();
|
|
||||||
DependencyManager.Instance.RegisterType<IOrderLogic, OrderLogic>();
|
|
||||||
DependencyManager.Instance.RegisterType<IComputerLogic, ComputerLogic>();
|
|
||||||
DependencyManager.Instance.RegisterType<IReportLogic, ReportLogic>();
|
|
||||||
DependencyManager.Instance.RegisterType<IClientLogic, ClientLogic>();
|
|
||||||
DependencyManager.Instance.RegisterType<IImplementerLogic, ImplementerLogic>();
|
|
||||||
DependencyManager.Instance.RegisterType<IMessageInfoLogic, MessageInfoLogic>();
|
|
||||||
DependencyManager.Instance.RegisterType<AbstractSaveToExcel, SaveToExcel>();
|
|
||||||
DependencyManager.Instance.RegisterType<AbstractSaveToWord, SaveToWord>();
|
|
||||||
DependencyManager.Instance.RegisterType<AbstractSaveToPdf, SaveToPdf>();
|
|
||||||
DependencyManager.Instance.RegisterType<IWorkProcess, WorkModeling>();
|
|
||||||
DependencyManager.Instance.RegisterType<AbstractMailWorker, MailKitWorker>(true);
|
|
||||||
DependencyManager.Instance.RegisterType<IBackUpLogic, BackUpLogic>();
|
|
||||||
DependencyManager.Instance.RegisterType<FormMain>();
|
|
||||||
DependencyManager.Instance.RegisterType<FormComponent>();
|
|
||||||
DependencyManager.Instance.RegisterType<FormComponents>();
|
|
||||||
DependencyManager.Instance.RegisterType<FormComputers>();
|
|
||||||
DependencyManager.Instance.RegisterType<FormCreateOrder>();
|
|
||||||
DependencyManager.Instance.RegisterType<FormComputer>();
|
|
||||||
DependencyManager.Instance.RegisterType<FormComputerComponent>();
|
|
||||||
DependencyManager.Instance.RegisterType<FormReportComputerComponents>();
|
|
||||||
DependencyManager.Instance.RegisterType<FormReportOrders>();
|
|
||||||
DependencyManager.Instance.RegisterType<FormClients>();
|
|
||||||
DependencyManager.Instance.RegisterType<FormImplementer>();
|
|
||||||
DependencyManager.Instance.RegisterType<FormImplementers>();
|
|
||||||
DependencyManager.Instance.RegisterType<FormMails>();
|
|
||||||
}
|
}
|
||||||
private static void MailCheck(object obj) => DependencyManager.Instance.Resolve<AbstractMailWorker>()?.MailCheck();
|
private static void MailCheck(object obj) => ServiceProvider?.GetService<AbstractMailWorker>()?.MailCheck();
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user