оно должно работать но не работает
This commit is contained in:
parent
06a496aa5f
commit
501b3bb6cf
46
SushiBar/SushiBar/Extensions/DataGridViewExtension.cs
Normal file
46
SushiBar/SushiBar/Extensions/DataGridViewExtension.cs
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
using SushiBarContracts.Attributes;
|
||||||
|
|
||||||
|
namespace SushiBar.Extensions
|
||||||
|
{
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
24
SushiBar/SushiBar/Forms/FormClients.Designer.cs
generated
24
SushiBar/SushiBar/Forms/FormClients.Designer.cs
generated
@ -28,19 +28,19 @@
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private void InitializeComponent()
|
private void InitializeComponent()
|
||||||
{
|
{
|
||||||
DataGridView = new DataGridView();
|
dataGridView = new DataGridView();
|
||||||
DeleteButton = new Button();
|
DeleteButton = new Button();
|
||||||
((System.ComponentModel.ISupportInitialize)DataGridView).BeginInit();
|
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
|
||||||
SuspendLayout();
|
SuspendLayout();
|
||||||
//
|
//
|
||||||
// DataGridView
|
// dataGridView
|
||||||
//
|
//
|
||||||
DataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||||
DataGridView.Location = new Point(12, 34);
|
dataGridView.Location = new Point(12, 34);
|
||||||
DataGridView.Name = "DataGridView";
|
dataGridView.Name = "DataGridView";
|
||||||
DataGridView.RowTemplate.Height = 25;
|
dataGridView.RowTemplate.Height = 25;
|
||||||
DataGridView.Size = new Size(776, 404);
|
dataGridView.Size = new Size(776, 404);
|
||||||
DataGridView.TabIndex = 0;
|
dataGridView.TabIndex = 0;
|
||||||
//
|
//
|
||||||
// DeleteButton
|
// DeleteButton
|
||||||
//
|
//
|
||||||
@ -58,17 +58,17 @@
|
|||||||
AutoScaleMode = AutoScaleMode.Font;
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
ClientSize = new Size(800, 450);
|
ClientSize = new Size(800, 450);
|
||||||
Controls.Add(DeleteButton);
|
Controls.Add(DeleteButton);
|
||||||
Controls.Add(DataGridView);
|
Controls.Add(dataGridView);
|
||||||
Name = "ClientsForm";
|
Name = "ClientsForm";
|
||||||
Text = "Клиенты";
|
Text = "Клиенты";
|
||||||
Load += ClientsForm_Load;
|
Load += ClientsForm_Load;
|
||||||
((System.ComponentModel.ISupportInitialize)DataGridView).EndInit();
|
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
|
||||||
ResumeLayout(false);
|
ResumeLayout(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
private DataGridView DataGridView;
|
private DataGridView dataGridView;
|
||||||
private Button DeleteButton;
|
private Button DeleteButton;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,4 +1,5 @@
|
|||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
|
using SushiBar.Extensions;
|
||||||
using SushiBarContracts.BindingModels;
|
using SushiBarContracts.BindingModels;
|
||||||
using SushiBarContracts.BusinessLogicsContracts;
|
using SushiBarContracts.BusinessLogicsContracts;
|
||||||
|
|
||||||
@ -22,14 +23,8 @@ namespace SushiBar.Forms
|
|||||||
var list = _logic.ReadList(null);
|
var list = _logic.ReadList(null);
|
||||||
if (list != null)
|
if (list != null)
|
||||||
{
|
{
|
||||||
DataGridView.DataSource = list;
|
dataGridView.FillandConfigGrid(list);
|
||||||
DataGridView.Columns["Id"].Visible = false;
|
_logger.LogInformation("Загрузка клиентов");
|
||||||
DataGridView.Columns["ClientFIO"].AutoSizeMode =
|
|
||||||
DataGridViewAutoSizeColumnMode.Fill;
|
|
||||||
DataGridView.Columns["Email"].AutoSizeMode =
|
|
||||||
DataGridViewAutoSizeColumnMode.Fill;
|
|
||||||
DataGridView.Columns["Password"].AutoSizeMode =
|
|
||||||
DataGridViewAutoSizeColumnMode.Fill;
|
|
||||||
}
|
}
|
||||||
_logger.LogInformation("Загрузка клиентов");
|
_logger.LogInformation("Загрузка клиентов");
|
||||||
}
|
}
|
||||||
@ -47,12 +42,12 @@ namespace SushiBar.Forms
|
|||||||
|
|
||||||
private void DeleteButton_Click(object sender, EventArgs e)
|
private void DeleteButton_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
if (DataGridView.SelectedRows.Count == 1)
|
if (dataGridView.SelectedRows.Count == 1)
|
||||||
{
|
{
|
||||||
if (MessageBox.Show("Удалить запись?", "Вопрос",
|
if (MessageBox.Show("Удалить запись?", "Вопрос",
|
||||||
MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
||||||
{
|
{
|
||||||
int id = Convert.ToInt32(DataGridView.SelectedRows[0].Cells["Id"].Value);
|
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||||
_logger.LogInformation("Удаление клиента");
|
_logger.LogInformation("Удаление клиента");
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
using SushiBarContracts.BindingModels;
|
using SushiBarContracts.BindingModels;
|
||||||
using SushiBarContracts.BusinessLogicsContracts;
|
using SushiBarContracts.BusinessLogicsContracts;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
|
using SushiBar.Extensions;
|
||||||
|
|
||||||
namespace SushiBar.Forms
|
namespace SushiBar.Forms
|
||||||
{
|
{
|
||||||
@ -22,13 +23,7 @@ namespace SushiBar.Forms
|
|||||||
{
|
{
|
||||||
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["ComponentName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
|
||||||
}
|
|
||||||
_logger.LogInformation("Загрузка компонентов");
|
_logger.LogInformation("Загрузка компонентов");
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
|
@ -20,17 +20,18 @@ namespace SushiBar.Forms
|
|||||||
}
|
}
|
||||||
private void FormCreateOrder_Load(object sender, EventArgs e)
|
private void FormCreateOrder_Load(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
|
_logger.LogInformation("Загрузка суши для заказа");
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
_logger.LogInformation("Загрузка суши для заказа");
|
var list = _logicS.ReadList(null);
|
||||||
List<SushiViewModel>? _list = _logicS.ReadList(null);
|
if (list != null)
|
||||||
if (_list != null)
|
|
||||||
{
|
{
|
||||||
ComboBoxSushi.DisplayMember = "SushiName";
|
ComboBoxSushi.DisplayMember = "SushiCreamName";
|
||||||
ComboBoxSushi.ValueMember = "Id";
|
ComboBoxSushi.ValueMember = "Id";
|
||||||
ComboBoxSushi.DataSource = _list;
|
ComboBoxSushi.DataSource = list;
|
||||||
ComboBoxSushi.SelectedItem = null;
|
ComboBoxSushi.SelectedItem = null;
|
||||||
}
|
}
|
||||||
|
_logger.LogInformation("Суши загружено");
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
@ -40,8 +40,7 @@ namespace SushiBar.Forms
|
|||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
_logger.LogError(ex, "Ошибка получения исполнителя");
|
_logger.LogError(ex, "Ошибка получения исполнителя");
|
||||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
MessageBoxIcon.Error);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
|
using SushiBar.Extensions;
|
||||||
using SushiBarContracts.BindingModels;
|
using SushiBarContracts.BindingModels;
|
||||||
using SushiBarContracts.BusinessLogicsContracts;
|
using SushiBarContracts.BusinessLogicsContracts;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
|
||||||
namespace SushiBar.Forms
|
namespace SushiBar.Forms
|
||||||
{
|
{
|
||||||
@ -24,23 +26,13 @@ namespace SushiBar.Forms
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var list = _logic.ReadList(null);
|
dataGridView.FillandConfigGrid(_logic.ReadList(null));
|
||||||
if (list != null)
|
_logger.LogInformation("Загрузка исполнителей");
|
||||||
{
|
|
||||||
dataGridView.DataSource = list;
|
|
||||||
dataGridView.Columns["Id"].Visible = false;
|
|
||||||
dataGridView.Columns["ImplementerFIO"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
|
||||||
dataGridView.Columns["Password"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
|
||||||
dataGridView.Columns["Qualification"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
|
||||||
dataGridView.Columns["WorkExperience"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
|
||||||
}
|
|
||||||
_logger.LogInformation("Загрузка компонентов");
|
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
_logger.LogError(ex, "Ошибка загрузки исполнителей");
|
_logger.LogError(ex, "Ошибка загрузки исполнителей");
|
||||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
MessageBoxIcon.Error);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private void CreateButton_Click(object sender, EventArgs e)
|
private void CreateButton_Click(object sender, EventArgs e)
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
|
using SushiBar.Extensions;
|
||||||
using SushiBarContracts.BusinessLogicsContracts;
|
using SushiBarContracts.BusinessLogicsContracts;
|
||||||
|
|
||||||
namespace SushiBar.Forms
|
namespace SushiBar.Forms
|
||||||
@ -18,21 +19,13 @@ namespace SushiBar.Forms
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var list = _logic.ReadList(null);
|
dataGridView.FillandConfigGrid(_logic.ReadList(null));
|
||||||
if (list != null)
|
|
||||||
{
|
|
||||||
dataGridView.DataSource = list;
|
|
||||||
dataGridView.Columns["ClientId"].Visible = false;
|
|
||||||
dataGridView.Columns["MessageId"].Visible = false;
|
|
||||||
dataGridView.Columns["Body"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
|
||||||
}
|
|
||||||
_logger.LogInformation("Загрузка списка писем");
|
_logger.LogInformation("Загрузка списка писем");
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
_logger.LogError(ex, "Ошибка загрузки писем");
|
_logger.LogError(ex, "Ошибка загрузки писем");
|
||||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
MessageBoxIcon.Error);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
23
SushiBar/SushiBar/Forms/FormMain.Designer.cs
generated
23
SushiBar/SushiBar/Forms/FormMain.Designer.cs
generated
@ -40,6 +40,7 @@
|
|||||||
componentsReportПоСушиToolStripMenuItem = new ToolStripMenuItem();
|
componentsReportПоСушиToolStripMenuItem = new ToolStripMenuItem();
|
||||||
orderReportToolStripMenuItem = new ToolStripMenuItem();
|
orderReportToolStripMenuItem = new ToolStripMenuItem();
|
||||||
startWorksToolStripMenuItem = new ToolStripMenuItem();
|
startWorksToolStripMenuItem = new ToolStripMenuItem();
|
||||||
|
MailToolStripMenuItem = new ToolStripMenuItem();
|
||||||
отчётыToolStripMenuItem = new ToolStripMenuItem();
|
отчётыToolStripMenuItem = new ToolStripMenuItem();
|
||||||
sushisToolStripMenuItem = new ToolStripMenuItem();
|
sushisToolStripMenuItem = new ToolStripMenuItem();
|
||||||
componentSushisToolStripMenuItem = new ToolStripMenuItem();
|
componentSushisToolStripMenuItem = new ToolStripMenuItem();
|
||||||
@ -49,7 +50,7 @@
|
|||||||
buttonOrderReady = new Button();
|
buttonOrderReady = new Button();
|
||||||
buttonIssuedOrder = new Button();
|
buttonIssuedOrder = new Button();
|
||||||
buttonRef = new Button();
|
buttonRef = new Button();
|
||||||
MailToolStripMenuItem = new ToolStripMenuItem();
|
backupToolStripMenuItem = new ToolStripMenuItem();
|
||||||
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
|
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
|
||||||
menuStrip1.SuspendLayout();
|
menuStrip1.SuspendLayout();
|
||||||
SuspendLayout();
|
SuspendLayout();
|
||||||
@ -69,7 +70,7 @@
|
|||||||
// menuStrip1
|
// menuStrip1
|
||||||
//
|
//
|
||||||
menuStrip1.ImageScalingSize = new Size(20, 20);
|
menuStrip1.ImageScalingSize = new Size(20, 20);
|
||||||
menuStrip1.Items.AddRange(new ToolStripItem[] { toolStripMenuItem, отчётыToolStripMenuItem1, startWorksToolStripMenuItem, MailToolStripMenuItem });
|
menuStrip1.Items.AddRange(new ToolStripItem[] { toolStripMenuItem, отчётыToolStripMenuItem1, startWorksToolStripMenuItem, MailToolStripMenuItem, backupToolStripMenuItem });
|
||||||
menuStrip1.Location = new Point(0, 0);
|
menuStrip1.Location = new Point(0, 0);
|
||||||
menuStrip1.Name = "menuStrip1";
|
menuStrip1.Name = "menuStrip1";
|
||||||
menuStrip1.Size = new Size(1184, 28);
|
menuStrip1.Size = new Size(1184, 28);
|
||||||
@ -146,6 +147,13 @@
|
|||||||
startWorksToolStripMenuItem.Text = "Запуск работ";
|
startWorksToolStripMenuItem.Text = "Запуск работ";
|
||||||
startWorksToolStripMenuItem.Click += startWorksToolStripMenuItem_Click;
|
startWorksToolStripMenuItem.Click += startWorksToolStripMenuItem_Click;
|
||||||
//
|
//
|
||||||
|
// MailToolStripMenuItem
|
||||||
|
//
|
||||||
|
MailToolStripMenuItem.Name = "MailToolStripMenuItem";
|
||||||
|
MailToolStripMenuItem.Size = new Size(65, 24);
|
||||||
|
MailToolStripMenuItem.Text = "Почта";
|
||||||
|
MailToolStripMenuItem.Click += MailToolStripMenuItem_Click;
|
||||||
|
//
|
||||||
// отчётыToolStripMenuItem
|
// отчётыToolStripMenuItem
|
||||||
//
|
//
|
||||||
отчётыToolStripMenuItem.Name = "отчётыToolStripMenuItem";
|
отчётыToolStripMenuItem.Name = "отчётыToolStripMenuItem";
|
||||||
@ -221,12 +229,12 @@
|
|||||||
buttonRef.UseVisualStyleBackColor = true;
|
buttonRef.UseVisualStyleBackColor = true;
|
||||||
buttonRef.Click += ButtonRef_Click;
|
buttonRef.Click += ButtonRef_Click;
|
||||||
//
|
//
|
||||||
// MailToolStripMenuItem
|
// backupToolStripMenuItem
|
||||||
//
|
//
|
||||||
MailToolStripMenuItem.Name = "MailToolStripMenuItem";
|
backupToolStripMenuItem.Name = "backupToolStripMenuItem";
|
||||||
MailToolStripMenuItem.Size = new Size(65, 24);
|
backupToolStripMenuItem.Size = new Size(123, 24);
|
||||||
MailToolStripMenuItem.Text = "Почта";
|
backupToolStripMenuItem.Text = "Создать бекап";
|
||||||
MailToolStripMenuItem.Click += MailToolStripMenuItem_Click;
|
backupToolStripMenuItem.Click += backupToolStripMenuItem_Click;
|
||||||
//
|
//
|
||||||
// FormMain
|
// FormMain
|
||||||
//
|
//
|
||||||
@ -277,5 +285,6 @@
|
|||||||
private ToolStripMenuItem implementersToolStripMenuItem;
|
private ToolStripMenuItem implementersToolStripMenuItem;
|
||||||
private ToolStripMenuItem startWorksToolStripMenuItem;
|
private ToolStripMenuItem startWorksToolStripMenuItem;
|
||||||
private ToolStripMenuItem MailToolStripMenuItem;
|
private ToolStripMenuItem MailToolStripMenuItem;
|
||||||
|
private ToolStripMenuItem backupToolStripMenuItem;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,4 +1,6 @@
|
|||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
|
using SushiBar.Extensions;
|
||||||
|
using SushiBarBusinessLogic.BusinessLogic;
|
||||||
using SushiBarBusinessLogic.BusinessLogics;
|
using SushiBarBusinessLogic.BusinessLogics;
|
||||||
using SushiBarContracts.BindingModels;
|
using SushiBarContracts.BindingModels;
|
||||||
using SushiBarContracts.BusinessLogicsContracts;
|
using SushiBarContracts.BusinessLogicsContracts;
|
||||||
@ -11,13 +13,22 @@ namespace SushiBar.Forms
|
|||||||
private readonly IOrderLogic _orderLogic;
|
private readonly IOrderLogic _orderLogic;
|
||||||
private readonly IReportLogic _reportLogic;
|
private readonly IReportLogic _reportLogic;
|
||||||
private readonly IWorkProcess _workProcess;
|
private readonly IWorkProcess _workProcess;
|
||||||
public 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();
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
_orderLogic = orderLogic;
|
_orderLogic = orderLogic;
|
||||||
_reportLogic = reportLogic;
|
_reportLogic = reportLogic;
|
||||||
_workProcess = workProcess;
|
_workProcess = workProcess;
|
||||||
|
_backUpLogic = backUpLogic;
|
||||||
}
|
}
|
||||||
private void FormMain_Load(object sender, EventArgs e)
|
private void FormMain_Load(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
@ -25,22 +36,15 @@ namespace SushiBar.Forms
|
|||||||
}
|
}
|
||||||
private void LoadData()
|
private void LoadData()
|
||||||
{
|
{
|
||||||
|
_logger.LogInformation("Загрузка заказов");
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var list = _orderLogic.ReadList(null);
|
dataGridView.FillandConfigGrid(_orderLogic.ReadList(null));
|
||||||
if (list != null)
|
|
||||||
{
|
|
||||||
dataGridView.DataSource = list;
|
|
||||||
dataGridView.Columns["SushiId"].Visible = false;
|
|
||||||
dataGridView.Columns["ClientId"].Visible = false;
|
|
||||||
dataGridView.Columns["ImplementerId"].Visible = false;
|
|
||||||
dataGridView.Columns["SushiName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
|
||||||
}
|
|
||||||
_logger.LogInformation("Загрузка заказов");
|
_logger.LogInformation("Загрузка заказов");
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
_logger.LogError(ex, "Ошибка загрузки суши");
|
_logger.LogError(ex, "Ошибка загрузки заказов");
|
||||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -204,5 +208,28 @@ namespace SushiBar.Forms
|
|||||||
form.ShowDialog();
|
form.ShowDialog();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void backupToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (_backUpLogic != null)
|
||||||
|
{
|
||||||
|
var fbd = new FolderBrowserDialog();
|
||||||
|
if (fbd.ShowDialog() == DialogResult.OK)
|
||||||
|
{
|
||||||
|
_backUpLogic.CreateBackUp(new BackUpSaveBinidngModel
|
||||||
|
{
|
||||||
|
FolderName = fbd.SelectedPath
|
||||||
|
});
|
||||||
|
MessageBox.Show("Бекап создан", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
|
using SushiBar.Extensions;
|
||||||
using SushiBarContracts.BindingModels;
|
using SushiBarContracts.BindingModels;
|
||||||
using SushiBarContracts.BusinessLogicsContracts;
|
using SushiBarContracts.BusinessLogicsContracts;
|
||||||
|
|
||||||
@ -22,14 +23,7 @@ namespace SushiBar.Forms
|
|||||||
{
|
{
|
||||||
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["SushiComponents"].Visible = false;
|
|
||||||
dataGridView.Columns["SushiName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
|
||||||
}
|
|
||||||
_logger.LogInformation("Загрузка суши");
|
_logger.LogInformation("Загрузка суши");
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
|
BIN
SushiBar/SushiBar/ImplementationExtensions.dll
Normal file
BIN
SushiBar/SushiBar/ImplementationExtensions.dll
Normal file
Binary file not shown.
BIN
SushiBar/SushiBar/ImplementationExtensionst.dll
Normal file
BIN
SushiBar/SushiBar/ImplementationExtensionst.dll
Normal file
Binary file not shown.
@ -1,16 +1,15 @@
|
|||||||
using IceCreamShopContracts.StoragesContracts;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using NLog.Extensions.Logging;
|
using NLog.Extensions.Logging;
|
||||||
using SushiBar.Forms;
|
using SushiBar.Forms;
|
||||||
|
using SushiBarBusinessLogic.BusinessLogic;
|
||||||
using SushiBarBusinessLogic.BusinessLogics;
|
using SushiBarBusinessLogic.BusinessLogics;
|
||||||
using SushiBarBusinessLogic.MailWorker;
|
using SushiBarBusinessLogic.MailWorker;
|
||||||
using SushiBarBusinessLogic.OfficePackage;
|
using SushiBarBusinessLogic.OfficePackage;
|
||||||
using SushiBarBusinessLogic.OfficePackage.Implements;
|
using SushiBarBusinessLogic.OfficePackage.Implements;
|
||||||
using SushiBarContracts.BindingModels;
|
using SushiBarContracts.BindingModels;
|
||||||
using SushiBarContracts.BusinessLogicsContracts;
|
using SushiBarContracts.BusinessLogicsContracts;
|
||||||
using SushiBarContracts.StoragesContracts;
|
using SushiBarContracts.DI;
|
||||||
using SushiBarDatabaseImplement.Implements;
|
|
||||||
|
|
||||||
namespace SushiBar
|
namespace SushiBar
|
||||||
{
|
{
|
||||||
@ -28,12 +27,11 @@ namespace SushiBar
|
|||||||
// 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,
|
||||||
@ -48,53 +46,52 @@ namespace SushiBar
|
|||||||
}
|
}
|
||||||
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<IComponentStorage, ComponentStorage>();
|
|
||||||
services.AddTransient<IOrderStorage, OrderStorage>();
|
|
||||||
services.AddTransient<ISushiStorage, SushiStorage>();
|
|
||||||
services.AddTransient<IClientStorage, ClientStorage>();
|
|
||||||
services.AddTransient<IImplementerStorage, ImplementerStorage>();
|
|
||||||
services.AddTransient<IMessageInfoStorage, MessageInfoStorage>();
|
|
||||||
|
|
||||||
services.AddTransient<IComponentLogic, ComponentLogic>();
|
DependencyManager.Instance.RegisterType<IClientLogic, ClientLogic>();
|
||||||
services.AddTransient<IOrderLogic, OrderLogic>();
|
DependencyManager.Instance.RegisterType<IImplementerLogic, ImplementerLogic>();
|
||||||
services.AddTransient<ISushiLogic, SushiLogic>();
|
DependencyManager.Instance.RegisterType<IComponentLogic, ComponentLogic>();
|
||||||
services.AddTransient<IReportLogic, ReportLogic>();
|
DependencyManager.Instance.RegisterType<IOrderLogic, OrderLogic>();
|
||||||
services.AddTransient<IClientLogic, ClientLogic>();
|
DependencyManager.Instance.RegisterType<ISushiLogic, SushiLogic>();
|
||||||
services.AddTransient<IImplementerLogic, ImplementerLogic>();
|
DependencyManager.Instance.RegisterType<IReportLogic, ReportLogic>();
|
||||||
services.AddSingleton<IWorkProcess, WorkModeling>();
|
DependencyManager.Instance.RegisterType<IWorkProcess, WorkModeling>();
|
||||||
services.AddTransient<IMessageInfoLogic, MessageInfoLogic>();
|
DependencyManager.Instance.RegisterType<IMessageInfoLogic, MessageInfoLogic>();
|
||||||
|
DependencyManager.Instance.RegisterType<IBackUpLogic, BackUpLogic>();
|
||||||
|
|
||||||
services.AddTransient<FormMain>();
|
DependencyManager.Instance.RegisterType<AbstractMailWorker, MailKitWorker>();
|
||||||
services.AddTransient<FormComponent>();
|
|
||||||
services.AddTransient<FormComponents>();
|
|
||||||
services.AddTransient<FormCreateOrder>();
|
|
||||||
services.AddTransient<FormClients>();
|
|
||||||
services.AddTransient<FormSushi>();
|
|
||||||
services.AddTransient<FormSushiComponent>();
|
|
||||||
services.AddTransient<FormSushis>();
|
|
||||||
services.AddTransient<FormReportSushiComponents>();
|
|
||||||
services.AddTransient<FormReportOrders>();
|
|
||||||
services.AddTransient<FormImplementers>();
|
|
||||||
services.AddTransient<FormImplementer>();
|
|
||||||
services.AddTransient<FormMailView>();
|
|
||||||
|
|
||||||
services.AddTransient<AbstractSaveToExcel, SaveToExcel>();
|
DependencyManager.Instance.RegisterType<AbstractSaveToExcel, SaveToExcel>();
|
||||||
services.AddTransient<AbstractSaveToWord, SaveToWord>();
|
DependencyManager.Instance.RegisterType<AbstractSaveToWord, SaveToWord>();
|
||||||
services.AddTransient<AbstractSaveToPdf, SaveToPdf>();
|
DependencyManager.Instance.RegisterType<AbstractSaveToPdf, SaveToPdf>();
|
||||||
services.AddSingleton<AbstractMailWorker, MailKitWorker>();
|
|
||||||
|
DependencyManager.Instance.RegisterType<FormMain>();
|
||||||
|
DependencyManager.Instance.RegisterType<FormComponent>();
|
||||||
|
DependencyManager.Instance.RegisterType<FormComponents>();
|
||||||
|
DependencyManager.Instance.RegisterType<FormCreateOrder>();
|
||||||
|
DependencyManager.Instance.RegisterType<FormClients>();
|
||||||
|
DependencyManager.Instance.RegisterType<FormSushi>();
|
||||||
|
DependencyManager.Instance.RegisterType<FormSushiComponent>();
|
||||||
|
DependencyManager.Instance.RegisterType<FormSushis>();
|
||||||
|
DependencyManager.Instance.RegisterType<FormReportSushiComponents>();
|
||||||
|
DependencyManager.Instance.RegisterType<FormReportOrders>();
|
||||||
|
DependencyManager.Instance.RegisterType<FormImplementers>();
|
||||||
|
DependencyManager.Instance.RegisterType<FormImplementer>();
|
||||||
|
DependencyManager.Instance.RegisterType<FormMailView>();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void MailCheck(object obj) => ServiceProvider?.GetService<AbstractMailWorker>()?.MailCheck();
|
private static void MailCheck(object obj) => ServiceProvider?.GetService<AbstractMailWorker>()?.MailCheck();
|
||||||
|
@ -23,9 +23,6 @@
|
|||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\SushiBarBusinessLogic\SushiBarBusinessLogic.csproj" />
|
<ProjectReference Include="..\SushiBarBusinessLogic\SushiBarBusinessLogic.csproj" />
|
||||||
<ProjectReference Include="..\SushiBarDatabaseImplement\SushiBarDatabaseImplement.csproj" />
|
|
||||||
<ProjectReference Include="..\SushiBarFileImplement\SushiBarFileImplement.csproj" />
|
|
||||||
<ProjectReference Include="..\SushiBarListImplement\SushiBarListImplement.csproj" />
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
90
SushiBar/SushiBarBusinessLogic/BusinessLogics/BackUpLogic.cs
Normal file
90
SushiBar/SushiBarBusinessLogic/BusinessLogics/BackUpLogic.cs
Normal file
@ -0,0 +1,90 @@
|
|||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using SushiBarContracts.BindingModels;
|
||||||
|
using SushiBarContracts.BusinessLogicsContracts;
|
||||||
|
using SushiBarContracts.StoragesContracts;
|
||||||
|
using SushiBarDataModels;
|
||||||
|
using System.IO.Compression;
|
||||||
|
using System.Reflection;
|
||||||
|
using System.Runtime.Serialization.Json;
|
||||||
|
|
||||||
|
namespace SushiBarBusinessLogic.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)
|
||||||
|
{
|
||||||
|
if (type.IsInterface && type.GetInterface(typeIId.Name) != null)
|
||||||
|
{
|
||||||
|
var modelType = _backUpInfo.GetTypeByModelInterface(type.Name);
|
||||||
|
if (modelType == null)
|
||||||
|
{
|
||||||
|
throw new InvalidOperationException($"Не найден класс - модель для { type.Name }");
|
||||||
|
}
|
||||||
|
_logger.LogDebug("Call SaveToFile method for {name} type", type.Name);
|
||||||
|
method?.MakeGenericMethod(modelType).Invoke(this, new object[] { model.FolderName });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_logger.LogDebug("Create zip and remove folder");
|
||||||
|
ZipFile.CreateFromDirectory(model.FolderName, fileName);
|
||||||
|
dirInfo.Delete(true);
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private void SaveToFile<T>(string folderName) where T : class, new()
|
||||||
|
{
|
||||||
|
var records = _backUpInfo.GetList<T>();
|
||||||
|
if (records == null)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("{type} type get null list", typeof(T).Name);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var jsonFormatter = new DataContractJsonSerializer(typeof(List<T>));
|
||||||
|
using var fs = new FileStream(string.Format("{0}/{1}.json", folderName, typeof(T).Name), FileMode.OpenOrCreate);
|
||||||
|
jsonFormatter.WriteObject(fs, records);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -1,8 +1,8 @@
|
|||||||
using IceCreamShopContracts.StoragesContracts;
|
using Microsoft.Extensions.Logging;
|
||||||
using Microsoft.Extensions.Logging;
|
|
||||||
using SushiBarContracts.BindingModels;
|
using SushiBarContracts.BindingModels;
|
||||||
using SushiBarContracts.BusinessLogicsContracts;
|
using SushiBarContracts.BusinessLogicsContracts;
|
||||||
using SushiBarContracts.SearchModels;
|
using SushiBarContracts.SearchModels;
|
||||||
|
using SushiBarContracts.StoragesContracts;
|
||||||
using SushiBarContracts.ViewModels;
|
using SushiBarContracts.ViewModels;
|
||||||
|
|
||||||
namespace SushiBarBusinessLogic.BusinessLogics
|
namespace SushiBarBusinessLogic.BusinessLogics
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\SushiBarContracts\SushiBarContracts.csproj" />
|
<ProjectReference Include="..\SushiBarContracts\SushiBarContracts.csproj" />
|
||||||
|
<ProjectReference Include="..\SushiBarDataModels\SushiBarDataModels.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
22
SushiBar/SushiBarContracts/Attributes/ColumnAttribute.cs
Normal file
22
SushiBar/SushiBarContracts/Attributes/ColumnAttribute.cs
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
namespace SushiBarContracts.Attributes
|
||||||
|
{
|
||||||
|
[AttributeUsage(AttributeTargets.Property)]
|
||||||
|
public class ColumnAttribute : Attribute
|
||||||
|
{
|
||||||
|
public ColumnAttribute(string title = "", bool visible = true, int width = 0,
|
||||||
|
GridViewAutoSize gridViewAutoSize = GridViewAutoSize.None, bool isUseAutoSize = false)
|
||||||
|
{
|
||||||
|
Title = title;
|
||||||
|
Visible = visible;
|
||||||
|
Width = width;
|
||||||
|
GridViewAutoSize = gridViewAutoSize;
|
||||||
|
IsUseAutoSize = isUseAutoSize;
|
||||||
|
}
|
||||||
|
public string Title { get; private set; }
|
||||||
|
public bool Visible { get; private set; }
|
||||||
|
public int Width { get; private set; }
|
||||||
|
public GridViewAutoSize GridViewAutoSize { get; private set; }
|
||||||
|
public bool IsUseAutoSize { get; private set; }
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
14
SushiBar/SushiBarContracts/Attributes/GridViewAutoSize.cs
Normal file
14
SushiBar/SushiBarContracts/Attributes/GridViewAutoSize.cs
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
namespace SushiBarContracts.Attributes
|
||||||
|
{
|
||||||
|
public enum GridViewAutoSize
|
||||||
|
{
|
||||||
|
NotSet = 0,
|
||||||
|
None = 1,
|
||||||
|
ColumnHeader = 2,
|
||||||
|
AllCellsExceptHeader = 4,
|
||||||
|
AllCells = 6,
|
||||||
|
DisplayedCellsExceptHeader = 8,
|
||||||
|
DisplayedCells = 10,
|
||||||
|
Fill = 16
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,8 @@
|
|||||||
|
namespace SushiBarContracts.BindingModels
|
||||||
|
{
|
||||||
|
public class BackUpSaveBinidngModel
|
||||||
|
{
|
||||||
|
public string FolderName { get; set; } = string.Empty;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -15,5 +15,7 @@ namespace SushiBarContracts.BindingModels
|
|||||||
public string Body { get; set; } = string.Empty;
|
public string Body { get; set; } = string.Empty;
|
||||||
|
|
||||||
public DateTime DateDelivery { get; set; }
|
public DateTime DateDelivery { get; set; }
|
||||||
|
|
||||||
|
public int Id => throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,9 @@
|
|||||||
|
using SushiBarContracts.BindingModels;
|
||||||
|
|
||||||
|
namespace SushiBarContracts.BusinessLogicsContracts
|
||||||
|
{
|
||||||
|
public interface IBackUpLogic
|
||||||
|
{
|
||||||
|
void CreateBackUp(BackUpSaveBinidngModel model);
|
||||||
|
}
|
||||||
|
}
|
45
SushiBar/SushiBarContracts/DI/DependencyManager.cs
Normal file
45
SushiBar/SushiBarContracts/DI/DependencyManager.cs
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
|
||||||
|
namespace SushiBarContracts.DI
|
||||||
|
{
|
||||||
|
public class DependencyManager
|
||||||
|
{
|
||||||
|
private readonly IDependencyContainer _dependencyManager;
|
||||||
|
private static DependencyManager? _manager;
|
||||||
|
private static readonly object _locjObject = new();
|
||||||
|
private DependencyManager()
|
||||||
|
{
|
||||||
|
_dependencyManager = new ServiceDependencyContainer();
|
||||||
|
}
|
||||||
|
public static DependencyManager Instance
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (_manager == null) {
|
||||||
|
lock (_locjObject)
|
||||||
|
{
|
||||||
|
_manager = new DependencyManager();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return _manager;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public static void InitDependency()
|
||||||
|
{
|
||||||
|
var ext = ServiceProviderLoader.GetImplementationExtensions();
|
||||||
|
if (ext == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException("Отсутствуют компонент для загрузки зависимостей по модулям");
|
||||||
|
}
|
||||||
|
ext.RegisterServices();
|
||||||
|
}
|
||||||
|
public void AddLogging(Action<ILoggingBuilder> configure) =>
|
||||||
|
_dependencyManager.AddLogging(configure);
|
||||||
|
public void RegisterType<T, U>(bool isSingle = false) where U :
|
||||||
|
class, T where T : class =>
|
||||||
|
_dependencyManager.RegisterType<T, U>(isSingle);
|
||||||
|
public void RegisterType<T>(bool isSingle = false) where T : class =>
|
||||||
|
_dependencyManager.RegisterType<T>(isSingle);
|
||||||
|
public T Resolve<T>() => _dependencyManager.Resolve<T>();
|
||||||
|
}
|
||||||
|
}
|
12
SushiBar/SushiBarContracts/DI/IDependencyContainer.cs
Normal file
12
SushiBar/SushiBarContracts/DI/IDependencyContainer.cs
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
|
||||||
|
namespace SushiBarContracts.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,9 @@
|
|||||||
|
namespace SushiBarContracts.DI
|
||||||
|
{
|
||||||
|
public interface IImplementationExtension
|
||||||
|
{
|
||||||
|
public int Priority { get; }
|
||||||
|
public void RegisterServices();
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
57
SushiBar/SushiBarContracts/DI/ServiceDependencyContainer.cs
Normal file
57
SushiBar/SushiBarContracts/DI/ServiceDependencyContainer.cs
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
|
||||||
|
namespace SushiBarContracts.DI
|
||||||
|
{
|
||||||
|
public class ServiceDependencyContainer : IDependencyContainer
|
||||||
|
{
|
||||||
|
private ServiceProvider? _serviceProvider;
|
||||||
|
|
||||||
|
private readonly ServiceCollection _serviceCollection;
|
||||||
|
|
||||||
|
public ServiceDependencyContainer()
|
||||||
|
{
|
||||||
|
_serviceCollection = new ServiceCollection();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void AddLogging(Action<ILoggingBuilder> configure)
|
||||||
|
{
|
||||||
|
_serviceCollection.AddLogging(configure);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void RegisterType<T>(bool isSingle) where T : class
|
||||||
|
{
|
||||||
|
if (isSingle)
|
||||||
|
{
|
||||||
|
_serviceCollection.AddSingleton<T>();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_serviceCollection.AddTransient<T>();
|
||||||
|
}
|
||||||
|
_serviceProvider = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void RegisterType<T, U>(bool isSingle) where U : class, T where T : class
|
||||||
|
{
|
||||||
|
if (isSingle)
|
||||||
|
{
|
||||||
|
_serviceCollection.AddSingleton<T, U>();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_serviceCollection.AddTransient<T, U>();
|
||||||
|
}
|
||||||
|
_serviceProvider = null;
|
||||||
|
}
|
||||||
|
public T Resolve<T>()
|
||||||
|
{
|
||||||
|
if (_serviceProvider == null)
|
||||||
|
{
|
||||||
|
_serviceProvider = _serviceCollection.BuildServiceProvider();
|
||||||
|
}
|
||||||
|
return _serviceProvider.GetService<T>()!;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
53
SushiBar/SushiBarContracts/DI/ServiceProviderLoader.cs
Normal file
53
SushiBar/SushiBarContracts/DI/ServiceProviderLoader.cs
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
using System.Reflection;
|
||||||
|
|
||||||
|
namespace SushiBarContracts.DI
|
||||||
|
{
|
||||||
|
public static partial class ServiceProviderLoader
|
||||||
|
{
|
||||||
|
public static IImplementationExtension? GetImplementationExtensions()
|
||||||
|
{
|
||||||
|
IImplementationExtension? source = null;
|
||||||
|
var files = Directory
|
||||||
|
.GetFiles(
|
||||||
|
TryGetImplementationExtensionsFolder(),
|
||||||
|
"*.dll",
|
||||||
|
SearchOption.AllDirectories
|
||||||
|
);
|
||||||
|
foreach (var file in files.Distinct())
|
||||||
|
{
|
||||||
|
Assembly asm = Assembly.LoadFrom(file);
|
||||||
|
foreach (var t in asm.GetExportedTypes())
|
||||||
|
{
|
||||||
|
if (t.IsClass &&
|
||||||
|
typeof(IImplementationExtension).IsAssignableFrom(t))
|
||||||
|
{
|
||||||
|
if (source == null)
|
||||||
|
{
|
||||||
|
source = (IImplementationExtension)Activator.CreateInstance(t)!;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var newSource = (IImplementationExtension)Activator.CreateInstance(t)!;
|
||||||
|
if (newSource.Priority > source.Priority)
|
||||||
|
{
|
||||||
|
source = newSource;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return source;
|
||||||
|
}
|
||||||
|
private static string TryGetImplementationExtensionsFolder()
|
||||||
|
{
|
||||||
|
var directory = new DirectoryInfo(Directory.GetCurrentDirectory());
|
||||||
|
while (directory != null && !directory.GetDirectories("ImplementationExtensions",
|
||||||
|
SearchOption.AllDirectories).Any(x => x.Name == "ImplementationExtensions"))
|
||||||
|
{
|
||||||
|
directory = directory.Parent;
|
||||||
|
}
|
||||||
|
return $"{directory?.FullName}\\ImplementationExtensions";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,8 @@
|
|||||||
|
namespace SushiBarContracts.StoragesContracts
|
||||||
|
{
|
||||||
|
public interface IBackUpInfo
|
||||||
|
{
|
||||||
|
List<T>? GetList<T>() where T : class, new();
|
||||||
|
Type? GetTypeByModelInterface(string modelInterfaceName);
|
||||||
|
}
|
||||||
|
}
|
@ -2,7 +2,7 @@
|
|||||||
using SushiBarContracts.SearchModels;
|
using SushiBarContracts.SearchModels;
|
||||||
using SushiBarContracts.ViewModels;
|
using SushiBarContracts.ViewModels;
|
||||||
|
|
||||||
namespace IceCreamShopContracts.StoragesContracts
|
namespace SushiBarContracts.StoragesContracts
|
||||||
{
|
{
|
||||||
public interface IImplementerStorage
|
public interface IImplementerStorage
|
||||||
{
|
{
|
||||||
|
@ -4,8 +4,13 @@
|
|||||||
<TargetFramework>net6.0</TargetFramework>
|
<TargetFramework>net6.0</TargetFramework>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
|
<BaseOutputPath>\bin</BaseOutputPath>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Microsoft.Extensions.Logging" Version="7.0.0" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\SushiBarDataModels\SushiBarDataModels.csproj" />
|
<ProjectReference Include="..\SushiBarDataModels\SushiBarDataModels.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
@ -1,15 +1,16 @@
|
|||||||
using System.ComponentModel;
|
using SushiBarContracts.Attributes;
|
||||||
|
using SushiBarDataModels.Models;
|
||||||
|
|
||||||
namespace SushiBarContracts.ViewModels
|
namespace SushiBarContracts.ViewModels
|
||||||
{
|
{
|
||||||
public class ClientViewModel
|
public class ClientViewModel : IClientModel
|
||||||
{
|
{
|
||||||
|
[Column(visible: false)]
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
[DisplayName("ФИО клиента")]
|
|
||||||
public string ClientFIO { get; set; } = string.Empty;
|
public string ClientFIO { get; set; } = string.Empty;
|
||||||
[DisplayName("Логин (эл. почта)")]
|
[Column(title: "Email клиента", 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,14 +1,15 @@
|
|||||||
using SushiBarDataModels.Models;
|
using SushiBarContracts.Attributes;
|
||||||
using System.ComponentModel;
|
using SushiBarDataModels.Models;
|
||||||
|
|
||||||
namespace SushiBarContracts.ViewModels
|
namespace SushiBarContracts.ViewModels
|
||||||
{
|
{
|
||||||
public class ComponentViewModel : IComponentModel
|
public class ComponentViewModel : IComponentModel
|
||||||
{
|
{
|
||||||
|
[Column(visible: false)]
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
[DisplayName("Название компонента")]
|
[Column(title: "Название компонента", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)]
|
||||||
public string ComponentName { get; set; } = string.Empty;
|
public string ComponentName { get; set; } = string.Empty;
|
||||||
[DisplayName("Цена")]
|
[Column(title: "Цена", width: 80)]
|
||||||
public double Cost { get; set; }
|
public double Cost { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,18 +1,19 @@
|
|||||||
using SushiBarDataModels.Models;
|
using SushiBarContracts.Attributes;
|
||||||
using System.ComponentModel;
|
using SushiBarDataModels.Models;
|
||||||
|
|
||||||
namespace SushiBarContracts.ViewModels
|
namespace SushiBarContracts.ViewModels
|
||||||
{
|
{
|
||||||
public class ImplementerViewModel : IImplementerModel
|
public class ImplementerViewModel : IImplementerModel
|
||||||
{
|
{
|
||||||
|
[Column(visible: false)]
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
[DisplayName("ФИО исполнителя")]
|
[Column(title: "ФИО исполнителя", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)]
|
||||||
public string ImplementerFIO { get; set; } = string.Empty;
|
public string ImplementerFIO { get; set; } = string.Empty;
|
||||||
[DisplayName("Стаж работы")]
|
[Column(title: "Стаж работы", gridViewAutoSize: GridViewAutoSize.AllCells, isUseAutoSize: true)]
|
||||||
public int WorkExperience { get; set; } = 0;
|
public int WorkExperience { get; set; } = 0;
|
||||||
[DisplayName("Квалификация")]
|
[Column(title: "Квалификация", gridViewAutoSize: GridViewAutoSize.AllCells, isUseAutoSize: true)]
|
||||||
public int Qualification { get; set; } = 0;
|
public int Qualification { get; set; } = 0;
|
||||||
[DisplayName("Пароль")]
|
[Column(title: "Пароль", width: 150)]
|
||||||
public string Password { get; set; } = string.Empty;
|
public string Password { get; set; } = string.Empty;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,24 +1,27 @@
|
|||||||
using SushiBarDataModels.Models;
|
using SushiBarContracts.Attributes;
|
||||||
using System.ComponentModel;
|
using SushiBarDataModels.Models;
|
||||||
|
|
||||||
namespace SushiBarContracts.ViewModels
|
namespace SushiBarContracts.ViewModels
|
||||||
{
|
{
|
||||||
public class MessageInfoViewModel : IMessageInfoModel
|
public class MessageInfoViewModel : IMessageInfoModel
|
||||||
{
|
{
|
||||||
|
[Column(visible: false)]
|
||||||
public string MessageId { get; set; } = string.Empty;
|
public string MessageId { get; set; } = string.Empty;
|
||||||
|
[Column(visible: false)]
|
||||||
public int? ClientId { get; set; }
|
public int? ClientId { get; set; }
|
||||||
|
|
||||||
[DisplayName("Отправитель")]
|
[Column(title: "Отправитель", gridViewAutoSize: GridViewAutoSize.DisplayedCells, isUseAutoSize: true)]
|
||||||
public string SenderName { get; set; } = string.Empty;
|
public string SenderName { get; set; } = string.Empty;
|
||||||
|
|
||||||
[DisplayName("Дата письма")]
|
[Column(title: "Дата письма", width: 100)]
|
||||||
public DateTime DateDelivery { get; set; }
|
public DateTime DateDelivery { get; set; }
|
||||||
|
|
||||||
[DisplayName("Заголовок")]
|
[Column(title: "Заголовок", width: 150)]
|
||||||
public string Subject { get; set; } = string.Empty;
|
public string Subject { get; set; } = string.Empty;
|
||||||
|
|
||||||
[DisplayName("Текст")]
|
[Column(title: "Текст", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)]
|
||||||
public string Body { get; set; } = string.Empty;
|
public string Body { get; set; } = string.Empty;
|
||||||
|
[Column(visible: false)]
|
||||||
|
public int Id => throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,31 +1,34 @@
|
|||||||
using SushiBarDataModels.Enums;
|
using SushiBarContracts.Attributes;
|
||||||
|
using SushiBarDataModels.Enums;
|
||||||
using SushiBarDataModels.Models;
|
using SushiBarDataModels.Models;
|
||||||
using System.ComponentModel;
|
|
||||||
|
|
||||||
namespace SushiBarContracts.ViewModels
|
namespace SushiBarContracts.ViewModels
|
||||||
{
|
{
|
||||||
public class OrderViewModel : IOrderModel
|
public class OrderViewModel : IOrderModel
|
||||||
{
|
{
|
||||||
[DisplayName("Номер")]
|
[Column(title: "Номер", gridViewAutoSize: GridViewAutoSize.AllCells, isUseAutoSize: true)]
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
|
[Column(visible: false)]
|
||||||
public int SushiId { get; set; }
|
public int SushiId { 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; }
|
||||||
[DisplayName("Клиент")]
|
[Column(title: "ФИО клиента", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)]
|
||||||
public string ClientFIO { get; set; } = string.Empty;
|
public string ClientFIO { get; set; } = string.Empty;
|
||||||
[DisplayName("Суши")]
|
[Column(title: "Суши", gridViewAutoSize: GridViewAutoSize.AllCells, isUseAutoSize: true)]
|
||||||
public string SushiName { get; set; } = string.Empty;
|
public string SushiName { get; set; } = string.Empty;
|
||||||
[DisplayName("Исполнитель")]
|
[Column(title: "ФИО исполнителя", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)]
|
||||||
public string ImplementerName { get; set;} = string.Empty;
|
public string ImplementerName { get; set;} = string.Empty;
|
||||||
[DisplayName("Количество")]
|
[Column(title: "Количество", gridViewAutoSize: GridViewAutoSize.AllCells, isUseAutoSize: true)]
|
||||||
public int Count { get; set; }
|
public int Count { get; set; }
|
||||||
[DisplayName("Сумма")]
|
[Column(title: "Сумма", gridViewAutoSize: GridViewAutoSize.AllCells, isUseAutoSize: true)]
|
||||||
public double Sum { get; set; }
|
public double Sum { get; set; }
|
||||||
[DisplayName("Статус")]
|
[Column(title: "Статус", gridViewAutoSize: GridViewAutoSize.AllCells, isUseAutoSize: true)]
|
||||||
public OrderStatus Status { get; set; } = OrderStatus.Неизвестен;
|
public OrderStatus Status { get; set; } = OrderStatus.Неизвестен;
|
||||||
[DisplayName("Дата создания")]
|
[Column(title: "Дата создания", width: 100)]
|
||||||
public DateTime DateCreate { get; set; } = DateTime.Now;
|
public DateTime DateCreate { get; set; } = DateTime.Now;
|
||||||
[DisplayName("Дата выполнения")]
|
[Column(title: "Дата выполнения", width: 100)]
|
||||||
public DateTime? DateImplement { get; set; }
|
public DateTime? DateImplement { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,4 @@
|
|||||||
using System;
|
namespace SushiBarContracts.ViewModels
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace SushiBarContracts.ViewModels
|
|
||||||
{
|
{
|
||||||
public class ReportOrdersViewModel
|
public class ReportOrdersViewModel
|
||||||
{
|
{
|
||||||
|
@ -1,10 +1,4 @@
|
|||||||
using System;
|
namespace SushiBarContracts.ViewModels
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace SushiBarContracts.ViewModels
|
|
||||||
{
|
{
|
||||||
public class ReportSushiComponentViewModel
|
public class ReportSushiComponentViewModel
|
||||||
{
|
{
|
||||||
|
@ -1,15 +1,17 @@
|
|||||||
using SushiBarDataModels.Models;
|
using SushiBarContracts.Attributes;
|
||||||
using System.ComponentModel;
|
using SushiBarDataModels.Models;
|
||||||
|
|
||||||
namespace SushiBarContracts.ViewModels
|
namespace SushiBarContracts.ViewModels
|
||||||
{
|
{
|
||||||
public class SushiViewModel : ISushiModel
|
public class SushiViewModel : ISushiModel
|
||||||
{
|
{
|
||||||
|
[Column(visible: false)]
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
[DisplayName("Название суши")]
|
[Column(title: "Название Суши", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)]
|
||||||
public string SushiName { get; set; } = string.Empty;
|
public string SushiName { get; set; } = string.Empty;
|
||||||
[DisplayName("Цена")]
|
[Column(title: "Цена", width: 100)]
|
||||||
public double Price { get; set; }
|
public double Price { get; set; }
|
||||||
|
[Column(visible: false)]
|
||||||
public Dictionary<int, (IComponentModel, int)> SushiComponents
|
public Dictionary<int, (IComponentModel, int)> SushiComponents
|
||||||
{
|
{
|
||||||
get;
|
get;
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
namespace SushiBarDataModels.Models
|
namespace SushiBarDataModels.Models
|
||||||
{
|
{
|
||||||
public interface IMessageInfoModel
|
public interface IMessageInfoModel : IId
|
||||||
{
|
{
|
||||||
string MessageId { get; }
|
string MessageId { get; }
|
||||||
int? ClientId { get; }
|
int? ClientId { get; }
|
||||||
@ -8,6 +8,5 @@
|
|||||||
DateTime DateDelivery { get; }
|
DateTime DateDelivery { get; }
|
||||||
string Subject { get; }
|
string Subject { get; }
|
||||||
string Body { get; }
|
string Body { get; }
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,21 @@
|
|||||||
|
using SushiBarContracts.DI;
|
||||||
|
using SushiBarContracts.StoragesContracts;
|
||||||
|
using SushiBarDatabaseImplement.Implements;
|
||||||
|
|
||||||
|
namespace SushiBarDatabaseImplement
|
||||||
|
{
|
||||||
|
public class DatabaseImplementationExtension : IImplementationExtension
|
||||||
|
{
|
||||||
|
public int Priority => 2;
|
||||||
|
public void RegisterServices()
|
||||||
|
{
|
||||||
|
DependencyManager.Instance.RegisterType<IClientStorage, ClientStorage>();
|
||||||
|
DependencyManager.Instance.RegisterType<IComponentStorage, ComponentStorage>();
|
||||||
|
DependencyManager.Instance.RegisterType<IImplementerStorage, ImplementerStorage>();
|
||||||
|
DependencyManager.Instance.RegisterType<IMessageInfoStorage, MessageInfoStorage>();
|
||||||
|
DependencyManager.Instance.RegisterType<IOrderStorage, OrderStorage>();
|
||||||
|
DependencyManager.Instance.RegisterType<ISushiStorage, SushiStorage>();
|
||||||
|
DependencyManager.Instance.RegisterType<IBackUpInfo, BackUpInfo>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
27
SushiBar/SushiBarDatabaseImplement/Implements/BackUpInfo.cs
Normal file
27
SushiBar/SushiBarDatabaseImplement/Implements/BackUpInfo.cs
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
using SushiBarContracts.StoragesContracts;
|
||||||
|
|
||||||
|
namespace SushiBarDatabaseImplement.Implements
|
||||||
|
{
|
||||||
|
public class BackUpInfo : IBackUpInfo
|
||||||
|
{
|
||||||
|
public List<T>? GetList<T>() where T : class, new()
|
||||||
|
{
|
||||||
|
using var context = new SushiBarDatabase();
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,6 +1,6 @@
|
|||||||
using IceCreamShopContracts.StoragesContracts;
|
using SushiBarContracts.BindingModels;
|
||||||
using SushiBarContracts.BindingModels;
|
|
||||||
using SushiBarContracts.SearchModels;
|
using SushiBarContracts.SearchModels;
|
||||||
|
using SushiBarContracts.StoragesContracts;
|
||||||
using SushiBarContracts.ViewModels;
|
using SushiBarContracts.ViewModels;
|
||||||
using SushiBarDatabaseImplement.Models;
|
using SushiBarDatabaseImplement.Models;
|
||||||
|
|
||||||
|
@ -46,5 +46,7 @@ namespace SushiBarDatabaseImplement.Models
|
|||||||
SenderName = SenderName,
|
SenderName = SenderName,
|
||||||
DateDelivery = DateDelivery,
|
DateDelivery = DateDelivery,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
public int Id => throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
63
SushiBar/SushiBarDatabaseImplement/Properties/Resources.Designer.cs
generated
Normal file
63
SushiBar/SushiBarDatabaseImplement/Properties/Resources.Designer.cs
generated
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
//------------------------------------------------------------------------------
|
||||||
|
// <auto-generated>
|
||||||
|
// Этот код создан программой.
|
||||||
|
// Исполняемая версия:4.0.30319.42000
|
||||||
|
//
|
||||||
|
// Изменения в этом файле могут привести к неправильной работе и будут потеряны в случае
|
||||||
|
// повторной генерации кода.
|
||||||
|
// </auto-generated>
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
namespace SushiBarDatabaseImplement.Properties {
|
||||||
|
using System;
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Класс ресурса со строгой типизацией для поиска локализованных строк и т.д.
|
||||||
|
/// </summary>
|
||||||
|
// Этот класс создан автоматически классом StronglyTypedResourceBuilder
|
||||||
|
// с помощью такого средства, как ResGen или Visual Studio.
|
||||||
|
// Чтобы добавить или удалить член, измените файл .ResX и снова запустите ResGen
|
||||||
|
// с параметром /str или перестройте свой проект VS.
|
||||||
|
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]
|
||||||
|
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||||
|
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||||
|
internal class Resources {
|
||||||
|
|
||||||
|
private static global::System.Resources.ResourceManager resourceMan;
|
||||||
|
|
||||||
|
private static global::System.Globalization.CultureInfo resourceCulture;
|
||||||
|
|
||||||
|
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
|
||||||
|
internal Resources() {
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Возвращает кэшированный экземпляр ResourceManager, использованный этим классом.
|
||||||
|
/// </summary>
|
||||||
|
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||||
|
internal static global::System.Resources.ResourceManager ResourceManager {
|
||||||
|
get {
|
||||||
|
if (object.ReferenceEquals(resourceMan, null)) {
|
||||||
|
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("SushiBarDatabaseImplement.Properties.Resources", typeof(Resources).Assembly);
|
||||||
|
resourceMan = temp;
|
||||||
|
}
|
||||||
|
return resourceMan;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Перезаписывает свойство CurrentUICulture текущего потока для всех
|
||||||
|
/// обращений к ресурсу с помощью этого класса ресурса со строгой типизацией.
|
||||||
|
/// </summary>
|
||||||
|
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||||
|
internal static global::System.Globalization.CultureInfo Culture {
|
||||||
|
get {
|
||||||
|
return resourceCulture;
|
||||||
|
}
|
||||||
|
set {
|
||||||
|
resourceCulture = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
101
SushiBar/SushiBarDatabaseImplement/Properties/Resources.resx
Normal file
101
SushiBar/SushiBarDatabaseImplement/Properties/Resources.resx
Normal file
@ -0,0 +1,101 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<root>
|
||||||
|
<!--
|
||||||
|
Microsoft ResX Schema
|
||||||
|
|
||||||
|
Version 1.3
|
||||||
|
|
||||||
|
The primary goals of this format is to allow a simple XML format
|
||||||
|
that is mostly human readable. The generation and parsing of the
|
||||||
|
various data types are done through the TypeConverter classes
|
||||||
|
associated with the data types.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
... ado.net/XML headers & schema ...
|
||||||
|
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||||
|
<resheader name="version">1.3</resheader>
|
||||||
|
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||||
|
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||||
|
<data name="Name1">this is my long string</data>
|
||||||
|
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||||
|
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||||
|
[base64 mime encoded serialized .NET Framework object]
|
||||||
|
</data>
|
||||||
|
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||||
|
[base64 mime encoded string representing a byte array form of the .NET Framework object]
|
||||||
|
</data>
|
||||||
|
|
||||||
|
There are any number of "resheader" rows that contain simple
|
||||||
|
name/value pairs.
|
||||||
|
|
||||||
|
Each data row contains a name, and value. The row also contains a
|
||||||
|
type or mimetype. Type corresponds to a .NET class that support
|
||||||
|
text/value conversion through the TypeConverter architecture.
|
||||||
|
Classes that don't support this are serialized and stored with the
|
||||||
|
mimetype set.
|
||||||
|
|
||||||
|
The mimetype is used for serialized objects, and tells the
|
||||||
|
ResXResourceReader how to depersist the object. This is currently not
|
||||||
|
extensible. For a given mimetype the value must be set accordingly:
|
||||||
|
|
||||||
|
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||||
|
that the ResXResourceWriter will generate, however the reader can
|
||||||
|
read any of the formats listed below.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.binary.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Serialization.Formatters.Binary.BinaryFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.soap.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||||
|
value : The object must be serialized into a byte array
|
||||||
|
: using a System.ComponentModel.TypeConverter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
-->
|
||||||
|
|
||||||
|
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||||
|
<xsd:element name="root" msdata:IsDataSet="true">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:choice maxOccurs="unbounded">
|
||||||
|
<xsd:element name="data">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="resheader">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:choice>
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:schema>
|
||||||
|
<resheader name="resmimetype">
|
||||||
|
<value>text/microsoft-resx</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="version">
|
||||||
|
<value>1.3</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="reader">
|
||||||
|
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="writer">
|
||||||
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
</root>
|
@ -26,4 +26,23 @@
|
|||||||
<ProjectReference Include="..\SushiBarDataModels\SushiBarDataModels.csproj" />
|
<ProjectReference Include="..\SushiBarDataModels\SushiBarDataModels.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<Compile Update="Properties\Resources.Designer.cs">
|
||||||
|
<DesignTime>True</DesignTime>
|
||||||
|
<AutoGen>True</AutoGen>
|
||||||
|
<DependentUpon>Resources.resx</DependentUpon>
|
||||||
|
</Compile>
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<EmbeddedResource Update="Properties\Resources.resx">
|
||||||
|
<Generator>ResXFileCodeGenerator</Generator>
|
||||||
|
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
||||||
|
</EmbeddedResource>
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
|
||||||
|
<Exec Command="copy /Y "$(TargetDir)*.dll" "$(SolutionDir)ImplementationExtensions\*.dll"" />
|
||||||
|
</Target>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
@ -0,0 +1,21 @@
|
|||||||
|
using SushiBarContracts.DI;
|
||||||
|
using SushiBarContracts.StoragesContracts;
|
||||||
|
using SushiBarFileImplement.Implements;
|
||||||
|
|
||||||
|
namespace SushiBarFileImplement
|
||||||
|
{
|
||||||
|
public class FileImplementationExtension : IImplementationExtension
|
||||||
|
{
|
||||||
|
public int Priority => 0;
|
||||||
|
public void RegisterServices()
|
||||||
|
{
|
||||||
|
DependencyManager.Instance.RegisterType<IClientStorage, ClientStorage>();
|
||||||
|
DependencyManager.Instance.RegisterType<IComponentStorage, ComponentStorage>();
|
||||||
|
DependencyManager.Instance.RegisterType<IImplementerStorage, ImplementerStorage>();
|
||||||
|
DependencyManager.Instance.RegisterType<IMessageInfoStorage, MessageInfoStorage>();
|
||||||
|
DependencyManager.Instance.RegisterType<IOrderStorage, OrderStorage>();
|
||||||
|
DependencyManager.Instance.RegisterType<ISushiStorage, SushiStorage>();
|
||||||
|
DependencyManager.Instance.RegisterType<IBackUpInfo, BackUpInfo>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
38
SushiBar/SushiBarFileImplement/Implements/BackUpInfo.cs
Normal file
38
SushiBar/SushiBarFileImplement/Implements/BackUpInfo.cs
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
using SushiBarContracts.StoragesContracts;
|
||||||
|
using System.Reflection;
|
||||||
|
|
||||||
|
namespace SushiBarFileImplement.Implements
|
||||||
|
{
|
||||||
|
public class BackUpInfo : IBackUpInfo
|
||||||
|
{
|
||||||
|
private readonly DataFileSingleton source;
|
||||||
|
private readonly PropertyInfo[] sourceProperties;
|
||||||
|
|
||||||
|
public BackUpInfo()
|
||||||
|
{
|
||||||
|
source = DataFileSingleton.GetInstance();
|
||||||
|
sourceProperties = source.GetType().GetProperties(BindingFlags.Instance | BindingFlags.Public);
|
||||||
|
}
|
||||||
|
public Type? GetTypeByModelInterface(string modelInterfaceName)
|
||||||
|
{
|
||||||
|
var assembly = typeof(BackUpInfo).Assembly;
|
||||||
|
var types = assembly.GetTypes();
|
||||||
|
foreach (var type in types)
|
||||||
|
{
|
||||||
|
if (type.IsClass &&
|
||||||
|
type.GetInterface(modelInterfaceName) != null)
|
||||||
|
{
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
public List<T>? GetList<T>() where T : class, new()
|
||||||
|
{
|
||||||
|
var requredType = typeof(T);
|
||||||
|
return (List<T>?)sourceProperties.FirstOrDefault(x => x.PropertyType.IsGenericType && x.PropertyType.GetGenericArguments()[0] == requredType)
|
||||||
|
?.GetValue(source);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -1,11 +1,12 @@
|
|||||||
using SushiBarContracts.BindingModels;
|
using SushiBarContracts.BindingModels;
|
||||||
using SushiBarContracts.SearchModels;
|
using SushiBarContracts.SearchModels;
|
||||||
|
using SushiBarContracts.StoragesContracts;
|
||||||
using SushiBarContracts.ViewModels;
|
using SushiBarContracts.ViewModels;
|
||||||
using SushiBarFileImplement.Models;
|
using SushiBarFileImplement.Models;
|
||||||
|
|
||||||
namespace SushiBarFileImplement.Implements
|
namespace SushiBarFileImplement.Implements
|
||||||
{
|
{
|
||||||
public class ClientStorage
|
public class ClientStorage : IClientStorage
|
||||||
{
|
{
|
||||||
private readonly DataFileSingleton source;
|
private readonly DataFileSingleton source;
|
||||||
public ClientStorage()
|
public ClientStorage()
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
using IceCreamShopContracts.StoragesContracts;
|
using SushiBarContracts.BindingModels;
|
||||||
using SushiBarContracts.BindingModels;
|
|
||||||
using SushiBarContracts.SearchModels;
|
using SushiBarContracts.SearchModels;
|
||||||
|
using SushiBarContracts.StoragesContracts;
|
||||||
using SushiBarContracts.ViewModels;
|
using SushiBarContracts.ViewModels;
|
||||||
using SushiBarFileImplement.Models;
|
using SushiBarFileImplement.Models;
|
||||||
|
|
||||||
|
@ -71,5 +71,7 @@ namespace SushiBarFileImplement.Models
|
|||||||
new XAttribute("SenderName", SenderName),
|
new XAttribute("SenderName", SenderName),
|
||||||
new XAttribute("DateDelivery", DateDelivery)
|
new XAttribute("DateDelivery", DateDelivery)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
public int Id => throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
17
SushiBar/SushiBarListImplement/Implements/BackUpInfo.cs
Normal file
17
SushiBar/SushiBarListImplement/Implements/BackUpInfo.cs
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
using SushiBarContracts.StoragesContracts;
|
||||||
|
|
||||||
|
namespace SushiBarListImplement.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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,6 +1,6 @@
|
|||||||
using IceCreamShopContracts.StoragesContracts;
|
using SushiBarContracts.BindingModels;
|
||||||
using SushiBarContracts.BindingModels;
|
|
||||||
using SushiBarContracts.SearchModels;
|
using SushiBarContracts.SearchModels;
|
||||||
|
using SushiBarContracts.StoragesContracts;
|
||||||
using SushiBarContracts.ViewModels;
|
using SushiBarContracts.ViewModels;
|
||||||
using SushiBarListImplement.Models;
|
using SushiBarListImplement.Models;
|
||||||
|
|
||||||
|
@ -0,0 +1,22 @@
|
|||||||
|
using SushiBarContracts.DI;
|
||||||
|
using SushiBarContracts.StoragesContracts;
|
||||||
|
using SushiBarListImplement.Implements;
|
||||||
|
|
||||||
|
namespace SushiBarListImplement
|
||||||
|
{
|
||||||
|
public class ListImplementationExtension : IImplementationExtension
|
||||||
|
{
|
||||||
|
public int Priority => 0;
|
||||||
|
public void RegisterServices()
|
||||||
|
{
|
||||||
|
DependencyManager.Instance.RegisterType<IClientStorage, ClientStorage>();
|
||||||
|
DependencyManager.Instance.RegisterType<IComponentStorage, ComponentStorage>();
|
||||||
|
DependencyManager.Instance.RegisterType<IImplementerStorage, ImplementerStorage>();
|
||||||
|
DependencyManager.Instance.RegisterType<IMessageInfoStorage, MessageInfoStorage>();
|
||||||
|
DependencyManager.Instance.RegisterType<IOrderStorage, OrderStorage>();
|
||||||
|
DependencyManager.Instance.RegisterType<ISushiStorage, SushiStorage>();
|
||||||
|
DependencyManager.Instance.RegisterType<IBackUpInfo, BackUpInfo>();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -45,5 +45,6 @@ namespace SushiBarListImplement.Models
|
|||||||
DateDelivery = DateDelivery,
|
DateDelivery = DateDelivery,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
public int Id => throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user