вроде готово
This commit is contained in:
parent
60b6950156
commit
4deff59b2b
11
Secure/SecureShop/App.config
Normal file
11
Secure/SecureShop/App.config
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
|
<configuration>
|
||||||
|
<appSettings>
|
||||||
|
<add key="SmtpClientHost" value="smtp.gmail.com" />
|
||||||
|
<add key="SmtpClientPort" value="587" />
|
||||||
|
<add key="PopHost" value="pop.gmail.com" />
|
||||||
|
<add key="PopPort" value="995" />
|
||||||
|
<add key="MailLogin" value="nothellfirescream@gmail.com" />
|
||||||
|
<add key="MailPassword" value="luqw smah ospl znhv" />
|
||||||
|
</appSettings>
|
||||||
|
</configuration>
|
292
Secure/SecureShop/FormMain.Designer.cs
generated
292
Secure/SecureShop/FormMain.Designer.cs
generated
@ -28,207 +28,204 @@
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private void InitializeComponent()
|
private void InitializeComponent()
|
||||||
{
|
{
|
||||||
this.menuStrip = new System.Windows.Forms.MenuStrip();
|
menuStrip = new MenuStrip();
|
||||||
this.справочникиToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
справочникиToolStripMenuItem = new ToolStripMenuItem();
|
||||||
this.FacilitiessToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
FacilitiessToolStripMenuItem = new ToolStripMenuItem();
|
||||||
this.SecuresToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
SecuresToolStripMenuItem = new ToolStripMenuItem();
|
||||||
this.ClientsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
ClientsToolStripMenuItem = new ToolStripMenuItem();
|
||||||
this.ImplementersToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
ImplementersToolStripMenuItem = new ToolStripMenuItem();
|
||||||
this.отчётыToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
отчётыToolStripMenuItem = new ToolStripMenuItem();
|
||||||
this.SecuresReportToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
SecuresReportToolStripMenuItem = new ToolStripMenuItem();
|
||||||
this.SecureFacilitiessReportToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
SecureFacilitiessReportToolStripMenuItem = new ToolStripMenuItem();
|
||||||
this.OrdersReportToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
OrdersReportToolStripMenuItem = new ToolStripMenuItem();
|
||||||
this.StartWorkingToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
StartWorkingToolStripMenuItem = new ToolStripMenuItem();
|
||||||
this.dataGridView = new System.Windows.Forms.DataGridView();
|
dataGridView = new DataGridView();
|
||||||
this.buttonCreateOrder = new System.Windows.Forms.Button();
|
buttonCreateOrder = new Button();
|
||||||
this.buttonTakeOrderInWork = new System.Windows.Forms.Button();
|
buttonTakeOrderInWork = new Button();
|
||||||
this.buttonOrderReady = new System.Windows.Forms.Button();
|
buttonOrderReady = new Button();
|
||||||
this.buttonIssuedOrder = new System.Windows.Forms.Button();
|
buttonIssuedOrder = new Button();
|
||||||
this.buttonRef = new System.Windows.Forms.Button();
|
buttonRef = new Button();
|
||||||
this.menuStrip.SuspendLayout();
|
сообщенияToolStripMenuItem = new ToolStripMenuItem();
|
||||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
|
menuStrip.SuspendLayout();
|
||||||
this.SuspendLayout();
|
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
|
||||||
|
SuspendLayout();
|
||||||
//
|
//
|
||||||
// menuStrip
|
// menuStrip
|
||||||
//
|
//
|
||||||
this.menuStrip.ImageScalingSize = new System.Drawing.Size(20, 20);
|
menuStrip.ImageScalingSize = new Size(20, 20);
|
||||||
this.menuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
menuStrip.Items.AddRange(new ToolStripItem[] { справочникиToolStripMenuItem, отчётыToolStripMenuItem, StartWorkingToolStripMenuItem, сообщенияToolStripMenuItem });
|
||||||
this.справочникиToolStripMenuItem,
|
menuStrip.Location = new Point(0, 0);
|
||||||
this.отчётыToolStripMenuItem,
|
menuStrip.Name = "menuStrip";
|
||||||
this.StartWorkingToolStripMenuItem});
|
menuStrip.Padding = new Padding(5, 2, 0, 2);
|
||||||
this.menuStrip.Location = new System.Drawing.Point(0, 0);
|
menuStrip.Size = new Size(1149, 24);
|
||||||
this.menuStrip.Name = "menuStrip";
|
menuStrip.TabIndex = 0;
|
||||||
this.menuStrip.Padding = new System.Windows.Forms.Padding(5, 2, 0, 2);
|
menuStrip.Text = "Справочники";
|
||||||
this.menuStrip.Size = new System.Drawing.Size(1149, 24);
|
|
||||||
this.menuStrip.TabIndex = 0;
|
|
||||||
this.menuStrip.Text = "Справочники";
|
|
||||||
//
|
//
|
||||||
// справочникиToolStripMenuItem
|
// справочникиToolStripMenuItem
|
||||||
//
|
//
|
||||||
this.справочникиToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
справочникиToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { FacilitiessToolStripMenuItem, SecuresToolStripMenuItem, ClientsToolStripMenuItem, ImplementersToolStripMenuItem });
|
||||||
this.FacilitiessToolStripMenuItem,
|
справочникиToolStripMenuItem.Name = "справочникиToolStripMenuItem";
|
||||||
this.SecuresToolStripMenuItem,
|
справочникиToolStripMenuItem.Size = new Size(94, 20);
|
||||||
this.ClientsToolStripMenuItem,
|
справочникиToolStripMenuItem.Text = "Справочники";
|
||||||
this.ImplementersToolStripMenuItem});
|
|
||||||
this.справочникиToolStripMenuItem.Name = "справочникиToolStripMenuItem";
|
|
||||||
this.справочникиToolStripMenuItem.Size = new System.Drawing.Size(94, 20);
|
|
||||||
this.справочникиToolStripMenuItem.Text = "Справочники";
|
|
||||||
//
|
//
|
||||||
// FacilitiessToolStripMenuItem
|
// FacilitiessToolStripMenuItem
|
||||||
//
|
//
|
||||||
this.FacilitiessToolStripMenuItem.Name = "FacilitiessToolStripMenuItem";
|
FacilitiessToolStripMenuItem.Name = "FacilitiessToolStripMenuItem";
|
||||||
this.FacilitiessToolStripMenuItem.Size = new System.Drawing.Size(200, 22);
|
FacilitiessToolStripMenuItem.Size = new Size(200, 22);
|
||||||
this.FacilitiessToolStripMenuItem.Text = "Оборудование";
|
FacilitiessToolStripMenuItem.Text = "Оборудование";
|
||||||
this.FacilitiessToolStripMenuItem.Click += new System.EventHandler(this.FacilitiessToolStripMenuItem_Click);
|
FacilitiessToolStripMenuItem.Click += FacilitiessToolStripMenuItem_Click;
|
||||||
//
|
//
|
||||||
// SecuresToolStripMenuItem
|
// SecuresToolStripMenuItem
|
||||||
//
|
//
|
||||||
this.SecuresToolStripMenuItem.Name = "SecuresToolStripMenuItem";
|
SecuresToolStripMenuItem.Name = "SecuresToolStripMenuItem";
|
||||||
this.SecuresToolStripMenuItem.Size = new System.Drawing.Size(200, 22);
|
SecuresToolStripMenuItem.Size = new Size(200, 22);
|
||||||
this.SecuresToolStripMenuItem.Text = "Система безопасности";
|
SecuresToolStripMenuItem.Text = "Система безопасности";
|
||||||
this.SecuresToolStripMenuItem.Click += new System.EventHandler(this.SecuresToolStripMenuItem_Click);
|
SecuresToolStripMenuItem.Click += SecuresToolStripMenuItem_Click;
|
||||||
//
|
//
|
||||||
// ClientsToolStripMenuItem
|
// ClientsToolStripMenuItem
|
||||||
//
|
//
|
||||||
this.ClientsToolStripMenuItem.Name = "ClientsToolStripMenuItem";
|
ClientsToolStripMenuItem.Name = "ClientsToolStripMenuItem";
|
||||||
this.ClientsToolStripMenuItem.Size = new System.Drawing.Size(200, 22);
|
ClientsToolStripMenuItem.Size = new Size(200, 22);
|
||||||
this.ClientsToolStripMenuItem.Text = "Клиенты";
|
ClientsToolStripMenuItem.Text = "Клиенты";
|
||||||
this.ClientsToolStripMenuItem.Click += new System.EventHandler(this.ClientsToolStripMenuItem_Click);
|
ClientsToolStripMenuItem.Click += ClientsToolStripMenuItem_Click;
|
||||||
//
|
//
|
||||||
// ImplementersToolStripMenuItem
|
// ImplementersToolStripMenuItem
|
||||||
//
|
//
|
||||||
this.ImplementersToolStripMenuItem.Name = "ImplementersToolStripMenuItem";
|
ImplementersToolStripMenuItem.Name = "ImplementersToolStripMenuItem";
|
||||||
this.ImplementersToolStripMenuItem.Size = new System.Drawing.Size(200, 22);
|
ImplementersToolStripMenuItem.Size = new Size(200, 22);
|
||||||
this.ImplementersToolStripMenuItem.Text = "Исполнители";
|
ImplementersToolStripMenuItem.Text = "Исполнители";
|
||||||
this.ImplementersToolStripMenuItem.Click += new System.EventHandler(this.ImplementersToolStripMenuItem_Click);
|
ImplementersToolStripMenuItem.Click += ImplementersToolStripMenuItem_Click;
|
||||||
//
|
//
|
||||||
// отчётыToolStripMenuItem
|
// отчётыToolStripMenuItem
|
||||||
//
|
//
|
||||||
this.отчётыToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
отчётыToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { SecuresReportToolStripMenuItem, SecureFacilitiessReportToolStripMenuItem, OrdersReportToolStripMenuItem });
|
||||||
this.SecuresReportToolStripMenuItem,
|
отчётыToolStripMenuItem.Name = "отчётыToolStripMenuItem";
|
||||||
this.SecureFacilitiessReportToolStripMenuItem,
|
отчётыToolStripMenuItem.Size = new Size(60, 20);
|
||||||
this.OrdersReportToolStripMenuItem});
|
отчётыToolStripMenuItem.Text = "Отчёты";
|
||||||
this.отчётыToolStripMenuItem.Name = "отчётыToolStripMenuItem";
|
|
||||||
this.отчётыToolStripMenuItem.Size = new System.Drawing.Size(60, 20);
|
|
||||||
this.отчётыToolStripMenuItem.Text = "Отчёты";
|
|
||||||
//
|
//
|
||||||
// SecuresReportToolStripMenuItem
|
// SecuresReportToolStripMenuItem
|
||||||
//
|
//
|
||||||
this.SecuresReportToolStripMenuItem.Name = "SecuresReportToolStripMenuItem";
|
SecuresReportToolStripMenuItem.Name = "SecuresReportToolStripMenuItem";
|
||||||
this.SecuresReportToolStripMenuItem.Size = new System.Drawing.Size(236, 22);
|
SecuresReportToolStripMenuItem.Size = new Size(236, 22);
|
||||||
this.SecuresReportToolStripMenuItem.Text = "Список систем безопасности";
|
SecuresReportToolStripMenuItem.Text = "Список систем безопасности";
|
||||||
this.SecuresReportToolStripMenuItem.Click += new System.EventHandler(this.SecuresReportToolStripMenuItem_Click);
|
SecuresReportToolStripMenuItem.Click += SecuresReportToolStripMenuItem_Click;
|
||||||
//
|
//
|
||||||
// SecureFacilitiessReportToolStripMenuItem
|
// SecureFacilitiessReportToolStripMenuItem
|
||||||
//
|
//
|
||||||
this.SecureFacilitiessReportToolStripMenuItem.Name = "SecureFacilitiessReportToolStripMenuItem";
|
SecureFacilitiessReportToolStripMenuItem.Name = "SecureFacilitiessReportToolStripMenuItem";
|
||||||
this.SecureFacilitiessReportToolStripMenuItem.Size = new System.Drawing.Size(236, 22);
|
SecureFacilitiessReportToolStripMenuItem.Size = new Size(236, 22);
|
||||||
this.SecureFacilitiessReportToolStripMenuItem.Text = "Оборудование по СБ";
|
SecureFacilitiessReportToolStripMenuItem.Text = "Оборудование по СБ";
|
||||||
this.SecureFacilitiessReportToolStripMenuItem.Click += new System.EventHandler(this.SecureFacilitiessReportToolStripMenuItem_Click);
|
SecureFacilitiessReportToolStripMenuItem.Click += SecureFacilitiessReportToolStripMenuItem_Click;
|
||||||
//
|
//
|
||||||
// OrdersReportToolStripMenuItem
|
// OrdersReportToolStripMenuItem
|
||||||
//
|
//
|
||||||
this.OrdersReportToolStripMenuItem.Name = "OrdersReportToolStripMenuItem";
|
OrdersReportToolStripMenuItem.Name = "OrdersReportToolStripMenuItem";
|
||||||
this.OrdersReportToolStripMenuItem.Size = new System.Drawing.Size(236, 22);
|
OrdersReportToolStripMenuItem.Size = new Size(236, 22);
|
||||||
this.OrdersReportToolStripMenuItem.Text = "Список заказов";
|
OrdersReportToolStripMenuItem.Text = "Список заказов";
|
||||||
this.OrdersReportToolStripMenuItem.Click += new System.EventHandler(this.OrdersReportToolStripMenuItem_Click);
|
OrdersReportToolStripMenuItem.Click += OrdersReportToolStripMenuItem_Click;
|
||||||
//
|
//
|
||||||
// StartWorkingToolStripMenuItem
|
// StartWorkingToolStripMenuItem
|
||||||
//
|
//
|
||||||
this.StartWorkingToolStripMenuItem.Name = "StartWorkingToolStripMenuItem";
|
StartWorkingToolStripMenuItem.Name = "StartWorkingToolStripMenuItem";
|
||||||
this.StartWorkingToolStripMenuItem.Size = new System.Drawing.Size(92, 20);
|
StartWorkingToolStripMenuItem.Size = new Size(92, 20);
|
||||||
this.StartWorkingToolStripMenuItem.Text = "Запуск работ";
|
StartWorkingToolStripMenuItem.Text = "Запуск работ";
|
||||||
this.StartWorkingToolStripMenuItem.Click += new System.EventHandler(this.StartWorkingToolStripMenuItem_Click);
|
StartWorkingToolStripMenuItem.Click += StartWorkingToolStripMenuItem_Click;
|
||||||
//
|
//
|
||||||
// dataGridView
|
// dataGridView
|
||||||
//
|
//
|
||||||
this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||||
this.dataGridView.Location = new System.Drawing.Point(12, 26);
|
dataGridView.Location = new Point(12, 26);
|
||||||
this.dataGridView.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
dataGridView.Margin = new Padding(3, 2, 3, 2);
|
||||||
this.dataGridView.Name = "dataGridView";
|
dataGridView.Name = "dataGridView";
|
||||||
this.dataGridView.RowHeadersWidth = 51;
|
dataGridView.RowHeadersWidth = 51;
|
||||||
this.dataGridView.RowTemplate.Height = 29;
|
dataGridView.RowTemplate.Height = 29;
|
||||||
this.dataGridView.Size = new System.Drawing.Size(957, 305);
|
dataGridView.Size = new Size(957, 305);
|
||||||
this.dataGridView.TabIndex = 1;
|
dataGridView.TabIndex = 1;
|
||||||
//
|
//
|
||||||
// buttonCreateOrder
|
// buttonCreateOrder
|
||||||
//
|
//
|
||||||
this.buttonCreateOrder.Location = new System.Drawing.Point(975, 34);
|
buttonCreateOrder.Location = new Point(975, 34);
|
||||||
this.buttonCreateOrder.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
buttonCreateOrder.Margin = new Padding(3, 2, 3, 2);
|
||||||
this.buttonCreateOrder.Name = "buttonCreateOrder";
|
buttonCreateOrder.Name = "buttonCreateOrder";
|
||||||
this.buttonCreateOrder.Size = new System.Drawing.Size(170, 22);
|
buttonCreateOrder.Size = new Size(170, 22);
|
||||||
this.buttonCreateOrder.TabIndex = 2;
|
buttonCreateOrder.TabIndex = 2;
|
||||||
this.buttonCreateOrder.Text = "Создать заказ";
|
buttonCreateOrder.Text = "Создать заказ";
|
||||||
this.buttonCreateOrder.UseVisualStyleBackColor = true;
|
buttonCreateOrder.UseVisualStyleBackColor = true;
|
||||||
this.buttonCreateOrder.Click += new System.EventHandler(this.ButtonCreateOrder_Click);
|
buttonCreateOrder.Click += ButtonCreateOrder_Click;
|
||||||
//
|
//
|
||||||
// buttonTakeOrderInWork
|
// buttonTakeOrderInWork
|
||||||
//
|
//
|
||||||
this.buttonTakeOrderInWork.Location = new System.Drawing.Point(975, 60);
|
buttonTakeOrderInWork.Location = new Point(975, 60);
|
||||||
this.buttonTakeOrderInWork.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
buttonTakeOrderInWork.Margin = new Padding(3, 2, 3, 2);
|
||||||
this.buttonTakeOrderInWork.Name = "buttonTakeOrderInWork";
|
buttonTakeOrderInWork.Name = "buttonTakeOrderInWork";
|
||||||
this.buttonTakeOrderInWork.Size = new System.Drawing.Size(170, 22);
|
buttonTakeOrderInWork.Size = new Size(170, 22);
|
||||||
this.buttonTakeOrderInWork.TabIndex = 3;
|
buttonTakeOrderInWork.TabIndex = 3;
|
||||||
this.buttonTakeOrderInWork.Text = "Отдать на выполнение";
|
buttonTakeOrderInWork.Text = "Отдать на выполнение";
|
||||||
this.buttonTakeOrderInWork.UseVisualStyleBackColor = true;
|
buttonTakeOrderInWork.UseVisualStyleBackColor = true;
|
||||||
this.buttonTakeOrderInWork.Click += new System.EventHandler(this.ButtonTakeOrderInWork_Click);
|
buttonTakeOrderInWork.Click += ButtonTakeOrderInWork_Click;
|
||||||
//
|
//
|
||||||
// buttonOrderReady
|
// buttonOrderReady
|
||||||
//
|
//
|
||||||
this.buttonOrderReady.Location = new System.Drawing.Point(975, 86);
|
buttonOrderReady.Location = new Point(975, 86);
|
||||||
this.buttonOrderReady.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
buttonOrderReady.Margin = new Padding(3, 2, 3, 2);
|
||||||
this.buttonOrderReady.Name = "buttonOrderReady";
|
buttonOrderReady.Name = "buttonOrderReady";
|
||||||
this.buttonOrderReady.Size = new System.Drawing.Size(170, 22);
|
buttonOrderReady.Size = new Size(170, 22);
|
||||||
this.buttonOrderReady.TabIndex = 4;
|
buttonOrderReady.TabIndex = 4;
|
||||||
this.buttonOrderReady.Text = "Заказ готов";
|
buttonOrderReady.Text = "Заказ готов";
|
||||||
this.buttonOrderReady.UseVisualStyleBackColor = true;
|
buttonOrderReady.UseVisualStyleBackColor = true;
|
||||||
this.buttonOrderReady.Click += new System.EventHandler(this.ButtonOrderReady_Click);
|
buttonOrderReady.Click += ButtonOrderReady_Click;
|
||||||
//
|
//
|
||||||
// buttonIssuedOrder
|
// buttonIssuedOrder
|
||||||
//
|
//
|
||||||
this.buttonIssuedOrder.Location = new System.Drawing.Point(975, 112);
|
buttonIssuedOrder.Location = new Point(975, 112);
|
||||||
this.buttonIssuedOrder.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
buttonIssuedOrder.Margin = new Padding(3, 2, 3, 2);
|
||||||
this.buttonIssuedOrder.Name = "buttonIssuedOrder";
|
buttonIssuedOrder.Name = "buttonIssuedOrder";
|
||||||
this.buttonIssuedOrder.Size = new System.Drawing.Size(170, 22);
|
buttonIssuedOrder.Size = new Size(170, 22);
|
||||||
this.buttonIssuedOrder.TabIndex = 5;
|
buttonIssuedOrder.TabIndex = 5;
|
||||||
this.buttonIssuedOrder.Text = "Заказ выдан";
|
buttonIssuedOrder.Text = "Заказ выдан";
|
||||||
this.buttonIssuedOrder.UseVisualStyleBackColor = true;
|
buttonIssuedOrder.UseVisualStyleBackColor = true;
|
||||||
this.buttonIssuedOrder.Click += new System.EventHandler(this.ButtonIssuedOrder_Click);
|
buttonIssuedOrder.Click += ButtonIssuedOrder_Click;
|
||||||
//
|
//
|
||||||
// buttonRef
|
// buttonRef
|
||||||
//
|
//
|
||||||
this.buttonRef.Location = new System.Drawing.Point(975, 138);
|
buttonRef.Location = new Point(975, 138);
|
||||||
this.buttonRef.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
buttonRef.Margin = new Padding(3, 2, 3, 2);
|
||||||
this.buttonRef.Name = "buttonRef";
|
buttonRef.Name = "buttonRef";
|
||||||
this.buttonRef.Size = new System.Drawing.Size(170, 22);
|
buttonRef.Size = new Size(170, 22);
|
||||||
this.buttonRef.TabIndex = 6;
|
buttonRef.TabIndex = 6;
|
||||||
this.buttonRef.Text = "Обновить";
|
buttonRef.Text = "Обновить";
|
||||||
this.buttonRef.UseVisualStyleBackColor = true;
|
buttonRef.UseVisualStyleBackColor = true;
|
||||||
this.buttonRef.Click += new System.EventHandler(this.ButtonRef_Click);
|
buttonRef.Click += ButtonRef_Click;
|
||||||
|
//
|
||||||
|
// сообщенияToolStripMenuItem
|
||||||
|
//
|
||||||
|
сообщенияToolStripMenuItem.Name = "сообщенияToolStripMenuItem";
|
||||||
|
сообщенияToolStripMenuItem.Size = new Size(85, 20);
|
||||||
|
сообщенияToolStripMenuItem.Text = "Сообщения";
|
||||||
|
сообщенияToolStripMenuItem.Click += сообщенияToolStripMenuItem_Click;
|
||||||
//
|
//
|
||||||
// FormMain
|
// FormMain
|
||||||
//
|
//
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
this.ClientSize = new System.Drawing.Size(1149, 338);
|
ClientSize = new Size(1149, 338);
|
||||||
this.Controls.Add(this.buttonRef);
|
Controls.Add(buttonRef);
|
||||||
this.Controls.Add(this.buttonIssuedOrder);
|
Controls.Add(buttonIssuedOrder);
|
||||||
this.Controls.Add(this.buttonOrderReady);
|
Controls.Add(buttonOrderReady);
|
||||||
this.Controls.Add(this.buttonTakeOrderInWork);
|
Controls.Add(buttonTakeOrderInWork);
|
||||||
this.Controls.Add(this.buttonCreateOrder);
|
Controls.Add(buttonCreateOrder);
|
||||||
this.Controls.Add(this.dataGridView);
|
Controls.Add(dataGridView);
|
||||||
this.Controls.Add(this.menuStrip);
|
Controls.Add(menuStrip);
|
||||||
this.MainMenuStrip = this.menuStrip;
|
MainMenuStrip = menuStrip;
|
||||||
this.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
Margin = new Padding(3, 2, 3, 2);
|
||||||
this.Name = "FormMain";
|
Name = "FormMain";
|
||||||
this.Text = "Магазин систем безопасности";
|
Text = "Магазин систем безопасности";
|
||||||
this.Load += new System.EventHandler(this.FormMain_Load);
|
Load += FormMain_Load;
|
||||||
this.menuStrip.ResumeLayout(false);
|
menuStrip.ResumeLayout(false);
|
||||||
this.menuStrip.PerformLayout();
|
menuStrip.PerformLayout();
|
||||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
|
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
|
||||||
this.ResumeLayout(false);
|
ResumeLayout(false);
|
||||||
this.PerformLayout();
|
PerformLayout();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
@ -250,5 +247,6 @@
|
|||||||
private ToolStripMenuItem ClientsToolStripMenuItem;
|
private ToolStripMenuItem ClientsToolStripMenuItem;
|
||||||
private ToolStripMenuItem ImplementersToolStripMenuItem;
|
private ToolStripMenuItem ImplementersToolStripMenuItem;
|
||||||
private ToolStripMenuItem StartWorkingToolStripMenuItem;
|
private ToolStripMenuItem StartWorkingToolStripMenuItem;
|
||||||
|
private ToolStripMenuItem сообщенияToolStripMenuItem;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -2,6 +2,7 @@
|
|||||||
using SecureShopContracts.BindingModels;
|
using SecureShopContracts.BindingModels;
|
||||||
using SecureShopContracts.BusinessLogicsContracts;
|
using SecureShopContracts.BusinessLogicsContracts;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
|
using SecureShopView;
|
||||||
|
|
||||||
namespace SecureShopView
|
namespace SecureShopView
|
||||||
{
|
{
|
||||||
@ -214,5 +215,14 @@ namespace SecureShopView
|
|||||||
_workProcessLogic.DoWork((Program.ServiceProvider?.GetService(typeof(IImplementerLogic)) as IImplementerLogic)!, _orderLogic);
|
_workProcessLogic.DoWork((Program.ServiceProvider?.GetService(typeof(IImplementerLogic)) as IImplementerLogic)!, _orderLogic);
|
||||||
MessageBox.Show("Процесс обработки запущен", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
MessageBox.Show("Процесс обработки запущен", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void сообщенияToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
var service = Program.ServiceProvider?.GetService(typeof(FormMessages));
|
||||||
|
if (service is FormMessages form)
|
||||||
|
{
|
||||||
|
form.ShowDialog();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
61
Secure/SecureShop/FormMessages.Designer.cs
generated
Normal file
61
Secure/SecureShop/FormMessages.Designer.cs
generated
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
namespace SecureShopView
|
||||||
|
{
|
||||||
|
partial class FormMessages
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Required designer variable.
|
||||||
|
/// </summary>
|
||||||
|
private System.ComponentModel.IContainer components = null;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Clean up any resources being used.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||||
|
protected override void Dispose(bool disposing)
|
||||||
|
{
|
||||||
|
if (disposing && (components != null))
|
||||||
|
{
|
||||||
|
components.Dispose();
|
||||||
|
}
|
||||||
|
base.Dispose(disposing);
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Windows Form Designer generated code
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Required method for Designer support - do not modify
|
||||||
|
/// the contents of this method with the code editor.
|
||||||
|
/// </summary>
|
||||||
|
private void InitializeComponent()
|
||||||
|
{
|
||||||
|
dataGridView = new DataGridView();
|
||||||
|
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
|
||||||
|
SuspendLayout();
|
||||||
|
//
|
||||||
|
// dataGridView
|
||||||
|
//
|
||||||
|
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||||
|
dataGridView.Location = new Point(12, 12);
|
||||||
|
dataGridView.Name = "dataGridView";
|
||||||
|
dataGridView.RowTemplate.Height = 25;
|
||||||
|
dataGridView.Size = new Size(776, 426);
|
||||||
|
dataGridView.TabIndex = 0;
|
||||||
|
//
|
||||||
|
// FormMessages
|
||||||
|
//
|
||||||
|
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||||
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
|
ClientSize = new Size(800, 450);
|
||||||
|
Controls.Add(dataGridView);
|
||||||
|
Name = "FormMessages";
|
||||||
|
Text = "Сообщения";
|
||||||
|
Load += FormMessages_Load;
|
||||||
|
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
|
||||||
|
ResumeLayout(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private DataGridView dataGridView;
|
||||||
|
}
|
||||||
|
}
|
53
Secure/SecureShop/FormMessages.cs
Normal file
53
Secure/SecureShop/FormMessages.cs
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
using SecureShopContracts.BusinessLogicsContracts;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Data;
|
||||||
|
using System.Drawing;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
|
||||||
|
namespace SecureShopView
|
||||||
|
{
|
||||||
|
public partial class FormMessages : Form
|
||||||
|
{
|
||||||
|
private readonly ILogger _logger;
|
||||||
|
private readonly IMessageInfoLogic _logic;
|
||||||
|
|
||||||
|
public FormMessages(ILogger<FormSecures> logger, IMessageInfoLogic logic)
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
_logger = logger;
|
||||||
|
_logic = logic;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void FormMessages_Load(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void LoadData()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var list = _logic.ReadList(null);
|
||||||
|
if (list != null)
|
||||||
|
{
|
||||||
|
dataGridView.DataSource = list;
|
||||||
|
dataGridView.Columns["ClientId"].Visible = false;
|
||||||
|
dataGridView.Columns["MessageId"].Visible = false;
|
||||||
|
dataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
|
||||||
|
}
|
||||||
|
_logger.LogInformation("Загрузка сообщений");
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка загрузки сообщений");
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
60
Secure/SecureShop/FormMessages.resx
Normal file
60
Secure/SecureShop/FormMessages.resx
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
<root>
|
||||||
|
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||||
|
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||||
|
<xsd:element name="root" msdata:IsDataSet="true">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:choice maxOccurs="unbounded">
|
||||||
|
<xsd:element name="metadata">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="assembly">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:attribute name="alias" type="xsd:string" />
|
||||||
|
<xsd:attribute name="name" type="xsd:string" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<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" use="required" msdata:Ordinal="1" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</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>2.0</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="reader">
|
||||||
|
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="writer">
|
||||||
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
</root>
|
@ -1,4 +1,4 @@
|
|||||||
using SecureShopBusinessLogic.BusinessLogics;
|
using SecureShopBusinessLogic.BusinessLogics;
|
||||||
using SecureShopContracts.BusinessLogicsContracts;
|
using SecureShopContracts.BusinessLogicsContracts;
|
||||||
using SecureShopContracts.StoragesContracts;
|
using SecureShopContracts.StoragesContracts;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
@ -7,7 +7,9 @@ using NLog.Extensions.Logging;
|
|||||||
using SecureShopBusinessLogic.OfficePackage;
|
using SecureShopBusinessLogic.OfficePackage;
|
||||||
using SecureShopBusinessLogic.OfficePackage.Implements;
|
using SecureShopBusinessLogic.OfficePackage.Implements;
|
||||||
using SecureShopDatabaseImplement.Implements;
|
using SecureShopDatabaseImplement.Implements;
|
||||||
using SecureShopView;
|
using SecureShopBusinessLogic.MailWorker;
|
||||||
|
using SecureShopContracts.BindingModels;
|
||||||
|
|
||||||
|
|
||||||
namespace SecureShopView
|
namespace SecureShopView
|
||||||
{
|
{
|
||||||
@ -27,6 +29,25 @@ namespace SecureShopView
|
|||||||
var services = new ServiceCollection();
|
var services = new ServiceCollection();
|
||||||
ConfigureServices(services);
|
ConfigureServices(services);
|
||||||
_serviceProvider = services.BuildServiceProvider();
|
_serviceProvider = services.BuildServiceProvider();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var mailSender = _serviceProvider.GetService<AbstractMailWorker>();
|
||||||
|
mailSender?.MailConfig(new MailConfigBindingModel
|
||||||
|
{
|
||||||
|
MailLogin = System.Configuration.ConfigurationManager.AppSettings["MailLogin"] ?? string.Empty,
|
||||||
|
MailPassword = System.Configuration.ConfigurationManager.AppSettings["MailPassword"] ?? string.Empty,
|
||||||
|
SmtpClientHost = System.Configuration.ConfigurationManager.AppSettings["SmtpClientHost"] ?? string.Empty,
|
||||||
|
SmtpClientPort = Convert.ToInt32(System.Configuration.ConfigurationManager.AppSettings["SmtpClientPort"]),
|
||||||
|
PopHost = System.Configuration.ConfigurationManager.AppSettings["PopHost"] ?? string.Empty,
|
||||||
|
PopPort = Convert.ToInt32(System.Configuration.ConfigurationManager.AppSettings["PopPort"])
|
||||||
|
});
|
||||||
|
var timer = new System.Threading.Timer(new TimerCallback(MailCheck!), null, 0, 100000);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
var logger = _serviceProvider.GetService<ILogger>();
|
||||||
|
logger?.LogError(ex, "Îøèáêà ðàáîòû ñ ïî÷òîé");
|
||||||
|
}
|
||||||
Application.Run(_serviceProvider.GetRequiredService<FormMain>());
|
Application.Run(_serviceProvider.GetRequiredService<FormMain>());
|
||||||
}
|
}
|
||||||
private static void ConfigureServices(ServiceCollection services)
|
private static void ConfigureServices(ServiceCollection services)
|
||||||
@ -40,11 +61,16 @@ namespace SecureShopView
|
|||||||
services.AddTransient<IOrderStorage, OrderStorage>();
|
services.AddTransient<IOrderStorage, OrderStorage>();
|
||||||
services.AddTransient<IClientStorage, ClientStorage>();
|
services.AddTransient<IClientStorage, ClientStorage>();
|
||||||
services.AddTransient<ISecureStorage, SecureStorage>();
|
services.AddTransient<ISecureStorage, SecureStorage>();
|
||||||
|
services.AddTransient<IMessageInfoStorage, MessageInfoStorage>();
|
||||||
services.AddTransient<IFacilitiesLogic, FacilitiesLogic>();
|
services.AddTransient<IFacilitiesLogic, FacilitiesLogic>();
|
||||||
|
services.AddTransient<IMessageInfoLogic, MessageInfoLogic>();
|
||||||
services.AddTransient<IOrderLogic, OrderLogic>();
|
services.AddTransient<IOrderLogic, OrderLogic>();
|
||||||
services.AddTransient<ISecureLogic, SecureLogic>();
|
services.AddTransient<ISecureLogic, SecureLogic>();
|
||||||
services.AddTransient<IClientLogic, ClientLogic>();
|
services.AddTransient<IClientLogic, ClientLogic>();
|
||||||
|
services.AddSingleton<AbstractMailWorker, MailKitWorker>();
|
||||||
services.AddTransient<IImplementerLogic, ImplementerLogic>();
|
services.AddTransient<IImplementerLogic, ImplementerLogic>();
|
||||||
|
services.AddTransient<FormMessages>();
|
||||||
|
|
||||||
services.AddTransient<FormMain>();
|
services.AddTransient<FormMain>();
|
||||||
services.AddTransient<IImplementerStorage, ImplementerStorage>();
|
services.AddTransient<IImplementerStorage, ImplementerStorage>();
|
||||||
services.AddTransient<IReportLogic, ReportLogic>();
|
services.AddTransient<IReportLogic, ReportLogic>();
|
||||||
@ -64,6 +90,6 @@ namespace SecureShopView
|
|||||||
services.AddTransient<FormSecures>();
|
services.AddTransient<FormSecures>();
|
||||||
services.AddTransient<FormClients>();
|
services.AddTransient<FormClients>();
|
||||||
}
|
}
|
||||||
|
private static void MailCheck(object obj) => ServiceProvider?.GetService<AbstractMailWorker>()?.MailCheck();
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -9,13 +9,13 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.5">
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.7">
|
||||||
<PrivateAssets>all</PrivateAssets>
|
<PrivateAssets>all</PrivateAssets>
|
||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="7.0.0" />
|
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="7.0.0" />
|
||||||
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="7.0.0" />
|
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="7.0.1" />
|
||||||
<PackageReference Include="NLog.Extensions.Logging" Version="5.2.3" />
|
<PackageReference Include="NLog.Extensions.Logging" Version="5.3.0" />
|
||||||
<PackageReference Include="ReportViewerCore.WinForms" Version="15.1.17" />
|
<PackageReference Include="ReportViewerCore.WinForms" Version="15.1.17" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
@ -32,5 +32,10 @@
|
|||||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||||
</None>
|
</None>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<None Update="App.config">
|
||||||
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||||
|
</None>
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
@ -4,6 +4,7 @@ using SecureShopContracts.SearchModels;
|
|||||||
using SecureShopContracts.StoragesContracts;
|
using SecureShopContracts.StoragesContracts;
|
||||||
using SecureShopContracts.ViewModels;
|
using SecureShopContracts.ViewModels;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
|
using System.Text.RegularExpressions;
|
||||||
|
|
||||||
namespace SecureShopBusinessLogic.BusinessLogics
|
namespace SecureShopBusinessLogic.BusinessLogics
|
||||||
{
|
{
|
||||||
@ -96,6 +97,15 @@ namespace SecureShopBusinessLogic.BusinessLogics
|
|||||||
{
|
{
|
||||||
throw new ArgumentNullException("Нет имени клиента", nameof(model.ClientFIO));
|
throw new ArgumentNullException("Нет имени клиента", nameof(model.ClientFIO));
|
||||||
}
|
}
|
||||||
|
if (!Regex.IsMatch(model.Email, @"^(?("")(""[^""]+?""@)|(([0-9a-z]((\.(?!\.))|[-!#\$%&'\*\+/=\?\^`\{\}\|~\w])*)(?<=[0-9a-z])@))" +
|
||||||
|
@"(?(\[)(\[(\d{1,3}\.){3}\d{1,3}\])|(([0-9a-z][-\w]*[0-9a-z]*\.)+[a-z0-9]{2,17}))$", RegexOptions.IgnoreCase))
|
||||||
|
{
|
||||||
|
throw new ArgumentException("Некорректная почта, сынок", nameof(model.Email));
|
||||||
|
}
|
||||||
|
if (!Regex.IsMatch(model.Password, @"^((\w+\d+\W+)|(\w+\W+\d+)|(\d+\w+\W+)|(\d+\W+\w+)|(\W+\w+\d+)|(\W+\d+\w+))[\w\d\W]*$", RegexOptions.IgnoreCase) || model.Password.Length < 10 || model.Password.Length > 50)
|
||||||
|
{
|
||||||
|
throw new ArgumentException("Думай лучше. Плохой пароль", nameof(model.Password));
|
||||||
|
}
|
||||||
_logger.LogInformation("Client. ClientFIO:{ClientFIO}. Id: {Id}", model.ClientFIO, model.Id);
|
_logger.LogInformation("Client. ClientFIO:{ClientFIO}. Id: {Id}", model.ClientFIO, model.Id);
|
||||||
var element = _clientStorage.GetElement(new ClientSearchModel
|
var element = _clientStorage.GetElement(new ClientSearchModel
|
||||||
{
|
{
|
||||||
|
@ -3,6 +3,7 @@ using SecureShopContracts.BusinessLogicsContracts;
|
|||||||
using SecureShopContracts.SearchModels;
|
using SecureShopContracts.SearchModels;
|
||||||
using SecureShopContracts.StoragesContracts;
|
using SecureShopContracts.StoragesContracts;
|
||||||
using SecureShopContracts.ViewModels;
|
using SecureShopContracts.ViewModels;
|
||||||
|
using SecureShopBusinessLogic.MailWorker;
|
||||||
using SecureShopDataModels.Enums;
|
using SecureShopDataModels.Enums;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
|
|
||||||
@ -12,11 +13,15 @@ namespace SecureShopBusinessLogic.BusinessLogics
|
|||||||
{
|
{
|
||||||
private readonly ILogger _logger;
|
private readonly ILogger _logger;
|
||||||
private readonly IOrderStorage _orderStorage;
|
private readonly IOrderStorage _orderStorage;
|
||||||
|
private readonly AbstractMailWorker _abstractMailWorker;
|
||||||
|
private readonly IClientStorage _clientStorage;
|
||||||
|
|
||||||
public OrderLogic(ILogger<OrderLogic> logger, IOrderStorage orderStorage)
|
public OrderLogic(ILogger<OrderLogic> logger, IOrderStorage orderStorage, AbstractMailWorker abstractMailWorker, IClientStorage clientStorage)
|
||||||
{
|
{
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
_orderStorage = orderStorage;
|
_orderStorage = orderStorage;
|
||||||
|
_abstractMailWorker = abstractMailWorker;
|
||||||
|
_clientStorage = clientStorage;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<OrderViewModel>? ReadList(OrderSearchModel? model)
|
public List<OrderViewModel>? ReadList(OrderSearchModel? model)
|
||||||
@ -66,11 +71,19 @@ namespace SecureShopBusinessLogic.BusinessLogics
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
model.Status = OrderStatus.Принят;
|
model.Status = OrderStatus.Принят;
|
||||||
if (_orderStorage.Insert(model) == null)
|
var order = _orderStorage.Insert(model);
|
||||||
|
if (order == null)
|
||||||
{
|
{
|
||||||
_logger.LogWarning("Insert operation failed");
|
_logger.LogWarning("Insert operation failed");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
var client = _clientStorage.GetElement(new() { Id = order.ClientId });
|
||||||
|
if (client == null)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("Client not found");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
SendMail(client.Email, $"Новый заказ создан. Номер заказа - {order.Id}", $"Заказ №{order.Id} от {order.DateCreate} на сумму {order.Sum:C2} принят.");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -104,11 +117,19 @@ namespace SecureShopBusinessLogic.BusinessLogics
|
|||||||
model.DateImplement = viewModel.DateImplement;
|
model.DateImplement = viewModel.DateImplement;
|
||||||
}
|
}
|
||||||
CheckModel(model);
|
CheckModel(model);
|
||||||
if (_orderStorage.Update(model) == null)
|
var order = _orderStorage.Update(model);
|
||||||
|
if (order == null)
|
||||||
{
|
{
|
||||||
_logger.LogWarning("Change status operation failed");
|
_logger.LogWarning("Change status operation failed");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
var client = _clientStorage.GetElement(new() { Id = order.ClientId });
|
||||||
|
if (client == null)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("Client not found");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
SendMail(client.Email, $"Заказ №{order.Id}", $"Заказ №{order.Id} изменил статус на {order.Status}.");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -128,6 +149,15 @@ namespace SecureShopBusinessLogic.BusinessLogics
|
|||||||
_logger.LogInformation("ReadElement find. Id:{Id}", element.Id);
|
_logger.LogInformation("ReadElement find. Id:{Id}", element.Id);
|
||||||
return element;
|
return element;
|
||||||
}
|
}
|
||||||
|
public void SendMail(string email, string title, string body)
|
||||||
|
{
|
||||||
|
_abstractMailWorker.MailSendAsync(new()
|
||||||
|
{
|
||||||
|
MailAddress = email,
|
||||||
|
Subject = title,
|
||||||
|
Text = body
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
public bool TakeOrderInWork(OrderBindingModel model)
|
public bool TakeOrderInWork(OrderBindingModel model)
|
||||||
{
|
{
|
||||||
|
@ -0,0 +1,95 @@
|
|||||||
|
using SecureShopContracts.BindingModels;
|
||||||
|
using SecureShopContracts.BusinessLogicsContracts;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
|
||||||
|
namespace SecureShopBusinessLogic.MailWorker
|
||||||
|
{
|
||||||
|
public abstract class AbstractMailWorker
|
||||||
|
{
|
||||||
|
protected string _mailLogin = string.Empty;
|
||||||
|
|
||||||
|
protected string _mailPassword = string.Empty;
|
||||||
|
|
||||||
|
protected string _smtpClientHost = string.Empty;
|
||||||
|
|
||||||
|
protected int _smtpClientPort;
|
||||||
|
|
||||||
|
protected string _popHost = string.Empty;
|
||||||
|
|
||||||
|
protected int _popPort;
|
||||||
|
|
||||||
|
private readonly IMessageInfoLogic _messageInfoLogic;
|
||||||
|
|
||||||
|
private readonly ILogger _logger;
|
||||||
|
|
||||||
|
private readonly IClientLogic _clientLogic;
|
||||||
|
public AbstractMailWorker(ILogger<AbstractMailWorker> logger, IMessageInfoLogic messageInfoLogic, IClientLogic clientLogic)
|
||||||
|
{
|
||||||
|
_logger = logger;
|
||||||
|
_messageInfoLogic = messageInfoLogic;
|
||||||
|
_clientLogic = clientLogic;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void MailConfig(MailConfigBindingModel config)
|
||||||
|
{
|
||||||
|
_mailLogin = config.MailLogin;
|
||||||
|
_mailPassword = config.MailPassword;
|
||||||
|
_smtpClientHost = config.SmtpClientHost;
|
||||||
|
_smtpClientPort = config.SmtpClientPort;
|
||||||
|
_popHost = config.PopHost;
|
||||||
|
_popPort = config.PopPort;
|
||||||
|
_logger.LogDebug("Config: {login}, {password}, {clientHost}, {clientPOrt}, {popHost}, {popPort}", _mailLogin, _mailPassword, _smtpClientHost, _smtpClientPort, _popHost, _popPort);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async void MailSendAsync(MailSendInfoBindingModel info)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(_mailLogin) || string.IsNullOrEmpty(_mailPassword))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (string.IsNullOrEmpty(_smtpClientHost) || _smtpClientPort == 0)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (string.IsNullOrEmpty(info.MailAddress) || string.IsNullOrEmpty(info.Subject) || string.IsNullOrEmpty(info.Text))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
_logger.LogDebug("Send Mail: {To}, {Subject}", info.MailAddress, info.Subject);
|
||||||
|
await SendMailAsync(info);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async void MailCheck()
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(_mailLogin) || string.IsNullOrEmpty(_mailPassword))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (string.IsNullOrEmpty(_popHost) || _popPort == 0)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_messageInfoLogic == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var list = await ReceiveMailAsync();
|
||||||
|
_logger.LogDebug("Check Mail: {Count} new mails", list.Count);
|
||||||
|
foreach (var mail in list)
|
||||||
|
{
|
||||||
|
mail.ClientId = _clientLogic.ReadElement(new() { Email = mail.SenderName })?.Id;
|
||||||
|
_messageInfoLogic.Create(mail);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected abstract Task SendMailAsync(MailSendInfoBindingModel info);
|
||||||
|
|
||||||
|
protected abstract Task<List<MessageInfoBindingModel>> ReceiveMailAsync();
|
||||||
|
}
|
||||||
|
}
|
78
Secure/SecureShopBusinessLogic/MailWorker/MailKitWorker.cs
Normal file
78
Secure/SecureShopBusinessLogic/MailWorker/MailKitWorker.cs
Normal file
@ -0,0 +1,78 @@
|
|||||||
|
using SecureShopContracts.BindingModels;
|
||||||
|
using SecureShopContracts.BusinessLogicsContracts;
|
||||||
|
using MailKit.Net.Pop3;
|
||||||
|
using MailKit.Security;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using System.Net;
|
||||||
|
using System.Net.Mail;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace SecureShopBusinessLogic.MailWorker
|
||||||
|
{
|
||||||
|
public class MailKitWorker : AbstractMailWorker
|
||||||
|
{
|
||||||
|
public MailKitWorker(ILogger<MailKitWorker> logger, IMessageInfoLogic messageInfoLogic, IClientLogic clientLogic) : base(logger, messageInfoLogic, clientLogic) { }
|
||||||
|
|
||||||
|
protected override async Task SendMailAsync(MailSendInfoBindingModel info)
|
||||||
|
{
|
||||||
|
using var objMailMessage = new MailMessage();
|
||||||
|
using var objSmtpClient = new SmtpClient(_smtpClientHost, _smtpClientPort);
|
||||||
|
try
|
||||||
|
{
|
||||||
|
objMailMessage.From = new MailAddress(_mailLogin);
|
||||||
|
objMailMessage.To.Add(new MailAddress(info.MailAddress));
|
||||||
|
objMailMessage.Subject = info.Subject;
|
||||||
|
objMailMessage.Body = info.Text;
|
||||||
|
objMailMessage.SubjectEncoding = Encoding.UTF8;
|
||||||
|
objMailMessage.BodyEncoding = Encoding.UTF8;
|
||||||
|
|
||||||
|
objSmtpClient.UseDefaultCredentials = false;
|
||||||
|
objSmtpClient.EnableSsl = true;
|
||||||
|
objSmtpClient.DeliveryMethod = SmtpDeliveryMethod.Network;
|
||||||
|
objSmtpClient.Credentials = new NetworkCredential(_mailLogin, _mailPassword);
|
||||||
|
|
||||||
|
await Task.Run(() => objSmtpClient.Send(objMailMessage));
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override async Task<List<MessageInfoBindingModel>> ReceiveMailAsync()
|
||||||
|
{
|
||||||
|
var list = new List<MessageInfoBindingModel>();
|
||||||
|
using var client = new Pop3Client();
|
||||||
|
await Task.Run(() =>
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
client.Connect(_popHost, _popPort, SecureSocketOptions.SslOnConnect);
|
||||||
|
client.Authenticate(_mailLogin, _mailPassword);
|
||||||
|
for (int i = 0; i < client.Count; i++)
|
||||||
|
{
|
||||||
|
var message = client.GetMessage(i);
|
||||||
|
foreach (var mail in message.From.Mailboxes)
|
||||||
|
{
|
||||||
|
list.Add(new MessageInfoBindingModel
|
||||||
|
{
|
||||||
|
DateDelivery = message.Date.DateTime,
|
||||||
|
MessageId = message.MessageId,
|
||||||
|
SenderName = mail.Address,
|
||||||
|
Subject = message.Subject,
|
||||||
|
Body = message.TextBody
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (AuthenticationException)
|
||||||
|
{ }
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
client.Disconnect(true);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -8,7 +8,8 @@
|
|||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="DocumentFormat.OpenXml" Version="2.20.0" />
|
<PackageReference Include="DocumentFormat.OpenXml" Version="2.20.0" />
|
||||||
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="7.0.0" />
|
<PackageReference Include="MailKit" Version="4.0.0" />
|
||||||
|
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="7.0.1" />
|
||||||
<PackageReference Include="PdfSharp.MigraDoc.Standard" Version="1.51.15" />
|
<PackageReference Include="PdfSharp.MigraDoc.Standard" Version="1.51.15" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
@ -143,5 +143,14 @@ namespace SecureShopClientApp.Controllers
|
|||||||
var iceCr = APIClient.GetRequest<SecureViewModel>($"api/main/getsecure?secureId={secure}");
|
var iceCr = APIClient.GetRequest<SecureViewModel>($"api/main/getsecure?secureId={secure}");
|
||||||
return count * (iceCr?.Price ?? 1);
|
return count * (iceCr?.Price ?? 1);
|
||||||
}
|
}
|
||||||
|
[HttpGet]
|
||||||
|
public IActionResult Mails()
|
||||||
|
{
|
||||||
|
if (APIClient.Client == null)
|
||||||
|
{
|
||||||
|
return Redirect("~/Home/Enter");
|
||||||
|
}
|
||||||
|
return View(APIClient.GetRequest<List<MessageInfoViewModel>>($"api/client/getmessages?clientId={APIClient.Client.Id}"));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
54
Secure/SecureShopClientApp/Views/Home/Mails.cshtml
Normal file
54
Secure/SecureShopClientApp/Views/Home/Mails.cshtml
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
@using SecureShopContracts.ViewModels
|
||||||
|
|
||||||
|
@model List<MessageInfoViewModel>
|
||||||
|
|
||||||
|
@{
|
||||||
|
ViewData["Title"] = "Mails";
|
||||||
|
}
|
||||||
|
|
||||||
|
<div class="text-center">
|
||||||
|
<h1 class="display-4">Заказы</h1>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="text-center">
|
||||||
|
@{
|
||||||
|
if (Model == null)
|
||||||
|
{
|
||||||
|
<h3 class="display-4">Авторизируйтесь</h3>
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
<table class="table">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>
|
||||||
|
Дата письма
|
||||||
|
</th>
|
||||||
|
<th>
|
||||||
|
Заголовок
|
||||||
|
</th>
|
||||||
|
<th>
|
||||||
|
Текст
|
||||||
|
</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
@foreach (var item in Model)
|
||||||
|
{
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
@Html.DisplayFor(modelItem => item.DateDelivery)
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
@Html.DisplayFor(modelItem => item.Subject)
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
@Html.DisplayFor(modelItem => item.Body)
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
}
|
||||||
|
</div>
|
@ -25,6 +25,9 @@
|
|||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Privacy">Личные данные</a>
|
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Privacy">Личные данные</a>
|
||||||
</li>
|
</li>
|
||||||
|
<li class="nav-item">
|
||||||
|
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Mails">Письма</a>
|
||||||
|
</li>
|
||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Enter">Вход</a>
|
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Enter">Вход</a>
|
||||||
</li>
|
</li>
|
||||||
|
@ -0,0 +1,17 @@
|
|||||||
|
namespace SecureShopContracts.BindingModels
|
||||||
|
{
|
||||||
|
public class MailConfigBindingModel
|
||||||
|
{
|
||||||
|
public string MailLogin { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
public string MailPassword { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
public string SmtpClientHost { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
public int SmtpClientPort { get; set; }
|
||||||
|
|
||||||
|
public string PopHost { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
public int PopPort { get; set; }
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,11 @@
|
|||||||
|
namespace SecureShopContracts.BindingModels
|
||||||
|
{
|
||||||
|
public class MailSendInfoBindingModel
|
||||||
|
{
|
||||||
|
public string MailAddress { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
public string Subject { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
public string Text { get; set; } = string.Empty;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,19 @@
|
|||||||
|
using SecureShopDataModels.Models;
|
||||||
|
|
||||||
|
namespace SecureShopContracts.BindingModels
|
||||||
|
{
|
||||||
|
public class MessageInfoBindingModel : IMessageInfoModel
|
||||||
|
{
|
||||||
|
public string MessageId { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
public int? ClientId { get; set; }
|
||||||
|
|
||||||
|
public string SenderName { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
public string Subject { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
public string Body { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
public DateTime DateDelivery { get; set; }
|
||||||
|
}
|
||||||
|
}
|
44
Secure/SecureShopContracts/BindingModels/MessageInfoLogic.cs
Normal file
44
Secure/SecureShopContracts/BindingModels/MessageInfoLogic.cs
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using SecureShopContracts.BindingModels;
|
||||||
|
using SecureShopContracts.BusinessLogicsContracts;
|
||||||
|
using SecureShopContracts.SearchModels;
|
||||||
|
using SecureShopContracts.StoragesContracts;
|
||||||
|
using SecureShopContracts.ViewModels;
|
||||||
|
|
||||||
|
namespace SecureShopBusinessLogic.BusinessLogics
|
||||||
|
{
|
||||||
|
public class MessageInfoLogic : IMessageInfoLogic
|
||||||
|
{
|
||||||
|
private readonly ILogger _logger;
|
||||||
|
private readonly IMessageInfoStorage _messageInfoStorage;
|
||||||
|
|
||||||
|
public MessageInfoLogic(ILogger<MessageInfoLogic> logger, IMessageInfoStorage messageInfoStorage)
|
||||||
|
{
|
||||||
|
_logger = logger;
|
||||||
|
_messageInfoStorage = messageInfoStorage;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Create(MessageInfoBindingModel model)
|
||||||
|
{
|
||||||
|
if (_messageInfoStorage.Insert(model) == null)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("Insert operation failed");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<MessageInfoViewModel>? ReadList(MessageInfoSearchModel? model)
|
||||||
|
{
|
||||||
|
_logger.LogInformation("ReadList. MessageId:{MessageId}", model?.MessageId);
|
||||||
|
var list = model == null ? _messageInfoStorage.GetFullList() : _messageInfoStorage.GetFilteredList(model);
|
||||||
|
if (list == null)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("ReadList return null list");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
_logger.LogInformation("ReadList. Count:{Count}", list.Count);
|
||||||
|
return list.OrderByDescending(x => x.DateDelivery).ToList();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,13 @@
|
|||||||
|
using SecureShopContracts.BindingModels;
|
||||||
|
using SecureShopContracts.SearchModels;
|
||||||
|
using SecureShopContracts.ViewModels;
|
||||||
|
|
||||||
|
namespace SecureShopContracts.BusinessLogicsContracts
|
||||||
|
{
|
||||||
|
public interface IMessageInfoLogic
|
||||||
|
{
|
||||||
|
List<MessageInfoViewModel>? ReadList(MessageInfoSearchModel? model);
|
||||||
|
|
||||||
|
bool Create(MessageInfoBindingModel model);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,9 @@
|
|||||||
|
namespace SecureShopContracts.SearchModels
|
||||||
|
{
|
||||||
|
public class MessageInfoSearchModel
|
||||||
|
{
|
||||||
|
public int? ClientId { get; set; }
|
||||||
|
|
||||||
|
public string? MessageId { get; set; }
|
||||||
|
}
|
||||||
|
}
|
@ -6,6 +6,10 @@
|
|||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="7.0.1" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\SecureShopDataModels\SecureShopDataModels.csproj" />
|
<ProjectReference Include="..\SecureShopDataModels\SecureShopDataModels.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
@ -0,0 +1,17 @@
|
|||||||
|
using SecureShopContracts.BindingModels;
|
||||||
|
using SecureShopContracts.SearchModels;
|
||||||
|
using SecureShopContracts.ViewModels;
|
||||||
|
|
||||||
|
namespace SecureShopContracts.StoragesContracts
|
||||||
|
{
|
||||||
|
public interface IMessageInfoStorage
|
||||||
|
{
|
||||||
|
List<MessageInfoViewModel> GetFullList();
|
||||||
|
|
||||||
|
List<MessageInfoViewModel> GetFilteredList(MessageInfoSearchModel model);
|
||||||
|
|
||||||
|
MessageInfoViewModel? GetElement(MessageInfoSearchModel model);
|
||||||
|
|
||||||
|
MessageInfoViewModel? Insert(MessageInfoBindingModel model);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,24 @@
|
|||||||
|
using SecureShopDataModels.Models;
|
||||||
|
using System.ComponentModel;
|
||||||
|
|
||||||
|
namespace SecureShopContracts.ViewModels
|
||||||
|
{
|
||||||
|
public class MessageInfoViewModel : IMessageInfoModel
|
||||||
|
{
|
||||||
|
public string MessageId { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
public int? ClientId { get; set; }
|
||||||
|
|
||||||
|
[DisplayName("Отправитель")]
|
||||||
|
public string SenderName { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
[DisplayName("Дата письма")]
|
||||||
|
public DateTime DateDelivery { get; set; }
|
||||||
|
|
||||||
|
[DisplayName("Заголовок")]
|
||||||
|
public string Subject { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
[DisplayName("Текст")]
|
||||||
|
public string Body { get; set; } = string.Empty;
|
||||||
|
}
|
||||||
|
}
|
17
Secure/SecureShopDataModels/Models/IMessageInfoModel.cs
Normal file
17
Secure/SecureShopDataModels/Models/IMessageInfoModel.cs
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
namespace SecureShopDataModels.Models
|
||||||
|
{
|
||||||
|
public interface IMessageInfoModel
|
||||||
|
{
|
||||||
|
string MessageId { get; }
|
||||||
|
|
||||||
|
int? ClientId { get; }
|
||||||
|
|
||||||
|
string SenderName { get; }
|
||||||
|
|
||||||
|
DateTime DateDelivery { get; }
|
||||||
|
|
||||||
|
string Subject { get; }
|
||||||
|
|
||||||
|
string Body { get; }
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,49 @@
|
|||||||
|
using SecureShopContracts.BindingModels;
|
||||||
|
using SecureShopContracts.SearchModels;
|
||||||
|
using SecureShopContracts.StoragesContracts;
|
||||||
|
using SecureShopContracts.ViewModels;
|
||||||
|
using SecureShopDatabaseImplement.Models;
|
||||||
|
|
||||||
|
namespace SecureShopDatabaseImplement.Implements
|
||||||
|
{
|
||||||
|
public class MessageInfoStorage : IMessageInfoStorage
|
||||||
|
{
|
||||||
|
public MessageInfoViewModel? GetElement(MessageInfoSearchModel model)
|
||||||
|
{
|
||||||
|
using var context = new SecureShopDatabase();
|
||||||
|
return context.MessageInfos
|
||||||
|
.FirstOrDefault(x => !string.IsNullOrEmpty(x.MessageId) && x.MessageId == model.MessageId)
|
||||||
|
?.GetViewModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<MessageInfoViewModel> GetFilteredList(MessageInfoSearchModel model)
|
||||||
|
{
|
||||||
|
using var context = new SecureShopDatabase();
|
||||||
|
return context.MessageInfos
|
||||||
|
.Where(x => x.ClientId.HasValue && x.ClientId == model.ClientId)
|
||||||
|
.Select(x => x.GetViewModel)
|
||||||
|
.ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<MessageInfoViewModel> GetFullList()
|
||||||
|
{
|
||||||
|
using var context = new SecureShopDatabase();
|
||||||
|
return context.MessageInfos
|
||||||
|
.Select(x => x.GetViewModel)
|
||||||
|
.ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
public MessageInfoViewModel? Insert(MessageInfoBindingModel model)
|
||||||
|
{
|
||||||
|
using var context = new SecureShopDatabase();
|
||||||
|
var newMessage = MessageInfo.Create(model);
|
||||||
|
if (newMessage == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
context.MessageInfos.Add(newMessage);
|
||||||
|
context.SaveChanges();
|
||||||
|
return newMessage.GetViewModel;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -18,7 +18,8 @@ namespace SecureShopDatabaseImplement.Models
|
|||||||
|
|
||||||
[ForeignKey("ClientId")]
|
[ForeignKey("ClientId")]
|
||||||
public virtual List<Order> Orders { get; set; } = new();
|
public virtual List<Order> Orders { get; set; } = new();
|
||||||
|
[ForeignKey("ClientId")]
|
||||||
|
public virtual List<MessageInfo> MessageInfos { get; set; } = new();
|
||||||
public static Client? Create(ClientBindingModel model)
|
public static Client? Create(ClientBindingModel model)
|
||||||
{
|
{
|
||||||
if (model == null)
|
if (model == null)
|
||||||
|
52
Secure/SecureShopDatabaseImplement/Models/MessageInfo.cs
Normal file
52
Secure/SecureShopDatabaseImplement/Models/MessageInfo.cs
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
using SecureShopContracts.BindingModels;
|
||||||
|
using SecureShopContracts.ViewModels;
|
||||||
|
using SecureShopDataModels.Models;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
|
||||||
|
namespace SecureShopDatabaseImplement.Models
|
||||||
|
{
|
||||||
|
public class MessageInfo : IMessageInfoModel
|
||||||
|
{
|
||||||
|
[Key]
|
||||||
|
public string MessageId { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
public int? ClientId { get; set; }
|
||||||
|
[Required]
|
||||||
|
public string SenderName { get; set; } = string.Empty;
|
||||||
|
[Required]
|
||||||
|
public DateTime DateDelivery { get; set; } = DateTime.Now;
|
||||||
|
[Required]
|
||||||
|
public string Subject { get; set; } = string.Empty;
|
||||||
|
[Required]
|
||||||
|
public string Body { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
public virtual Client? Client { get; set; }
|
||||||
|
|
||||||
|
public static MessageInfo? Create(MessageInfoBindingModel? model)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return new MessageInfo()
|
||||||
|
{
|
||||||
|
MessageId = model.MessageId,
|
||||||
|
ClientId = model.ClientId,
|
||||||
|
SenderName = model.SenderName,
|
||||||
|
DateDelivery = model.DateDelivery,
|
||||||
|
Subject = model.Subject,
|
||||||
|
Body = model.Body
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public MessageInfoViewModel GetViewModel => new()
|
||||||
|
{
|
||||||
|
MessageId = MessageId,
|
||||||
|
ClientId = ClientId,
|
||||||
|
SenderName = SenderName,
|
||||||
|
DateDelivery = DateDelivery,
|
||||||
|
Subject = Subject,
|
||||||
|
Body = Body
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
@ -25,5 +25,7 @@ namespace SecureShopDatabaseImplement
|
|||||||
public virtual DbSet<Client> Clients { set; get; }
|
public virtual DbSet<Client> Clients { set; get; }
|
||||||
|
|
||||||
public virtual DbSet<Implementer> Implementers { set; get; }
|
public virtual DbSet<Implementer> Implementers { set; get; }
|
||||||
|
|
||||||
|
public virtual DbSet<MessageInfo> MessageInfos { set; get; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,9 +7,9 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.5" />
|
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.7" />
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="7.0.5" />
|
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="7.0.7" />
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="7.0.5">
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="7.0.7">
|
||||||
<PrivateAssets>all</PrivateAssets>
|
<PrivateAssets>all</PrivateAssets>
|
||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
|
@ -11,9 +11,11 @@ namespace SecureShopFileImplement
|
|||||||
private readonly string SecureFileName = "Secure.xml";
|
private readonly string SecureFileName = "Secure.xml";
|
||||||
public List<Facilities> Facilitiess { get; private set; }
|
public List<Facilities> Facilitiess { get; private set; }
|
||||||
private readonly string ClientFileName = "Client.xml";
|
private readonly string ClientFileName = "Client.xml";
|
||||||
|
private readonly string MessageInfoFileName = "MessageInfo.xml";
|
||||||
public List<Order> Orders { get; private set; }
|
public List<Order> Orders { get; private set; }
|
||||||
public List<Secure> Secures { get; private set; }
|
public List<Secure> Secures { get; private set; }
|
||||||
public List<Client> Clients { get; private set; }
|
public List<Client> Clients { get; private set; }
|
||||||
|
public List<MessageInfo> MessageInfos { get; private set; }
|
||||||
|
|
||||||
public static DataFileSingleton GetInstance()
|
public static DataFileSingleton GetInstance()
|
||||||
{
|
{
|
||||||
@ -28,12 +30,15 @@ namespace SecureShopFileImplement
|
|||||||
public void SaveSecures() => SaveData(Secures, SecureFileName, "Secures", x => x.GetXElement);
|
public void SaveSecures() => SaveData(Secures, SecureFileName, "Secures", x => x.GetXElement);
|
||||||
public void SaveOrders() => SaveData(Orders, OrderFileName, "Orders", x => x.GetXElement);
|
public void SaveOrders() => SaveData(Orders, OrderFileName, "Orders", x => x.GetXElement);
|
||||||
public void SaveClients() => SaveData(Clients, ClientFileName, "Clients", x => x.GetXElement);
|
public void SaveClients() => SaveData(Clients, ClientFileName, "Clients", x => x.GetXElement);
|
||||||
|
public void SaveMessageInfos() => SaveData(MessageInfos, MessageInfoFileName, "MessageInfos", x => x.GetXElement);
|
||||||
|
|
||||||
private DataFileSingleton()
|
private DataFileSingleton()
|
||||||
{
|
{
|
||||||
Facilitiess = LoadData(FacilitiesFileName, "Facilities", x => Facilities.Create(x)!)!;
|
Facilitiess = LoadData(FacilitiesFileName, "Facilities", x => Facilities.Create(x)!)!;
|
||||||
Secures = LoadData(SecureFileName, "Secure", x => Secure.Create(x)!)!;
|
Secures = LoadData(SecureFileName, "Secure", x => Secure.Create(x)!)!;
|
||||||
Orders = LoadData(OrderFileName, "Order", x => Order.Create(x)!)!;
|
Orders = LoadData(OrderFileName, "Order", x => Order.Create(x)!)!;
|
||||||
Clients = LoadData(ClientFileName, "Client", x => Client.Create(x)!)!;
|
Clients = LoadData(ClientFileName, "Client", x => Client.Create(x)!)!;
|
||||||
|
MessageInfos = LoadData(MessageInfoFileName, "MessageInfo", x => MessageInfo.Create(x)!)!;
|
||||||
}
|
}
|
||||||
private static List<T>? LoadData<T>(string filename, string xmlNodeName, Func<XElement, T> selectFunction)
|
private static List<T>? LoadData<T>(string filename, string xmlNodeName, Func<XElement, T> selectFunction)
|
||||||
{
|
{
|
||||||
|
@ -0,0 +1,57 @@
|
|||||||
|
using SecureShopContracts.BindingModels;
|
||||||
|
using SecureShopContracts.SearchModels;
|
||||||
|
using SecureShopContracts.StoragesContracts;
|
||||||
|
using SecureShopContracts.ViewModels;
|
||||||
|
using SecureShopFileImplement.Models;
|
||||||
|
|
||||||
|
namespace SecureShopFileImplement.Implements
|
||||||
|
{
|
||||||
|
public class MessageInfoStorage : IMessageInfoStorage
|
||||||
|
{
|
||||||
|
private readonly DataFileSingleton _source;
|
||||||
|
|
||||||
|
public MessageInfoStorage()
|
||||||
|
{
|
||||||
|
_source = DataFileSingleton.GetInstance();
|
||||||
|
}
|
||||||
|
public MessageInfoViewModel? GetElement(MessageInfoSearchModel model)
|
||||||
|
{
|
||||||
|
if (!string.IsNullOrEmpty(model.MessageId))
|
||||||
|
{
|
||||||
|
return _source.MessageInfos
|
||||||
|
.FirstOrDefault(x => x.MessageId == model.MessageId)
|
||||||
|
?.GetViewModel;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<MessageInfoViewModel> GetFilteredList(MessageInfoSearchModel model)
|
||||||
|
{
|
||||||
|
if (model.ClientId.HasValue)
|
||||||
|
{
|
||||||
|
return _source.MessageInfos
|
||||||
|
.Where(x => x.ClientId == model.ClientId)
|
||||||
|
.Select(x => x.GetViewModel)
|
||||||
|
.ToList();
|
||||||
|
}
|
||||||
|
return new();
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<MessageInfoViewModel> GetFullList()
|
||||||
|
{
|
||||||
|
return _source.MessageInfos.Select(x => x.GetViewModel).ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
public MessageInfoViewModel? Insert(MessageInfoBindingModel model)
|
||||||
|
{
|
||||||
|
var newMessage = MessageInfo.Create(model);
|
||||||
|
if (newMessage == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
_source.MessageInfos.Add(newMessage);
|
||||||
|
_source.SaveClients();
|
||||||
|
return newMessage.GetViewModel;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -26,6 +26,10 @@ namespace SecureShopFileImplement.Implements
|
|||||||
{
|
{
|
||||||
return _source.Orders.Where(x => x.ClientId == model.ClientId).Select(x => GetViewModel(x)).ToList();
|
return _source.Orders.Where(x => x.ClientId == model.ClientId).Select(x => GetViewModel(x)).ToList();
|
||||||
}
|
}
|
||||||
|
if (model.Status.HasValue)
|
||||||
|
{
|
||||||
|
return _source.Orders.Where(x => x.Status == model.Status).Select(x => GetViewModel(x)).ToList();
|
||||||
|
}
|
||||||
if (!model.Id.HasValue && model.DateFrom.HasValue && model.DateTo.HasValue)
|
if (!model.Id.HasValue && model.DateFrom.HasValue && model.DateTo.HasValue)
|
||||||
{
|
{
|
||||||
return _source.Orders.Where(x => x.DateCreate >= model.DateFrom && x.DateCreate <= model.DateTo)
|
return _source.Orders.Where(x => x.DateCreate >= model.DateFrom && x.DateCreate <= model.DateTo)
|
||||||
@ -36,6 +40,14 @@ namespace SecureShopFileImplement.Implements
|
|||||||
}
|
}
|
||||||
public OrderViewModel? GetElement(OrderSearchModel model)
|
public OrderViewModel? GetElement(OrderSearchModel model)
|
||||||
{
|
{
|
||||||
|
if (model.ImplementerId.HasValue && model.Status.HasValue)
|
||||||
|
{
|
||||||
|
return _source.Orders.FirstOrDefault(x => x.ImplementerId == model.ImplementerId && x.Status == model.Status)?.GetViewModel;
|
||||||
|
}
|
||||||
|
if (model.ImplementerId.HasValue)
|
||||||
|
{
|
||||||
|
return _source.Orders.FirstOrDefault(x => x.ImplementerId == model.ImplementerId)?.GetViewModel;
|
||||||
|
}
|
||||||
if (!model.Id.HasValue)
|
if (!model.Id.HasValue)
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
|
67
Secure/SecureShopFileImplement/Models/MessageInfo.cs
Normal file
67
Secure/SecureShopFileImplement/Models/MessageInfo.cs
Normal file
@ -0,0 +1,67 @@
|
|||||||
|
using SecureShopContracts.BindingModels;
|
||||||
|
using SecureShopContracts.ViewModels;
|
||||||
|
using SecureShopDataModels.Models;
|
||||||
|
using System.Xml.Linq;
|
||||||
|
|
||||||
|
namespace SecureShopFileImplement.Models
|
||||||
|
{
|
||||||
|
public class MessageInfo : IMessageInfoModel
|
||||||
|
{
|
||||||
|
public string MessageId { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
public int? ClientId { get; set; }
|
||||||
|
|
||||||
|
public string SenderName { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
public DateTime DateDelivery { get; set; } = DateTime.Now;
|
||||||
|
|
||||||
|
public string Subject { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
public string Body { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
public static MessageInfo? Create(MessageInfoBindingModel model)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return new MessageInfo()
|
||||||
|
{
|
||||||
|
MessageId = model.MessageId,
|
||||||
|
ClientId = model.ClientId,
|
||||||
|
SenderName = model.SenderName,
|
||||||
|
DateDelivery = model.DateDelivery,
|
||||||
|
Subject = model.Subject,
|
||||||
|
Body = model.Body
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public static MessageInfo? Create(XElement element)
|
||||||
|
{
|
||||||
|
if (element == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return new MessageInfo()
|
||||||
|
{
|
||||||
|
MessageId = element.Element("MessageId")!.Value,
|
||||||
|
ClientId = Convert.ToInt32(element.Element("ClientId")!.Value),
|
||||||
|
SenderName = element.Element("MessageId")!.Value,
|
||||||
|
DateDelivery = DateTime.ParseExact(element.Element("DateDelivery")!.Value, "G", null),
|
||||||
|
Subject = element.Element("MessageId")!.Value,
|
||||||
|
Body = element.Element("MessageId")!.Value
|
||||||
|
};
|
||||||
|
}
|
||||||
|
public MessageInfoViewModel GetViewModel => new()
|
||||||
|
{
|
||||||
|
MessageId = MessageId,
|
||||||
|
ClientId = ClientId,
|
||||||
|
SenderName = SenderName,
|
||||||
|
DateDelivery = DateDelivery,
|
||||||
|
Subject = Subject,
|
||||||
|
Body = Body
|
||||||
|
};
|
||||||
|
|
||||||
|
public XElement GetXElement => new("MessageInfo", new XAttribute("MessageId", MessageId), new XElement("ClientId", ClientId), new XElement("SenderName", SenderName), new XElement("DateDelivery", DateDelivery), new XElement("Subject", Subject), new XElement("Body", Body));
|
||||||
|
}
|
||||||
|
}
|
@ -10,6 +10,7 @@ namespace SecureShopListImplement
|
|||||||
public List<Secure> Secures { get; set; }
|
public List<Secure> Secures { get; set; }
|
||||||
public List<Client> Clients { get; set; }
|
public List<Client> Clients { get; set; }
|
||||||
public List<Implementer> Implementers { get; set; }
|
public List<Implementer> Implementers { get; set; }
|
||||||
|
public List<MessageInfo> MessageInfos { get; set; }
|
||||||
|
|
||||||
private DataListSingleton()
|
private DataListSingleton()
|
||||||
{
|
{
|
||||||
@ -17,6 +18,7 @@ namespace SecureShopListImplement
|
|||||||
Orders = new List<Order>();
|
Orders = new List<Order>();
|
||||||
Secures = new List<Secure>();
|
Secures = new List<Secure>();
|
||||||
Clients = new List<Client>();
|
Clients = new List<Client>();
|
||||||
|
MessageInfos = new();
|
||||||
Implementers = new();
|
Implementers = new();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -0,0 +1,65 @@
|
|||||||
|
using SecureShopContracts.BindingModels;
|
||||||
|
using SecureShopContracts.SearchModels;
|
||||||
|
using SecureShopContracts.StoragesContracts;
|
||||||
|
using SecureShopContracts.ViewModels;
|
||||||
|
using SecureShopListImplement.Models;
|
||||||
|
|
||||||
|
namespace SecureShopListImplement.Implements
|
||||||
|
{
|
||||||
|
public class MessageInfoStorage : IMessageInfoStorage
|
||||||
|
{
|
||||||
|
private readonly DataListSingleton _source;
|
||||||
|
|
||||||
|
public MessageInfoStorage()
|
||||||
|
{
|
||||||
|
_source = DataListSingleton.GetInstance();
|
||||||
|
}
|
||||||
|
public MessageInfoViewModel? GetElement(MessageInfoSearchModel model)
|
||||||
|
{
|
||||||
|
foreach (var elem in _source.MessageInfos)
|
||||||
|
{
|
||||||
|
if (!string.IsNullOrEmpty(model.MessageId) && model.MessageId == elem.MessageId)
|
||||||
|
return elem.GetViewModel;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<MessageInfoViewModel> GetFilteredList(MessageInfoSearchModel model)
|
||||||
|
{
|
||||||
|
var result = new List<MessageInfoViewModel>();
|
||||||
|
if (model.ClientId.HasValue)
|
||||||
|
{
|
||||||
|
foreach (var message in _source.MessageInfos)
|
||||||
|
{
|
||||||
|
if (message.ClientId.HasValue && message.ClientId == model.ClientId)
|
||||||
|
{
|
||||||
|
result.Add(message.GetViewModel);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<MessageInfoViewModel> GetFullList()
|
||||||
|
{
|
||||||
|
var result = new List<MessageInfoViewModel>();
|
||||||
|
foreach (var message in _source.MessageInfos)
|
||||||
|
{
|
||||||
|
result.Add(message.GetViewModel);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public MessageInfoViewModel? Insert(MessageInfoBindingModel model)
|
||||||
|
{
|
||||||
|
|
||||||
|
var newMessage = MessageInfo.Create(model);
|
||||||
|
if (newMessage == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
_source.MessageInfos.Add(newMessage);
|
||||||
|
return newMessage.GetViewModel;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -39,6 +39,17 @@ namespace SecureShopListImplement.Implements
|
|||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
if (model.Status.HasValue)
|
||||||
|
{
|
||||||
|
foreach (var order in _source.Orders)
|
||||||
|
{
|
||||||
|
if (order.Status == model.Status)
|
||||||
|
{
|
||||||
|
result.Add(GetViewModel(order));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
if (!model.Id.HasValue && model.DateFrom.HasValue && model.DateTo.HasValue)
|
if (!model.Id.HasValue && model.DateFrom.HasValue && model.DateTo.HasValue)
|
||||||
{
|
{
|
||||||
foreach (var order in _source.Orders)
|
foreach (var order in _source.Orders)
|
||||||
|
47
Secure/SecureShopListImplement/Models/MessageInfo.cs
Normal file
47
Secure/SecureShopListImplement/Models/MessageInfo.cs
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
using SecureShopContracts.BindingModels;
|
||||||
|
using SecureShopContracts.ViewModels;
|
||||||
|
using SecureShopDataModels.Models;
|
||||||
|
|
||||||
|
namespace SecureShopListImplement.Models
|
||||||
|
{
|
||||||
|
public class MessageInfo : IMessageInfoModel
|
||||||
|
{
|
||||||
|
public string MessageId { get; private set; } = string.Empty;
|
||||||
|
|
||||||
|
public int? ClientId { get; private set; }
|
||||||
|
|
||||||
|
public string SenderName { get; private set; } = string.Empty;
|
||||||
|
|
||||||
|
public DateTime DateDelivery { get; private set; } = DateTime.Now;
|
||||||
|
|
||||||
|
public string Subject { get; private set; } = string.Empty;
|
||||||
|
|
||||||
|
public string Body { get; private set; } = string.Empty;
|
||||||
|
public static MessageInfo? Create(MessageInfoBindingModel? model)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return new MessageInfo()
|
||||||
|
{
|
||||||
|
MessageId = model.MessageId,
|
||||||
|
ClientId = model.ClientId,
|
||||||
|
SenderName = model.SenderName,
|
||||||
|
DateDelivery = model.DateDelivery,
|
||||||
|
Subject = model.Subject,
|
||||||
|
Body = model.Body
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public MessageInfoViewModel GetViewModel => new()
|
||||||
|
{
|
||||||
|
MessageId = MessageId,
|
||||||
|
ClientId = ClientId,
|
||||||
|
SenderName = SenderName,
|
||||||
|
DateDelivery = DateDelivery,
|
||||||
|
Subject = Subject,
|
||||||
|
Body = Body
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
@ -14,10 +14,13 @@ namespace SecureShopRestApi.Controllers
|
|||||||
|
|
||||||
private readonly IClientLogic _logic;
|
private readonly IClientLogic _logic;
|
||||||
|
|
||||||
public ClientController(IClientLogic logic, ILogger<ClientController> logger)
|
private readonly IMessageInfoLogic _mailLogic;
|
||||||
|
|
||||||
|
public ClientController(IClientLogic logic, ILogger<ClientController> logger, IMessageInfoLogic mailLogic)
|
||||||
{
|
{
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
_logic = logic;
|
_logic = logic;
|
||||||
|
_mailLogic = mailLogic;
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
@ -38,6 +41,23 @@ namespace SecureShopRestApi.Controllers
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[HttpGet]
|
||||||
|
public List<MessageInfoViewModel>? GetMessages(int clientId)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return _mailLogic.ReadList(new MessageInfoSearchModel
|
||||||
|
{
|
||||||
|
ClientId = clientId
|
||||||
|
});
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка получения писем клиента");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
public void Register(ClientBindingModel model)
|
public void Register(ClientBindingModel model)
|
||||||
{
|
{
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
using SecureShopBusinessLogic.BusinessLogics;
|
using SecureShopBusinessLogic.BusinessLogics;
|
||||||
|
using SecureShopBusinessLogic.MailWorker;
|
||||||
|
using SecureShopContracts.BindingModels;
|
||||||
using SecureShopContracts.BusinessLogicsContracts;
|
using SecureShopContracts.BusinessLogicsContracts;
|
||||||
using SecureShopContracts.StoragesContracts;
|
using SecureShopContracts.StoragesContracts;
|
||||||
using SecureShopDatabaseImplement.Implements;
|
using SecureShopDatabaseImplement.Implements;
|
||||||
@ -13,11 +15,15 @@ builder.Services.AddTransient<IClientStorage, ClientStorage>();
|
|||||||
builder.Services.AddTransient<IOrderStorage, OrderStorage>();
|
builder.Services.AddTransient<IOrderStorage, OrderStorage>();
|
||||||
builder.Services.AddTransient<ISecureStorage, SecureStorage>();
|
builder.Services.AddTransient<ISecureStorage, SecureStorage>();
|
||||||
builder.Services.AddTransient<IImplementerStorage, ImplementerStorage>();
|
builder.Services.AddTransient<IImplementerStorage, ImplementerStorage>();
|
||||||
|
builder.Services.AddTransient<IMessageInfoStorage, MessageInfoStorage>();
|
||||||
|
|
||||||
builder.Services.AddTransient<IOrderLogic, OrderLogic>();
|
builder.Services.AddTransient<IOrderLogic, OrderLogic>();
|
||||||
builder.Services.AddTransient<IClientLogic, ClientLogic>();
|
builder.Services.AddTransient<IClientLogic, ClientLogic>();
|
||||||
builder.Services.AddTransient<ISecureLogic, SecureLogic>();
|
builder.Services.AddTransient<ISecureLogic, SecureLogic>();
|
||||||
builder.Services.AddTransient<IImplementerLogic, ImplementerLogic>();
|
builder.Services.AddTransient<IImplementerLogic, ImplementerLogic>();
|
||||||
|
builder.Services.AddTransient<IMessageInfoLogic, MessageInfoLogic>();
|
||||||
|
|
||||||
|
builder.Services.AddSingleton<AbstractMailWorker, MailKitWorker>();
|
||||||
|
|
||||||
builder.Services.AddControllers();
|
builder.Services.AddControllers();
|
||||||
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
|
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
|
||||||
@ -29,6 +35,17 @@ builder.Services.AddSwaggerGen(c =>
|
|||||||
|
|
||||||
var app = builder.Build();
|
var app = builder.Build();
|
||||||
|
|
||||||
|
var mailSender = app.Services.GetService<AbstractMailWorker>();
|
||||||
|
mailSender?.MailConfig(new MailConfigBindingModel
|
||||||
|
{
|
||||||
|
MailLogin = builder.Configuration?.GetSection("MailLogin")?.Value?.ToString() ?? string.Empty,
|
||||||
|
MailPassword = builder.Configuration?.GetSection("MailPassword")?.Value?.ToString() ?? string.Empty,
|
||||||
|
SmtpClientHost = builder.Configuration?.GetSection("SmtpClientHost")?.Value?.ToString() ?? string.Empty,
|
||||||
|
SmtpClientPort = Convert.ToInt32(builder.Configuration?.GetSection("SmtpClientPort")?.Value?.ToString()),
|
||||||
|
PopHost = builder.Configuration?.GetSection("PopHost")?.Value?.ToString() ?? string.Empty,
|
||||||
|
PopPort = Convert.ToInt32(builder.Configuration?.GetSection("PopPort")?.Value?.ToString())
|
||||||
|
});
|
||||||
|
|
||||||
// Configure the HTTP request pipeline.
|
// Configure the HTTP request pipeline.
|
||||||
if (app.Environment.IsDevelopment())
|
if (app.Environment.IsDevelopment())
|
||||||
{
|
{
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Microsoft.Extensions.Logging.Log4Net.AspNetCore" Version="6.1.0" />
|
<PackageReference Include="Microsoft.Extensions.Logging.Log4Net.AspNetCore" Version="6.1.0" />
|
||||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.2.3" />
|
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.5.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
@ -5,5 +5,11 @@
|
|||||||
"Microsoft.AspNetCore": "Warning"
|
"Microsoft.AspNetCore": "Warning"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"AllowedHosts": "*"
|
"AllowedHosts": "*",
|
||||||
|
"SmtpClientHost": "smtp.gmail.com",
|
||||||
|
"SmtpClientPort": "587",
|
||||||
|
"PopHost": "pop.gmail.com",
|
||||||
|
"PopPort": "995",
|
||||||
|
"MailLogin": "vertolet.kirill73@gmail.com",
|
||||||
|
"MailPassword": "xehc ozzy jxqa gtvt"
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user