This commit is contained in:
VictoriaPresnyakova 2023-05-02 14:50:43 +04:00
parent 50ce8a61b1
commit 7a1e2a6849
26 changed files with 439 additions and 261 deletions

View File

@ -32,25 +32,18 @@ namespace JewelryStore
} }
private void LoadData() private void LoadData()
{ {
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; catch (Exception ex)
dataGridView.Columns["ComponentName"].AutoSizeMode = {
DataGridViewAutoSizeColumnMode.Fill; _logger.LogError(ex, "Ошибка загрузки компонентов");
} MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
_logger.LogInformation("Загрузка компонентов"); }
} }
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка загрузки компонентов");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
MessageBoxIcon.Error);
}
}
private void buttonAdd_Click(object sender, EventArgs e) private void buttonAdd_Click(object sender, EventArgs e)
{ {

View File

@ -96,25 +96,17 @@ namespace JewelryStore
private void LoadData() private void LoadData()
{ {
try try
{ {
var list = _logic.ReadList(null); dataGridView.FillAndConfigGrid(_logic.ReadList(null));
_logger.LogInformation("Загрузка исполнителей");
if (list != null) }
{ catch (Exception ex)
DataGridView.DataSource = list; {
DataGridView.Columns["Id"].Visible = false; _logger.LogError(ex, "Ошибка загрузки исполнителей");
DataGridView.Columns["ImplementerFIO"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
} MessageBoxIcon.Error);
}
_logger.LogInformation("Загрузка исполнителей"); }
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка загрузки исполнителей");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
} }
} }

View File

