diff --git a/JewelryStore/JewerlyStoreView/App.config b/JewelryStore/JewerlyStoreView/App.config
new file mode 100644
index 0000000..ffb059c
--- /dev/null
+++ b/JewelryStore/JewerlyStoreView/App.config
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/JewelryStore/JewerlyStoreView/FormMails.Designer.cs b/JewelryStore/JewerlyStoreView/FormMails.Designer.cs
new file mode 100644
index 0000000..e9bd2ff
--- /dev/null
+++ b/JewelryStore/JewerlyStoreView/FormMails.Designer.cs
@@ -0,0 +1,61 @@
+namespace JewerlyStoreView
+{
+ partial class FormMails
+ {
+ ///
+ /// 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.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
+ dataGridView.Location = new Point(12, 12);
+ dataGridView.Name = "dataGridView";
+ dataGridView.RowTemplate.Height = 25;
+ dataGridView.Size = new Size(767, 426);
+ dataGridView.TabIndex = 0;
+ //
+ // FormMails
+ //
+ AutoScaleDimensions = new SizeF(7F, 15F);
+ AutoScaleMode = AutoScaleMode.Font;
+ ClientSize = new Size(800, 450);
+ Controls.Add(dataGridView);
+ Name = "FormMails";
+ Text = "FormMails";
+ Load += FormMails_Load;
+ ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
+ ResumeLayout(false);
+ }
+
+ #endregion
+
+ private DataGridView dataGridView;
+ }
+}
\ No newline at end of file
diff --git a/JewelryStore/JewerlyStoreView/FormMails.cs b/JewelryStore/JewerlyStoreView/FormMails.cs
new file mode 100644
index 0000000..418b45c
--- /dev/null
+++ b/JewelryStore/JewerlyStoreView/FormMails.cs
@@ -0,0 +1,47 @@
+using JewelryStoreContracts.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 JewerlyStoreView
+{
+ public partial class FormMails : Form
+ {
+ private readonly ILogger _logger;
+ private readonly IMessageInfoLogic _logic;
+ public FormMails(ILogger logger, IMessageInfoLogic logic)
+ {
+ InitializeComponent();
+ _logger = logger;
+ _logic = logic;
+ }
+
+ private void FormMails_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("Load mails");
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Load mails error");
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+ }
+}
diff --git a/JewelryStore/JewerlyStoreView/FormMails.resx b/JewelryStore/JewerlyStoreView/FormMails.resx
new file mode 100644
index 0000000..af32865
--- /dev/null
+++ b/JewelryStore/JewerlyStoreView/FormMails.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/JewelryStore/JewerlyStoreView/FormMain.Designer.cs b/JewelryStore/JewerlyStoreView/FormMain.Designer.cs
index be99a3b..1e27053 100644
--- a/JewelryStore/JewerlyStoreView/FormMain.Designer.cs
+++ b/JewelryStore/JewerlyStoreView/FormMain.Designer.cs
@@ -35,6 +35,7 @@
изделияToolStripMenuItem = new ToolStripMenuItem();
клиентыToolStripMenuItem = new ToolStripMenuItem();
исполнителиToolStripMenuItem = new ToolStripMenuItem();
+ почтовыеПисьмаToolStripMenuItem = new ToolStripMenuItem();
отчётыToolStripMenuItem = new ToolStripMenuItem();
списокКомпонентовToolStripMenuItem = new ToolStripMenuItem();
компонентыПоИзделиямToolStripMenuItem = new ToolStripMenuItem();
@@ -68,7 +69,7 @@
//
// справочникиToolStripMenuItem
//
- справочникиToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { компонентыToolStripMenuItem, изделияToolStripMenuItem, клиентыToolStripMenuItem, исполнителиToolStripMenuItem });
+ справочникиToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { компонентыToolStripMenuItem, изделияToolStripMenuItem, клиентыToolStripMenuItem, исполнителиToolStripMenuItem, почтовыеПисьмаToolStripMenuItem });
справочникиToolStripMenuItem.Name = "справочникиToolStripMenuItem";
справочникиToolStripMenuItem.Size = new Size(94, 20);
справочникиToolStripMenuItem.Text = "Справочники";
@@ -101,6 +102,13 @@
исполнителиToolStripMenuItem.Text = "Исполнители";
исполнителиToolStripMenuItem.Click += исполнителиToolStripMenuItem_Click;
//
+ // почтовыеПисьмаToolStripMenuItem
+ //
+ почтовыеПисьмаToolStripMenuItem.Name = "почтовыеПисьмаToolStripMenuItem";
+ почтовыеПисьмаToolStripMenuItem.Size = new Size(149, 22);
+ почтовыеПисьмаToolStripMenuItem.Text = "ПочтовыеПисьма";
+ почтовыеПисьмаToolStripMenuItem.Click += emailsToolStripMenuItem_Click;
+ //
// отчётыToolStripMenuItem
//
отчётыToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { списокКомпонентовToolStripMenuItem, компонентыПоИзделиямToolStripMenuItem, списокЗаказовToolStripMenuItem });
@@ -207,5 +215,6 @@
private ToolStripMenuItem клиентыToolStripMenuItem;
private ToolStripMenuItem запускРаботToolStripMenuItem;
private ToolStripMenuItem исполнителиToolStripMenuItem;
+ private ToolStripMenuItem почтовыеПисьмаToolStripMenuItem;
}
}
\ No newline at end of file
diff --git a/JewelryStore/JewerlyStoreView/FormMain.cs b/JewelryStore/JewerlyStoreView/FormMain.cs
index 61a36fe..4e25820 100644
--- a/JewelryStore/JewerlyStoreView/FormMain.cs
+++ b/JewelryStore/JewerlyStoreView/FormMain.cs
@@ -171,5 +171,14 @@ namespace JewelryStoreView
_orderLogic);
MessageBox.Show("Процесс обработки запущен", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
+
+ private void emailsToolStripMenuItem_Click(object sender, EventArgs e)
+ {
+ var service = Program.ServiceProvider?.GetService(typeof(FormMails));
+ if (service is FormMails form)
+ {
+ form.ShowDialog();
+ }
+ }
}
}
diff --git a/JewelryStore/JewerlyStoreView/JewerlyStoreView.csproj b/JewelryStore/JewerlyStoreView/JewerlyStoreView.csproj
index ac64bd3..ee6a2a4 100644
--- a/JewelryStore/JewerlyStoreView/JewerlyStoreView.csproj
+++ b/JewelryStore/JewerlyStoreView/JewerlyStoreView.csproj
@@ -33,6 +33,9 @@
+
+ Always
+
Always
diff --git a/JewelryStore/JewerlyStoreView/Program.cs b/JewelryStore/JewerlyStoreView/Program.cs
index 21a5a79..8b9d0d7 100644
--- a/JewelryStore/JewerlyStoreView/Program.cs
+++ b/JewelryStore/JewerlyStoreView/Program.cs
@@ -1,4 +1,4 @@
-using JewelryStoreContracts.BusinessLogicsContracts;
+using JewelryStoreContracts.BusinessLogicsContracts;
using JewelryStoreContracts.StoragesContracts;
using JewelryStoreDatabaseImplement.Implements;
using Microsoft.Extensions.DependencyInjection;
@@ -9,6 +9,8 @@ using JewelryStoreBusinessLogic.OfficePackage.Implements;
using JewelryStoreBusinessLogic.OfficePackage;
using System.Drawing;
using JewerlyStoreView;
+using JewelryStoreBusinessLogic.MailWorker;
+using JewelryStoreContracts.BindingModels;
namespace JewelryStoreView
{
@@ -29,7 +31,28 @@ namespace JewelryStoreView
var services = new ServiceCollection();
ConfigureServices(services);
_serviceProvider = services.BuildServiceProvider();
- Application.Run(_serviceProvider.GetRequiredService());
+ try
+ {
+ var mailSender = _serviceProvider.GetService();
+ 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();
+ logger?.LogError(ex, "Ошибка работы с почтой");
+ }
+
+ Application.Run(_serviceProvider.GetRequiredService());
}
private static void ConfigureServices(ServiceCollection services)
{
@@ -38,24 +61,27 @@ namespace JewelryStoreView
option.SetMinimumLevel(LogLevel.Information);
option.AddNLog("nlog.config");
});
- services.AddTransient();// ? . ?
+ services.AddTransient();// а где они были? не было. почему? не знаю
services.AddTransient();
services.AddTransient();
services.AddTransient();
services.AddTransient();
+ services.AddTransient();
services.AddTransient();
services.AddTransient();
services.AddTransient();
services.AddTransient();
- services.AddTransient();// ? . ?
+ services.AddTransient();// а где они были? не было. почему? не знаю
services.AddTransient();
+ services.AddTransient();
services.AddTransient();
services.AddTransient();
services.AddTransient();
services.AddTransient();
- services.AddTransient();
+ services.AddSingleton();
+ services.AddTransient();
services.AddTransient();
- services.AddTransient(); // ? . ?
+ services.AddTransient(); // а где они были? не было. почему? не знаю
services.AddTransient();
services.AddTransient();
services.AddTransient();
@@ -65,6 +91,8 @@ namespace JewelryStoreView
services.AddTransient();
services.AddTransient();
services.AddTransient();
+ services.AddTransient();
}
- }
+ private static void MailCheck(object obj) => ServiceProvider?.GetService()?.MailCheck();
+ }
}
\ No newline at end of file