Compare commits
2 Commits
2b46e846b7
...
30232a2301
Author | SHA1 | Date | |
---|---|---|---|
30232a2301 | |||
10cd579784 |
2
.gitignore
vendored
2
.gitignore
vendored
@ -69,6 +69,8 @@ ScaffoldingReadMe.txt
|
||||
# StyleCop
|
||||
StyleCopReport.xml
|
||||
|
||||
/BlacksmithWorkshop/ImplementationExtensions
|
||||
|
||||
# Files built by Visual Studio
|
||||
*_i.c
|
||||
*_p.c
|
||||
|
@ -0,0 +1,41 @@
|
||||
using BlackcmithWorkshopFileImplement;
|
||||
using BlacksmithWorkshopContracts.StoragesContracts;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BlacksmithWorkshopFileImplement
|
||||
{
|
||||
public class BackUpInfo : IBackUpInfo
|
||||
{
|
||||
private readonly DataFileSingleton source;
|
||||
private readonly PropertyInfo[] sourceProperties;
|
||||
public BackUpInfo()
|
||||
{
|
||||
source = DataFileSingleton.GetInstance();
|
||||
sourceProperties = source.GetType().GetProperties(BindingFlags.Instance | BindingFlags.Public);
|
||||
}
|
||||
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;
|
||||
}
|
||||
public List<T>? GetList<T>() where T : class, new()
|
||||
{
|
||||
var requredType = typeof(T);
|
||||
return (List<T>?)sourceProperties.FirstOrDefault(x => x.PropertyType.IsGenericType &&
|
||||
x.PropertyType.GetGenericArguments()[0] == requredType)?.GetValue(source);
|
||||
}
|
||||
}
|
||||
}
|
@ -15,4 +15,9 @@
|
||||
<ProjectReference Include="..\BlacksmithWorkshopDataModels\BlacksmithWorkshopDataModels.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
|
||||
<Exec Command="copy /Y "$(TargetDir)*.dll" "$(SolutionDir)ImplementationExtensions\*.dll"" />
|
||||
</Target>
|
||||
|
||||
</Project>
|
||||
|
@ -0,0 +1,32 @@
|
||||
using BlacksmithWorkshopContracts.DI;
|
||||
using BlacksmithWorkshopContracts.StoragesContracts;
|
||||
using BlacksmithWorkshopFileImplement.Implements;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BlacksmithWorkshopFileImplement
|
||||
{
|
||||
public class FileImplementationExtension : 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<IManufactureStorage,
|
||||
ManufactureStorage>();
|
||||
DependencyManager.Instance.RegisterType<IBackUpInfo, BackUpInfo>();
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,50 @@
|
||||
using BlacksmithWorkshopContracts.Attributes;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BlacksmithWorkshop
|
||||
{
|
||||
public static class DataGridViewExtension
|
||||
{
|
||||
public static void FillAndConfigGrid<T>(this DataGridView grid, List<T>? data)
|
||||
{
|
||||
if (data == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
grid.DataSource = data;
|
||||
var type = typeof(T);
|
||||
var properties = type.GetProperties();
|
||||
foreach (DataGridViewColumn column in grid.Columns)
|
||||
{
|
||||
var property = properties.FirstOrDefault(x => x.Name == column.Name);
|
||||
if (property == null)
|
||||
{
|
||||
throw new InvalidOperationException($"В типе {type.Name} не найдено свойство с именем {column.Name}");
|
||||
}
|
||||
var attribute = property.GetCustomAttributes(typeof(ColumnAttribute), true)?.SingleOrDefault();
|
||||
if (attribute == null)
|
||||
{
|
||||
throw new InvalidOperationException($"Не найден атрибут типа ColumnAttribute для свойства {property.Name}");
|
||||
}
|
||||
if (attribute is ColumnAttribute columnAttr)
|
||||
{
|
||||
column.HeaderText = columnAttr.Title;
|
||||
column.Visible = columnAttr.Visible;
|
||||
if (columnAttr.IsUseAutoSize)
|
||||
{
|
||||
column.AutoSizeMode = (DataGridViewAutoSizeColumnMode)Enum.Parse(typeof(DataGridViewAutoSizeColumnMode),
|
||||
columnAttr.GridViewAutoSize.ToString());
|
||||
}
|
||||
else
|
||||
{
|
||||
column.Width = columnAttr.Width;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,5 +1,6 @@
|
||||
using BlacksmithWorkshopContracts.BindingModels;
|
||||
using BlacksmithWorkshopContracts.BusinessLogicsContracts;
|
||||
using BlacksmithWorkshopContracts.DI;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@ -51,7 +52,7 @@ namespace BlacksmithWorkshop
|
||||
}
|
||||
private void AddButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormComponent));
|
||||
var service = DependencyManager.Instance.Resolve<FormComponent>();
|
||||
if (service is FormComponent form)
|
||||
{
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
@ -64,8 +65,7 @@ namespace BlacksmithWorkshop
|
||||
{
|
||||
if (dataGridView.SelectedRows.Count == 1)
|
||||
{
|
||||
var service =
|
||||
Program.ServiceProvider?.GetService(typeof(FormComponent));
|
||||
var service = DependencyManager.Instance.Resolve<FormComponent>();
|
||||
if (service is FormComponent form)
|
||||
{
|
||||
form.Id =
|
||||
|
@ -20,218 +20,226 @@
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
menuStrip = new MenuStrip();
|
||||
GuidesToolStripMenuItem = new ToolStripMenuItem();
|
||||
ComponentsToolStripMenuItem = new ToolStripMenuItem();
|
||||
ManufacturesToolStripMenuItem = new ToolStripMenuItem();
|
||||
ClientsToolStripMenuItem = new ToolStripMenuItem();
|
||||
ImplementersToolStripMenuItem = new ToolStripMenuItem();
|
||||
StartWorkingToolStripMenuItem = new ToolStripMenuItem();
|
||||
ReportsToolStripMenuItem = new ToolStripMenuItem();
|
||||
ManufacturesListToolStripMenuItem = new ToolStripMenuItem();
|
||||
ManufacturesComponentsListToolStripMenuItem = new ToolStripMenuItem();
|
||||
OrdersListToolStripMenuItem = new ToolStripMenuItem();
|
||||
dataGridView = new DataGridView();
|
||||
buttonCreateOrder = new Button();
|
||||
buttonRefresh = new Button();
|
||||
buttonIssued = new Button();
|
||||
buttonReady = new Button();
|
||||
buttonTakeInWork = new Button();
|
||||
MailToolStripMenuItem = new ToolStripMenuItem();
|
||||
menuStrip.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
|
||||
SuspendLayout();
|
||||
//
|
||||
// menuStrip
|
||||
//
|
||||
menuStrip.ImageScalingSize = new Size(24, 24);
|
||||
menuStrip.Items.AddRange(new ToolStripItem[] { GuidesToolStripMenuItem, ReportsToolStripMenuItem });
|
||||
menuStrip.Location = new Point(0, 0);
|
||||
menuStrip.Name = "menuStrip";
|
||||
menuStrip.Padding = new Padding(9, 3, 0, 3);
|
||||
menuStrip.Size = new Size(1810, 35);
|
||||
menuStrip.TabIndex = 0;
|
||||
menuStrip.Text = "Меню";
|
||||
//
|
||||
// GuidesToolStripMenuItem
|
||||
//
|
||||
GuidesToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { ComponentsToolStripMenuItem, ManufacturesToolStripMenuItem, ClientsToolStripMenuItem, ImplementersToolStripMenuItem, StartWorkingToolStripMenuItem, MailToolStripMenuItem });
|
||||
GuidesToolStripMenuItem.Name = "GuidesToolStripMenuItem";
|
||||
GuidesToolStripMenuItem.Size = new Size(139, 29);
|
||||
GuidesToolStripMenuItem.Text = "Справочники";
|
||||
//
|
||||
// ComponentsToolStripMenuItem
|
||||
//
|
||||
ComponentsToolStripMenuItem.Name = "ComponentsToolStripMenuItem";
|
||||
ComponentsToolStripMenuItem.Size = new Size(272, 34);
|
||||
ComponentsToolStripMenuItem.Text = "Компоненты";
|
||||
ComponentsToolStripMenuItem.Click += ComponentsStripMenuItem_Click;
|
||||
//
|
||||
// ManufacturesToolStripMenuItem
|
||||
//
|
||||
ManufacturesToolStripMenuItem.Name = "ManufacturesToolStripMenuItem";
|
||||
ManufacturesToolStripMenuItem.Size = new Size(272, 34);
|
||||
ManufacturesToolStripMenuItem.Text = "Кузнечные изделия";
|
||||
ManufacturesToolStripMenuItem.Click += ManufacturesStripMenuItem_Click;
|
||||
//
|
||||
// ClientsToolStripMenuItem
|
||||
//
|
||||
ClientsToolStripMenuItem.Name = "ClientsToolStripMenuItem";
|
||||
ClientsToolStripMenuItem.Size = new Size(272, 34);
|
||||
ClientsToolStripMenuItem.Text = "Клиенты";
|
||||
ClientsToolStripMenuItem.Click += ClientsToolStripMenuItem_Click;
|
||||
//
|
||||
// ImplementersToolStripMenuItem
|
||||
//
|
||||
ImplementersToolStripMenuItem.Name = "ImplementersToolStripMenuItem";
|
||||
ImplementersToolStripMenuItem.Size = new Size(272, 34);
|
||||
ImplementersToolStripMenuItem.Text = "Исполнители";
|
||||
ImplementersToolStripMenuItem.Click += ImplementersToolStripMenuItem_Click;
|
||||
//
|
||||
// StartWorkingToolStripMenuItem
|
||||
//
|
||||
StartWorkingToolStripMenuItem.Name = "StartWorkingToolStripMenuItem";
|
||||
StartWorkingToolStripMenuItem.Size = new Size(272, 34);
|
||||
StartWorkingToolStripMenuItem.Text = "Старт работ";
|
||||
StartWorkingToolStripMenuItem.Click += StartWorkingToolStripMenuItem_Click;
|
||||
//
|
||||
// ReportsToolStripMenuItem
|
||||
//
|
||||
ReportsToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { ManufacturesListToolStripMenuItem, ManufacturesComponentsListToolStripMenuItem, OrdersListToolStripMenuItem });
|
||||
ReportsToolStripMenuItem.Name = "ReportsToolStripMenuItem";
|
||||
ReportsToolStripMenuItem.Size = new Size(88, 29);
|
||||
ReportsToolStripMenuItem.Text = "Отчёты";
|
||||
//
|
||||
// ManufacturesListToolStripMenuItem
|
||||
//
|
||||
ManufacturesListToolStripMenuItem.Name = "ManufacturesListToolStripMenuItem";
|
||||
ManufacturesListToolStripMenuItem.Size = new Size(335, 34);
|
||||
ManufacturesListToolStripMenuItem.Text = "Список кузнечных изделий";
|
||||
ManufacturesListToolStripMenuItem.Click += ManufacturesListToolStripMenuItem_Click;
|
||||
//
|
||||
// ManufacturesComponentsListToolStripMenuItem
|
||||
//
|
||||
ManufacturesComponentsListToolStripMenuItem.Name = "ManufacturesComponentsListToolStripMenuItem";
|
||||
ManufacturesComponentsListToolStripMenuItem.Size = new Size(335, 34);
|
||||
ManufacturesComponentsListToolStripMenuItem.Text = "Компоненты по изделиям";
|
||||
ManufacturesComponentsListToolStripMenuItem.Click += ManufacturesComponentsListToolStripMenuItem_Click;
|
||||
//
|
||||
// OrdersListToolStripMenuItem
|
||||
//
|
||||
OrdersListToolStripMenuItem.Name = "OrdersListToolStripMenuItem";
|
||||
OrdersListToolStripMenuItem.Size = new Size(335, 34);
|
||||
OrdersListToolStripMenuItem.Text = "Список заказов";
|
||||
OrdersListToolStripMenuItem.Click += OrdersListToolStripMenuItem_Click;
|
||||
//
|
||||
// dataGridView
|
||||
//
|
||||
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
dataGridView.Location = new Point(0, 38);
|
||||
dataGridView.Margin = new Padding(4, 5, 4, 5);
|
||||
dataGridView.Name = "dataGridView";
|
||||
dataGridView.RowHeadersWidth = 62;
|
||||
dataGridView.RowTemplate.Height = 25;
|
||||
dataGridView.Size = new Size(1573, 712);
|
||||
dataGridView.TabIndex = 1;
|
||||
//
|
||||
// buttonCreateOrder
|
||||
//
|
||||
buttonCreateOrder.Location = new Point(1581, 45);
|
||||
buttonCreateOrder.Margin = new Padding(4, 5, 4, 5);
|
||||
buttonCreateOrder.Name = "buttonCreateOrder";
|
||||
buttonCreateOrder.Size = new Size(211, 52);
|
||||
buttonCreateOrder.TabIndex = 2;
|
||||
buttonCreateOrder.Text = "Создать заказ";
|
||||
buttonCreateOrder.UseVisualStyleBackColor = true;
|
||||
buttonCreateOrder.Click += CreateOrderButton_Click;
|
||||
//
|
||||
// buttonRefresh
|
||||
//
|
||||
buttonRefresh.Location = new Point(1581, 292);
|
||||
buttonRefresh.Margin = new Padding(4, 5, 4, 5);
|
||||
buttonRefresh.Name = "buttonRefresh";
|
||||
buttonRefresh.Size = new Size(211, 52);
|
||||
buttonRefresh.TabIndex = 3;
|
||||
buttonRefresh.Text = "Обновить список";
|
||||
buttonRefresh.UseVisualStyleBackColor = true;
|
||||
buttonRefresh.Click += RefreshButton_Click;
|
||||
//
|
||||
// buttonIssued
|
||||
//
|
||||
buttonIssued.Location = new Point(1581, 230);
|
||||
buttonIssued.Margin = new Padding(4, 5, 4, 5);
|
||||
buttonIssued.Name = "buttonIssued";
|
||||
buttonIssued.Size = new Size(211, 52);
|
||||
buttonIssued.TabIndex = 4;
|
||||
buttonIssued.Text = "Заказ выдан";
|
||||
buttonIssued.UseVisualStyleBackColor = true;
|
||||
buttonIssued.Click += IssuedButton_Click;
|
||||
//
|
||||
// buttonReady
|
||||
//
|
||||
buttonReady.Location = new Point(1581, 168);
|
||||
buttonReady.Margin = new Padding(4, 5, 4, 5);
|
||||
buttonReady.Name = "buttonReady";
|
||||
buttonReady.Size = new Size(211, 52);
|
||||
buttonReady.TabIndex = 5;
|
||||
buttonReady.Text = "Заказ готов";
|
||||
buttonReady.UseVisualStyleBackColor = true;
|
||||
buttonReady.Click += ReadyButton_Click;
|
||||
//
|
||||
// buttonTakeInWork
|
||||
//
|
||||
buttonTakeInWork.Location = new Point(1581, 107);
|
||||
buttonTakeInWork.Margin = new Padding(4, 5, 4, 5);
|
||||
buttonTakeInWork.Name = "buttonTakeInWork";
|
||||
buttonTakeInWork.Size = new Size(211, 52);
|
||||
buttonTakeInWork.TabIndex = 6;
|
||||
buttonTakeInWork.Text = "Отдать на выполнение";
|
||||
buttonTakeInWork.UseVisualStyleBackColor = true;
|
||||
buttonTakeInWork.Click += TakeInWorkButton_Click;
|
||||
//
|
||||
// MailToolStripMenuItem
|
||||
//
|
||||
MailToolStripMenuItem.Name = "MailToolStripMenuItem";
|
||||
MailToolStripMenuItem.Size = new Size(272, 34);
|
||||
MailToolStripMenuItem.Text = "Почта";
|
||||
MailToolStripMenuItem.Click += MailToolStripMenuItem_Click;
|
||||
//
|
||||
// FormMain
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(10F, 25F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(1810, 750);
|
||||
Controls.Add(buttonTakeInWork);
|
||||
Controls.Add(buttonReady);
|
||||
Controls.Add(buttonIssued);
|
||||
Controls.Add(buttonRefresh);
|
||||
Controls.Add(buttonCreateOrder);
|
||||
Controls.Add(dataGridView);
|
||||
Controls.Add(menuStrip);
|
||||
MainMenuStrip = menuStrip;
|
||||
Margin = new Padding(4, 5, 4, 5);
|
||||
Name = "FormMain";
|
||||
StartPosition = FormStartPosition.CenterParent;
|
||||
Text = "Кузница";
|
||||
Load += FormMain_Load;
|
||||
menuStrip.ResumeLayout(false);
|
||||
menuStrip.PerformLayout();
|
||||
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
menuStrip = new MenuStrip();
|
||||
GuidesToolStripMenuItem = new ToolStripMenuItem();
|
||||
ComponentsToolStripMenuItem = new ToolStripMenuItem();
|
||||
ManufacturesToolStripMenuItem = new ToolStripMenuItem();
|
||||
ClientsToolStripMenuItem = new ToolStripMenuItem();
|
||||
ImplementersToolStripMenuItem = new ToolStripMenuItem();
|
||||
StartWorkingToolStripMenuItem = new ToolStripMenuItem();
|
||||
MailToolStripMenuItem = new ToolStripMenuItem();
|
||||
ReportsToolStripMenuItem = new ToolStripMenuItem();
|
||||
ManufacturesListToolStripMenuItem = new ToolStripMenuItem();
|
||||
ManufacturesComponentsListToolStripMenuItem = new ToolStripMenuItem();
|
||||
OrdersListToolStripMenuItem = new ToolStripMenuItem();
|
||||
dataGridView = new DataGridView();
|
||||
buttonCreateOrder = new Button();
|
||||
buttonRefresh = new Button();
|
||||
buttonIssued = new Button();
|
||||
buttonReady = new Button();
|
||||
buttonTakeInWork = new Button();
|
||||
BackupToolStripMenuItem = new ToolStripMenuItem();
|
||||
menuStrip.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
|
||||
SuspendLayout();
|
||||
//
|
||||
// menuStrip
|
||||
//
|
||||
menuStrip.ImageScalingSize = new Size(24, 24);
|
||||
menuStrip.Items.AddRange(new ToolStripItem[] { GuidesToolStripMenuItem, ReportsToolStripMenuItem });
|
||||
menuStrip.Location = new Point(0, 0);
|
||||
menuStrip.Name = "menuStrip";
|
||||
menuStrip.Padding = new Padding(9, 3, 0, 3);
|
||||
menuStrip.Size = new Size(1810, 35);
|
||||
menuStrip.TabIndex = 0;
|
||||
menuStrip.Text = "Меню";
|
||||
//
|
||||
// GuidesToolStripMenuItem
|
||||
//
|
||||
GuidesToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { ComponentsToolStripMenuItem, ManufacturesToolStripMenuItem, ClientsToolStripMenuItem, ImplementersToolStripMenuItem, StartWorkingToolStripMenuItem, MailToolStripMenuItem, BackupToolStripMenuItem });
|
||||
GuidesToolStripMenuItem.Name = "GuidesToolStripMenuItem";
|
||||
GuidesToolStripMenuItem.Size = new Size(139, 29);
|
||||
GuidesToolStripMenuItem.Text = "Справочники";
|
||||
//
|
||||
// ComponentsToolStripMenuItem
|
||||
//
|
||||
ComponentsToolStripMenuItem.Name = "ComponentsToolStripMenuItem";
|
||||
ComponentsToolStripMenuItem.Size = new Size(272, 34);
|
||||
ComponentsToolStripMenuItem.Text = "Компоненты";
|
||||
ComponentsToolStripMenuItem.Click += ComponentsStripMenuItem_Click;
|
||||
//
|
||||
// ManufacturesToolStripMenuItem
|
||||
//
|
||||
ManufacturesToolStripMenuItem.Name = "ManufacturesToolStripMenuItem";
|
||||
ManufacturesToolStripMenuItem.Size = new Size(272, 34);
|
||||
ManufacturesToolStripMenuItem.Text = "Кузнечные изделия";
|
||||
ManufacturesToolStripMenuItem.Click += ManufacturesStripMenuItem_Click;
|
||||
//
|
||||
// ClientsToolStripMenuItem
|
||||
//
|
||||
ClientsToolStripMenuItem.Name = "ClientsToolStripMenuItem";
|
||||
ClientsToolStripMenuItem.Size = new Size(272, 34);
|
||||
ClientsToolStripMenuItem.Text = "Клиенты";
|
||||
ClientsToolStripMenuItem.Click += ClientsToolStripMenuItem_Click;
|
||||
//
|
||||
// ImplementersToolStripMenuItem
|
||||
//
|
||||
ImplementersToolStripMenuItem.Name = "ImplementersToolStripMenuItem";
|
||||
ImplementersToolStripMenuItem.Size = new Size(272, 34);
|
||||
ImplementersToolStripMenuItem.Text = "Исполнители";
|
||||
ImplementersToolStripMenuItem.Click += ImplementersToolStripMenuItem_Click;
|
||||
//
|
||||
// StartWorkingToolStripMenuItem
|
||||
//
|
||||
StartWorkingToolStripMenuItem.Name = "StartWorkingToolStripMenuItem";
|
||||
StartWorkingToolStripMenuItem.Size = new Size(272, 34);
|
||||
StartWorkingToolStripMenuItem.Text = "Старт работ";
|
||||
StartWorkingToolStripMenuItem.Click += StartWorkingToolStripMenuItem_Click;
|
||||
//
|
||||
// MailToolStripMenuItem
|
||||
//
|
||||
MailToolStripMenuItem.Name = "MailToolStripMenuItem";
|
||||
MailToolStripMenuItem.Size = new Size(272, 34);
|
||||
MailToolStripMenuItem.Text = "Почта";
|
||||
MailToolStripMenuItem.Click += MailToolStripMenuItem_Click;
|
||||
//
|
||||
// ReportsToolStripMenuItem
|
||||
//
|
||||
ReportsToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { ManufacturesListToolStripMenuItem, ManufacturesComponentsListToolStripMenuItem, OrdersListToolStripMenuItem });
|
||||
ReportsToolStripMenuItem.Name = "ReportsToolStripMenuItem";
|
||||
ReportsToolStripMenuItem.Size = new Size(88, 29);
|
||||
ReportsToolStripMenuItem.Text = "Отчёты";
|
||||
//
|
||||
// ManufacturesListToolStripMenuItem
|
||||
//
|
||||
ManufacturesListToolStripMenuItem.Name = "ManufacturesListToolStripMenuItem";
|
||||
ManufacturesListToolStripMenuItem.Size = new Size(335, 34);
|
||||
ManufacturesListToolStripMenuItem.Text = "Список кузнечных изделий";
|
||||
ManufacturesListToolStripMenuItem.Click += ManufacturesListToolStripMenuItem_Click;
|
||||
//
|
||||
// ManufacturesComponentsListToolStripMenuItem
|
||||
//
|
||||
ManufacturesComponentsListToolStripMenuItem.Name = "ManufacturesComponentsListToolStripMenuItem";
|
||||
ManufacturesComponentsListToolStripMenuItem.Size = new Size(335, 34);
|
||||
ManufacturesComponentsListToolStripMenuItem.Text = "Компоненты по изделиям";
|
||||
ManufacturesComponentsListToolStripMenuItem.Click += ManufacturesComponentsListToolStripMenuItem_Click;
|
||||
//
|
||||
// OrdersListToolStripMenuItem
|
||||
//
|
||||
OrdersListToolStripMenuItem.Name = "OrdersListToolStripMenuItem";
|
||||
OrdersListToolStripMenuItem.Size = new Size(335, 34);
|
||||
OrdersListToolStripMenuItem.Text = "Список заказов";
|
||||
OrdersListToolStripMenuItem.Click += OrdersListToolStripMenuItem_Click;
|
||||
//
|
||||
// dataGridView
|
||||
//
|
||||
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
dataGridView.Location = new Point(0, 38);
|
||||
dataGridView.Margin = new Padding(4, 5, 4, 5);
|
||||
dataGridView.Name = "dataGridView";
|
||||
dataGridView.RowHeadersWidth = 62;
|
||||
dataGridView.RowTemplate.Height = 25;
|
||||
dataGridView.Size = new Size(1573, 712);
|
||||
dataGridView.TabIndex = 1;
|
||||
//
|
||||
// buttonCreateOrder
|
||||
//
|
||||
buttonCreateOrder.Location = new Point(1581, 45);
|
||||
buttonCreateOrder.Margin = new Padding(4, 5, 4, 5);
|
||||
buttonCreateOrder.Name = "buttonCreateOrder";
|
||||
buttonCreateOrder.Size = new Size(211, 52);
|
||||
buttonCreateOrder.TabIndex = 2;
|
||||
buttonCreateOrder.Text = "Создать заказ";
|
||||
buttonCreateOrder.UseVisualStyleBackColor = true;
|
||||
buttonCreateOrder.Click += CreateOrderButton_Click;
|
||||
//
|
||||
// buttonRefresh
|
||||
//
|
||||
buttonRefresh.Location = new Point(1581, 292);
|
||||
buttonRefresh.Margin = new Padding(4, 5, 4, 5);
|
||||
buttonRefresh.Name = "buttonRefresh";
|
||||
buttonRefresh.Size = new Size(211, 52);
|
||||
buttonRefresh.TabIndex = 3;
|
||||
buttonRefresh.Text = "Обновить список";
|
||||
buttonRefresh.UseVisualStyleBackColor = true;
|
||||
buttonRefresh.Click += RefreshButton_Click;
|
||||
//
|
||||
// buttonIssued
|
||||
//
|
||||
buttonIssued.Location = new Point(1581, 230);
|
||||
buttonIssued.Margin = new Padding(4, 5, 4, 5);
|
||||
buttonIssued.Name = "buttonIssued";
|
||||
buttonIssued.Size = new Size(211, 52);
|
||||
buttonIssued.TabIndex = 4;
|
||||
buttonIssued.Text = "Заказ выдан";
|
||||
buttonIssued.UseVisualStyleBackColor = true;
|
||||
buttonIssued.Click += IssuedButton_Click;
|
||||
//
|
||||
// buttonReady
|
||||
//
|
||||
buttonReady.Location = new Point(1581, 168);
|
||||
buttonReady.Margin = new Padding(4, 5, 4, 5);
|
||||
buttonReady.Name = "buttonReady";
|
||||
buttonReady.Size = new Size(211, 52);
|
||||
buttonReady.TabIndex = 5;
|
||||
buttonReady.Text = "Заказ готов";
|
||||
buttonReady.UseVisualStyleBackColor = true;
|
||||
buttonReady.Click += ReadyButton_Click;
|
||||
//
|
||||
// buttonTakeInWork
|
||||
//
|
||||
buttonTakeInWork.Location = new Point(1581, 107);
|
||||
buttonTakeInWork.Margin = new Padding(4, 5, 4, 5);
|
||||
buttonTakeInWork.Name = "buttonTakeInWork";
|
||||
buttonTakeInWork.Size = new Size(211, 52);
|
||||
buttonTakeInWork.TabIndex = 6;
|
||||
buttonTakeInWork.Text = "Отдать на выполнение";
|
||||
buttonTakeInWork.UseVisualStyleBackColor = true;
|
||||
buttonTakeInWork.Click += TakeInWorkButton_Click;
|
||||
//
|
||||
// BackupToolStripMenuItem
|
||||
//
|
||||
BackupToolStripMenuItem.Name = "BackupToolStripMenuItem";
|
||||
BackupToolStripMenuItem.Size = new Size(272, 34);
|
||||
BackupToolStripMenuItem.Text = "Создать бэкап";
|
||||
BackupToolStripMenuItem.Click += BackupToolStripMenuItem_Click;
|
||||
//
|
||||
// FormMain
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(10F, 25F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(1810, 750);
|
||||
Controls.Add(buttonTakeInWork);
|
||||
Controls.Add(buttonReady);
|
||||
Controls.Add(buttonIssued);
|
||||
Controls.Add(buttonRefresh);
|
||||
Controls.Add(buttonCreateOrder);
|
||||
Controls.Add(dataGridView);
|
||||
Controls.Add(menuStrip);
|
||||
MainMenuStrip = menuStrip;
|
||||
Margin = new Padding(4, 5, 4, 5);
|
||||
Name = "FormMain";
|
||||
StartPosition = FormStartPosition.CenterParent;
|
||||
Text = "Кузница";
|
||||
Load += FormMain_Load;
|
||||
menuStrip.ResumeLayout(false);
|
||||
menuStrip.PerformLayout();
|
||||
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
private MenuStrip menuStrip;
|
||||
private MenuStrip menuStrip;
|
||||
private ToolStripMenuItem GuidesToolStripMenuItem;
|
||||
private ToolStripMenuItem ComponentsToolStripMenuItem;
|
||||
private ToolStripMenuItem ManufacturesToolStripMenuItem;
|
||||
@ -249,5 +257,6 @@
|
||||
private ToolStripMenuItem ImplementersToolStripMenuItem;
|
||||
private ToolStripMenuItem StartWorkingToolStripMenuItem;
|
||||
private ToolStripMenuItem MailToolStripMenuItem;
|
||||
}
|
||||
private ToolStripMenuItem BackupToolStripMenuItem;
|
||||
}
|
||||
}
|
@ -1,5 +1,7 @@
|
||||
using BlacksmithWorkshopContracts.BindingModels;
|
||||
using BlacksmithWorkshopBusinessLogic.BusinessLogics;
|
||||
using BlacksmithWorkshopContracts.BindingModels;
|
||||
using BlacksmithWorkshopContracts.BusinessLogicsContracts;
|
||||
using BlacksmithWorkshopContracts.DI;
|
||||
using BlacksmithWorkshopDataModels.Enums;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
@ -14,222 +16,249 @@ using System.Windows.Forms;
|
||||
|
||||
namespace BlacksmithWorkshop
|
||||
{
|
||||
public partial class FormMain : Form
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IOrderLogic _orderLogic;
|
||||
private readonly IReportLogic _reportLogic;
|
||||
private readonly IWorkProcess _workProcess;
|
||||
public FormMain(ILogger<FormMain> logger, IOrderLogic orderLogic,
|
||||
IReportLogic reportLogic, IWorkProcess workProcess)
|
||||
{
|
||||
InitializeComponent();
|
||||
_logger = logger;
|
||||
_orderLogic = orderLogic;
|
||||
_reportLogic = reportLogic;
|
||||
_workProcess = workProcess;
|
||||
}
|
||||
private void ComponentsStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormComponents));
|
||||
if (service is FormComponents form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
}
|
||||
}
|
||||
private void FormMain_Load(object sender, EventArgs e)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
private void LoadData()
|
||||
{
|
||||
_logger.LogInformation("Загрузка заказов");
|
||||
try
|
||||
{
|
||||
var list = _orderLogic.ReadList(null);
|
||||
if (list != null)
|
||||
{
|
||||
dataGridView.DataSource = list;
|
||||
dataGridView.Columns["ManufactureId"].Visible = false;
|
||||
dataGridView.Columns["ImplementerId"].Visible = false;
|
||||
dataGridView.Columns["ClientId"].Visible = false;
|
||||
dataGridView.Columns["ManufactureName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||
dataGridView.Columns["ClientFIO"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||
dataGridView.Columns["ImplementerFIO"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||
}
|
||||
_logger.LogInformation("Загрузка заказов");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка загрузки заказов");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
private void ManufacturesStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormManufactures));
|
||||
if (service is FormManufactures form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
}
|
||||
}
|
||||
private void CreateOrderButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormCreateOrder));
|
||||
if (service is FormCreateOrder form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
private OrderBindingModel CreateBindingModel(int id, bool isDone = false)
|
||||
{
|
||||
return new OrderBindingModel
|
||||
{
|
||||
Id = id,
|
||||
ManufactureId = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["ManufactureId"].Value),
|
||||
ClientId = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["ClientId"].Value),
|
||||
Status = Enum.Parse<OrderStatus>(dataGridView.SelectedRows[0].Cells["Status"].Value.ToString() ?? String.Empty),
|
||||
Count = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Count"].Value),
|
||||
Sum = double.Parse(dataGridView.SelectedRows[0].Cells["Sum"].Value.ToString() ?? String.Empty),
|
||||
DateCreate = DateTime.Parse(dataGridView.SelectedRows[0].Cells["DateCreate"].Value.ToString() ?? String.Empty),
|
||||
};
|
||||
}
|
||||
private void TakeInWorkButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (dataGridView.SelectedRows.Count == 1)
|
||||
{
|
||||
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||
_logger.LogInformation("Заказ №{id}. Меняется статус на 'В работе'", id);
|
||||
try
|
||||
{
|
||||
var operationResult = _orderLogic.TakeOrderInWork(CreateBindingModel(id));
|
||||
if (!operationResult)
|
||||
{
|
||||
throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
|
||||
}
|
||||
LoadData();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка передачи заказа в работу");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
|
||||
MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
private void ReadyButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (dataGridView.SelectedRows.Count == 1)
|
||||
{
|
||||
int id =
|
||||
Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||
_logger.LogInformation("Заказ №{id}. Меняется статус на 'Готов'",
|
||||
id);
|
||||
try
|
||||
{
|
||||
var operationResult = _orderLogic.FinishOrder(CreateBindingModel(id));
|
||||
if (!operationResult)
|
||||
{
|
||||
throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
|
||||
}
|
||||
LoadData();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка отметки о готовности заказа");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
private void IssuedButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (dataGridView.SelectedRows.Count == 1)
|
||||
{
|
||||
int id =
|
||||
Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||
_logger.LogInformation("Заказ №{id}. Меняется статус на 'Выдан'",
|
||||
id);
|
||||
try
|
||||
{
|
||||
var operationResult = _orderLogic.DeliveryOrder(CreateBindingModel(id));
|
||||
if (!operationResult)
|
||||
{
|
||||
throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
|
||||
}
|
||||
_logger.LogInformation("Заказ №{id} выдан", id);
|
||||
LoadData();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка отметки о выдачи заказа");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
|
||||
MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
private void RefreshButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
private void ManufacturesListToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
using var dialog = new SaveFileDialog { Filter = "docx|*.docx" };
|
||||
if (dialog.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
_reportLogic.SaveManufacturesToWordFile(new ReportBindingModel
|
||||
{
|
||||
FileName = dialog.FileName
|
||||
});
|
||||
MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK,
|
||||
MessageBoxIcon.Information);
|
||||
}
|
||||
}
|
||||
private void ManufacturesComponentsListToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormReportManufacturesComponents));
|
||||
if (service is FormReportManufacturesComponents form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
}
|
||||
}
|
||||
private void OrdersListToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormReportOrders));
|
||||
if (service is FormReportOrders form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
}
|
||||
}
|
||||
private void ClientsToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(ClientsForm));
|
||||
if (service is ClientsForm form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
}
|
||||
}
|
||||
private void StartWorkingToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
_workProcess.DoWork((Program.ServiceProvider?.GetService(typeof(IImplementerLogic)) as IImplementerLogic)!, _orderLogic);
|
||||
MessageBox.Show("Процесс обработки запущен", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
}
|
||||
private void ImplementersToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(ImplementersForm));
|
||||
if (service is ImplementersForm form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
}
|
||||
}
|
||||
public partial class FormMain : Form
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IOrderLogic _orderLogic;
|
||||
private readonly IReportLogic _reportLogic;
|
||||
private readonly IWorkProcess _workProcess;
|
||||
private readonly IBackUpLogic _backUpLogic;
|
||||
public FormMain(ILogger<FormMain> logger, IOrderLogic orderLogic,
|
||||
IReportLogic reportLogic, IWorkProcess workProcess, IBackUpLogic backUpLogic)
|
||||
{
|
||||
InitializeComponent();
|
||||
_logger = logger;
|
||||
_orderLogic = orderLogic;
|
||||
_reportLogic = reportLogic;
|
||||
_workProcess = workProcess;
|
||||
_backUpLogic = backUpLogic;
|
||||
}
|
||||
private void ComponentsStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = DependencyManager.Instance.Resolve<FormComponents>();
|
||||
if (service is FormComponents form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
}
|
||||
}
|
||||
private void FormMain_Load(object sender, EventArgs e)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
private void LoadData()
|
||||
{
|
||||
_logger.LogInformation("Загрузка заказов");
|
||||
try
|
||||
{
|
||||
var list = _orderLogic.ReadList(null);
|
||||
if (list != null)
|
||||
{
|
||||
dataGridView.DataSource = list;
|
||||
dataGridView.Columns["ManufactureId"].Visible = false;
|
||||
dataGridView.Columns["ImplementerId"].Visible = false;
|
||||
dataGridView.Columns["ClientId"].Visible = false;
|
||||
dataGridView.Columns["ManufactureName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||
dataGridView.Columns["ClientFIO"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||
dataGridView.Columns["ImplementerFIO"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||
}
|
||||
_logger.LogInformation("Загрузка заказов");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка загрузки заказов");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
private void ManufacturesStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = DependencyManager.Instance.Resolve<FormManufactures>();
|
||||
if (service is FormManufactures form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
}
|
||||
}
|
||||
private void CreateOrderButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = DependencyManager.Instance.Resolve<FormCreateOrder>();
|
||||
if (service is FormCreateOrder form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
private OrderBindingModel CreateBindingModel(int id, bool isDone = false)
|
||||
{
|
||||
return new OrderBindingModel
|
||||
{
|
||||
Id = id,
|
||||
ManufactureId = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["ManufactureId"].Value),
|
||||
ClientId = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["ClientId"].Value),
|
||||
Status = Enum.Parse<OrderStatus>(dataGridView.SelectedRows[0].Cells["Status"].Value.ToString() ?? String.Empty),
|
||||
Count = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Count"].Value),
|
||||
Sum = double.Parse(dataGridView.SelectedRows[0].Cells["Sum"].Value.ToString() ?? String.Empty),
|
||||
DateCreate = DateTime.Parse(dataGridView.SelectedRows[0].Cells["DateCreate"].Value.ToString() ?? String.Empty),
|
||||
};
|
||||
}
|
||||
private void TakeInWorkButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (dataGridView.SelectedRows.Count == 1)
|
||||
{
|
||||
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||
_logger.LogInformation("Заказ №{id}. Меняется статус на 'В работе'", id);
|
||||
try
|
||||
{
|
||||
var operationResult = _orderLogic.TakeOrderInWork(CreateBindingModel(id));
|
||||
if (!operationResult)
|
||||
{
|
||||
throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
|
||||
}
|
||||
LoadData();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка передачи заказа в работу");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
|
||||
MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
private void ReadyButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (dataGridView.SelectedRows.Count == 1)
|
||||
{
|
||||
int id =
|
||||
Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||
_logger.LogInformation("Заказ №{id}. Меняется статус на 'Готов'",
|
||||
id);
|
||||
try
|
||||
{
|
||||
var operationResult = _orderLogic.FinishOrder(CreateBindingModel(id));
|
||||
if (!operationResult)
|
||||
{
|
||||
throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
|
||||
}
|
||||
LoadData();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка отметки о готовности заказа");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
private void IssuedButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (dataGridView.SelectedRows.Count == 1)
|
||||
{
|
||||
int id =
|
||||
Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||
_logger.LogInformation("Заказ №{id}. Меняется статус на 'Выдан'",
|
||||
id);
|
||||
try
|
||||
{
|
||||
var operationResult = _orderLogic.DeliveryOrder(CreateBindingModel(id));
|
||||
if (!operationResult)
|
||||
{
|
||||
throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
|
||||
}
|
||||
_logger.LogInformation("Заказ №{id} выдан", id);
|
||||
LoadData();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка отметки о выдачи заказа");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
|
||||
MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
private void RefreshButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
private void ManufacturesListToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
using var dialog = new SaveFileDialog { Filter = "docx|*.docx" };
|
||||
if (dialog.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
_reportLogic.SaveManufacturesToWordFile(new ReportBindingModel
|
||||
{
|
||||
FileName = dialog.FileName
|
||||
});
|
||||
MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK,
|
||||
MessageBoxIcon.Information);
|
||||
}
|
||||
}
|
||||
private void ManufacturesComponentsListToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = DependencyManager.Instance.Resolve<FormReportManufacturesComponents>();
|
||||
if (service is FormReportManufacturesComponents form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
}
|
||||
}
|
||||
private void OrdersListToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = DependencyManager.Instance.Resolve<FormReportOrders>();
|
||||
if (service is FormReportOrders form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
}
|
||||
}
|
||||
private void ClientsToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = DependencyManager.Instance.Resolve<ClientsForm>();
|
||||
if (service is ClientsForm form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
}
|
||||
}
|
||||
private void StartWorkingToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
_workProcess.DoWork(DependencyManager.Instance.Resolve<IImplementerLogic>(), _orderLogic);
|
||||
MessageBox.Show("Процесс обработки запущен", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
}
|
||||
private void ImplementersToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = DependencyManager.Instance.Resolve<ImplementersForm>();
|
||||
if (service is ImplementersForm form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
}
|
||||
}
|
||||
|
||||
private void MailToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(ViewMailForm));
|
||||
if (service is ViewMailForm form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
}
|
||||
}
|
||||
}
|
||||
private void MailToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = DependencyManager.Instance.Resolve<ViewMailForm>();
|
||||
if (service is ViewMailForm form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
}
|
||||
}
|
||||
|
||||
private void BackupToolStripMenuItem_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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
using BlacksmithWorkshopContracts.BindingModels;
|
||||
using BlacksmithWorkshopContracts.BusinessLogicsContracts;
|
||||
using BlacksmithWorkshopContracts.DI;
|
||||
using BlacksmithWorkshopContracts.SearchModels;
|
||||
using BlacksmithWorkshopDataModels.Models;
|
||||
using Microsoft.Extensions.Logging;
|
||||
@ -79,7 +80,7 @@ namespace BlacksmithWorkshop
|
||||
}
|
||||
private void ButtonAdd_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormManufactureComponent));
|
||||
var service = DependencyManager.Instance.Resolve<FormManufactureComponent>();
|
||||
if (service is FormManufactureComponent form)
|
||||
{
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
@ -105,7 +106,7 @@ namespace BlacksmithWorkshop
|
||||
{
|
||||
if (dataGridView.SelectedRows.Count == 1)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormManufactureComponent));
|
||||
var service = DependencyManager.Instance.Resolve<FormManufactureComponent>();
|
||||
if (service is FormManufactureComponent form)
|
||||
{
|
||||
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells[0].Value);
|
||||
|
@ -1,5 +1,6 @@
|
||||
using BlacksmithWorkshopContracts.BindingModels;
|
||||
using BlacksmithWorkshopContracts.BusinessLogicsContracts;
|
||||
using BlacksmithWorkshopContracts.DI;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@ -49,7 +50,7 @@ namespace BlacksmithWorkshop
|
||||
}
|
||||
private void AddButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormManufacture));
|
||||
var service = DependencyManager.Instance.Resolve<FormManufacture>();
|
||||
if (service is FormManufacture form)
|
||||
{
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
@ -62,7 +63,7 @@ namespace BlacksmithWorkshop
|
||||
{
|
||||
if (dataGridView.SelectedRows.Count == 1)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormManufacture));
|
||||
var service = DependencyManager.Instance.Resolve<FormManufacture>();
|
||||
if (service is FormManufacture form)
|
||||
{
|
||||
var tmp = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||
|
@ -1,5 +1,6 @@
|
||||
using BlacksmithWorkshopContracts.BindingModels;
|
||||
using BlacksmithWorkshopContracts.BusinessLogicsContracts;
|
||||
using BlacksmithWorkshopContracts.DI;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@ -51,7 +52,7 @@ namespace BlacksmithWorkshop
|
||||
}
|
||||
private void CreateButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(ImplementerForm));
|
||||
var service = DependencyManager.Instance.Resolve<ImplementerForm>();
|
||||
if (service is ImplementerForm form)
|
||||
{
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
@ -60,12 +61,12 @@ namespace BlacksmithWorkshop
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void ChangeButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (dataGridView1.SelectedRows.Count == 1)
|
||||
{
|
||||
var service =
|
||||
Program.ServiceProvider?.GetService(typeof(ImplementerForm));
|
||||
var service = DependencyManager.Instance.Resolve<ImplementerForm>();
|
||||
if (service is ImplementerForm form)
|
||||
{
|
||||
form.Id = Convert.ToInt32(dataGridView1.SelectedRows[0].Cells["Id"].Value);
|
||||
|
@ -10,90 +10,78 @@ using NLog.Extensions.Logging;
|
||||
using System;
|
||||
using BlacksmithWorkshopContracts.BindingModels;
|
||||
using BlacksmithWorkshopBusinessLogic.MailWorker;
|
||||
using BlacksmithWorkshopContracts.DI;
|
||||
|
||||
namespace BlacksmithWorkshop
|
||||
{
|
||||
internal static class Program
|
||||
{
|
||||
private static ServiceProvider? _serviceProvider;
|
||||
public static ServiceProvider? ServiceProvider => _serviceProvider;
|
||||
/// <summary>
|
||||
/// The main entry point for the application.
|
||||
/// </summary>
|
||||
[STAThread]
|
||||
static void Main()
|
||||
{
|
||||
// To customize application configuration such as set high DPI settings or default font,
|
||||
// see https://aka.ms/applicationconfiguration.
|
||||
ApplicationConfiguration.Initialize();
|
||||
var services = new ServiceCollection();
|
||||
ConfigureServices(services);
|
||||
_serviceProvider = services.BuildServiceProvider();
|
||||
try
|
||||
{
|
||||
var mailSender = _serviceProvider.GetService<AbstractMailWorker>();
|
||||
mailSender?.MailConfig(new MailConfigBindingModel
|
||||
{
|
||||
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);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
var logger = _serviceProvider.GetService<ILogger>();
|
||||
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<IManufactureStorage, ManufactureStorage>();
|
||||
services.AddTransient<IComponentLogic, ComponentLogic>();
|
||||
services.AddTransient<IOrderLogic, OrderLogic>();
|
||||
services.AddTransient<IManufactureLogic, ManufactureLogic>();
|
||||
services.AddTransient<IReportLogic, ReportLogic>();
|
||||
services.AddTransient<AbstractSaveToExcel, SaveToExcel>();
|
||||
services.AddTransient<AbstractSaveToWord, SaveToWord>();
|
||||
services.AddTransient<AbstractSaveToPdf, SaveToPdf>();
|
||||
services.AddTransient<IClientLogic, ClientLogic>();
|
||||
services.AddTransient<IClientStorage, ClientStorage>();
|
||||
services.AddTransient<IImplementerLogic, ImplementerLogic>();
|
||||
services.AddTransient<IImplementerStorage, ImplementerStorage>();
|
||||
services.AddTransient<IMessageInfoLogic, MessageInfoLogic>();
|
||||
services.AddTransient<IMessageInfoStorage, MessageInfoStorage>();
|
||||
services.AddSingleton<AbstractMailWorker, MailKitWorker>();
|
||||
services.AddTransient<IWorkProcess, WorkModeling>();
|
||||
services.AddTransient<FormMain>();
|
||||
services.AddTransient<FormComponent>();
|
||||
services.AddTransient<FormComponents>();
|
||||
services.AddTransient<FormCreateOrder>();
|
||||
services.AddTransient<FormManufacture>();
|
||||
services.AddTransient<FormManufactures>();
|
||||
services.AddTransient<FormManufactureComponent>();
|
||||
services.AddTransient<FormReportManufacturesComponents>();
|
||||
services.AddTransient<FormReportOrders>();
|
||||
services.AddTransient<ClientsForm>();
|
||||
services.AddTransient<ImplementersForm>();
|
||||
services.AddTransient<ImplementerForm>();
|
||||
services.AddTransient<ViewMailForm>();
|
||||
}
|
||||
private static void MailCheck(object obj) => ServiceProvider?
|
||||
.GetService<AbstractMailWorker>()?.MailCheck();
|
||||
}
|
||||
}
|
||||
internal static class Program
|
||||
{
|
||||
[STAThread]
|
||||
static void Main()
|
||||
{
|
||||
ApplicationConfiguration.Initialize();
|
||||
var services = new ServiceCollection();
|
||||
InitDependency();
|
||||
try
|
||||
{
|
||||
var mailSender = DependencyManager.Instance.Resolve<AbstractMailWorker>();
|
||||
mailSender?.MailConfig(new MailConfigBindingModel
|
||||
{
|
||||
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);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
var logger = DependencyManager.Instance.Resolve<ILogger>();
|
||||
logger?.LogError(ex, "Îøèáêà ðàáîòû ñ ïî÷òîé");
|
||||
}
|
||||
Application.Run(DependencyManager.Instance.Resolve<FormMain>());
|
||||
}
|
||||
private static void InitDependency()
|
||||
{
|
||||
DependencyManager.InitDependency();
|
||||
DependencyManager.Instance.AddLogging(option =>
|
||||
{
|
||||
option.SetMinimumLevel(LogLevel.Information);
|
||||
option.AddNLog("nlog.config");
|
||||
});
|
||||
DependencyManager.Instance.RegisterType<IClientLogic, ClientLogic>();
|
||||
DependencyManager.Instance.RegisterType<IImplementerLogic, ImplementerLogic>();
|
||||
DependencyManager.Instance.RegisterType<IComponentLogic, ComponentLogic>();
|
||||
DependencyManager.Instance.RegisterType<IOrderLogic, OrderLogic>();
|
||||
DependencyManager.Instance.RegisterType<IManufactureLogic, ManufactureLogic>();
|
||||
DependencyManager.Instance.RegisterType<IReportLogic, ReportLogic>();
|
||||
DependencyManager.Instance.RegisterType<IMessageInfoLogic, MessageInfoLogic>();
|
||||
DependencyManager.Instance.RegisterType<IBackUpLogic, BackUpLogic>();
|
||||
DependencyManager.Instance.RegisterType<AbstractMailWorker, MailKitWorker>(true);
|
||||
DependencyManager.Instance.RegisterType<IWorkProcess, WorkModeling>();
|
||||
DependencyManager.Instance.RegisterType<AbstractSaveToExcel, SaveToExcel>();
|
||||
DependencyManager.Instance.RegisterType<AbstractSaveToWord, SaveToWord>();
|
||||
DependencyManager.Instance.RegisterType<AbstractSaveToPdf, SaveToPdf>();
|
||||
DependencyManager.Instance.RegisterType<FormMain>();
|
||||
DependencyManager.Instance.RegisterType<ImplementerForm>();
|
||||
DependencyManager.Instance.RegisterType<ImplementersForm>();
|
||||
DependencyManager.Instance.RegisterType<ClientsForm>();
|
||||
DependencyManager.Instance.RegisterType<FormComponent>();
|
||||
DependencyManager.Instance.RegisterType<FormComponents>();
|
||||
DependencyManager.Instance.RegisterType<FormCreateOrder>();
|
||||
DependencyManager.Instance.RegisterType<FormManufacture>();
|
||||
DependencyManager.Instance.RegisterType<FormManufactureComponent>();
|
||||
DependencyManager.Instance.RegisterType<FormManufactures>();
|
||||
DependencyManager.Instance.RegisterType<FormReportManufacturesComponents>();
|
||||
DependencyManager.Instance.RegisterType<FormReportOrders>();
|
||||
DependencyManager.Instance.RegisterType<ViewMailForm>();
|
||||
}
|
||||
private static void MailCheck(object obj) =>
|
||||
DependencyManager.Instance.Resolve<AbstractMailWorker>()?.MailCheck();
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,98 @@
|
||||
using BlacksmithWorkshopContracts.BindingModels;
|
||||
using BlacksmithWorkshopContracts.BusinessLogicsContracts;
|
||||
using BlacksmithWorkshopContracts.StoragesContracts;
|
||||
using BlacksmithWorkshopDataModels;
|
||||
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 BlacksmithWorkshopBusinessLogic.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);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,28 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BlacksmithWorkshopContracts.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; }
|
||||
}
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BlacksmithWorkshopContracts.Attributes
|
||||
{
|
||||
public enum GridViewAutoSize
|
||||
{
|
||||
NotSet = 0,
|
||||
None = 1,
|
||||
ColumnHeader = 2,
|
||||
AllCellsExceptHeader = 4,
|
||||
AllCells = 6,
|
||||
DisplayedCellsExceptHeader = 8,
|
||||
DisplayedCells = 10,
|
||||
Fill = 16
|
||||
}
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BlacksmithWorkshopContracts.BindingModels
|
||||
{
|
||||
public class BackUpSaveBinidngModel
|
||||
{
|
||||
public string FolderName { get; set; } = string.Empty;
|
||||
}
|
||||
}
|
@ -8,6 +8,7 @@
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="MailKit" Version="4.5.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Logging" Version="6.0.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
@ -0,0 +1,14 @@
|
||||
using BlacksmithWorkshopContracts.BindingModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BlacksmithWorkshopContracts.BusinessLogicsContracts
|
||||
{
|
||||
public interface IBackUpLogic
|
||||
{
|
||||
void CreateBackUp(BackUpSaveBinidngModel model);
|
||||
}
|
||||
}
|
@ -0,0 +1,50 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BlacksmithWorkshopContracts.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>();
|
||||
}
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BlacksmithWorkshopContracts.DI
|
||||
{
|
||||
public interface IDependencyContainer
|
||||
{
|
||||
void AddLogging(Action<ILoggingBuilder> configure);
|
||||
void RegisterType<T, U>(bool isSingle) where U : class, T where T : class;
|
||||
void RegisterType<T>(bool isSingle) where T : class;
|
||||
T Resolve<T>();
|
||||
}
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BlacksmithWorkshopContracts.DI
|
||||
{
|
||||
public interface IImplementationExtension
|
||||
{
|
||||
public int Priority { get; }
|
||||
public void RegisterServices();
|
||||
}
|
||||
}
|
@ -0,0 +1,61 @@
|
||||
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 BlacksmithWorkshopContracts.DI
|
||||
{
|
||||
public class ServiceDependencyContainer : IDependencyContainer
|
||||
{
|
||||
private ServiceProvider? _serviceProvider;
|
||||
private readonly ServiceCollection _serviceCollection;
|
||||
|
||||
public ServiceDependencyContainer()
|
||||
{
|
||||
_serviceCollection = new ServiceCollection();
|
||||
}
|
||||
|
||||
public void AddLogging(Action<ILoggingBuilder> configure)
|
||||
{
|
||||
_serviceCollection.AddLogging(configure);
|
||||
}
|
||||
|
||||
public void RegisterType<T>(bool isSingle) where T : class
|
||||
{
|
||||
if (isSingle)
|
||||
{
|
||||
_serviceCollection.AddSingleton<T>();
|
||||
}
|
||||
else
|
||||
{
|
||||
_serviceCollection.AddTransient<T>();
|
||||
}
|
||||
_serviceProvider = null;
|
||||
}
|
||||
|
||||
public 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 T Resolve<T>()
|
||||
{
|
||||
if (_serviceProvider == null)
|
||||
{
|
||||
_serviceProvider = _serviceCollection.BuildServiceProvider();
|
||||
}
|
||||
return _serviceProvider.GetService<T>()!;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,54 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BlacksmithWorkshopContracts.DI
|
||||
{
|
||||
public static partial class ServiceProviderLoader
|
||||
{
|
||||
public static IImplementationExtension? GetImplementationExtensions()
|
||||
{
|
||||
IImplementationExtension? source = null;
|
||||
var files = Directory.GetFiles(TryGetImplementationExtensionsFolder(), "*.dll",
|
||||
SearchOption.AllDirectories);
|
||||
foreach (var file in files.Distinct())
|
||||
{
|
||||
Assembly asm = Assembly.LoadFrom(file);
|
||||
foreach (var t in asm.GetExportedTypes())
|
||||
{
|
||||
if (t.IsClass &&
|
||||
typeof(IImplementationExtension).IsAssignableFrom(t))
|
||||
{
|
||||
if (source == null)
|
||||
{
|
||||
source = (IImplementationExtension)Activator.CreateInstance(t)!;
|
||||
}
|
||||
else
|
||||
{
|
||||
var newSource = (IImplementationExtension)Activator.CreateInstance(t)!;
|
||||
if (newSource.Priority > source.Priority)
|
||||
{
|
||||
source = newSource;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return source;
|
||||
}
|
||||
|
||||
private static string TryGetImplementationExtensionsFolder()
|
||||
{
|
||||
var directory = new DirectoryInfo(Directory.GetCurrentDirectory());
|
||||
while (directory != null && !directory.GetDirectories("ImplementationExtensions",
|
||||
SearchOption.AllDirectories).Any(x => x.Name == "ImplementationExtensions"))
|
||||
{
|
||||
directory = directory.Parent;
|
||||
}
|
||||
return $"{directory?.FullName}\\ImplementationExtensions";
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BlacksmithWorkshopContracts.StoragesContracts
|
||||
{
|
||||
public interface IBackUpInfo
|
||||
{
|
||||
List<T>? GetList<T>() where T : class, new();
|
||||
Type? GetTypeByModelInterface(string modelInterfaceName);
|
||||
}
|
||||
}
|
@ -0,0 +1,32 @@
|
||||
using BlacksmithWorkshopContracts.StoragesContracts;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BlacksmithWorkshopDatabaseImplement
|
||||
{
|
||||
public class BackUpInfo : IBackUpInfo
|
||||
{
|
||||
public List<T>? GetList<T>() where T : class, new()
|
||||
{
|
||||
using var context = new BlacksmithWorkshopDataBase();
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
@ -21,4 +21,9 @@
|
||||
<ProjectReference Include="..\BlacksmithWorkshopDataModels\BlacksmithWorkshopDataModels.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
|
||||
<Exec Command="copy /Y "$(TargetDir)*.dll" "$(SolutionDir)ImplementationExtensions\*.dll"" />
|
||||
</Target>
|
||||
|
||||
</Project>
|
||||
|
@ -0,0 +1,32 @@
|
||||
using BlacksmithWorkshopContracts.DI;
|
||||
using BlacksmithWorkshopContracts.StoragesContracts;
|
||||
using BlacksmithWorkshopDatabaseImplement.Implements;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BlacksmithWorkshopDatabaseImplement
|
||||
{
|
||||
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<IManufactureStorage,
|
||||
ManufactureStorage>();
|
||||
DependencyManager.Instance.RegisterType<IBackUpInfo, BackUpInfo>();
|
||||
}
|
||||
}
|
||||
}
|
298
BlacksmithWorkshop/BlacksmithWorkshopDatabaseImplement/Migrations/20240602125215_InitCreate.Designer.cs
generated
Normal file
298
BlacksmithWorkshop/BlacksmithWorkshopDatabaseImplement/Migrations/20240602125215_InitCreate.Designer.cs
generated
Normal file
@ -0,0 +1,298 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using BlacksmithWorkshopDatabaseImplement;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Metadata;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace BlacksmithWorkshopDatabaseImplement.Migrations
|
||||
{
|
||||
[DbContext(typeof(BlacksmithWorkshopDataBase))]
|
||||
[Migration("20240602125215_InitCreate")]
|
||||
partial class InitCreate
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "7.0.16")
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 128);
|
||||
|
||||
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
|
||||
|
||||
modelBuilder.Entity("BlacksmithWorkshopDataModels.Models.Implementer", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("ImplementerFIO")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Password")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<int>("Qualification")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("WorkExperience")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Implementers");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.Client", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("ClientFIO")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Email")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Password")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Clients");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.Component", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("ComponentName")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<double>("Cost")
|
||||
.HasColumnType("float");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Components");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.Manufacture", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("ManufactureName")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<double>("Price")
|
||||
.HasColumnType("float");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Manufactures");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.ManufactureComponent", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("ComponentId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("Count")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("ManufactureId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ComponentId");
|
||||
|
||||
b.HasIndex("ManufactureId");
|
||||
|
||||
b.ToTable("ManufactureComponents");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.MessageInfo", b =>
|
||||
{
|
||||
b.Property<string>("MessageId")
|
||||
.HasColumnType("nvarchar(450)");
|
||||
|
||||
b.Property<string>("Body")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<int?>("ClientId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<DateTime>("DateDelivery")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<string>("SenderName")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Subject")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("MessageId");
|
||||
|
||||
b.HasIndex("ClientId");
|
||||
|
||||
b.ToTable("Messages");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.Order", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("ClientId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("Count")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<DateTime>("DateCreate")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<DateTime?>("DateImplement")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<int?>("ImplementerId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("ManufactureId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("Status")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<double>("Sum")
|
||||
.HasColumnType("float");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ClientId");
|
||||
|
||||
b.HasIndex("ImplementerId");
|
||||
|
||||
b.HasIndex("ManufactureId");
|
||||
|
||||
b.ToTable("Orders");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.ManufactureComponent", b =>
|
||||
{
|
||||
b.HasOne("BlacksmithWorkshopDatabaseImplement.Models.Component", "Component")
|
||||
.WithMany("ManufactureComponents")
|
||||
.HasForeignKey("ComponentId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("BlacksmithWorkshopDatabaseImplement.Models.Manufacture", "Manufacture")
|
||||
.WithMany("Components")
|
||||
.HasForeignKey("ManufactureId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Component");
|
||||
|
||||
b.Navigation("Manufacture");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.MessageInfo", b =>
|
||||
{
|
||||
b.HasOne("BlacksmithWorkshopDatabaseImplement.Models.Client", "Client")
|
||||
.WithMany("MessageInfos")
|
||||
.HasForeignKey("ClientId");
|
||||
|
||||
b.Navigation("Client");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.Order", b =>
|
||||
{
|
||||
b.HasOne("BlacksmithWorkshopDatabaseImplement.Models.Client", "Client")
|
||||
.WithMany("Orders")
|
||||
.HasForeignKey("ClientId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("BlacksmithWorkshopDataModels.Models.Implementer", "Implementer")
|
||||
.WithMany("Orders")
|
||||
.HasForeignKey("ImplementerId");
|
||||
|
||||
b.HasOne("BlacksmithWorkshopDatabaseImplement.Models.Manufacture", "Manufacture")
|
||||
.WithMany("Orders")
|
||||
.HasForeignKey("ManufactureId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Client");
|
||||
|
||||
b.Navigation("Implementer");
|
||||
|
||||
b.Navigation("Manufacture");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BlacksmithWorkshopDataModels.Models.Implementer", b =>
|
||||
{
|
||||
b.Navigation("Orders");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.Client", b =>
|
||||
{
|
||||
b.Navigation("MessageInfos");
|
||||
|
||||
b.Navigation("Orders");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.Component", b =>
|
||||
{
|
||||
b.Navigation("ManufactureComponents");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.Manufacture", b =>
|
||||
{
|
||||
b.Navigation("Components");
|
||||
|
||||
b.Navigation("Orders");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,213 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace BlacksmithWorkshopDatabaseImplement.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class InitCreate : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Clients",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
ClientFIO = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
Email = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
Password = table.Column<string>(type: "nvarchar(max)", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Clients", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Components",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
ComponentName = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
Cost = table.Column<double>(type: "float", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Components", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Implementers",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
ImplementerFIO = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
Password = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
Qualification = table.Column<int>(type: "int", nullable: false),
|
||||
WorkExperience = table.Column<int>(type: "int", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Implementers", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Manufactures",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
ManufactureName = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
Price = table.Column<double>(type: "float", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Manufactures", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Messages",
|
||||
columns: table => new
|
||||
{
|
||||
MessageId = table.Column<string>(type: "nvarchar(450)", nullable: false),
|
||||
ClientId = table.Column<int>(type: "int", nullable: true),
|
||||
SenderName = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
DateDelivery = table.Column<DateTime>(type: "datetime2", nullable: false),
|
||||
Subject = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
Body = table.Column<string>(type: "nvarchar(max)", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Messages", x => x.MessageId);
|
||||
table.ForeignKey(
|
||||
name: "FK_Messages_Clients_ClientId",
|
||||
column: x => x.ClientId,
|
||||
principalTable: "Clients",
|
||||
principalColumn: "Id");
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "ManufactureComponents",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
ManufactureId = table.Column<int>(type: "int", nullable: false),
|
||||
ComponentId = table.Column<int>(type: "int", nullable: false),
|
||||
Count = table.Column<int>(type: "int", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_ManufactureComponents", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_ManufactureComponents_Components_ComponentId",
|
||||
column: x => x.ComponentId,
|
||||
principalTable: "Components",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_ManufactureComponents_Manufactures_ManufactureId",
|
||||
column: x => x.ManufactureId,
|
||||
principalTable: "Manufactures",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Orders",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
ClientId = table.Column<int>(type: "int", nullable: false),
|
||||
Count = table.Column<int>(type: "int", nullable: false),
|
||||
Sum = table.Column<double>(type: "float", nullable: false),
|
||||
Status = table.Column<int>(type: "int", nullable: false),
|
||||
DateCreate = table.Column<DateTime>(type: "datetime2", nullable: false),
|
||||
DateImplement = table.Column<DateTime>(type: "datetime2", nullable: true),
|
||||
ManufactureId = table.Column<int>(type: "int", nullable: false),
|
||||
ImplementerId = table.Column<int>(type: "int", nullable: true)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Orders", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_Orders_Clients_ClientId",
|
||||
column: x => x.ClientId,
|
||||
principalTable: "Clients",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_Orders_Implementers_ImplementerId",
|
||||
column: x => x.ImplementerId,
|
||||
principalTable: "Implementers",
|
||||
principalColumn: "Id");
|
||||
table.ForeignKey(
|
||||
name: "FK_Orders_Manufactures_ManufactureId",
|
||||
column: x => x.ManufactureId,
|
||||
principalTable: "Manufactures",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_ManufactureComponents_ComponentId",
|
||||
table: "ManufactureComponents",
|
||||
column: "ComponentId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_ManufactureComponents_ManufactureId",
|
||||
table: "ManufactureComponents",
|
||||
column: "ManufactureId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Messages_ClientId",
|
||||
table: "Messages",
|
||||
column: "ClientId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Orders_ClientId",
|
||||
table: "Orders",
|
||||
column: "ClientId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Orders_ImplementerId",
|
||||
table: "Orders",
|
||||
column: "ImplementerId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Orders_ManufactureId",
|
||||
table: "Orders",
|
||||
column: "ManufactureId");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropTable(
|
||||
name: "ManufactureComponents");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Messages");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Orders");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Components");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Clients");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Implementers");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Manufactures");
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
using BlacksmithWorkshopContracts.StoragesContracts;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BlacksmithWorkshopListImplement
|
||||
{
|
||||
public class BackUpInfo : IBackUpInfo
|
||||
{
|
||||
public List<T>? GetList<T>() where T : class, new()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public Type? GetTypeByModelInterface(string modelInterfaceName)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
@ -15,4 +15,8 @@
|
||||
<ProjectReference Include="..\BlacksmithWorkshopDataModels\BlacksmithWorkshopDataModels.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
|
||||
<Exec Command="copy /Y "$(TargetDir)*.dll" "$(SolutionDir)ImplementationExtensions\*.dll"" />
|
||||
</Target>
|
||||
|
||||
</Project>
|
||||
|
@ -0,0 +1,33 @@
|
||||
using BlacksmithWorkshopContracts.DI;
|
||||
using BlacksmithWorkshopContracts.StoragesContracts;
|
||||
using BlacksmithWorkshopListImplement.Implements;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BlacksmithWorkshopListImplement
|
||||
{
|
||||
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<IManufactureStorage,
|
||||
ManufactureStorage>();
|
||||
DependencyManager.Instance.RegisterType<IBackUpInfo,
|
||||
BackUpInfo>();
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user