@ -27,28 +27,18 @@ namespace JewelryStore
private void LoadData() private void LoadData()
{ {
try try
{ {
var list = _logic.ReadList(null); DataGridView.FillAndConfigGrid(_logic.ReadList(null));
_logger.LogInformation("Загрузка изделий");
if (list != null) }
{ catch (Exception ex)
DataGridView.DataSource = list; {
DataGridView.Columns["Id"].Visible = false; _logger.LogError(ex, "Ошибка загрузки изделий");
DataGridView.Columns["JewelName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
DataGridView.Columns["JewelComponents"].Visible = false; }
}
}
_logger.LogInformation("Загрузка компонентов");
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка загрузки компонентов");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void AddButton_Click(object sender, EventArgs e) private void AddButton_Click(object sender, EventArgs e)
{ {

View File

@ -29,15 +29,8 @@ namespace JewelryStore
{ {
try try
{ {
var list = _logic.ReadList(null); dataGridView.FillAndConfigGrid(_logic.ReadList(null));
if (list != null) _logger.LogInformation("Загрузка списка писем");
{
DataGridView.DataSource = list;
DataGridView.Columns["ClientId"].Visible = false;
DataGridView.Columns["MessageId"].Visible = false;
DataGridView.Columns["Body"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
}
_logger.LogInformation("Загрузка писем");
} }
catch (Exception ex) catch (Exception ex)
{ {

View File

@ -42,27 +42,18 @@ namespace JewelryStore
} }
private void LoadData() private void LoadData()
{ {
_logger.LogInformation("Загрузка заказов"); try
try {
{ DataGridView.FillAndConfigGrid(_orderLogic.ReadList(null));
var list = _orderLogic.ReadList(null); _logger.LogInformation("Загрузка заказов");
}
if (list != null) catch (Exception ex)
{ {
dataGridView.DataSource = list; _logger.LogError(ex, "Ошибка загрузки заказов");
dataGridView.Columns["JewelId"].Visible = false; MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
dataGridView.Columns["ClientId"].Visible = false; MessageBoxIcon.Error);
dataGridView.Columns["ImplementerId"].Visible = false; }
} }
_logger.LogInformation("Загрузка заказов");
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка загрузки заказов");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void компонентыToolStripMenuItem_Click(object sender, EventArgs e) private void компонентыToolStripMenuItem_Click(object sender, EventArgs e)
{ {

View File

@ -11,95 +11,83 @@ using JewelryStoreBusinessLogic.OfficePackage;
using JewelryStoreBusinessLogic.OfficePackage.Implements; using JewelryStoreBusinessLogic.OfficePackage.Implements;
using JewelryStoreBusinessLogic.MailWorker; using JewelryStoreBusinessLogic.MailWorker;
using JewelryStoreContracts.BindingModels; using JewelryStoreContracts.BindingModels;
using JewelryStoreContracts.DI;
namespace JewelryStore namespace JewelryStore
{ {
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>
[STAThread] [STAThread]
static void Main() static void Main()
{ {
// To customize application configuration such as set high DPI ApplicationConfiguration.Initialize();
//settings or default font, InitDependency();
// see https://aka.ms/applicationconfiguration. try
ApplicationConfiguration.Initialize(); {
var services = new ServiceCollection(); var mailSender = DependencyManager.Instance.Resolve<AbstractMailWorker>(); mailSender?.MailConfig(new MailConfigBindingModel
ConfigureServices(services); {
_serviceProvider = services.BuildServiceProvider(); MailLogin = System.Configuration.ConfigurationManager.AppSettings["MailLogin"] ?? string.Empty,
try MailPassword = System.Configuration.ConfigurationManager.AppSettings["MailPassword"] ?? string.Empty,
{ SmtpClientHost = System.Configuration.ConfigurationManager.AppSettings["SmtpClientHost"] ?? string.Empty,
var mailSender = _serviceProvider.GetService<AbstractMailWorker>(); SmtpClientPort = Convert.ToInt32(System.Configuration.ConfigurationManager.AppSettings["SmtpClientPort"]),
mailSender?.MailConfig(new MailConfigBindingModel PopHost = System.Configuration.ConfigurationManager.AppSettings["PopHost"] ?? string.Empty,
{ PopPort = Convert.ToInt32(System.Configuration.ConfigurationManager.AppSettings["PopPort"])
MailLogin = System.Configuration.ConfigurationManager.AppSettings["MailLogin"] ?? string.Empty, });
MailPassword = System.Configuration.ConfigurationManager.AppSettings["MailPassword"] ?? string.Empty,
SmtpClientHost = System.Configuration.ConfigurationManager.AppSettings["SmtpClientHost"] ?? string.Empty,
SmtpClientPort = Convert.ToInt32(System.Configuration.ConfigurationManager.AppSettings["SmtpClientPort"]),
PopHost = System.Configuration.ConfigurationManager.AppSettings["PopHost"] ?? string.Empty,
PopPort = Convert.ToInt32(System.Configuration.ConfigurationManager.AppSettings["PopPort"])
});
// ñîçäàåì òàéìåð var timer = new System.Threading.Timer(new TimerCallback(MailCheck!), null, 0, 100000);
var timer = new System.Threading.Timer(new TimerCallback(MailCheck!), null, 0, 100000); }
} catch (Exception ex)
catch (Exception ex) {
{ var logger = DependencyManager.Instance.Resolve<ILogger>();
var logger = _serviceProvider.GetService<ILogger>(); logger?.LogError(ex, "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
logger?.LogError(ex, "Îøèáêà ðàáîòû ñ ïî÷òîé"); }
}
Application.Run(_serviceProvider.GetRequiredService<FormMain>());
}
private static void ConfigureServices(ServiceCollection services)
{
services.AddLogging(option =>
{
option.SetMinimumLevel(LogLevel.Information);
option.AddNLog("nlog.config");
});
services.AddTransient<IComponentStorage, ComponentStorage>();
services.AddTransient<IOrderStorage, OrderStorage>();
services.AddTransient<IJewelStorage, JewelStorage>();
services.AddTransient<IClientStorage, ClientStorage>();
services.AddTransient<IImplementerStorage, ImplementerStorage>();
services.AddTransient<IMessageInfoStorage, MessageInfoStorage>();
Application.Run(DependencyManager.Instance.Resolve<FormMain>());
}
services.AddTransient<IWorkProcess, WorkModeling>(); private static void InitDependency()
services.AddSingleton<AbstractMailWorker, MailKitWorker>(); {
DependencyManager.InitDependency();
services.AddTransient<IComponentLogic, ComponentLogic>(); DependencyManager.Instance.AddLogging(option =>
services.AddTransient<IOrderLogic, OrderLogic>(); {
services.AddTransient<IJewelLogic, JewelLogic>(); option.SetMinimumLevel(LogLevel.Information);
services.AddTransient<IClientLogic, ClientLogic>(); option.AddNLog("nlog.config");
services.AddTransient<IReportLogic, ReportLogic>(); });
services.AddTransient<IImplementerLogic, ImplementerLogic>(); DependencyManager.Instance.RegisterType<IComponentLogic, ComponentLogic>();
services.AddTransient<IMessageInfoLogic, MessageInfoLogic>(); DependencyManager.Instance.RegisterType<IOrderLogic, OrderLogic>();
services.AddTransient<IBackUpLogic, BackUpLogic>(); DependencyManager.Instance.RegisterType<IJewelLogic, JewelLogic>();
DependencyManager.Instance.RegisterType<IReportLogic, ReportLogic>();
DependencyManager.Instance.RegisterType<IClientLogic, ClientLogic>();
DependencyManager.Instance.RegisterType<IImplementerLogic, ImplementerLogic>();
DependencyManager.Instance.RegisterType<IMessageInfoLogic, MessageInfoLogic>();
DependencyManager.Instance.RegisterType<IWorkProcess, WorkModeling>();
DependencyManager.Instance.RegisterType<IBackUpLogic, BackUpLogic>();
DependencyManager.Instance.RegisterType<AbstractMailWorker, MailKitWorker>(true);
services.AddTransient<AbstractSaveToExcel, SaveToExcel>(); DependencyManager.Instance.RegisterType<AbstractSaveToExcel, SaveToExcel>();
services.AddTransient<AbstractSaveToWord, SaveToWord>(); DependencyManager.Instance.RegisterType<AbstractSaveToWord, SaveToWord>();
services.AddTransient<AbstractSaveToPdf, SaveToPdf>(); DependencyManager.Instance.RegisterType<AbstractSaveToPdf, SaveToPdf>();
services.AddTransient<FormMain>(); DependencyManager.Instance.RegisterType<FormMain>();
services.AddTransient<FormComponent>(); DependencyManager.Instance.RegisterType<FormComponent>();
services.AddTransient<FormComponents>(); DependencyManager.Instance.RegisterType<FormComponents>();
services.AddTransient<FormCreateOrder>(); DependencyManager.Instance.RegisterType<FormCreateOrder>();
services.AddTransient<FormJewel>(); DependencyManager.Instance.RegisterType<FormJewel>();
services.AddTransient<FormJewelComponent>(); DependencyManager.Instance.RegisterType<FormJewelComponent>();
services.AddTransient<FormJewels>(); DependencyManager.Instance.RegisterType<FormJewels>();
services.AddTransient<FormReportJewelComponents>(); DependencyManager.Instance.RegisterType<FormReportJewelComponents>();
services.AddTransient<FormReportOrders>(); DependencyManager.Instance.RegisterType<FormReportOrders>();
services.AddTransient<FormClients>(); DependencyManager.Instance.RegisterType<FormClients>();
services.AddTransient<FormImplementer>(); DependencyManager.Instance.RegisterType<FormImplementers>();
services.AddTransient<FormImplementers>(); DependencyManager.Instance.RegisterType<FormImplementer>();
services.AddTransient<FormMails>(); DependencyManager.Instance.RegisterType<FormMails>();
} }
private static void MailCheck(object obj) => ServiceProvider?.GetService<AbstractMailWorker>()?.MailCheck(); private static void MailCheck(object obj) => DependencyManager.Instance.Resolve<AbstractMailWorker>()?.MailCheck();
} }
} }

View File

@ -0,0 +1,62 @@
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 JewelryStoreContracts.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>()!;
}
}
}

View File

@ -0,0 +1,42 @@
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 JewelryStoreContracts.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);
}
}
}

View File

@ -9,6 +9,7 @@
<ItemGroup> <ItemGroup>
<PackageReference Include="Microsoft.Extensions.Logging" Version="7.0.0" /> <PackageReference Include="Microsoft.Extensions.Logging" Version="7.0.0" />
<PackageReference Include="PdfSharp.MigraDoc.Standard" Version="1.51.15" /> <PackageReference Include="PdfSharp.MigraDoc.Standard" Version="1.51.15" />
<PackageReference Include="Unity" Version="5.11.10" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

View File

@ -1,4 +1,5 @@
using JewelryStoreDataModels.Models; using JewelryStoreContracts.Attributes;
using JewelryStoreDataModels.Models;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel; using System.ComponentModel;
@ -10,9 +11,13 @@ namespace JewelryStoreContracts.ViewModels
{ {
public class ClientViewModel : IClientModel public class ClientViewModel : IClientModel
{ {
public int Id { get; set; } [Column(visible: false)]
public string ClientFIO { get; set; } = string.Empty; public int Id { get; set; }
public string Email { get; set; } = string.Empty; [Column("ФИО клиента", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)]
public string Password { get; set; } = string.Empty; public string ClientFIO { get; set; } = string.Empty;
[Column("Логин (эл. почта)", width: 150)]
public string Email { get; set; } = string.Empty;
[Column("Пароль", width: 150)]
public string Password { get; set; } = string.Empty;
} }
} }

View File

@ -1,4 +1,5 @@
using JewelryStoreDataModels.Models; using JewelryStoreContracts.Attributes;
using JewelryStoreDataModels.Models;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel; using System.ComponentModel;
@ -10,10 +11,11 @@ namespace JewelryStoreContracts.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("Название компонента", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)]
[DisplayName("Цена")] public string ComponentName { get; set; } = string.Empty;
public double Cost { get; set; } [Column("Цена", width: 80)]
public double Cost { get; set; }
} }
} }

