diff --git a/SushiBar/SushiBar/Forms/FormMailView.Designer.cs b/SushiBar/SushiBar/Forms/FormMailView.Designer.cs
new file mode 100644
index 0000000..7bd6cca
--- /dev/null
+++ b/SushiBar/SushiBar/Forms/FormMailView.Designer.cs
@@ -0,0 +1,64 @@
+namespace SushiBar.Forms
+{
+ partial class FormMailView
+ {
+ ///
+ /// Required designer variable.
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// Clean up any resources being used.
+ ///
+ /// true if managed resources should be disposed; otherwise, false.
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Windows Form Designer generated code
+
+ ///
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ ///
+ private void InitializeComponent()
+ {
+ dataGridView = new DataGridView();
+ ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
+ SuspendLayout();
+ //
+ // dataGridView
+ //
+ dataGridView.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
+ dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
+ dataGridView.Location = new Point(12, 12);
+ dataGridView.Name = "dataGridView";
+ dataGridView.RowHeadersWidth = 51;
+ dataGridView.RowTemplate.Height = 29;
+ dataGridView.Size = new Size(776, 426);
+ dataGridView.TabIndex = 0;
+ //
+ // FormMail
+ //
+ AllowDrop = true;
+ AutoScaleDimensions = new SizeF(8F, 20F);
+ AutoScaleMode = AutoScaleMode.Font;
+ ClientSize = new Size(800, 450);
+ Controls.Add(dataGridView);
+ Name = "FormMail";
+ Text = "FormMail";
+ WindowState = FormWindowState.Maximized;
+ ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
+ ResumeLayout(false);
+ }
+
+ #endregion
+
+ private DataGridView dataGridView;
+ }
+}
\ No newline at end of file
diff --git a/SushiBar/SushiBar/Forms/FormMailView.cs b/SushiBar/SushiBar/Forms/FormMailView.cs
new file mode 100644
index 0000000..86b4437
--- /dev/null
+++ b/SushiBar/SushiBar/Forms/FormMailView.cs
@@ -0,0 +1,39 @@
+using Microsoft.Extensions.Logging;
+using SushiBarContracts.BusinessLogicsContracts;
+
+namespace SushiBar.Forms
+{
+ public partial class FormMailView : Form
+ {
+ private readonly ILogger _logger;
+ private readonly IMessageInfoLogic _logic;
+ public FormMailView(ILogger logger, IMessageInfoLogic logic)
+ {
+ InitializeComponent();
+ _logger = logger;
+ _logic = logic;
+ }
+
+ private void ViewMailForm_Load(object sender, EventArgs e)
+ {
+ try
+ {
+ var list = _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("Загрузка списка писем");
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Ошибка загрузки писем");
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
+ MessageBoxIcon.Error);
+ }
+ }
+ }
+}
diff --git a/SushiBar/SushiBar/Forms/FormMailView.resx b/SushiBar/SushiBar/Forms/FormMailView.resx
new file mode 100644
index 0000000..af32865
--- /dev/null
+++ b/SushiBar/SushiBar/Forms/FormMailView.resx
@@ -0,0 +1,120 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
\ No newline at end of file
diff --git a/SushiBar/SushiBar/Forms/FormMain.Designer.cs b/SushiBar/SushiBar/Forms/FormMain.Designer.cs
index d51313f..83a9518 100644
--- a/SushiBar/SushiBar/Forms/FormMain.Designer.cs
+++ b/SushiBar/SushiBar/Forms/FormMain.Designer.cs
@@ -39,6 +39,7 @@
sushisReportToolStripMenuItem = new ToolStripMenuItem();
componentsReportПоСушиToolStripMenuItem = new ToolStripMenuItem();
orderReportToolStripMenuItem = new ToolStripMenuItem();
+ startWorksToolStripMenuItem = new ToolStripMenuItem();
отчётыToolStripMenuItem = new ToolStripMenuItem();
sushisToolStripMenuItem = new ToolStripMenuItem();
componentSushisToolStripMenuItem = new ToolStripMenuItem();
@@ -48,7 +49,7 @@
buttonOrderReady = new Button();
buttonIssuedOrder = new Button();
buttonRef = new Button();
- startWorksToolStripMenuItem = new ToolStripMenuItem();
+ MailToolStripMenuItem = new ToolStripMenuItem();
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
menuStrip1.SuspendLayout();
SuspendLayout();
@@ -68,7 +69,7 @@
// menuStrip1
//
menuStrip1.ImageScalingSize = new Size(20, 20);
- menuStrip1.Items.AddRange(new ToolStripItem[] { toolStripMenuItem, отчётыToolStripMenuItem1, startWorksToolStripMenuItem });
+ menuStrip1.Items.AddRange(new ToolStripItem[] { toolStripMenuItem, отчётыToolStripMenuItem1, startWorksToolStripMenuItem, MailToolStripMenuItem });
menuStrip1.Location = new Point(0, 0);
menuStrip1.Name = "menuStrip1";
menuStrip1.Size = new Size(1184, 28);
@@ -85,28 +86,28 @@
// sushiToolStripMenuItem
//
sushiToolStripMenuItem.Name = "sushiToolStripMenuItem";
- sushiToolStripMenuItem.Size = new Size(224, 26);
+ sushiToolStripMenuItem.Size = new Size(185, 26);
sushiToolStripMenuItem.Text = "Суши";
sushiToolStripMenuItem.Click += SushiToolStripMenuItem_Click;
//
// componentsToolStripMenuItem
//
componentsToolStripMenuItem.Name = "componentsToolStripMenuItem";
- componentsToolStripMenuItem.Size = new Size(224, 26);
+ componentsToolStripMenuItem.Size = new Size(185, 26);
componentsToolStripMenuItem.Text = "Компоненты";
componentsToolStripMenuItem.Click += ComponentsToolStripMenuItem_Click;
//
// clientsToolStripMenuItem
//
clientsToolStripMenuItem.Name = "clientsToolStripMenuItem";
- clientsToolStripMenuItem.Size = new Size(224, 26);
+ clientsToolStripMenuItem.Size = new Size(185, 26);
clientsToolStripMenuItem.Text = "Клиенты";
clientsToolStripMenuItem.Click += clientsToolStripMenuItem_Click;
//
// implementersToolStripMenuItem
//
implementersToolStripMenuItem.Name = "implementersToolStripMenuItem";
- implementersToolStripMenuItem.Size = new Size(224, 26);
+ implementersToolStripMenuItem.Size = new Size(185, 26);
implementersToolStripMenuItem.Text = "Исполнители";
implementersToolStripMenuItem.Click += implementersToolStripMenuItem_Click;
//
@@ -138,6 +139,13 @@
orderReportToolStripMenuItem.Text = "Список заказов";
orderReportToolStripMenuItem.Click += orderReportToolStripMenuItem_Click;
//
+ // startWorksToolStripMenuItem
+ //
+ startWorksToolStripMenuItem.Name = "startWorksToolStripMenuItem";
+ startWorksToolStripMenuItem.Size = new Size(114, 24);
+ startWorksToolStripMenuItem.Text = "Запуск работ";
+ startWorksToolStripMenuItem.Click += startWorksToolStripMenuItem_Click;
+ //
// отчётыToolStripMenuItem
//
отчётыToolStripMenuItem.Name = "отчётыToolStripMenuItem";
@@ -213,12 +221,12 @@
buttonRef.UseVisualStyleBackColor = true;
buttonRef.Click += ButtonRef_Click;
//
- // startWorksToolStripMenuItem
+ // MailToolStripMenuItem
//
- startWorksToolStripMenuItem.Name = "startWorksToolStripMenuItem";
- startWorksToolStripMenuItem.Size = new Size(114, 24);
- startWorksToolStripMenuItem.Text = "Запуск работ";
- startWorksToolStripMenuItem.Click += startWorksToolStripMenuItem_Click;
+ MailToolStripMenuItem.Name = "MailToolStripMenuItem";
+ MailToolStripMenuItem.Size = new Size(65, 24);
+ MailToolStripMenuItem.Text = "Почта";
+ MailToolStripMenuItem.Click += MailToolStripMenuItem_Click;
//
// FormMain
//
@@ -268,5 +276,6 @@
private ToolStripMenuItem clientsToolStripMenuItem;
private ToolStripMenuItem implementersToolStripMenuItem;
private ToolStripMenuItem startWorksToolStripMenuItem;
+ private ToolStripMenuItem MailToolStripMenuItem;
}
}
\ No newline at end of file
diff --git a/SushiBar/SushiBar/Forms/FormMain.cs b/SushiBar/SushiBar/Forms/FormMain.cs
index 48b3e06..5b1b4e7 100644
--- a/SushiBar/SushiBar/Forms/FormMain.cs
+++ b/SushiBar/SushiBar/Forms/FormMain.cs
@@ -195,5 +195,14 @@ namespace SushiBar.Forms
_workProcess.DoWork((Program.ServiceProvider?.GetService(typeof(IImplementerLogic)) as IImplementerLogic)!, _orderLogic);
MessageBox.Show("Процесс обработки запущен", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
+
+ private void MailToolStripMenuItem_Click(object sender, EventArgs e)
+ {
+ var service = Program.ServiceProvider?.GetService(typeof(FormMailView));
+ if (service is FormMailView form)
+ {
+ form.ShowDialog();
+ }
+ }
}
}
diff --git a/SushiBar/SushiBar/Program.cs b/SushiBar/SushiBar/Program.cs
index c6f87db..eab4db8 100644
--- a/SushiBar/SushiBar/Program.cs
+++ b/SushiBar/SushiBar/Program.cs
@@ -66,6 +66,7 @@ namespace SushiBar
services.AddTransient();
services.AddTransient();
services.AddTransient();
+ services.AddTransient();
services.AddTransient();
services.AddTransient();
@@ -73,7 +74,8 @@ namespace SushiBar
services.AddTransient();
services.AddTransient();
services.AddTransient();
- services.AddTransient();
+ services.AddSingleton();
+ services.AddTransient();
services.AddTransient();
services.AddTransient();
@@ -87,10 +89,12 @@ namespace SushiBar
services.AddTransient();
services.AddTransient();
services.AddTransient();
+ services.AddTransient();
services.AddTransient();
services.AddTransient();
services.AddTransient();
+ services.AddSingleton();
}
private static void MailCheck(object obj) => ServiceProvider?.GetService()?.MailCheck();
diff --git a/SushiBar/SushiBarBusinessLogic/MailWorker/AbstractMailWorker.cs b/SushiBar/SushiBarBusinessLogic/MailWorker/AbstractMailWorker.cs
index 4cce4c4..634c8d1 100644
--- a/SushiBar/SushiBarBusinessLogic/MailWorker/AbstractMailWorker.cs
+++ b/SushiBar/SushiBarBusinessLogic/MailWorker/AbstractMailWorker.cs
@@ -69,7 +69,6 @@ namespace SushiBarBusinessLogic.MailWorker
}
}
protected abstract Task SendMailAsync(MailSendInfoBindingModel info);
- protected abstract Task>
- ReceiveMailAsync();
+ protected abstract Task> ReceiveMailAsync();
}
}
diff --git a/SushiBar/SushiBarBusinessLogic/MailWorker/MailKitWorker.cs b/SushiBar/SushiBarBusinessLogic/MailWorker/MailKitWorker.cs
index b36bd96..b0d2a5b 100644
--- a/SushiBar/SushiBarBusinessLogic/MailWorker/MailKitWorker.cs
+++ b/SushiBar/SushiBarBusinessLogic/MailWorker/MailKitWorker.cs
@@ -36,7 +36,7 @@ namespace SushiBarBusinessLogic.MailWorker
}
}
protected override async Task>
- ReceiveMailAsync()
+ ReceiveMailAsync()
{
var list = new List();
using var client = new Pop3Client();
diff --git a/SushiBar/SushiBarClientApi/appsettings.json b/SushiBar/SushiBarClientApi/appsettings.json
index 86fe7e8..5b47574 100644
--- a/SushiBar/SushiBarClientApi/appsettings.json
+++ b/SushiBar/SushiBarClientApi/appsettings.json
@@ -7,16 +7,5 @@
},
"AllowedHosts": "*",
- "IPAddress": "http://localhost:5050",
-
- "MailConfigBindingModel": {
- "SmtpClientHost": "smtp.yandex.ru",
- "SmtpClientPort": 465,
-
- "PopHost": "pop.yandex.com",
- "PopPort": 995,
-
- "MailLogin": "tester.b.moio@ya.ru",
- "MailPassword": "pyzzqswchjevecec"
- }
+ "IPAddress": "http://localhost:5050"
}
diff --git a/SushiBar/SushiBarDatabaseImplement/Implements/MessageInfoStorage.cs b/SushiBar/SushiBarDatabaseImplement/Implements/MessageInfoStorage.cs
index 3462ca1..9557a48 100644
--- a/SushiBar/SushiBarDatabaseImplement/Implements/MessageInfoStorage.cs
+++ b/SushiBar/SushiBarDatabaseImplement/Implements/MessageInfoStorage.cs
@@ -1,5 +1,4 @@
-using Microsoft.EntityFrameworkCore;
-using SushiBarContracts.BindingModels;
+using SushiBarContracts.BindingModels;
using SushiBarContracts.SearchModels;
using SushiBarContracts.StoragesContracts;
using SushiBarContracts.ViewModels;
@@ -42,7 +41,7 @@ namespace SushiBarDatabaseImplement.Implements
{
using var context = new SushiBarDatabase();
var newMessage = MessageInfo.Create(context, model);
- if (newMessage == null || context.Messages.Any(x => x.MessageId.Equals(model.MessageId)))
+ if (newMessage == null || newMessage.Body == null || context.Messages.Any(x => x.MessageId.Equals(model.MessageId)))
{
return null;
}
diff --git a/SushiBar/SushiBarDatabaseImplement/Models/MessageInfo.cs b/SushiBar/SushiBarDatabaseImplement/Models/MessageInfo.cs
index fb48ecd..5109a4a 100644
--- a/SushiBar/SushiBarDatabaseImplement/Models/MessageInfo.cs
+++ b/SushiBar/SushiBarDatabaseImplement/Models/MessageInfo.cs
@@ -28,11 +28,11 @@ namespace SushiBarDatabaseImplement.Models
}
return new()
{
- Body = model.Body,
- Subject = model.Subject,
+ Body = model.Body ?? string.Empty,
+ Subject = model.Subject ?? string.Empty,
ClientId = context.Clients.FirstOrDefault(x => x.Email == model.SenderName)?.Id,
MessageId = model.MessageId,
- SenderName = model.SenderName,
+ SenderName = model.SenderName ?? string.Empty,
DateDelivery = model.DateDelivery,
};
}
diff --git a/SushiBar/SushiBarRestApi/Program.cs b/SushiBar/SushiBarRestApi/Program.cs
index 78db750..63fac56 100644
--- a/SushiBar/SushiBarRestApi/Program.cs
+++ b/SushiBar/SushiBarRestApi/Program.cs
@@ -11,12 +11,22 @@ builder.Logging.SetMinimumLevel(LogLevel.Information);
builder.Logging.AddLog4Net("log4net.config");
// Add services to the container.
-builder.Services.AddSingleton();
-builder.Services.AddSingleton();
-builder.Services.AddSingleton();
-builder.Services.AddSingleton();
-builder.Services.AddSingleton();
-builder.Services.AddSingleton();
+builder.Services
+ .AddSingleton()
+ .AddSingleton()
+ .AddSingleton()
+ .AddSingleton();
+
+builder.Services
+ .AddSingleton()
+ .AddSingleton()
+ .AddSingleton()
+ .AddSingleton();
+
+builder.Services
+ .AddSingleton();
+
+
builder.Services.AddControllers();
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
diff --git a/SushiBar/SushiBarRestApi/appsettings.json b/SushiBar/SushiBarRestApi/appsettings.json
index 10f68b8..eca666a 100644
--- a/SushiBar/SushiBarRestApi/appsettings.json
+++ b/SushiBar/SushiBarRestApi/appsettings.json
@@ -5,5 +5,16 @@
"Microsoft.AspNetCore": "Warning"
}
},
- "AllowedHosts": "*"
+ "AllowedHosts": "*",
+
+ "MailConfigBindingModel": {
+ "SmtpClientHost": "smtp.yandex.ru",
+ "SmtpClientPort": 465,
+
+ "PopHost": "pop.yandex.com",
+ "PopPort": 995,
+
+ "MailLogin": "tester.b.moio@ya.ru",
+ "MailPassword": "pyzzqswchjevecec"
+ }
}