diff --git a/SushiBar/SushiBar/App.config b/SushiBar/SushiBar/App.config index 5ae12e7..a30a5cb 100644 --- a/SushiBar/SushiBar/App.config +++ b/SushiBar/SushiBar/App.config @@ -5,7 +5,7 @@ - - + + \ No newline at end of file diff --git a/SushiBar/SushiBar/FormMain.Designer.cs b/SushiBar/SushiBar/FormMain.Designer.cs index 292488a..773bf04 100644 --- a/SushiBar/SushiBar/FormMain.Designer.cs +++ b/SushiBar/SushiBar/FormMain.Designer.cs @@ -45,6 +45,7 @@ buttonSetToWork = new Button(); buttonCreateOrder = new Button(); dataGridView = new DataGridView(); + письмаToolStripMenuItem = new ToolStripMenuItem(); menuStrip.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit(); SuspendLayout(); @@ -68,41 +69,41 @@ // ингредиентыToolStripMenuItem // ингредиентыToolStripMenuItem.Name = "ингредиентыToolStripMenuItem"; - ингредиентыToolStripMenuItem.Size = new Size(180, 22); + ингредиентыToolStripMenuItem.Size = new Size(154, 22); ингредиентыToolStripMenuItem.Text = "Ингредиенты"; ингредиентыToolStripMenuItem.Click += IngredientsToolStripMenuItem_Click; // // сушиToolStripMenuItem // сушиToolStripMenuItem.Name = "сушиToolStripMenuItem"; - сушиToolStripMenuItem.Size = new Size(180, 22); + сушиToolStripMenuItem.Size = new Size(154, 22); сушиToolStripMenuItem.Text = "Суши"; сушиToolStripMenuItem.Click += SushiToolStripMenuItem_Click; // // клиентыToolStripMenuItem // клиентыToolStripMenuItem.Name = "клиентыToolStripMenuItem"; - клиентыToolStripMenuItem.Size = new Size(180, 22); + клиентыToolStripMenuItem.Size = new Size(154, 22); клиентыToolStripMenuItem.Text = "Клиенты"; клиентыToolStripMenuItem.Click += клиентыToolStripMenuItem_Click; // // исполнителиToolStripMenuItem // исполнителиToolStripMenuItem.Name = "исполнителиToolStripMenuItem"; - исполнителиToolStripMenuItem.Size = new Size(180, 22); + исполнителиToolStripMenuItem.Size = new Size(154, 22); исполнителиToolStripMenuItem.Text = "Исполнители"; исполнителиToolStripMenuItem.Click += employersToolStripMenuItem_Click; // // начатьРаботуToolStripMenuItem // начатьРаботуToolStripMenuItem.Name = "начатьРаботуToolStripMenuItem"; - начатьРаботуToolStripMenuItem.Size = new Size(180, 22); + начатьРаботуToolStripMenuItem.Size = new Size(154, 22); начатьРаботуToolStripMenuItem.Text = "Начать работу"; начатьРаботуToolStripMenuItem.Click += startWorkToolStripMenuItem_Click; // // отчетыToolStripMenuItem // - отчетыToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { списокСушиToolStripMenuItem, сушиСИнгредиентамиToolStripMenuItem, списокЗаказовToolStripMenuItem }); + отчетыToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { списокСушиToolStripMenuItem, сушиСИнгредиентамиToolStripMenuItem, списокЗаказовToolStripMenuItem, письмаToolStripMenuItem }); отчетыToolStripMenuItem.Name = "отчетыToolStripMenuItem"; отчетыToolStripMenuItem.Size = new Size(60, 20); отчетыToolStripMenuItem.Text = "Отчеты"; @@ -200,6 +201,13 @@ dataGridView.Size = new Size(919, 426); dataGridView.TabIndex = 7; // + // письмаToolStripMenuItem + // + письмаToolStripMenuItem.Name = "письмаToolStripMenuItem"; + письмаToolStripMenuItem.Size = new Size(203, 22); + письмаToolStripMenuItem.Text = "Письма"; + письмаToolStripMenuItem.Click += письмаToolStripMenuItem_Click; + // // FormMain // AutoScaleDimensions = new SizeF(7F, 15F); @@ -242,5 +250,6 @@ private ToolStripMenuItem клиентыToolStripMenuItem; private ToolStripMenuItem исполнителиToolStripMenuItem; private ToolStripMenuItem начатьРаботуToolStripMenuItem; + private ToolStripMenuItem письмаToolStripMenuItem; } } \ No newline at end of file diff --git a/SushiBar/SushiBar/FormMain.cs b/SushiBar/SushiBar/FormMain.cs index 7748147..e9057ef 100644 --- a/SushiBar/SushiBar/FormMain.cs +++ b/SushiBar/SushiBar/FormMain.cs @@ -34,7 +34,8 @@ namespace SushiBarView { dataGridView.DataSource = list; dataGridView.Columns["SushiId"].Visible = false; - dataGridView.Columns["Implementerid"].Visible=false; + dataGridView.Columns["Implementerid"].Visible = false; + dataGridView.Columns["ClientEmail"].Visible = false; } _logger.LogInformation("Загрузка заказов"); } @@ -199,5 +200,14 @@ namespace SushiBarView _workProcess.DoWork((Program.ServiceProvider?.GetService(typeof(IImplementerLogic)) as IImplementerLogic)!, _orderLogic); MessageBox.Show("Процесс обработки запущен", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information); } + + private void письмаToolStripMenuItem_Click(object sender, EventArgs e) + { + var service = Program.ServiceProvider?.GetService(typeof(FormViewMail)); + if (service is FormViewMail form) + { + form.ShowDialog(); + } + } } } \ No newline at end of file diff --git a/SushiBar/SushiBar/FormViewMail.Designer.cs b/SushiBar/SushiBar/FormViewMail.Designer.cs new file mode 100644 index 0000000..0f71814 --- /dev/null +++ b/SushiBar/SushiBar/FormViewMail.Designer.cs @@ -0,0 +1,61 @@ +namespace SushiBarView +{ + partial class FormViewMail + { + /// + /// 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.Dock = DockStyle.Fill; + dataGridView.Location = new Point(0, 0); + dataGridView.Name = "dataGridView"; + dataGridView.Size = new Size(800, 450); + dataGridView.TabIndex = 0; + // + // FormViewMail + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(800, 450); + Controls.Add(dataGridView); + Name = "FormViewMail"; + Text = "FormViewMail"; + Load += FormViewMail_Load; + ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit(); + ResumeLayout(false); + } + + #endregion + + private DataGridView dataGridView; + } +} \ No newline at end of file diff --git a/SushiBar/SushiBar/FormViewMail.cs b/SushiBar/SushiBar/FormViewMail.cs new file mode 100644 index 0000000..6bc7378 --- /dev/null +++ b/SushiBar/SushiBar/FormViewMail.cs @@ -0,0 +1,39 @@ +using Microsoft.Extensions.Logging; +using SushiBarContracts.BusinessLogicsContracts; + + +namespace SushiBarView +{ + public partial class FormViewMail : Form + { + private readonly ILogger _logger; + private readonly IMessageInfoLogic _logic; + public FormViewMail(ILogger logger, IMessageInfoLogic logic) + { + InitializeComponent(); + _logger = logger; + _logic = logic; + } + private void FormViewMail_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/FormViewMail.resx b/SushiBar/SushiBar/FormViewMail.resx new file mode 100644 index 0000000..af32865 --- /dev/null +++ b/SushiBar/SushiBar/FormViewMail.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/Program.cs b/SushiBar/SushiBar/Program.cs index c546fba..4605c28 100644 --- a/SushiBar/SushiBar/Program.cs +++ b/SushiBar/SushiBar/Program.cs @@ -88,6 +88,7 @@ namespace SushiBarView services.AddTransient(); services.AddTransient(); services.AddTransient(); + services.AddTransient(); services.AddTransient(); diff --git a/SushiBar/SushiBar/SushiBarView.csproj b/SushiBar/SushiBar/SushiBarView.csproj index 8cfbc34..97e4567 100644 --- a/SushiBar/SushiBar/SushiBarView.csproj +++ b/SushiBar/SushiBar/SushiBarView.csproj @@ -29,4 +29,10 @@ + + + Always + + + \ No newline at end of file diff --git a/SushiBar/SushiBarBusinessLogic/BusinessLogics/MessageInfoLogic.cs b/SushiBar/SushiBarBusinessLogic/BusinessLogics/MessageInfoLogic.cs index dfecfb0..1579165 100644 --- a/SushiBar/SushiBarBusinessLogic/BusinessLogics/MessageInfoLogic.cs +++ b/SushiBar/SushiBarBusinessLogic/BusinessLogics/MessageInfoLogic.cs @@ -59,15 +59,10 @@ namespace SushiBarBusinessLogic { throw new ArgumentNullException("Не указао почта", nameof(model.SenderName)); } - if (string.IsNullOrEmpty(model.Subject)) - { - throw new ArgumentNullException("Не указана тема", nameof(model.Subject)); - } if (string.IsNullOrEmpty(model.Body)) { throw new ArgumentNullException("Не указан текст сообщения", nameof(model.Subject)); } - _logger.LogInformation("MessageInfo. MessageId:{MessageId}.SenderName:{SenderName}.Subject:{Subject}.Body:{Body}", model.MessageId, model.SenderName, model.Subject, model.Body); var element = _clientStorage.GetElement(new ClientSearchModel { diff --git a/SushiBar/SushiBarBusinessLogic/MailWorker/MailKitWorker.cs b/SushiBar/SushiBarBusinessLogic/MailWorker/MailKitWorker.cs index 19695b7..d396709 100644 --- a/SushiBar/SushiBarBusinessLogic/MailWorker/MailKitWorker.cs +++ b/SushiBar/SushiBarBusinessLogic/MailWorker/MailKitWorker.cs @@ -32,7 +32,7 @@ namespace SushiBarBusinessLogic.MailWorker objSmtpClient.DeliveryMethod = SmtpDeliveryMethod.Network; objSmtpClient.Credentials = new NetworkCredential(_mailLogin, _mailPassword); - await Task.Run(() => objSmtpClient.Send(objMailMessage)); + await Task.Run(() => objSmtpClient.Send(objMailMessage));////// вот тут выдаёт ошибку } catch (Exception) { diff --git a/SushiBar/SushiBarDatabaseImplement/Implements/MessageInfoStorage.cs b/SushiBar/SushiBarDatabaseImplement/Implements/MessageInfoStorage.cs index 1b9e480..529de05 100644 --- a/SushiBar/SushiBarDatabaseImplement/Implements/MessageInfoStorage.cs +++ b/SushiBar/SushiBarDatabaseImplement/Implements/MessageInfoStorage.cs @@ -23,17 +23,13 @@ namespace SushiBarDatabaseImplement.Implements { using var context = new SushiBarDatabase(); return context.Messages - .Where(x => x.ClientId == model.ClientId) - .Select(x => x.GetViewModel) - .ToList(); + .Where(x => x.ClientId == model.ClientId).Select(x => x.GetViewModel).ToList(); } public List GetFullList() { using var context = new SushiBarDatabase(); - return context.Messages - .Select(x => x.GetViewModel) - .ToList(); + return context.Messages.Select(x => x.GetViewModel).ToList(); } public MessageInfoViewModel? Insert(MessageInfoBindingModel model) diff --git a/SushiBar/SushiBarDatabaseImplement/Models/MessageInfo.cs b/SushiBar/SushiBarDatabaseImplement/Models/MessageInfo.cs index 3311430..10b0699 100644 --- a/SushiBar/SushiBarDatabaseImplement/Models/MessageInfo.cs +++ b/SushiBar/SushiBarDatabaseImplement/Models/MessageInfo.cs @@ -11,7 +11,7 @@ namespace SushiBarDatabaseImplement.Models [Key] public string MessageId { get; private set; } = string.Empty; - public int? ClientId { get; private set; } + public int? ClientId { get; private set; } public string SenderName { get; private set; } = string.Empty; diff --git a/SushiBar/SushiBarRestApi/appsettings.json b/SushiBar/SushiBarRestApi/appsettings.json index a5746b3..93780df 100644 --- a/SushiBar/SushiBarRestApi/appsettings.json +++ b/SushiBar/SushiBarRestApi/appsettings.json @@ -10,6 +10,6 @@ "SmtpClientPort": "587", "PopHost": "pop.gmail.com", "PopPort": "995", - "MailLogin": "89176335310x@gmail.com", - "MailPassword": "wmbu qrgy ocwl tadm" + "MailLogin": "allresourcesforlab@gmail.com", + "MailPassword": "eypt yuxk tylv dnpa" } \ No newline at end of file