View File

@ -1,4 +1,5 @@
using JewelryStoreDataModels.Models; using JewelryStoreContracts.Attributes;
using JewelryStoreDataModels.Models;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel; using System.ComponentModel;
@ -10,18 +11,16 @@ namespace JewelryStoreContracts.ViewModels
{ {
public class ImplementerViewModel : IImplementerModel public class ImplementerViewModel : IImplementerModel
{ {
public int Id { get; set; } [Column(visible: false)]
public int Id { get; set; }
[Column("ФИО исполнителя", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)]
public string ImplementerFIO { get; set; } = string.Empty;
[Column("Пароль", width: 150)]
[DisplayName("ФИО исполнителя")] public string Password { get; set; } = string.Empty;
public string ImplementerFIO { get; set; } = string.Empty; [Column("Стаж работы", gridViewAutoSize: GridViewAutoSize.AllCells, isUseAutoSize: true)]
public int WorkExperience { get; set; }
[DisplayName("Пароль")] [Column("Квалификация", gridViewAutoSize: GridViewAutoSize.AllCells, isUseAutoSize: true)]
public string Password { get; set; } = string.Empty; public int Qualification { get; set; }
[DisplayName("Стаж работы")]
public int WorkExperience { get; set; }
[DisplayName("Квалификация")]
public int Qualification { get; set; }
} }
} }

