diff --git a/ComputerShopBusinessLogic/BusinessLogics/OrderLogic.cs b/ComputerShopBusinessLogic/BusinessLogics/OrderLogic.cs index cecc0b7..645e832 100644 --- a/ComputerShopBusinessLogic/BusinessLogics/OrderLogic.cs +++ b/ComputerShopBusinessLogic/BusinessLogics/OrderLogic.cs @@ -85,7 +85,7 @@ namespace ComputerShopBusinessLogic.BusinessLogics } model1.Status = newStatus; if (model1.Status == OrderStatus.Выдан) model1.DateImplement = DateTime.Now; - var result = _orderStorage.Update(model); + var result = _orderStorage.Update(model1); if (result == null) { model1.Status--; diff --git a/ComputerShopBusinessLogic/MailWorker/AbstractMailWorker.cs b/ComputerShopBusinessLogic/MailWorker/AbstractMailWorker.cs index 09d20e8..3cfae46 100644 --- a/ComputerShopBusinessLogic/MailWorker/AbstractMailWorker.cs +++ b/ComputerShopBusinessLogic/MailWorker/AbstractMailWorker.cs @@ -76,7 +76,6 @@ namespace ComputerShopBusinessLogic.MailWorker } } protected abstract Task SendMailAsync(MailSendInfoBindingModel info); - protected abstract Task> - ReceiveMailAsync(); + protected abstract Task> ReceiveMailAsync(); } } diff --git a/ComputerShopBusinessLogic/MailWorker/MailKitWorker.cs b/ComputerShopBusinessLogic/MailWorker/MailKitWorker.cs index ac48d57..35bde32 100644 --- a/ComputerShopBusinessLogic/MailWorker/MailKitWorker.cs +++ b/ComputerShopBusinessLogic/MailWorker/MailKitWorker.cs @@ -39,8 +39,7 @@ namespace ComputerShopBusinessLogic.MailWorker throw; } } - protected override async Task> - ReceiveMailAsync() + protected override async Task> ReceiveMailAsync() { var list = new List(); using var client = new Pop3Client(); diff --git a/ComputerShopRestApi/appsettings.json b/ComputerShopRestApi/appsettings.json index 850e589..2fea8e4 100644 --- a/ComputerShopRestApi/appsettings.json +++ b/ComputerShopRestApi/appsettings.json @@ -12,5 +12,5 @@ "PopHost": "pop.gmail.com", "PopPort": "995", "MailLogin": "ulstulabs@gmail.com", - "MailPassword": "cfbm uwya lffr czrx" + "MailPassword": "tcsb rgny wsza xlyx" } diff --git a/ComputersShop/App.config b/ComputersShop/App.config index 513fdd3..b2e446b 100644 --- a/ComputersShop/App.config +++ b/ComputersShop/App.config @@ -6,6 +6,6 @@ - + \ No newline at end of file diff --git a/ComputersShop/FormMails.Designer.cs b/ComputersShop/FormMails.Designer.cs new file mode 100644 index 0000000..35aef03 --- /dev/null +++ b/ComputersShop/FormMails.Designer.cs @@ -0,0 +1,63 @@ +namespace ComputersShop +{ + 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() + { + this.dataGridView = new System.Windows.Forms.DataGridView(); + ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit(); + this.SuspendLayout(); + // + // dataGridView + // + this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; + this.dataGridView.Dock = System.Windows.Forms.DockStyle.Fill; + this.dataGridView.Location = new System.Drawing.Point(0, 0); + this.dataGridView.Name = "dataGridView"; + this.dataGridView.RowTemplate.Height = 25; + this.dataGridView.Size = new System.Drawing.Size(800, 450); + this.dataGridView.TabIndex = 0; + // + // FormMails + // + this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(800, 450); + this.Controls.Add(this.dataGridView); + this.Name = "FormMails"; + this.Text = "FormMails"; + this.Load += new System.EventHandler(this.FormMails_Load); + ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit(); + this.ResumeLayout(false); + + } + + #endregion + + private DataGridView dataGridView; + } +} \ No newline at end of file diff --git a/ComputersShop/FormMails.cs b/ComputersShop/FormMails.cs new file mode 100644 index 0000000..b768a79 --- /dev/null +++ b/ComputersShop/FormMails.cs @@ -0,0 +1,49 @@ +using ComputerShopContracts.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 ComputersShop +{ + 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("Загрузка писем"); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка загрузки писем"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, + MessageBoxIcon.Error); + } + } + } +} diff --git a/ComputersShop/FormMails.resx b/ComputersShop/FormMails.resx new file mode 100644 index 0000000..f298a7b --- /dev/null +++ b/ComputersShop/FormMails.resx @@ -0,0 +1,60 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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/ComputersShop/FormMain.Designer.cs b/ComputersShop/FormMain.Designer.cs index eb3088c..da97691 100644 --- a/ComputersShop/FormMain.Designer.cs +++ b/ComputersShop/FormMain.Designer.cs @@ -43,6 +43,7 @@ this.ButtonCreateOrder = new System.Windows.Forms.Button(); this.ButtonIssuedOrder = new System.Windows.Forms.Button(); this.ButtonRef = new System.Windows.Forms.Button(); + this.письмаToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.menuStrip1.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit(); this.SuspendLayout(); @@ -52,7 +53,8 @@ this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { this.справочникиToolStripMenuItem, this.отчетыToolStripMenuItem, - this.запускРаботToolStripMenuItem}); + this.запускРаботToolStripMenuItem, + this.письмаToolStripMenuItem}); this.menuStrip1.Location = new System.Drawing.Point(0, 0); this.menuStrip1.Name = "menuStrip1"; this.menuStrip1.Size = new System.Drawing.Size(1006, 24); @@ -175,6 +177,13 @@ this.ButtonRef.UseVisualStyleBackColor = true; this.ButtonRef.Click += new System.EventHandler(this.ButtonRef_Click); // + // письмаToolStripMenuItem + // + this.письмаToolStripMenuItem.Name = "письмаToolStripMenuItem"; + this.письмаToolStripMenuItem.Size = new System.Drawing.Size(62, 20); + this.письмаToolStripMenuItem.Text = "Письма"; + this.письмаToolStripMenuItem.Click += new System.EventHandler(this.письмаToolStripMenuItem_Click); + // // FormMain // this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); @@ -214,5 +223,6 @@ private ToolStripMenuItem клиентыToolStripMenuItem; private ToolStripMenuItem исполнителиToolStripMenuItem; private ToolStripMenuItem запускРаботToolStripMenuItem; + private ToolStripMenuItem письмаToolStripMenuItem; } } \ No newline at end of file diff --git a/ComputersShop/FormMain.cs b/ComputersShop/FormMain.cs index ae8e3f4..3a8bc9a 100644 --- a/ComputersShop/FormMain.cs +++ b/ComputersShop/FormMain.cs @@ -169,5 +169,14 @@ namespace ComputersShop MessageBox.Show("Процесс обработки запущен", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information); } + + private void письмаToolStripMenuItem_Click(object sender, EventArgs e) + { + var service = Program.ServiceProvider?.GetService(typeof(FormMails)); + if (service is FormMails form) + { + form.ShowDialog(); + } + } } } diff --git a/ComputersShop/Program.cs b/ComputersShop/Program.cs index 4bb6974..e55d673 100644 --- a/ComputersShop/Program.cs +++ b/ComputersShop/Program.cs @@ -90,6 +90,7 @@ namespace ComputersShop services.AddTransient(); services.AddTransient(); services.AddTransient(); + services.AddTransient(); } private static void MailCheck(object obj) => ServiceProvider?.GetService()?.MailCheck();