8 лаба
This commit is contained in:
parent
5eaa15c044
commit
9ece512f60
4
.gitignore
vendored
4
.gitignore
vendored
@ -398,3 +398,7 @@ FodyWeavers.xsd
|
|||||||
# JetBrains Rider
|
# JetBrains Rider
|
||||||
*.sln.iml
|
*.sln.iml
|
||||||
|
|
||||||
|
# dll файлы
|
||||||
|
*.dll
|
||||||
|
|
||||||
|
/SecuritySystem/ImplementationExtensions
|
63
SecuritySystem/SecuritySystem/DataGridViewExtension.cs
Normal file
63
SecuritySystem/SecuritySystem/DataGridViewExtension.cs
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
using SecuritySystemContracts.Attributes;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace SecuritySystem
|
||||||
|
{
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -36,19 +36,10 @@ namespace SecuritySystem
|
|||||||
|
|
||||||
private void LoadData()
|
private void LoadData()
|
||||||
{
|
{
|
||||||
_logger.LogInformation("Загрузка клиентов");
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var list = _clientLogic.ReadList(null);
|
dataGridView.FillandConfigGrid(_clientLogic.ReadList(null));
|
||||||
|
_logger.LogInformation("Загрузка клиентов");
|
||||||
if (list != null)
|
|
||||||
{
|
|
||||||
dataGridView.DataSource = list;
|
|
||||||
dataGridView.Columns["ClientFIO"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
|
||||||
}
|
|
||||||
|
|
||||||
_logger.LogInformation("Успешная загрузка клиентов");
|
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
using SecuritySystemContracts.BindingModels;
|
using SecuritySystemBusinessLogic.BusinessLogic;
|
||||||
|
using SecuritySystemContracts.BindingModels;
|
||||||
using SecuritySystemContracts.BusinessLogicsContracts;
|
using SecuritySystemContracts.BusinessLogicsContracts;
|
||||||
|
using SecuritySystemContracts.DI;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
@ -36,15 +38,7 @@ namespace SecuritySystem
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var list = _logic.ReadList(null);
|
dataGridView.FillandConfigGrid(_logic.ReadList(null));
|
||||||
|
|
||||||
//растягиваем колонку Название на всю ширину, колонку Id скрываем
|
|
||||||
if (list != null)
|
|
||||||
{
|
|
||||||
dataGridView.DataSource = list;
|
|
||||||
dataGridView.Columns["Id"].Visible = false;
|
|
||||||
dataGridView.Columns["ImplementerFIO"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
|
||||||
}
|
|
||||||
|
|
||||||
_logger.LogInformation("Загрузка исполнителей");
|
_logger.LogInformation("Загрузка исполнителей");
|
||||||
}
|
}
|
||||||
@ -58,25 +52,20 @@ namespace SecuritySystem
|
|||||||
|
|
||||||
private void ButtonCreate_Click(object sender, EventArgs e)
|
private void ButtonCreate_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
var service = Program.ServiceProvider?.GetService(typeof(FormImplementer));
|
var form = DependencyManager.Instance.Resolve<FormImplementer>();
|
||||||
|
|
||||||
if (service is FormImplementer form)
|
|
||||||
{
|
|
||||||
if (form.ShowDialog() == DialogResult.OK)
|
if (form.ShowDialog() == DialogResult.OK)
|
||||||
{
|
{
|
||||||
LoadData();
|
LoadData();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private void ButtonChange_Click(object sender, EventArgs e)
|
private void ButtonChange_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
if (dataGridView.SelectedRows.Count == 1)
|
if (dataGridView.SelectedRows.Count == 1)
|
||||||
{
|
{
|
||||||
var service = Program.ServiceProvider?.GetService(typeof(FormImplementer));
|
var form = DependencyManager.Instance.Resolve<FormImplementer>();
|
||||||
|
|
||||||
if (service is FormImplementer form)
|
|
||||||
{
|
|
||||||
form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||||
|
|
||||||
if (form.ShowDialog() == DialogResult.OK)
|
if (form.ShowDialog() == DialogResult.OK)
|
||||||
@ -85,7 +74,6 @@ namespace SecuritySystem
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private void ButtonDelete_Click(object sender, EventArgs e)
|
private void ButtonDelete_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
|
@ -38,15 +38,7 @@ namespace SecuritySystem
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var list = _messageLogic.ReadList(null);
|
dataGridView.FillandConfigGrid(_messageLogic.ReadList(null));
|
||||||
|
|
||||||
if (list != null)
|
|
||||||
{
|
|
||||||
dataGridView.DataSource = list;
|
|
||||||
dataGridView.Columns["MessageId"].Visible = false;
|
|
||||||
dataGridView.Columns["ClientId"].Visible = false;
|
|
||||||
dataGridView.Columns["Body"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
|
||||||
}
|
|
||||||
|
|
||||||
_logger.LogInformation("Успешная загрузка писем");
|
_logger.LogInformation("Успешная загрузка писем");
|
||||||
}
|
}
|
||||||
|
27
SecuritySystem/SecuritySystem/FormMain.Designer.cs
generated
27
SecuritySystem/SecuritySystem/FormMain.Designer.cs
generated
@ -33,6 +33,7 @@
|
|||||||
toolStripMenuItem = new ToolStripMenuItem();
|
toolStripMenuItem = new ToolStripMenuItem();
|
||||||
SensorToolStripMenuItem = new ToolStripMenuItem();
|
SensorToolStripMenuItem = new ToolStripMenuItem();
|
||||||
SecureToolStripMenuItem = new ToolStripMenuItem();
|
SecureToolStripMenuItem = new ToolStripMenuItem();
|
||||||
|
письмаToolStripMenuItem = new ToolStripMenuItem();
|
||||||
reportsToolStripMenuItem = new ToolStripMenuItem();
|
reportsToolStripMenuItem = new ToolStripMenuItem();
|
||||||
sensorsToolStripMenuItem = new ToolStripMenuItem();
|
sensorsToolStripMenuItem = new ToolStripMenuItem();
|
||||||
sensorSecuresToolStripMenuItem = new ToolStripMenuItem();
|
sensorSecuresToolStripMenuItem = new ToolStripMenuItem();
|
||||||
@ -45,7 +46,7 @@
|
|||||||
buttonCreateOrder = new Button();
|
buttonCreateOrder = new Button();
|
||||||
buttonRef = new Button();
|
buttonRef = new Button();
|
||||||
buttonIssuedOrder = new Button();
|
buttonIssuedOrder = new Button();
|
||||||
письмаToolStripMenuItem = new ToolStripMenuItem();
|
createBackUpToolStripMenuItem = new ToolStripMenuItem();
|
||||||
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
|
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
|
||||||
menuStrip1.SuspendLayout();
|
menuStrip1.SuspendLayout();
|
||||||
SuspendLayout();
|
SuspendLayout();
|
||||||
@ -64,7 +65,7 @@
|
|||||||
// menuStrip1
|
// menuStrip1
|
||||||
//
|
//
|
||||||
menuStrip1.ImageScalingSize = new Size(20, 20);
|
menuStrip1.ImageScalingSize = new Size(20, 20);
|
||||||
menuStrip1.Items.AddRange(new ToolStripItem[] { toolStripMenuItem, reportsToolStripMenuItem, workWithClientsToolStripMenuItem, workWithImplementerToolStripMenuItem, startingWorkToolStripMenuItem });
|
menuStrip1.Items.AddRange(new ToolStripItem[] { toolStripMenuItem, reportsToolStripMenuItem, workWithClientsToolStripMenuItem, workWithImplementerToolStripMenuItem, startingWorkToolStripMenuItem, createBackUpToolStripMenuItem });
|
||||||
menuStrip1.Location = new Point(0, 0);
|
menuStrip1.Location = new Point(0, 0);
|
||||||
menuStrip1.Name = "menuStrip1";
|
menuStrip1.Name = "menuStrip1";
|
||||||
menuStrip1.Padding = new Padding(5, 2, 0, 2);
|
menuStrip1.Padding = new Padding(5, 2, 0, 2);
|
||||||
@ -82,17 +83,24 @@
|
|||||||
// SensorToolStripMenuItem
|
// SensorToolStripMenuItem
|
||||||
//
|
//
|
||||||
SensorToolStripMenuItem.Name = "SensorToolStripMenuItem";
|
SensorToolStripMenuItem.Name = "SensorToolStripMenuItem";
|
||||||
SensorToolStripMenuItem.Size = new Size(180, 22);
|
SensorToolStripMenuItem.Size = new Size(130, 22);
|
||||||
SensorToolStripMenuItem.Text = "Заготовки";
|
SensorToolStripMenuItem.Text = "Заготовки";
|
||||||
SensorToolStripMenuItem.Click += SensorToolStripMenuItem_Click;
|
SensorToolStripMenuItem.Click += SensorToolStripMenuItem_Click;
|
||||||
//
|
//
|
||||||
// SecureToolStripMenuItem
|
// SecureToolStripMenuItem
|
||||||
//
|
//
|
||||||
SecureToolStripMenuItem.Name = "SecureToolStripMenuItem";
|
SecureToolStripMenuItem.Name = "SecureToolStripMenuItem";
|
||||||
SecureToolStripMenuItem.Size = new Size(180, 22);
|
SecureToolStripMenuItem.Size = new Size(130, 22);
|
||||||
SecureToolStripMenuItem.Text = "Изделия";
|
SecureToolStripMenuItem.Text = "Изделия";
|
||||||
SecureToolStripMenuItem.Click += SecureToolStripMenuItem_Click;
|
SecureToolStripMenuItem.Click += SecureToolStripMenuItem_Click;
|
||||||
//
|
//
|
||||||
|
// письмаToolStripMenuItem
|
||||||
|
//
|
||||||
|
письмаToolStripMenuItem.Name = "письмаToolStripMenuItem";
|
||||||
|
письмаToolStripMenuItem.Size = new Size(130, 22);
|
||||||
|
письмаToolStripMenuItem.Text = "Письма";
|
||||||
|
письмаToolStripMenuItem.Click += MailsToolStripMenuItem_Click;
|
||||||
|
//
|
||||||
// reportsToolStripMenuItem
|
// reportsToolStripMenuItem
|
||||||
//
|
//
|
||||||
reportsToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { sensorsToolStripMenuItem, sensorSecuresToolStripMenuItem, ordersToolStripMenuItem });
|
reportsToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { sensorsToolStripMenuItem, sensorSecuresToolStripMenuItem, ordersToolStripMenuItem });
|
||||||
@ -189,12 +197,12 @@
|
|||||||
buttonIssuedOrder.UseVisualStyleBackColor = true;
|
buttonIssuedOrder.UseVisualStyleBackColor = true;
|
||||||
buttonIssuedOrder.Click += ButtonIssuedOrder_Click;
|
buttonIssuedOrder.Click += ButtonIssuedOrder_Click;
|
||||||
//
|
//
|
||||||
// письмаToolStripMenuItem
|
// createBackUpToolStripMenuItem
|
||||||
//
|
//
|
||||||
письмаToolStripMenuItem.Name = "письмаToolStripMenuItem";
|
createBackUpToolStripMenuItem.Name = "createBackUpToolStripMenuItem";
|
||||||
письмаToolStripMenuItem.Size = new Size(180, 22);
|
createBackUpToolStripMenuItem.Size = new Size(97, 20);
|
||||||
письмаToolStripMenuItem.Text = "Письма";
|
createBackUpToolStripMenuItem.Text = "Создать бекап";
|
||||||
письмаToolStripMenuItem.Click += MailsToolStripMenuItem_Click;
|
createBackUpToolStripMenuItem.Click += CreateBackUpToolStripMenuItem_Click;
|
||||||
//
|
//
|
||||||
// FormMain
|
// FormMain
|
||||||
//
|
//
|
||||||
@ -235,5 +243,6 @@
|
|||||||
private Button buttonRef;
|
private Button buttonRef;
|
||||||
private Button buttonIssuedOrder;
|
private Button buttonIssuedOrder;
|
||||||
private ToolStripMenuItem письмаToolStripMenuItem;
|
private ToolStripMenuItem письмаToolStripMenuItem;
|
||||||
|
private ToolStripMenuItem createBackUpToolStripMenuItem;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,6 +1,7 @@
|
|||||||
using SecuritySystemBusinessLogic.BusinessLogic;
|
using SecuritySystemBusinessLogic.BusinessLogic;
|
||||||
using SecuritySystemContracts.BindingModels;
|
using SecuritySystemContracts.BindingModels;
|
||||||
using SecuritySystemContracts.BusinessLogicsContracts;
|
using SecuritySystemContracts.BusinessLogicsContracts;
|
||||||
|
using SecuritySystemContracts.DI;
|
||||||
using SecuritySystemDataModels.Enums;
|
using SecuritySystemDataModels.Enums;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using System;
|
using System;
|
||||||
@ -25,7 +26,9 @@ namespace SecuritySystem
|
|||||||
|
|
||||||
private readonly IWorkProcess _workProcess;
|
private readonly IWorkProcess _workProcess;
|
||||||
|
|
||||||
public FormMain(ILogger<FormMain> logger, IOrderLogic orderLogic, IReportLogic reportLogic, IWorkProcess workProcess)
|
private readonly IBackUpLogic _backUpLogic;
|
||||||
|
|
||||||
|
public FormMain(ILogger<FormMain> logger, IOrderLogic orderLogic, IReportLogic reportLogic, IWorkProcess workProcess, IBackUpLogic backUpLogic)
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
|
||||||
@ -33,6 +36,7 @@ namespace SecuritySystem
|
|||||||
_orderLogic = orderLogic;
|
_orderLogic = orderLogic;
|
||||||
_reportLogic = reportLogic;
|
_reportLogic = reportLogic;
|
||||||
_workProcess = workProcess;
|
_workProcess = workProcess;
|
||||||
|
_backUpLogic = backUpLogic;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void FormMain_Load(object sender, EventArgs e)
|
private void FormMain_Load(object sender, EventArgs e)
|
||||||
@ -46,18 +50,7 @@ namespace SecuritySystem
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var list = _orderLogic.ReadList(null);
|
dataGridView.FillandConfigGrid(_orderLogic.ReadList(null));
|
||||||
|
|
||||||
if (list != null)
|
|
||||||
{
|
|
||||||
dataGridView.DataSource = list;
|
|
||||||
dataGridView.Columns["SecureId"].Visible = false;
|
|
||||||
dataGridView.Columns["ImplementerId"].Visible = false;
|
|
||||||
dataGridView.Columns["ClientId"].Visible = false;
|
|
||||||
dataGridView.Columns["SecureName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
|
||||||
dataGridView.Columns["ClientFIO"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
|
||||||
dataGridView.Columns["ImplementerFIO"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
|
||||||
}
|
|
||||||
|
|
||||||
_logger.LogInformation("Çàãðóçêà çàêàçîâ");
|
_logger.LogInformation("Çàãðóçêà çàêàçîâ");
|
||||||
}
|
}
|
||||||
@ -70,36 +63,26 @@ namespace SecuritySystem
|
|||||||
|
|
||||||
private void SensorToolStripMenuItem_Click(object sender, EventArgs e)
|
private void SensorToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
var service = Program.ServiceProvider?.GetService(typeof(FormSensors));
|
var form = DependencyManager.Instance.Resolve<FormSensors>();
|
||||||
|
|
||||||
if (service is FormSensors form)
|
|
||||||
{
|
|
||||||
form.ShowDialog();
|
form.ShowDialog();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private void SecureToolStripMenuItem_Click(object sender, EventArgs e)
|
private void SecureToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
var service = Program.ServiceProvider?.GetService(typeof(FormSecures));
|
var form = DependencyManager.Instance.Resolve<FormSecures>();
|
||||||
|
|
||||||
if (service is FormSecures form)
|
|
||||||
{
|
|
||||||
form.ShowDialog();
|
form.ShowDialog();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private void ButtonCreateOrder_Click(object sender, EventArgs e)
|
private void ButtonCreateOrder_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
var service = Program.ServiceProvider?.GetService(typeof(FormCreateOrder));
|
var form = DependencyManager.Instance.Resolve<FormCreateOrder>();
|
||||||
|
|
||||||
if (service is FormCreateOrder form)
|
|
||||||
{
|
|
||||||
form.ShowDialog();
|
form.ShowDialog();
|
||||||
LoadData();
|
LoadData();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ButtonIssuedOrder_Click(object sender, EventArgs e)
|
private void ButtonIssuedOrder_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
if (dataGridView.SelectedRows.Count == 1)
|
if (dataGridView.SelectedRows.Count == 1)
|
||||||
@ -153,59 +136,70 @@ namespace SecuritySystem
|
|||||||
|
|
||||||
private void SensorSecuresToolStripMenuItem_Click(object sender, EventArgs e)
|
private void SensorSecuresToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
var service = Program.ServiceProvider?.GetService(typeof(FormReportSecureSensors));
|
var form = DependencyManager.Instance.Resolve<FormReportSecureSensors>();
|
||||||
|
|
||||||
if (service is FormReportSecureSensors form)
|
|
||||||
{
|
|
||||||
form.ShowDialog();
|
form.ShowDialog();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OrdersToolStripMenuItem_Click(object sender, EventArgs e)
|
private void OrdersToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
var service = Program.ServiceProvider?.GetService(typeof(FormReportOrders));
|
var form = DependencyManager.Instance.Resolve<FormReportOrders>();
|
||||||
|
|
||||||
if (service is FormReportOrders form)
|
|
||||||
{
|
|
||||||
form.ShowDialog();
|
form.ShowDialog();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private void ClientsToolStripMenuItem_Click(object sender, EventArgs e)
|
private void ClientsToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
var service = Program.ServiceProvider?.GetService(typeof(FormClients));
|
var form = DependencyManager.Instance.Resolve<FormClients>();
|
||||||
|
|
||||||
if (service is FormClients form)
|
|
||||||
{
|
|
||||||
form.ShowDialog();
|
form.ShowDialog();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private void StartingWorkToolStripMenuItem_Click(object sender, EventArgs e)
|
private void StartingWorkToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
_workProcess.DoWork((Program.ServiceProvider?.GetService(typeof(IImplementerLogic)) as IImplementerLogic)!, _orderLogic);
|
_workProcess.DoWork(DependencyManager.Instance.Resolve<IImplementerLogic>()!, _orderLogic);
|
||||||
|
|
||||||
MessageBox.Show("Ïðîöåññ îáðàáîòêè çàïóùåí", "Ñîîáùåíèå", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
MessageBox.Show("Ïðîöåññ îáðàáîòêè çàïóùåí", "Ñîîáùåíèå", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ImplementerToolStripMenuItem_Click(object sender, EventArgs e)
|
private void ImplementerToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
var service = Program.ServiceProvider?.GetService(typeof(FormImplementers));
|
var form = DependencyManager.Instance.Resolve<FormImplementers>();
|
||||||
|
|
||||||
if (service is FormImplementers form)
|
|
||||||
{
|
|
||||||
form.ShowDialog();
|
form.ShowDialog();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private void MailsToolStripMenuItem_Click(object sender, EventArgs e)
|
private void MailsToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
var service = Program.ServiceProvider?.GetService(typeof(FormMails));
|
var form = DependencyManager.Instance.Resolve<FormMails>();
|
||||||
|
|
||||||
if (service is FormMails form)
|
|
||||||
{
|
|
||||||
form.ShowDialog();
|
form.ShowDialog();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void CreateBackUpToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (_backUpLogic != null)
|
||||||
|
{
|
||||||
|
var fbd = new FolderBrowserDialog();
|
||||||
|
|
||||||
|
if (fbd.ShowDialog() == DialogResult.OK)
|
||||||
|
{
|
||||||
|
_backUpLogic.CreateBackUp(new 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 SecuritySystemContracts.BindingModels;
|
using SecuritySystemContracts.BindingModels;
|
||||||
using SecuritySystemContracts.BusinessLogicsContracts;
|
using SecuritySystemContracts.BusinessLogicsContracts;
|
||||||
|
using SecuritySystemContracts.DI;
|
||||||
using SecuritySystemContracts.SearchModels;
|
using SecuritySystemContracts.SearchModels;
|
||||||
using SecuritySystemDataModels.Models;
|
using SecuritySystemDataModels.Models;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
@ -89,10 +90,8 @@ namespace SecuritySystem
|
|||||||
|
|
||||||
private void ButtonAdd_Click(object sender, EventArgs e)
|
private void ButtonAdd_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
var service = Program.ServiceProvider?.GetService(typeof(FormSecureSensor));
|
var form = DependencyManager.Instance.Resolve<FormSecureSensor>();
|
||||||
|
|
||||||
if (service is FormSecureSensor form)
|
|
||||||
{
|
|
||||||
if (form.ShowDialog() == DialogResult.OK)
|
if (form.ShowDialog() == DialogResult.OK)
|
||||||
{
|
{
|
||||||
if (form.SensorModel == null)
|
if (form.SensorModel == null)
|
||||||
@ -114,16 +113,13 @@ namespace SecuritySystem
|
|||||||
LoadData();
|
LoadData();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private void ButtonUpd_Click(object sender, EventArgs e)
|
private void ButtonUpd_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
if (dataGridView.SelectedRows.Count == 1)
|
if (dataGridView.SelectedRows.Count == 1)
|
||||||
{
|
{
|
||||||
var service = Program.ServiceProvider?.GetService(typeof(FormSecureSensor));
|
var form = DependencyManager.Instance.Resolve<FormSecureSensor>();
|
||||||
|
|
||||||
if (service is FormSecureSensor form)
|
|
||||||
{
|
|
||||||
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells[0].Value);
|
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells[0].Value);
|
||||||
form.Id = id;
|
form.Id = id;
|
||||||
form.Count = _secureSensors[id].Item2;
|
form.Count = _secureSensors[id].Item2;
|
||||||
@ -142,7 +138,6 @@ namespace SecuritySystem
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private void ButtonDel_Click(object sender, EventArgs e)
|
private void ButtonDel_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
using SecuritySystemContracts.BindingModels;
|
using SecuritySystemBusinessLogic.BusinessLogic;
|
||||||
|
using SecuritySystemContracts.BindingModels;
|
||||||
using SecuritySystemContracts.BusinessLogicsContracts;
|
using SecuritySystemContracts.BusinessLogicsContracts;
|
||||||
|
using SecuritySystemContracts.DI;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
@ -18,6 +20,7 @@ namespace SecuritySystem
|
|||||||
private readonly ILogger _logger;
|
private readonly ILogger _logger;
|
||||||
|
|
||||||
private readonly ISecureLogic _logic;
|
private readonly ISecureLogic _logic;
|
||||||
|
|
||||||
public FormSecures(ILogger<FormSecures> logger, ISecureLogic logic)
|
public FormSecures(ILogger<FormSecures> logger, ISecureLogic logic)
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -36,15 +39,7 @@ namespace SecuritySystem
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var list = _logic.ReadList(null);
|
dataGridView.FillandConfigGrid(_logic.ReadList(null));
|
||||||
|
|
||||||
if (list != null)
|
|
||||||
{
|
|
||||||
dataGridView.DataSource = list;
|
|
||||||
dataGridView.Columns["Id"].Visible = false;
|
|
||||||
dataGridView.Columns["SecureSensors"].Visible = false;
|
|
||||||
dataGridView.Columns["SecureName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
|
||||||
}
|
|
||||||
|
|
||||||
_logger.LogInformation("Загрузка изделий");
|
_logger.LogInformation("Загрузка изделий");
|
||||||
}
|
}
|
||||||
@ -57,25 +52,20 @@ namespace SecuritySystem
|
|||||||
|
|
||||||
private void ButtonAdd_Click(object sender, EventArgs e)
|
private void ButtonAdd_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
var service = Program.ServiceProvider?.GetService(typeof(FormSecure));
|
var form = DependencyManager.Instance.Resolve<FormSecure>();
|
||||||
|
|
||||||
if (service is FormSecure form)
|
|
||||||
{
|
|
||||||
if (form.ShowDialog() == DialogResult.OK)
|
if (form.ShowDialog() == DialogResult.OK)
|
||||||
{
|
{
|
||||||
LoadData();
|
LoadData();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private void ButtonUpd_Click(object sender, EventArgs e)
|
private void ButtonUpd_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
if (dataGridView.SelectedRows.Count == 1)
|
if (dataGridView.SelectedRows.Count == 1)
|
||||||
{
|
{
|
||||||
var service = Program.ServiceProvider?.GetService(typeof(FormSecure));
|
var form = DependencyManager.Instance.Resolve<FormSecure>();
|
||||||
|
|
||||||
if (service is FormSecure form)
|
|
||||||
{
|
|
||||||
form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||||
|
|
||||||
if (form.ShowDialog() == DialogResult.OK)
|
if (form.ShowDialog() == DialogResult.OK)
|
||||||
@ -84,7 +74,6 @@ namespace SecuritySystem
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private void ButtonDelete_Click(object sender, EventArgs e)
|
private void ButtonDelete_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
using SecuritySystemContracts.BindingModels;
|
using SecuritySystemBusinessLogic.BusinessLogic;
|
||||||
|
using SecuritySystemContracts.BindingModels;
|
||||||
using SecuritySystemContracts.BusinessLogicsContracts;
|
using SecuritySystemContracts.BusinessLogicsContracts;
|
||||||
|
using SecuritySystemContracts.DI;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
@ -35,15 +37,7 @@ namespace SecuritySystem
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var list = _logic.ReadList(null);
|
dataGridView.FillandConfigGrid(_logic.ReadList(null));
|
||||||
|
|
||||||
//растягиваем колонку Название на всю ширину, колонку Id скрываем
|
|
||||||
if (list != null)
|
|
||||||
{
|
|
||||||
dataGridView.DataSource = list;
|
|
||||||
dataGridView.Columns["Id"].Visible = false;
|
|
||||||
dataGridView.Columns["SensorName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
|
||||||
}
|
|
||||||
|
|
||||||
_logger.LogInformation("Загрузка заготовок");
|
_logger.LogInformation("Загрузка заготовок");
|
||||||
}
|
}
|
||||||
@ -57,26 +51,21 @@ namespace SecuritySystem
|
|||||||
|
|
||||||
private void ButtonAdd_Click(object sender, EventArgs e)
|
private void ButtonAdd_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
var service = Program.ServiceProvider?.GetService(typeof(FormSensor));
|
var form = DependencyManager.Instance.Resolve<FormSensor>();
|
||||||
|
|
||||||
if (service is FormSensor form)
|
|
||||||
{
|
|
||||||
if (form.ShowDialog() == DialogResult.OK)
|
if (form.ShowDialog() == DialogResult.OK)
|
||||||
{
|
{
|
||||||
LoadData();
|
LoadData();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
//проверяем наличие выделенной строки
|
//проверяем наличие выделенной строки
|
||||||
private void ButtonUpd_Click(object sender, EventArgs e)
|
private void ButtonUpd_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
if (dataGridView.SelectedRows.Count == 1)
|
if (dataGridView.SelectedRows.Count == 1)
|
||||||
{
|
{
|
||||||
var service = Program.ServiceProvider?.GetService(typeof(FormSensor));
|
var form = DependencyManager.Instance.Resolve<FormSensor>();
|
||||||
|
|
||||||
if (service is FormSensor form)
|
|
||||||
{
|
|
||||||
form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||||
if (form.ShowDialog() == DialogResult.OK)
|
if (form.ShowDialog() == DialogResult.OK)
|
||||||
{
|
{
|
||||||
@ -84,7 +73,6 @@ namespace SecuritySystem
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private void ButtonDelete_Click(object sender, EventArgs e)
|
private void ButtonDelete_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
|
@ -4,6 +4,7 @@ using SecuritySystemBusinessLogic.OfficePackage;
|
|||||||
using SecuritySystemBusinessLogic.OfficePackage.Implements;
|
using SecuritySystemBusinessLogic.OfficePackage.Implements;
|
||||||
using SecuritySystemContracts.BindingModels;
|
using SecuritySystemContracts.BindingModels;
|
||||||
using SecuritySystemContracts.BusinessLogicsContracts;
|
using SecuritySystemContracts.BusinessLogicsContracts;
|
||||||
|
using SecuritySystemContracts.DI;
|
||||||
using SecuritySystemContracts.StoragesContracts;
|
using SecuritySystemContracts.StoragesContracts;
|
||||||
using SecuritySystemDatabaseImplement.Implements;
|
using SecuritySystemDatabaseImplement.Implements;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
@ -14,10 +15,6 @@ namespace SecuritySystem
|
|||||||
{
|
{
|
||||||
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>
|
||||||
@ -28,12 +25,11 @@ namespace SecuritySystem
|
|||||||
// see https://aka.ms/applicationconfiguration.
|
// see https://aka.ms/applicationconfiguration.
|
||||||
ApplicationConfiguration.Initialize();
|
ApplicationConfiguration.Initialize();
|
||||||
var services = new ServiceCollection();
|
var services = new ServiceCollection();
|
||||||
ConfigureServices(services);
|
InitDependency();
|
||||||
_serviceProvider = services.BuildServiceProvider();
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var mailSender = _serviceProvider.GetService<AbstractMailWorker>();
|
var mailSender = DependencyManager.Instance.Resolve<AbstractMailWorker>();
|
||||||
mailSender?.MailConfig(new MailConfigBindingModel
|
mailSender?.MailConfig(new MailConfigBindingModel
|
||||||
{
|
{
|
||||||
MailLogin = System.Configuration.ConfigurationManager.AppSettings["MailLogin"] ?? string.Empty,
|
MailLogin = System.Configuration.ConfigurationManager.AppSettings["MailLogin"] ?? string.Empty,
|
||||||
@ -49,60 +45,56 @@ namespace SecuritySystem
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
var logger = _serviceProvider.GetService<ILogger>();
|
var logger = DependencyManager.Instance.Resolve<ILogger>();
|
||||||
|
|
||||||
logger?.LogError(ex, "Îøèáêà ðàáîòû ñ ïî÷òîé");
|
logger?.LogError(ex, "Îøèáêà ðàáîòû ñ ïî÷òîé");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Application.Run(_serviceProvider.GetRequiredService<FormMain>());
|
Application.Run(DependencyManager.Instance.Resolve<FormMain>());
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void ConfigureServices(ServiceCollection services)
|
private static void InitDependency()
|
||||||
{
|
{
|
||||||
services.AddLogging(option =>
|
DependencyManager.InitDependency();
|
||||||
|
|
||||||
|
DependencyManager.Instance.AddLogging(option =>
|
||||||
{
|
{
|
||||||
option.SetMinimumLevel(LogLevel.Information);
|
option.SetMinimumLevel(LogLevel.Information);
|
||||||
option.AddNLog("nlog.config");
|
option.AddNLog("nlog.config");
|
||||||
});
|
});
|
||||||
|
|
||||||
services.AddTransient<ISensorStorage, SensorStorage>();
|
DependencyManager.Instance.RegisterType<ISensorLogic, SensorLogic>();
|
||||||
services.AddTransient<IOrderStorage, OrderStorage>();
|
DependencyManager.Instance.RegisterType<IOrderLogic, OrderLogic>();
|
||||||
services.AddTransient<ISecureStorage, SecureStorage>();
|
DependencyManager.Instance.RegisterType<ISecureLogic, SecureLogic>();
|
||||||
services.AddTransient<IClientStorage, ClientStorage>();
|
DependencyManager.Instance.RegisterType<IReportLogic, ReportLogic>();
|
||||||
services.AddTransient<IImplementerStorage, ImplementerStorage>();
|
DependencyManager.Instance.RegisterType<IClientLogic, ClientLogic>();
|
||||||
services.AddTransient<IMessageInfoStorage, MessageInfoStorage>();
|
DependencyManager.Instance.RegisterType<IImplementerLogic, ImplementerLogic>();
|
||||||
|
DependencyManager.Instance.RegisterType<IMessageInfoLogic, MessageInfoLogic>();
|
||||||
|
DependencyManager.Instance.RegisterType<IBackUpLogic, BackUpLogic>();
|
||||||
|
|
||||||
services.AddTransient<ISensorLogic, SensorLogic>();
|
DependencyManager.Instance.RegisterType<AbstractSaveToExcel, SaveToExcel>();
|
||||||
services.AddTransient<IOrderLogic, OrderLogic>();
|
DependencyManager.Instance.RegisterType<AbstractSaveToWord, SaveToWord>();
|
||||||
services.AddTransient<ISecureLogic, SecureLogic>();
|
DependencyManager.Instance.RegisterType<AbstractSaveToPdf, SaveToPdf>();
|
||||||
services.AddTransient<IReportLogic, ReportLogic>();
|
|
||||||
services.AddTransient<IClientLogic, ClientLogic>();
|
|
||||||
services.AddTransient<IImplementerLogic, ImplementerLogic>();
|
|
||||||
services.AddTransient<IMessageInfoLogic, MessageInfoLogic>();
|
|
||||||
|
|
||||||
services.AddTransient<AbstractSaveToExcel, SaveToExcel>();
|
DependencyManager.Instance.RegisterType<IWorkProcess, WorkModeling>();
|
||||||
services.AddTransient<AbstractSaveToWord, SaveToWord>();
|
DependencyManager.Instance.RegisterType<AbstractMailWorker, MailKitWorker>(true);
|
||||||
services.AddTransient<AbstractSaveToPdf, SaveToPdf>();
|
|
||||||
|
|
||||||
services.AddTransient<IWorkProcess, WorkModeling>();
|
DependencyManager.Instance.RegisterType<FormMain>();
|
||||||
services.AddSingleton<AbstractMailWorker, MailKitWorker>();
|
DependencyManager.Instance.RegisterType<FormSensor>();
|
||||||
|
DependencyManager.Instance.RegisterType<FormSensors>();
|
||||||
services.AddTransient<FormMain>();
|
DependencyManager.Instance.RegisterType<FormCreateOrder>();
|
||||||
services.AddTransient<FormSensor>();
|
DependencyManager.Instance.RegisterType<FormSecure>();
|
||||||
services.AddTransient<FormSensors>();
|
DependencyManager.Instance.RegisterType<FormSecureSensor>();
|
||||||
services.AddTransient<FormCreateOrder>();
|
DependencyManager.Instance.RegisterType<FormSecures>();
|
||||||
services.AddTransient<FormSecure>();
|
DependencyManager.Instance.RegisterType<FormReportSecureSensors>();
|
||||||
services.AddTransient<FormSecures>();
|
DependencyManager.Instance.RegisterType<FormReportOrders>();
|
||||||
services.AddTransient<FormSecureSensor>();
|
DependencyManager.Instance.RegisterType<FormClients>();
|
||||||
services.AddTransient<FormReportSecureSensors>();
|
DependencyManager.Instance.RegisterType<FormImplementer>();
|
||||||
services.AddTransient<FormReportOrders>();
|
DependencyManager.Instance.RegisterType<FormImplementers>();
|
||||||
services.AddTransient<FormClients>();
|
DependencyManager.Instance.RegisterType<FormMails>();
|
||||||
services.AddTransient<FormImplementers>();
|
|
||||||
services.AddTransient<FormImplementer>();
|
|
||||||
services.AddTransient<FormMails>();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void MailCheck(object obj) => ServiceProvider?.GetService<AbstractMailWorker>()?.MailCheck();
|
private static void MailCheck(object obj) => DependencyManager.Instance.Resolve<AbstractMailWorker>()?.MailCheck();
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -0,0 +1,129 @@
|
|||||||
|
using SecuritySystemContracts.BindingModels;
|
||||||
|
using SecuritySystemContracts.BusinessLogicsContracts;
|
||||||
|
using SecuritySystemContracts.StoragesContracts;
|
||||||
|
using SecuritySystemDataModels;
|
||||||
|
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 SecuritySystemBusinessLogic.BusinessLogic
|
||||||
|
{
|
||||||
|
public class BackUpLogic : IBackUpLogic
|
||||||
|
{
|
||||||
|
private readonly ILogger _logger;
|
||||||
|
|
||||||
|
private readonly IBackUpInfo _backUpInfo;
|
||||||
|
|
||||||
|
public BackUpLogic(ILogger<BackUpLogic> logger, IBackUpInfo backUpInfo)
|
||||||
|
{
|
||||||
|
_logger = logger;
|
||||||
|
_backUpInfo = backUpInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void CreateBackUp(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)
|
||||||
|
{
|
||||||
|
//проверка на то, является ли тип интерфейсом и унаследован ли он от IId
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
//три строчки ниже - сериализация файлов в json
|
||||||
|
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,33 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace SecuritySystemContracts.Attributes
|
||||||
|
{
|
||||||
|
//указываем, что данный атрибут можно прописать только в Property
|
||||||
|
[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,27 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace SecuritySystemContracts.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 SecuritySystemContracts.BindingModels
|
||||||
|
{
|
||||||
|
public class BackUpSaveBinidngModel
|
||||||
|
{
|
||||||
|
public string FolderName { get; set; } = string.Empty;
|
||||||
|
}
|
||||||
|
}
|
@ -9,6 +9,8 @@ namespace SecuritySystemContracts.BindingModels
|
|||||||
{
|
{
|
||||||
public class MessageInfoBindingModel : IMessageInfoModel
|
public class MessageInfoBindingModel : IMessageInfoModel
|
||||||
{
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
|
||||||
public string MessageId { get; set; } = string.Empty;
|
public string MessageId { get; set; } = string.Empty;
|
||||||
|
|
||||||
public int? ClientId { get; set; }
|
public int? ClientId { get; set; }
|
||||||
|
@ -0,0 +1,16 @@
|
|||||||
|
using SecuritySystemContracts.BindingModels;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace SecuritySystemContracts.BusinessLogicsContracts
|
||||||
|
{
|
||||||
|
//интерфейс создания бекапа
|
||||||
|
public interface IBackUpLogic
|
||||||
|
{
|
||||||
|
//путь и имя файла для архивации
|
||||||
|
void CreateBackUp(BackUpSaveBinidngModel model);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,63 @@
|
|||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace SecuritySystemContracts.DI
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Менеджер для работы с зависимостями
|
||||||
|
/// </summary>
|
||||||
|
public class DependencyManager
|
||||||
|
{
|
||||||
|
private readonly IDependencyContainer _dependencyManager;
|
||||||
|
|
||||||
|
private static DependencyManager? _manager;
|
||||||
|
|
||||||
|
private static readonly object _locjObject = new();
|
||||||
|
|
||||||
|
private DependencyManager()
|
||||||
|
{
|
||||||
|
_dependencyManager = new UnityDependencyContainer();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static DependencyManager Instance
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (_manager == null) { lock (_locjObject) { _manager = new DependencyManager(); } }
|
||||||
|
|
||||||
|
return _manager;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//Иницализация библиотек, в которых идут установки зависомстей
|
||||||
|
public static void InitDependency()
|
||||||
|
{
|
||||||
|
var ext = ServiceProviderLoader.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,26 @@
|
|||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace SecuritySystemContracts.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,20 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace SecuritySystemContracts.DI
|
||||||
|
{
|
||||||
|
|
||||||
|
//Интерфейс для регистрации зависимостей в модулях
|
||||||
|
public interface IImplementationExtension
|
||||||
|
{
|
||||||
|
//для установления приоритета
|
||||||
|
public int Priority { get; }
|
||||||
|
|
||||||
|
//Регистрация сервисов
|
||||||
|
public void RegisterServices();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -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 SecuritySystemContracts.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>()!;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,61 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Reflection;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace SecuritySystemContracts.DI
|
||||||
|
{
|
||||||
|
//Загрузчик данных
|
||||||
|
public static partial class ServiceProviderLoader
|
||||||
|
{
|
||||||
|
//Загрузка всех классов-реализаций IImplementationExtension
|
||||||
|
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,43 @@
|
|||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using Unity.Microsoft.Logging;
|
||||||
|
using Unity;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace SecuritySystemContracts.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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -15,6 +15,8 @@
|
|||||||
<PackageReference Include="Microsoft.Extensions.Logging" Version="8.0.0" />
|
<PackageReference Include="Microsoft.Extensions.Logging" Version="8.0.0" />
|
||||||
<PackageReference Include="NLog.Extensions.Logging" Version="5.3.8" />
|
<PackageReference Include="NLog.Extensions.Logging" Version="5.3.8" />
|
||||||
<PackageReference Include="System.Runtime.CompilerServices.Unsafe" Version="6.0.0" />
|
<PackageReference Include="System.Runtime.CompilerServices.Unsafe" Version="6.0.0" />
|
||||||
|
<PackageReference Include="Unity" Version="5.11.10" />
|
||||||
|
<PackageReference Include="Unity.Microsoft.Logging" Version="5.10.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
@ -0,0 +1,18 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace SecuritySystemContracts.StoragesContracts
|
||||||
|
{
|
||||||
|
//интерфейс получения данных по всем сущностям
|
||||||
|
public interface IBackUpInfo
|
||||||
|
{
|
||||||
|
//метод получения данных по всем сущностям
|
||||||
|
List<T>? GetList<T>() where T : class, new();
|
||||||
|
|
||||||
|
Type? GetTypeByModelInterface(string modelInterfaceName);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,4 +1,5 @@
|
|||||||
using SecuritySystemDataModels.Models;
|
using SecuritySystemContracts.Attributes;
|
||||||
|
using SecuritySystemDataModels.Models;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
@ -10,15 +11,16 @@ namespace SecuritySystemContracts.ViewModels
|
|||||||
{
|
{
|
||||||
public class ClientViewModel : IClientModel
|
public class ClientViewModel : IClientModel
|
||||||
{
|
{
|
||||||
|
[Column(visible: false)]
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
|
|
||||||
[DisplayName("ФИО клиента")]
|
[Column(title: "ФИО клиента", width: 150)]
|
||||||
public string ClientFIO { get; set; } = string.Empty;
|
public string ClientFIO { get; set; } = string.Empty;
|
||||||
|
|
||||||
[DisplayName("Логин (эл. почта)")]
|
[Column(title: "Логие (эл. почта)", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)]
|
||||||
public string Email { get; set; } = string.Empty;
|
public string Email { get; set; } = string.Empty;
|
||||||
|
|
||||||
[DisplayName("Пароль")]
|
[Column(title: "Пароль", width: 150)]
|
||||||
public string Password { get; set; } = string.Empty;
|
public string Password { get; set; } = string.Empty;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
using SecuritySystemDataModels.Models;
|
using SecuritySystemContracts.Attributes;
|
||||||
|
using SecuritySystemDataModels.Models;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
@ -10,18 +11,19 @@ namespace SecuritySystemContracts.ViewModels
|
|||||||
{
|
{
|
||||||
public class ImplementerViewModel : IImplementerModel
|
public class ImplementerViewModel : IImplementerModel
|
||||||
{
|
{
|
||||||
|
[Column(visible: false)]
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
|
|
||||||
[DisplayName("ФИО исполнителя")]
|
[Column(title: "ФИО исполнителя", width: 150)]
|
||||||
public string ImplementerFIO { get; set; } = string.Empty;
|
public string ImplementerFIO { get; set; } = string.Empty;
|
||||||
|
|
||||||
[DisplayName("Пароль")]
|
[Column(title: "Пароль", width: 150)]
|
||||||
public string Password { get; set; } = string.Empty;
|
public string Password { get; set; } = string.Empty;
|
||||||
|
|
||||||
[DisplayName("Стаж")]
|
[Column(title: "Стаж", width: 150)]
|
||||||
public int WorkExperience { get; set; }
|
public int WorkExperience { get; set; }
|
||||||
|
|
||||||
[DisplayName("Квалификация")]
|
[Column(title: "Квалификация", width: 150)]
|
||||||
public int Qualification { get; set; }
|
public int Qualification { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
using SecuritySystemDataModels.Models;
|
using SecuritySystemContracts.Attributes;
|
||||||
|
using SecuritySystemDataModels.Models;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
@ -10,20 +11,25 @@ namespace SecuritySystemContracts.ViewModels
|
|||||||
{
|
{
|
||||||
public class MessageInfoViewModel : IMessageInfoModel
|
public class MessageInfoViewModel : IMessageInfoModel
|
||||||
{
|
{
|
||||||
|
[Column(visible: false)]
|
||||||
|
public int Id { get; set; }
|
||||||
|
|
||||||
|
[Column(visible: false)]
|
||||||
public string MessageId { get; set; } = string.Empty;
|
public string MessageId { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
[Column(visible: false)]
|
||||||
public int? ClientId { get; set; }
|
public int? ClientId { get; set; }
|
||||||
|
|
||||||
[DisplayName("Отправитель")]
|
[Column(title: "Отправитель", width: 150)]
|
||||||
public string SenderName { get; set; } = string.Empty;
|
public string SenderName { get; set; } = string.Empty;
|
||||||
|
|
||||||
[DisplayName("Дата отправки")]
|
[Column(title: "Дата отправки", width: 150)]
|
||||||
public DateTime DateDelivery { get; set; } = DateTime.Now;
|
public DateTime DateDelivery { get; set; } = DateTime.Now;
|
||||||
|
|
||||||
[DisplayName("Заголовок")]
|
[Column(title: "Заголовок", width: 150)]
|
||||||
public string Subject { get; set; } = string.Empty;
|
public string Subject { get; set; } = string.Empty;
|
||||||
|
|
||||||
[DisplayName("Текст")]
|
[Column(title: "Текст", width: 150)]
|
||||||
public string Body { get; set; } = string.Empty;
|
public string Body { get; set; } = string.Empty;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
using SecuritySystemDataModels.Enums;
|
using SecuritySystemContracts.Attributes;
|
||||||
|
using SecuritySystemDataModels.Enums;
|
||||||
using SecuritySystemDataModels.Models;
|
using SecuritySystemDataModels.Models;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
@ -12,37 +13,40 @@ namespace SecuritySystemContracts.ViewModels
|
|||||||
//класс для отображения пользователю информации о заказах
|
//класс для отображения пользователю информации о заказах
|
||||||
public class OrderViewModel : IOrderModel
|
public class OrderViewModel : IOrderModel
|
||||||
{
|
{
|
||||||
[DisplayName("Номер")]
|
[Column(visible: false)]
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
|
|
||||||
|
[Column(visible: false)]
|
||||||
public int ClientId { get; set; }
|
public int ClientId { get; set; }
|
||||||
|
|
||||||
|
[Column(visible: false)]
|
||||||
public int? ImplementerId { get; set; }
|
public int? ImplementerId { get; set; }
|
||||||
|
|
||||||
|
[Column(visible: false)]
|
||||||
public int SecureId { get; set; }
|
public int SecureId { get; set; }
|
||||||
|
|
||||||
[DisplayName("ФИО клиента")]
|
[Column(title: "ФИО клиента", width: 150)]
|
||||||
public string ClientFIO { get; set; } = string.Empty;
|
public string ClientFIO { get; set; } = string.Empty;
|
||||||
|
|
||||||
[DisplayName("Изделие")]
|
[Column(title: "Изделие", width: 150)]
|
||||||
public string SecureName { get; set; } = string.Empty;
|
public string SecureName { get; set; } = string.Empty;
|
||||||
|
|
||||||
[DisplayName("ФИО исполнителя")]
|
[Column(title: "ФИО исполнителя", width: 150)]
|
||||||
public string ImplementerFIO { get; set; } = string.Empty;
|
public string ImplementerFIO { get; set; } = string.Empty;
|
||||||
|
|
||||||
[DisplayName("Количество")]
|
[Column(title: "Количество", width: 150)]
|
||||||
public int Count { get; set; }
|
public int Count { get; set; }
|
||||||
|
|
||||||
[DisplayName("Сумма")]
|
[Column(title: "Сумма", width: 150)]
|
||||||
public double Sum { get; set; }
|
public double Sum { get; set; }
|
||||||
|
|
||||||
[DisplayName("Статус")]
|
[Column(title: "Статус", width: 150)]
|
||||||
public OrderStatus Status { get; set; } = OrderStatus.Неизвестен;
|
public OrderStatus Status { get; set; } = OrderStatus.Неизвестен;
|
||||||
|
|
||||||
[DisplayName("Дата создания")]
|
[Column(title: "Дата создания", width: 150)]
|
||||||
public DateTime DateCreate { get; set; } = DateTime.Now;
|
public DateTime DateCreate { get; set; } = DateTime.Now;
|
||||||
|
|
||||||
[DisplayName("Дата выполнения")]
|
[Column(title: "Дата выполнения", width: 150)]
|
||||||
public DateTime? DateImplement { get; set; }
|
public DateTime? DateImplement { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
using SecuritySystemDataModels.Models;
|
using SecuritySystemContracts.Attributes;
|
||||||
|
using SecuritySystemDataModels.Models;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
@ -11,14 +12,16 @@ namespace SecuritySystemContracts.ViewModels
|
|||||||
//класс для отображения пользователю информаци о продуктах (изделиях)
|
//класс для отображения пользователю информаци о продуктах (изделиях)
|
||||||
public class SecureViewModel : ISecureModel
|
public class SecureViewModel : ISecureModel
|
||||||
{
|
{
|
||||||
|
[Column(visible: false)]
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
|
|
||||||
[DisplayName("Навание изделия")]
|
[Column(title: "Навание изделия", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)]
|
||||||
public string SecureName { get; set; } = string.Empty;
|
public string SecureName { get; set; } = string.Empty;
|
||||||
|
|
||||||
[DisplayName("Цена")]
|
[Column(title: "Цена", width: 150)]
|
||||||
public double Price { get; set; }
|
public double Price { get; set; }
|
||||||
|
|
||||||
|
[Column(visible: false)]
|
||||||
public Dictionary<int, (ISensorModel, int)> SecureSensors { get; set; } = new();
|
public Dictionary<int, (ISensorModel, int)> SecureSensors { get; set; } = new();
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -5,18 +5,20 @@ using System.Collections.Generic;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using SecuritySystemContracts.Attributes;
|
||||||
|
|
||||||
namespace SecuritySystemContracts.ViewModels
|
namespace SecuritySystemContracts.ViewModels
|
||||||
{
|
{
|
||||||
//класс для отображения пользователю данных
|
//класс для отображения пользователю данных
|
||||||
public class SensorViewModel : ISensorModel
|
public class SensorViewModel : ISensorModel
|
||||||
{
|
{
|
||||||
|
[Column(visible: false)]
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
|
|
||||||
[DisplayName("Название Датчика")]
|
[Column(title: "Название датчика", width: 150)]
|
||||||
public string SensorName { get; set; } = string.Empty;
|
public string SensorName { get; set; } = string.Empty;
|
||||||
|
|
||||||
[DisplayName("Цена")]
|
[Column(title: "Цена", width: 150)]
|
||||||
public double Cost { get; set; }
|
public double Cost { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -6,7 +6,7 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace SecuritySystemDataModels.Models
|
namespace SecuritySystemDataModels.Models
|
||||||
{
|
{
|
||||||
public interface IMessageInfoModel
|
public interface IMessageInfoModel : IId
|
||||||
{
|
{
|
||||||
string MessageId { get; }
|
string MessageId { get; }
|
||||||
|
|
||||||
|
@ -0,0 +1,33 @@
|
|||||||
|
using SecuritySystemContracts.DI;
|
||||||
|
using SecuritySystemContracts.StoragesContracts;
|
||||||
|
using SecuritySystemDatabaseImplement.Implements;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace SecuritySystemDatabaseImplement
|
||||||
|
{
|
||||||
|
public class DataBaseImplementationExtension : IImplementationExtension
|
||||||
|
{
|
||||||
|
public int Priority => 2;
|
||||||
|
|
||||||
|
public void RegisterServices()
|
||||||
|
{
|
||||||
|
DependencyManager.Instance.RegisterType<IClientStorage, ClientStorage>();
|
||||||
|
|
||||||
|
DependencyManager.Instance.RegisterType<ISensorStorage, SensorStorage>();
|
||||||
|
|
||||||
|
DependencyManager.Instance.RegisterType<IImplementerStorage, ImplementerStorage>();
|
||||||
|
|
||||||
|
DependencyManager.Instance.RegisterType<IMessageInfoStorage, MessageInfoStorage>();
|
||||||
|
|
||||||
|
DependencyManager.Instance.RegisterType<IOrderStorage, OrderStorage>();
|
||||||
|
|
||||||
|
DependencyManager.Instance.RegisterType<ISecureStorage, SecureStorage>();
|
||||||
|
|
||||||
|
DependencyManager.Instance.RegisterType<IBackUpInfo, BackUpInfo>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,36 @@
|
|||||||
|
using SecuritySystemContracts.StoragesContracts;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace SecuritySystemDatabaseImplement.Implements
|
||||||
|
{
|
||||||
|
public class BackUpInfo : IBackUpInfo
|
||||||
|
{
|
||||||
|
public List<T>? GetList<T>() where T : class, new()
|
||||||
|
{
|
||||||
|
using var context = new SecuritySystemDatabase();
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -6,22 +6,28 @@ using System.Collections.Generic;
|
|||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
using System.ComponentModel.DataAnnotations.Schema;
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Runtime.Serialization;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace SecuritySystemDatabaseImplement.Models
|
namespace SecuritySystemDatabaseImplement.Models
|
||||||
{
|
{
|
||||||
|
[DataContract]
|
||||||
public class Client : IClientModel
|
public class Client : IClientModel
|
||||||
{
|
{
|
||||||
|
[DataMember]
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
|
|
||||||
[Required]
|
[Required]
|
||||||
|
[DataMember]
|
||||||
public string ClientFIO { get; set; } = string.Empty;
|
public string ClientFIO { get; set; } = string.Empty;
|
||||||
|
|
||||||
[Required]
|
[Required]
|
||||||
|
[DataMember]
|
||||||
public string Email { get; set; } = string.Empty;
|
public string Email { get; set; } = string.Empty;
|
||||||
|
|
||||||
[Required]
|
[Required]
|
||||||
|
[DataMember]
|
||||||
public string Password { get; set; } = string.Empty;
|
public string Password { get; set; } = string.Empty;
|
||||||
|
|
||||||
//для реализации связи многие ко многим с заказами (так как клиенты могу сделать одинаковый заказ)
|
//для реализации связи многие ко многим с заказами (так как клиенты могу сделать одинаковый заказ)
|
||||||
|
@ -6,25 +6,32 @@ using System.Collections.Generic;
|
|||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
using System.ComponentModel.DataAnnotations.Schema;
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Runtime.Serialization;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace SecuritySystemDatabaseImplement.Models
|
namespace SecuritySystemDatabaseImplement.Models
|
||||||
{
|
{
|
||||||
|
[DataContract]
|
||||||
public class Implementer : IImplementerModel
|
public class Implementer : IImplementerModel
|
||||||
{
|
{
|
||||||
|
[DataMember]
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
|
|
||||||
[Required]
|
[Required]
|
||||||
|
[DataMember]
|
||||||
public string ImplementerFIO { get; set; } = string.Empty;
|
public string ImplementerFIO { get; set; } = string.Empty;
|
||||||
|
|
||||||
[Required]
|
[Required]
|
||||||
|
[DataMember]
|
||||||
public string Password { get; set; } = string.Empty;
|
public string Password { get; set; } = string.Empty;
|
||||||
|
|
||||||
[Required]
|
[Required]
|
||||||
|
[DataMember]
|
||||||
public int WorkExperience { get; set; }
|
public int WorkExperience { get; set; }
|
||||||
|
|
||||||
[Required]
|
[Required]
|
||||||
|
[DataMember]
|
||||||
public int Qualification { get; set; }
|
public int Qualification { get; set; }
|
||||||
|
|
||||||
//для реализации связи один ко многим с заказами
|
//для реализации связи один ко многим с заказами
|
||||||
|
@ -5,28 +5,29 @@ 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 SecuritySystemDatabaseImplement.Models
|
namespace SecuritySystemDatabaseImplement.Models
|
||||||
{
|
{
|
||||||
|
[DataContract]
|
||||||
public class MessageInfo : IMessageInfoModel
|
public class MessageInfo : IMessageInfoModel
|
||||||
{
|
{
|
||||||
|
public int Id => throw new NotImplementedException();
|
||||||
|
|
||||||
[Key]
|
[Key]
|
||||||
|
[DataMember]
|
||||||
public string MessageId { get; set; } = string.Empty;
|
public string MessageId { get; set; } = string.Empty;
|
||||||
|
|
||||||
public int? ClientId { get; set; }
|
public int? ClientId { get; set; }
|
||||||
|
|
||||||
[Required]
|
|
||||||
public string SenderName { get; set; } = string.Empty;
|
public string SenderName { get; set; } = string.Empty;
|
||||||
|
|
||||||
[Required]
|
|
||||||
public DateTime DateDelivery { get; set; } = DateTime.Now;
|
public DateTime DateDelivery { get; set; } = DateTime.Now;
|
||||||
|
|
||||||
[Required]
|
|
||||||
public string Subject { get; set; } = string.Empty;
|
public string Subject { get; set; } = string.Empty;
|
||||||
|
|
||||||
[Required]
|
|
||||||
public string Body { get; set; } = string.Empty;
|
public string Body { get; set; } = string.Empty;
|
||||||
|
|
||||||
public virtual Client? Client { get; set; }
|
public virtual Client? Client { get; set; }
|
||||||
|
@ -6,36 +6,47 @@ 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;
|
||||||
using System.Xml.Linq;
|
using System.Xml.Linq;
|
||||||
|
|
||||||
namespace SecuritySystemDatabaseImplement.Models
|
namespace SecuritySystemDatabaseImplement.Models
|
||||||
{
|
{
|
||||||
|
[DataContract]
|
||||||
public class Order : IOrderModel
|
public class Order : IOrderModel
|
||||||
{
|
{
|
||||||
|
[DataMember]
|
||||||
public int Id { get; private set; }
|
public int Id { get; private set; }
|
||||||
|
|
||||||
[Required]
|
[Required]
|
||||||
|
[DataMember]
|
||||||
public int SecureId { get; private set; }
|
public int SecureId { get; private set; }
|
||||||
|
|
||||||
[Required]
|
[Required]
|
||||||
|
[DataMember]
|
||||||
public int ClientId { get; private set; }
|
public int ClientId { get; private set; }
|
||||||
|
|
||||||
|
[DataMember]
|
||||||
public int? ImplementerId { get; private set; }
|
public int? ImplementerId { get; private set; }
|
||||||
|
|
||||||
[Required]
|
[Required]
|
||||||
|
[DataMember]
|
||||||
public int Count { get; private set; }
|
public int Count { get; private set; }
|
||||||
|
|
||||||
[Required]
|
[Required]
|
||||||
|
[DataMember]
|
||||||
public double Sum { get; private set; }
|
public double Sum { get; private set; }
|
||||||
|
|
||||||
[Required]
|
[Required]
|
||||||
|
[DataMember]
|
||||||
public OrderStatus Status { get; private set; } = OrderStatus.Неизвестен;
|
public OrderStatus Status { get; private set; } = OrderStatus.Неизвестен;
|
||||||
|
|
||||||
[Required]
|
[Required]
|
||||||
|
[DataMember]
|
||||||
public DateTime DateCreate { get; private set; } = DateTime.Now;
|
public DateTime DateCreate { get; private set; } = DateTime.Now;
|
||||||
|
|
||||||
|
[DataMember]
|
||||||
public DateTime? DateImplement { get; private set; }
|
public DateTime? DateImplement { get; private set; }
|
||||||
|
|
||||||
//для передачи названия изделия
|
//для передачи названия изделия
|
||||||
|
@ -7,25 +7,31 @@ using System.ComponentModel;
|
|||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
using System.ComponentModel.DataAnnotations.Schema;
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Runtime.Serialization;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace SecuritySystemDatabaseImplement.Models
|
namespace SecuritySystemDatabaseImplement.Models
|
||||||
{
|
{
|
||||||
|
[DataContract]
|
||||||
public class Secure : ISecureModel
|
public class Secure : ISecureModel
|
||||||
{
|
{
|
||||||
|
[DataMember]
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
|
|
||||||
[Required]
|
[Required]
|
||||||
|
[DataMember]
|
||||||
public string SecureName { get; set; } = string.Empty;
|
public string SecureName { get; set; } = string.Empty;
|
||||||
|
|
||||||
[Required]
|
[Required]
|
||||||
|
[DataMember]
|
||||||
public double Price { get; set; }
|
public double Price { get; set; }
|
||||||
|
|
||||||
public Dictionary<int, (ISensorModel, int)>? _secureSensors = null;
|
public Dictionary<int, (ISensorModel, int)>? _secureSensors = null;
|
||||||
|
|
||||||
//это поле не будет "мапиться" в бд
|
//это поле не будет "мапиться" в бд
|
||||||
[NotMapped]
|
[NotMapped]
|
||||||
|
[DataMember]
|
||||||
public Dictionary<int, (ISensorModel, int)> SecureSensors
|
public Dictionary<int, (ISensorModel, int)> SecureSensors
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
|
@ -2,11 +2,13 @@
|
|||||||
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 SecuritySystemDatabaseImplement.Models
|
namespace SecuritySystemDatabaseImplement.Models
|
||||||
{
|
{
|
||||||
|
[DataContract]
|
||||||
public class SecureSensor
|
public class SecureSensor
|
||||||
{
|
{
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
|
@ -7,19 +7,24 @@ using System.ComponentModel.DataAnnotations;
|
|||||||
using System.ComponentModel.DataAnnotations.Schema;
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
using System.Data;
|
using System.Data;
|
||||||
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 SecuritySystemDatabaseImplement.Models
|
namespace SecuritySystemDatabaseImplement.Models
|
||||||
{
|
{
|
||||||
|
[DataContract]
|
||||||
public class Sensor : ISensorModel
|
public class Sensor : ISensorModel
|
||||||
{
|
{
|
||||||
|
[DataMember]
|
||||||
public int Id { get; private set; }
|
public int Id { get; private set; }
|
||||||
|
|
||||||
[Required]
|
[Required]
|
||||||
|
[DataMember]
|
||||||
public string SensorName { get; private set; } = string.Empty;
|
public string SensorName { get; private set; } = string.Empty;
|
||||||
|
|
||||||
[Required]
|
[Required]
|
||||||
|
[DataMember]
|
||||||
public double Cost { get; set; }
|
public double Cost { get; set; }
|
||||||
|
|
||||||
//для реализации связи многие ко многим с изделиями
|
//для реализации связи многие ко многим с изделиями
|
||||||
|
@ -20,4 +20,8 @@
|
|||||||
<Folder Include="Migrations\" />
|
<Folder Include="Migrations\" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
|
||||||
|
<Exec Command="copy /Y "$(TargetDir)*.dll" "$(SolutionDir)ImplementationExtensions\*.dll"" />
|
||||||
|
</Target>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
@ -0,0 +1,34 @@
|
|||||||
|
using SecuritySystemContracts.DI;
|
||||||
|
using SecuritySystemContracts.StoragesContracts;
|
||||||
|
using SecuritySystemFileImplement.Implements;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace SecuritySystemFileImplement
|
||||||
|
{
|
||||||
|
//для реализации нужных нам зависимостей в данном варианте хранения информации
|
||||||
|
public class FileImplementationExtension : IImplementationExtension
|
||||||
|
{
|
||||||
|
public int Priority => 1;
|
||||||
|
|
||||||
|
public void RegisterServices()
|
||||||
|
{
|
||||||
|
DependencyManager.Instance.RegisterType<IClientStorage, ClientStorage>();
|
||||||
|
|
||||||
|
DependencyManager.Instance.RegisterType<ISensorStorage, SensorStorage>();
|
||||||
|
|
||||||
|
DependencyManager.Instance.RegisterType<IImplementerStorage, ImplementerStorage>();
|
||||||
|
|
||||||
|
DependencyManager.Instance.RegisterType<IMessageInfoStorage, MessageInfoStorage>();
|
||||||
|
|
||||||
|
DependencyManager.Instance.RegisterType<IOrderStorage, OrderStorage>();
|
||||||
|
|
||||||
|
DependencyManager.Instance.RegisterType<ISecureStorage, SecureStorage>();
|
||||||
|
|
||||||
|
DependencyManager.Instance.RegisterType<IBackUpInfo, BackUpInfo>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,37 @@
|
|||||||
|
using SecuritySystemContracts.StoragesContracts;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace SecuritySystemFileImplement.Implements
|
||||||
|
{
|
||||||
|
public class BackUpInfo : IBackUpInfo
|
||||||
|
{
|
||||||
|
public List<T>? GetList<T>() where T : class, new()
|
||||||
|
{
|
||||||
|
var source = DataFileSingleton.GetInstance();
|
||||||
|
|
||||||
|
return (List<T>?)source.GetType().GetProperties()
|
||||||
|
.FirstOrDefault(x => x.PropertyType.IsGenericType && x.PropertyType.GetGenericArguments()[0] == typeof(T))
|
||||||
|
?.GetValue(source);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Type? GetTypeByModelInterface(string modelInterfaceName)
|
||||||
|
{
|
||||||
|
var assembly = typeof(BackUpInfo).Assembly;
|
||||||
|
var types = assembly.GetTypes();
|
||||||
|
|
||||||
|
foreach (var type in types)
|
||||||
|
{
|
||||||
|
if (type.IsClass && type.GetInterface(modelInterfaceName) != null)
|
||||||
|
{
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -7,20 +7,26 @@ using System.Collections.Generic;
|
|||||||
using System.Data;
|
using System.Data;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
|
using System.Runtime.Serialization;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Xml.Linq;
|
using System.Xml.Linq;
|
||||||
|
|
||||||
namespace SecuritySystemFileImplement.Models
|
namespace SecuritySystemFileImplement.Models
|
||||||
{
|
{
|
||||||
|
[DataContract]
|
||||||
public class Client : IClientModel
|
public class Client : IClientModel
|
||||||
{
|
{
|
||||||
|
[DataMember]
|
||||||
public int Id { get; private set; }
|
public int Id { get; private set; }
|
||||||
|
|
||||||
|
[DataMember]
|
||||||
public string ClientFIO { get; private set; } = string.Empty;
|
public string ClientFIO { get; private set; } = string.Empty;
|
||||||
|
|
||||||
|
[DataMember]
|
||||||
public string Email { get; private set; } = string.Empty;
|
public string Email { get; private set; } = string.Empty;
|
||||||
|
|
||||||
|
[DataMember]
|
||||||
public string Password { get; private set; } = string.Empty;
|
public string Password { get; private set; } = string.Empty;
|
||||||
|
|
||||||
public static Client? Create(ClientBindingModel model)
|
public static Client? Create(ClientBindingModel model)
|
||||||
|
@ -5,22 +5,29 @@ using System;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
|
using System.Runtime.Serialization;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Xml.Linq;
|
using System.Xml.Linq;
|
||||||
|
|
||||||
namespace SecuritySystemFileImplement.Models
|
namespace SecuritySystemFileImplement.Models
|
||||||
{
|
{
|
||||||
|
[DataContract]
|
||||||
public class Implementer : IImplementerModel
|
public class Implementer : IImplementerModel
|
||||||
{
|
{
|
||||||
|
[DataMember]
|
||||||
public int Id { get; private set; }
|
public int Id { get; private set; }
|
||||||
|
|
||||||
|
[DataMember]
|
||||||
public string ImplementerFIO { get; private set; } = string.Empty;
|
public string ImplementerFIO { get; private set; } = string.Empty;
|
||||||
|
|
||||||
|
[DataMember]
|
||||||
public string Password { get; private set; } = string.Empty;
|
public string Password { get; private set; } = string.Empty;
|
||||||
|
|
||||||
|
[DataMember]
|
||||||
public int WorkExperience { get; private set; }
|
public int WorkExperience { get; private set; }
|
||||||
|
|
||||||
|
[DataMember]
|
||||||
public int Qualification { get; private set; }
|
public int Qualification { get; private set; }
|
||||||
|
|
||||||
public static Implementer? Create(ImplementerBindingModel model)
|
public static Implementer? Create(ImplementerBindingModel model)
|
||||||
|
@ -6,24 +6,34 @@ using System.Collections.Generic;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
|
using System.Runtime.Serialization;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Xml.Linq;
|
using System.Xml.Linq;
|
||||||
|
|
||||||
namespace SecuritySystemFileImplement.Models
|
namespace SecuritySystemFileImplement.Models
|
||||||
{
|
{
|
||||||
|
[DataContract]
|
||||||
public class MessageInfo : IMessageInfoModel
|
public class MessageInfo : IMessageInfoModel
|
||||||
{
|
{
|
||||||
|
public int Id { get; private set; }
|
||||||
|
|
||||||
|
[DataMember]
|
||||||
public string MessageId { get; private set; } = string.Empty;
|
public string MessageId { get; private set; } = string.Empty;
|
||||||
|
|
||||||
|
[DataMember]
|
||||||
public int? ClientId { get; private set; }
|
public int? ClientId { get; private set; }
|
||||||
|
|
||||||
|
[DataMember]
|
||||||
public string SenderName { get; private set; } = string.Empty;
|
public string SenderName { get; private set; } = string.Empty;
|
||||||
|
|
||||||
|
[DataMember]
|
||||||
public DateTime DateDelivery { get; private set; } = DateTime.Now;
|
public DateTime DateDelivery { get; private set; } = DateTime.Now;
|
||||||
|
|
||||||
|
[DataMember]
|
||||||
public string Subject { get; private set; } = string.Empty;
|
public string Subject { get; private set; } = string.Empty;
|
||||||
|
|
||||||
|
[DataMember]
|
||||||
public string Body { get; private set; } = string.Empty;
|
public string Body { get; private set; } = string.Empty;
|
||||||
|
|
||||||
public static MessageInfo? Create(MessageInfoBindingModel model)
|
public static MessageInfo? Create(MessageInfoBindingModel model)
|
||||||
|
@ -6,6 +6,7 @@ using System;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
|
using System.Runtime.Serialization;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Xml.Linq;
|
using System.Xml.Linq;
|
||||||
@ -13,24 +14,34 @@ using System.Xml.Linq;
|
|||||||
namespace SecuritySystemFileImplement.Models
|
namespace SecuritySystemFileImplement.Models
|
||||||
{
|
{
|
||||||
//класс, реализующий интерфейс модели заказа
|
//класс, реализующий интерфейс модели заказа
|
||||||
|
[DataContract]
|
||||||
public class Order : IOrderModel
|
public class Order : IOrderModel
|
||||||
{
|
{
|
||||||
|
[DataMember]
|
||||||
public int Id { get; private set; }
|
public int Id { get; private set; }
|
||||||
|
|
||||||
|
[DataMember]
|
||||||
public int ClientId { get; private set; }
|
public int ClientId { get; private set; }
|
||||||
|
|
||||||
|
[DataMember]
|
||||||
public int? ImplementerId { get; private set; }
|
public int? ImplementerId { get; private set; }
|
||||||
|
|
||||||
|
[DataMember]
|
||||||
public int SecureId { get; private set; }
|
public int SecureId { get; private set; }
|
||||||
|
|
||||||
|
[DataMember]
|
||||||
public int Count { get; private set; }
|
public int Count { get; private set; }
|
||||||
|
|
||||||
|
[DataMember]
|
||||||
public double Sum { get; private set; }
|
public double Sum { get; private set; }
|
||||||
|
|
||||||
|
[DataMember]
|
||||||
public OrderStatus Status { get; private set; } = OrderStatus.Неизвестен;
|
public OrderStatus Status { get; private set; } = OrderStatus.Неизвестен;
|
||||||
|
|
||||||
|
[DataMember]
|
||||||
public DateTime DateCreate { get; private set; } = DateTime.Now;
|
public DateTime DateCreate { get; private set; } = DateTime.Now;
|
||||||
|
|
||||||
|
[DataMember]
|
||||||
public DateTime? DateImplement { get; private set; }
|
public DateTime? DateImplement { get; private set; }
|
||||||
|
|
||||||
public static Order? Create(OrderBindingModel model)
|
public static Order? Create(OrderBindingModel model)
|
||||||
|
@ -4,6 +4,7 @@ using SecuritySystemDataModels.Models;
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Runtime.Serialization;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Xml.Linq;
|
using System.Xml.Linq;
|
||||||
@ -11,19 +12,23 @@ using System.Xml.Linq;
|
|||||||
namespace SecuritySystemFileImplement.Models
|
namespace SecuritySystemFileImplement.Models
|
||||||
{
|
{
|
||||||
//класс реализующий интерфейс модели изделия
|
//класс реализующий интерфейс модели изделия
|
||||||
|
[DataContract]
|
||||||
public class Secure : ISecureModel
|
public class Secure : ISecureModel
|
||||||
{
|
{
|
||||||
|
[DataMember]
|
||||||
public int Id { get; private set; }
|
public int Id { get; private set; }
|
||||||
|
|
||||||
|
[DataMember]
|
||||||
public string SecureName { get; private set; } = string.Empty;
|
public string SecureName { get; private set; } = string.Empty;
|
||||||
|
|
||||||
|
[DataMember]
|
||||||
public double Price { get; private set; }
|
public double Price { get; private set; }
|
||||||
|
|
||||||
public Dictionary<int, int> Sensors { get; private set; } = new();
|
public Dictionary<int, int> Sensors { get; private set; } = new();
|
||||||
|
|
||||||
|
|
||||||
private Dictionary<int, (ISensorModel, int)>? _secureSensors = null;
|
private Dictionary<int, (ISensorModel, int)>? _secureSensors = null;
|
||||||
|
|
||||||
|
[DataMember]
|
||||||
public Dictionary<int, (ISensorModel, int)> SecureSensors
|
public Dictionary<int, (ISensorModel, int)> SecureSensors
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
|
@ -5,6 +5,7 @@ using System;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Runtime.Serialization;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Xml.Linq;
|
using System.Xml.Linq;
|
||||||
@ -12,12 +13,16 @@ using System.Xml.Linq;
|
|||||||
namespace SecuritySystemFileImplement.Models
|
namespace SecuritySystemFileImplement.Models
|
||||||
{
|
{
|
||||||
//реализация интерфейса модели заготовки
|
//реализация интерфейса модели заготовки
|
||||||
|
[DataContract]
|
||||||
public class Sensor : ISensorModel
|
public class Sensor : ISensorModel
|
||||||
{
|
{
|
||||||
|
[DataMember]
|
||||||
public int Id { get; private set; }
|
public int Id { get; private set; }
|
||||||
|
|
||||||
|
[DataMember]
|
||||||
public string SensorName { get; private set; } = string.Empty;
|
public string SensorName { get; private set; } = string.Empty;
|
||||||
|
|
||||||
|
[DataMember]
|
||||||
public double Cost { get; set; }
|
public double Cost { get; set; }
|
||||||
|
|
||||||
public static Sensor? Create(SensorBindingModel model)
|
public static Sensor? Create(SensorBindingModel model)
|
||||||
|
@ -18,4 +18,8 @@
|
|||||||
<ProjectReference Include="..\SecuritySystemDataModels\SecuritySystemDataModels.csproj" />
|
<ProjectReference Include="..\SecuritySystemDataModels\SecuritySystemDataModels.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
|
||||||
|
<Exec Command="copy /Y "$(TargetDir)*.dll" "$(SolutionDir)ImplementationExtensions\*.dll"" />
|
||||||
|
</Target>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
@ -0,0 +1,22 @@
|
|||||||
|
using SecuritySystemContracts.StoragesContracts;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace SecuritySystemListImplement.Implements
|
||||||
|
{
|
||||||
|
public class BackUpInfo : IBackUpInfo
|
||||||
|
{
|
||||||
|
public List<T>? GetList<T>() where T : class, new()
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Type? GetTypeByModelInterface(string modelInterfaceName)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,34 @@
|
|||||||
|
using SecuritySystemContracts.DI;
|
||||||
|
using SecuritySystemContracts.StoragesContracts;
|
||||||
|
using SecuritySystemListImplement.Implements;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace SecuritySystemListImplement
|
||||||
|
{
|
||||||
|
public class ListImplementationExtension : IImplementationExtension
|
||||||
|
{
|
||||||
|
public int Priority => 0;
|
||||||
|
|
||||||
|
public void RegisterServices()
|
||||||
|
{
|
||||||
|
DependencyManager.Instance.RegisterType<IClientStorage, ClientStorage>();
|
||||||
|
|
||||||
|
DependencyManager.Instance.RegisterType<ISensorStorage, SensorStorage>();
|
||||||
|
|
||||||
|
DependencyManager.Instance.RegisterType<IImplementerStorage, ImplementerStorage>();
|
||||||
|
|
||||||
|
DependencyManager.Instance.RegisterType<IMessageInfoStorage, MessageInfoStorage>();
|
||||||
|
|
||||||
|
DependencyManager.Instance.RegisterType<IOrderStorage, OrderStorage>();
|
||||||
|
|
||||||
|
DependencyManager.Instance.RegisterType<ISecureStorage, SecureStorage>();
|
||||||
|
|
||||||
|
DependencyManager.Instance.RegisterType<IBackUpInfo, BackUpInfo>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -12,6 +12,8 @@ namespace SecuritySystemListImplement.Models
|
|||||||
{
|
{
|
||||||
public class MessageInfo : IMessageInfoModel
|
public class MessageInfo : IMessageInfoModel
|
||||||
{
|
{
|
||||||
|
public int Id { get; private set; }
|
||||||
|
|
||||||
public string MessageId { get; private set; } = string.Empty;
|
public string MessageId { get; private set; } = string.Empty;
|
||||||
|
|
||||||
public int? ClientId { get; private set; }
|
public int? ClientId { get; private set; }
|
||||||
|
@ -9,7 +9,7 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace SecuritySystemListImplement.Models
|
namespace SecuritySystemListImplement.Models
|
||||||
{
|
{
|
||||||
//класс реализующий интерфейс модели изделия
|
//класс, реализующий интерфейс модели изделия
|
||||||
public class Secure : ISecureModel
|
public class Secure : ISecureModel
|
||||||
{
|
{
|
||||||
//методы set делаем приватным, чтобы исключить неразрешённые манипуляции
|
//методы set делаем приватным, чтобы исключить неразрешённые манипуляции
|
||||||
|
@ -22,4 +22,8 @@
|
|||||||
<ProjectReference Include="..\SecuritySystemDataModels\SecuritySystemDataModels.csproj" />
|
<ProjectReference Include="..\SecuritySystemDataModels\SecuritySystemDataModels.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
|
||||||
|
<Exec Command="copy /Y "$(TargetDir)*.dll" "$(SolutionDir)ImplementationExtensions\*.dll"" />
|
||||||
|
</Target>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
BIN
SecuritySystem/Для бэкапа.zip
Normal file
BIN
SecuritySystem/Для бэкапа.zip
Normal file
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user