View File

@ -11,9 +11,7 @@ namespace JewelryStoreContracts.ViewModels
public class JewelViewModel : IJewelModel public class JewelViewModel : IJewelModel
{ {
public int Id { get; set; } public int Id { get; set; }
[DisplayName("Название драгоценности")]
public string JewelName { get; set; } = string.Empty; public string JewelName { get; set; } = string.Empty;
[DisplayName("Цена")]
public double Price { get; set; } public double Price { get; set; }
public Dictionary<int, (IComponentModel, int)> JewelComponents public Dictionary<int, (IComponentModel, int)> JewelComponents
{ {

View File

@ -1,4 +1,5 @@
using JewelryStoreDataModels.Models; using JewelryStoreContracts.Attributes;
using JewelryStoreDataModels.Models;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel; using System.ComponentModel;
@ -10,20 +11,17 @@ namespace JewelryStoreContracts.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("Заголовок", width: 150)]
[DisplayName("Тема")]
public string Subject { get; set; } = string.Empty; public string Subject { get; set; } = string.Empty;
[Column("Текст", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)]
[DisplayName("Содержание")]
public string Body { get; set; } = string.Empty; public string Body { get; set; } = string.Empty;
} }
} }

View File

@ -1,4 +1,5 @@
using JewelryStoreDataModels.Enums; using JewelryStoreContracts.Attributes;
using JewelryStoreDataModels.Enums;
using JewelryStoreDataModels.Models; using JewelryStoreDataModels.Models;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@ -11,32 +12,32 @@ namespace JewelryStoreContracts.ViewModels
{ {
public class OrderViewModel : IOrderModel public class OrderViewModel : IOrderModel
{ {
[DisplayName("Номер")]
public int Id { get; set; }
public int JewelId { get; set; }
public int ClientId { get; set; }
[DisplayName("Драгоценность")] [Column("Номер", gridViewAutoSize: GridViewAutoSize.AllCells, isUseAutoSize: true)]
public string JewelName { get; set; } = string.Empty; public int Id { get; set; }
[DisplayName("ФИО исполнителя")] [Column(visible: false)]
public string ImplementerFIO { get; set; } = string.Empty; public int JewelId { get; set; }
[Column(visible: false)]
[DisplayName("Клиент")] public int ClientId { get; set; }
public string ClientFIO { get; set; } = string.Empty; [Column("Изделие", gridViewAutoSize: GridViewAutoSize.AllCells, isUseAutoSize: true)]
public string JewelName { get; set; } = string.Empty;
[DisplayName("Количество")] [Column("Фамилия исполнителя", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)]
public int Count { get; set; } public string ImplementerFIO { get; set; } = string.Empty;
[Column("Фамилия клиента", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)]
[DisplayName("Сумма")] public string ClientFIO { get; set; } = string.Empty;
public double Sum { get; set; } [Column("Количество", gridViewAutoSize: GridViewAutoSize.AllCells, isUseAutoSize: true)]
[DisplayName("Статус")] public int Count { get; set; }
public OrderStatus Status { get; set; } = OrderStatus.Неизвестен; [Column("Сумма", gridViewAutoSize: GridViewAutoSize.AllCells, isUseAutoSize: true)]
[DisplayName("Дата создания")] public double Sum { get; set; }
public DateTime DateCreate { get; set; } = DateTime.Now; [Column("Статус", gridViewAutoSize: GridViewAutoSize.AllCells, isUseAutoSize: true)]
[DisplayName("Дата выполнения")] public OrderStatus Status { get; set; } = OrderStatus.Неизвестен;
public DateTime? DateImplement { get; set; } [Column("Дата создания", width: 100)]
public int? ImplementerId { get; set; } public DateTime DateCreate { get; set; } = DateTime.Now;
[Column("Дата выполнения", width: 100)]
public DateTime? DateImplement { get; set; }
[Column(visible: false)]
public int? ImplementerId { get; set; }
} }

View File

@ -0,0 +1,28 @@
using JewelryStoreContracts.DI;
using JewelryStoreContracts.StoragesContracts;
using JewelryStoreDatabaseImplement.Implements;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace JewelryStoreDatabaseImplement
{
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<IJewelStorage, JewelStorage>();
DependencyManager.Instance.RegisterType<IBackUpInfo, BackUpInfo>();
}
}
}

View File

@ -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 JewelryStoreDatabaseImplement.Models namespace JewelryStoreDatabaseImplement.Models
{ {
public class Client : IClientModel [DataContract]
public class Client : IClientModel
{ {
public int Id { get; private set; } [DataMember]
public int Id { get; private set; }
[Required] [Required]
public string ClientFIO { get; set; } = string.Empty; [DataMember]
public string ClientFIO { get; set; } = string.Empty;
[Required] [Required]
public string Email { get; set; } = string.Empty; [DataMember]
public string Email { get; set; } = string.Empty;
[Required] [Required]
public string Password { get; set; } = string.Empty; [DataMember]
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();

View File

@ -4,18 +4,24 @@ using JewelryStoreDatabaseImplement.Models;
using JewelryStoreDataModels.Models; using JewelryStoreDataModels.Models;
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema; using System.ComponentModel.DataAnnotations.Schema;
using System.Runtime.Serialization;
namespace JewelryStoreDatabaseImplement.Models namespace JewelryStoreDatabaseImplement.Models
{ {
public class Component : IComponentModel [DataContract]
public class Component : IComponentModel
{ {
public int Id { get; private set; } [DataMember]
public int Id { get; private set; }
[Required] [Required]
public string ComponentName { get; private set; } = string.Empty; [DataMember]
public string ComponentName { get; private set; } = string.Empty;
[Required] [Required]
public double Cost { get; set; } [DataMember]
public double Cost { get; set; }
[ForeignKey("ComponentId")] [ForeignKey("ComponentId")]
public virtual List<JewelComponent> JewelComponents { get; set; } = new(); public virtual List<JewelComponent> JewelComponents { get; set; } = new();

View File

@ -8,24 +8,32 @@ 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 JewelryStoreDatabaseImplement.Models namespace JewelryStoreDatabaseImplement.Models
{ {
public class Implementer : IImplementerModel [DataContract]
public class Implementer : IImplementerModel
{ {
[Required] [Required]
public string ImplementerFIO { get; private set; } = string.Empty; [DataMember]
public string ImplementerFIO { get; private set; } = string.Empty;
[Required] [Required]
public string Password { get; private set; } = string.Empty; [DataMember]
public string Password { get; private set; } = string.Empty;
[Required] [Required]
public int WorkExperience { get; private set; } [DataMember]
public int WorkExperience { get; private set; }
[Required] [Required]
public int Qualification { get; private set; } [DataMember]
public int Qualification { get; private set; }
public int Id { get; private set; } [DataMember]
public int Id { get; private set; }
[ForeignKey("ImplementerId")] [ForeignKey("ImplementerId")]
public virtual List<Order> Orders { get; private set; } = new(); public virtual List<Order> Orders { get; private set; } = new();

View File

@ -8,23 +8,30 @@ 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 JewelryStoreDatabaseImplement.Models namespace JewelryStoreDatabaseImplement.Models
{ {
public class Jewel : IJewelModel [DataContract]
public class Jewel : IJewelModel
{ {
public int Id { get; set; } [DataMember]
public int Id { get; set; }
[Required] [Required]
public string JewelName { get; set; } = string.Empty; [DataMember]
public string JewelName { get; set; } = string.Empty;
[Required] [Required]
public double Price { get; set; } [DataMember]
public double Price { get; set; }
private Dictionary<int, (IComponentModel, int)>? _jewelComponents = null; private Dictionary<int, (IComponentModel, int)>? _jewelComponents = null;
[NotMapped] [NotMapped]
public Dictionary<int, (IComponentModel, int)> JewelComponents [DataMember]
public Dictionary<int, (IComponentModel, int)> JewelComponents
{ {
get get
{ {

View File

@ -2,23 +2,30 @@
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 JewelryStoreDatabaseImplement.Models namespace JewelryStoreDatabaseImplement.Models
{ {
public class JewelComponent [DataContract]
public class JewelComponent
{ {
public int Id { get; set; } [DataMember]
public int Id { get; set; }
[Required] [Required]
public int JewelId { get; set; } [DataMember]
public int JewelId { get; set; }
[Required] [Required]
public int ComponentId { get; set; } [DataMember]
public int ComponentId { get; set; }
[Required] [Required]
public int Count { get; set; } [DataMember]
public int Count { get; set; }
public virtual Component Component { get; set; } = new(); public virtual Component Component { get; set; } = new();
public virtual Jewel Jewel { get; set; } = new(); public virtual Jewel Jewel { get; set; } = new();

View File

@ -5,14 +5,18 @@ 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 JewelryStoreDatabaseImplement.Models namespace JewelryStoreDatabaseImplement.Models
{ {
[DataContract]
public class Message: IMessageInfoModel public class Message: IMessageInfoModel
{ {
[Key] [Key]
[DataMember]
public string MessageId { get; private set; } = string.Empty; public string MessageId { get; private set; } = string.Empty;
public int? ClientId { get; private set; } public int? ClientId { get; private set; }
[Required] [Required]

View File

@ -8,30 +8,37 @@ using JewelryStoreContracts.BindingModels;
using JewelryStoreDataModels.Models; using JewelryStoreDataModels.Models;
using JewelryStoreDataModels.Enums; using JewelryStoreDataModels.Enums;
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using System.Runtime.Serialization;
namespace JewelryStoreDatabaseImplement.Models namespace JewelryStoreDatabaseImplement.Models
{ {
public class Order : IOrderModel [DataContract]
public class Order : IOrderModel
{ {
public int Id { get; private set; } public int Id { get; private set; }
[DataMember]
public int JewelId { get; private set; } public int JewelId { get; private set; }
[Required] [Required]
public int ClientId { get; set; } [DataMember]
public int? ImplementerId { get; private set; } public int ClientId { get; set; }
[DataMember]
public string JewelName { get; private set; } = string.Empty; public int? ImplementerId { get; private set; }
[DataMember]
public string JewelName { get; private set; } = string.Empty;
[Required] [Required]
public int Count { get; private set; } [DataMember]
public int Count { get; private set; }
[Required] [Required]
public double Sum { get; private set; } [DataMember]
public double Sum { get; private set; }
[Required] [Required]
public OrderStatus Status { get; private set; } = OrderStatus.Неизвестен; [DataMember]
public OrderStatus Status { get; private set; } = OrderStatus.Неизвестен;
[Required] [Required]
public DateTime DateCreate { get; private set; } = DateTime.Now; public DateTime DateCreate { get; private set; } = DateTime.Now;

View File

@ -0,0 +1,22 @@
using JewelryStoreContracts.StoragesContracts;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace JewelryStoreListImplement.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();
}
}
}

View File

@ -1,5 +1,6 @@
using JewelryStoreContracts.BindingModels; using JewelryStoreContracts.BindingModels;
using JewelryStoreContracts.SearchModels; using JewelryStoreContracts.SearchModels;
using JewelryStoreContracts.StoragesContracts;
using JewelryStoreContracts.ViewModels; using JewelryStoreContracts.ViewModels;
using JewelryStoreListImplement.Models; using JewelryStoreListImplement.Models;
using System; using System;
@ -10,7 +11,7 @@ using System.Threading.Tasks;
namespace JewelryStoreListImplement.Implements namespace JewelryStoreListImplement.Implements
{ {
public class ImplementerStorage public class ImplementerStorage : IImplementerStorage
{ {
private readonly DataListSingleton _source; private readonly DataListSingleton _source;
public ImplementerStorage() public ImplementerStorage()

View File

@ -0,0 +1,26 @@
using JewelryStoreContracts.DI;
using JewelryStoreContracts.StoragesContracts;
using JewelryStoreListImplement.Implements;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace JewelryStoreListImplement
{
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<IJewelStorage, JewelStorage>();
DependencyManager.Instance.RegisterType<IBackUpInfo, BackUpInfo>();
}
}
}