From 37b3d37d8a38c9e34334d5c2829e1f60251f1133 Mon Sep 17 00:00:00 2001 From: mayday Date: Sat, 22 Jun 2024 15:58:51 +0400 Subject: [PATCH] PIbd22_Kamcharova_K.A_lab7 --- RenovationWork/App.config | 11 + RenovationWork/FormMail.Designer.cs | 61 + RenovationWork/FormMail.cs | 48 + RenovationWork/FormMail.resx | 120 ++ RenovationWork/FormMain.Designer.cs | 461 +++---- RenovationWork/FormMain.cs | 393 +++--- RenovationWork/FormReportOrders.Designer.cs | 19 - RenovationWork/FormReportOrders.cs | 6 - RenovationWork/FormReportRepairComponents.cs | 3 - RenovationWork/Program.cs | 74 +- RenovationWork/RenovationWorkView.csproj | 7 - RenovationWork/ReportOrders.rdlc | 1174 ++++++++--------- .../BusinessLogics/ClientLogic.cs | 79 +- .../BusinessLogics/MessageInfoLogic.cs | 46 + .../BusinessLogics/OrderLogic.cs | 64 +- .../BusinessLogics/ReportLogic.cs | 20 +- .../MailWorker/AbstractMailWorker.cs | 83 ++ .../MailWorker/MailKitWorker.cs | 81 ++ .../OfficePackage/AbstractSaveToExcel.cs | 10 - .../OfficePackage/AbstractSaveToPdf.cs | 8 +- .../OfficePackage/AbstractSaveToWord.cs | 5 - .../HelperEnums/ExcelStyleInfoType.cs | 3 +- .../HelperEnums/PdfParagraphAlignmentType.cs | 1 - .../HelperModels/ExcelCellParameters.cs | 2 +- .../OfficePackage/HelperModels/PdfInfo.cs | 2 +- .../HelperModels/PdfParagraph.cs | 3 +- .../OfficePackage/HelperModels/WordInfo.cs | 3 +- .../HelperModels/WordParagraph.cs | 2 +- .../HelperModels/WordTextProperties.cs | 3 +- .../OfficePackage/Implements/SaveToExcel.cs | 44 +- .../OfficePackage/Implements/SaveToPdf.cs | 7 +- .../OfficePackage/Implements/SaveToWord.cs | 20 +- .../RenovationWorkBusinessLogic.csproj | 1 + RenovationWorkClientApp/APIClient.cs | 3 +- .../Controllers/HomeController.cs | 14 +- .../Views/Home/Mails.cshtml | 49 + .../Views/Shared/_Layout.cshtml | 3 + .../BindingModels/MailConfigBindingModel.cs | 18 + .../BindingModels/MailSendInfoBindingModel.cs | 15 + .../BindingModels/MessageInfoBindingModel.cs | 20 + .../IMessageInfoLogic.cs | 17 + .../BusinessLogicsContracts/IReportLogic.cs | 6 +- .../SearchModels/MessageInfoSearchModel.cs | 14 + .../StoragesContracts/IMessageInfoStorage.cs | 19 + .../ViewModels/MessageInfoViewModel.cs | 24 + .../ReportRepairComponentViewModel.cs | 2 +- .../Models/IMessageInfoModel.cs | 18 + .../Implements/MessageInfoStorage.cs | 53 + ...519185748_InitialCreateMail123.Designer.cs | 296 +++++ .../20240519185748_InitialCreateMail123.cs | 214 +++ .../RenovationWorkDatabaseModelSnapshot.cs | 39 + .../Models/MessageInfo.cs | 50 + .../RenovationWorkDatabase.cs | 5 +- .../DataFileSingleton.cs | 13 +- .../Implements/MessageInfoStorage.cs | 55 + .../Models/MessageInfo.cs | 71 + .../DataListSingleton.cs | 6 +- .../Implements/MessageInfoStorage.cs | 62 + .../Models/MessageInfo.cs | 46 + .../Controllers/ClientController.cs | 26 +- RenovationWorkRestApi/Program.cs | 20 + RenovationWorkRestApi/appsettings.json | 10 +- 62 files changed, 2799 insertions(+), 1253 deletions(-) create mode 100644 RenovationWork/App.config create mode 100644 RenovationWork/FormMail.Designer.cs create mode 100644 RenovationWork/FormMail.cs create mode 100644 RenovationWork/FormMail.resx create mode 100644 RenovationWorkBusinessLogic/BusinessLogics/MessageInfoLogic.cs create mode 100644 RenovationWorkBusinessLogic/MailWorker/AbstractMailWorker.cs create mode 100644 RenovationWorkBusinessLogic/MailWorker/MailKitWorker.cs create mode 100644 RenovationWorkClientApp/Views/Home/Mails.cshtml create mode 100644 RenovationWorkContracts/BindingModels/MailConfigBindingModel.cs create mode 100644 RenovationWorkContracts/BindingModels/MailSendInfoBindingModel.cs create mode 100644 RenovationWorkContracts/BindingModels/MessageInfoBindingModel.cs create mode 100644 RenovationWorkContracts/BusinessLogicsContracts/IMessageInfoLogic.cs create mode 100644 RenovationWorkContracts/SearchModels/MessageInfoSearchModel.cs create mode 100644 RenovationWorkContracts/StoragesContracts/IMessageInfoStorage.cs create mode 100644 RenovationWorkContracts/ViewModels/MessageInfoViewModel.cs create mode 100644 RenovationWorkDataModels/Models/IMessageInfoModel.cs create mode 100644 RenovationWorkDatabaseImplement/Implements/MessageInfoStorage.cs create mode 100644 RenovationWorkDatabaseImplement/Migrations/20240519185748_InitialCreateMail123.Designer.cs create mode 100644 RenovationWorkDatabaseImplement/Migrations/20240519185748_InitialCreateMail123.cs create mode 100644 RenovationWorkDatabaseImplement/Models/MessageInfo.cs create mode 100644 RenovationWorkFileImplement/Implements/MessageInfoStorage.cs create mode 100644 RenovationWorkFileImplement/Models/MessageInfo.cs create mode 100644 RenovationWorkListImplement/Implements/MessageInfoStorage.cs create mode 100644 RenovationWorkListImplement/Models/MessageInfo.cs diff --git a/RenovationWork/App.config b/RenovationWork/App.config new file mode 100644 index 0000000..443fdc6 --- /dev/null +++ b/RenovationWork/App.config @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/RenovationWork/FormMail.Designer.cs b/RenovationWork/FormMail.Designer.cs new file mode 100644 index 0000000..2f54e13 --- /dev/null +++ b/RenovationWork/FormMail.Designer.cs @@ -0,0 +1,61 @@ +namespace RenovationWorkView +{ + partial class FormMail + { + /// + /// 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(0, 0); + dataGridView.Name = "dataGridView"; + dataGridView.RowTemplate.Height = 25; + dataGridView.Size = new Size(761, 244); + dataGridView.TabIndex = 0; + // + // FormMail + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(761, 243); + Controls.Add(dataGridView); + Name = "FormMail"; + Text = "Письма"; + Load += FormMail_Load; + ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit(); + ResumeLayout(false); + } + + #endregion + + private DataGridView dataGridView; + } +} \ No newline at end of file diff --git a/RenovationWork/FormMail.cs b/RenovationWork/FormMail.cs new file mode 100644 index 0000000..125ecff --- /dev/null +++ b/RenovationWork/FormMail.cs @@ -0,0 +1,48 @@ +using Microsoft.Extensions.Logging; +using RenovationWorkContracts.BusinessLogicsContracts; +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 RenovationWorkView +{ + public partial class FormMail : Form + { + private readonly ILogger _logger; + private readonly IMessageInfoLogic _logic; + public FormMail(ILogger logger, IMessageInfoLogic logic) + { + InitializeComponent(); + _logger = logger; + _logic = logic; + } + + private void FormMail_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/RenovationWork/FormMail.resx b/RenovationWork/FormMail.resx new file mode 100644 index 0000000..af32865 --- /dev/null +++ b/RenovationWork/FormMail.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/RenovationWork/FormMain.Designer.cs b/RenovationWork/FormMain.Designer.cs index 011ff15..4470da3 100644 --- a/RenovationWork/FormMain.Designer.cs +++ b/RenovationWork/FormMain.Designer.cs @@ -1,234 +1,243 @@ namespace RenovationWorkView { - partial class FormMain - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; + partial class FormMain + { + /// + /// 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); - } + /// + /// 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 + #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() - { - menuStrip = new MenuStrip(); - refbooksToolStripMenuItem = new ToolStripMenuItem(); - componentsToolStripMenuItem = new ToolStripMenuItem(); - JobTypeToolStripMenuItem = new ToolStripMenuItem(); - ClientsToolStripMenuItem = new ToolStripMenuItem(); - ImplementersToolStripMenuItem = new ToolStripMenuItem(); - отчетыToolStripMenuItem = new ToolStripMenuItem(); - listComponentsToolStripMenuItem = new ToolStripMenuItem(); - componentRepairsПоИзделиямToolStripMenuItem = new ToolStripMenuItem(); - OrdersToolStripMenuItem = new ToolStripMenuItem(); - StartWorkingToolStripMenuItem = new ToolStripMenuItem(); - dataGridView = new DataGridView(); - buttonCreateOrder = new Button(); - buttonTakeOrderInWork = new Button(); - buttonOrderReady = new Button(); - buttonIssuedOrder = new Button(); - buttonRef = new Button(); - menuStrip.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit(); - SuspendLayout(); - // - // menuStrip - // - menuStrip.Items.AddRange(new ToolStripItem[] { refbooksToolStripMenuItem, отчетыToolStripMenuItem, StartWorkingToolStripMenuItem }); - menuStrip.Location = new Point(0, 0); - menuStrip.Name = "menuStrip"; - menuStrip.Size = new Size(1129, 24); - menuStrip.TabIndex = 0; - menuStrip.Text = "menuStrip1"; - // - // refbooksToolStripMenuItem - // - refbooksToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { componentsToolStripMenuItem, JobTypeToolStripMenuItem, ClientsToolStripMenuItem, ImplementersToolStripMenuItem }); - refbooksToolStripMenuItem.Name = "refbooksToolStripMenuItem"; - refbooksToolStripMenuItem.Size = new Size(94, 20); - refbooksToolStripMenuItem.Text = "Справочники"; - // - // componentsToolStripMenuItem - // - componentsToolStripMenuItem.Name = "componentsToolStripMenuItem"; - componentsToolStripMenuItem.Size = new Size(149, 22); - componentsToolStripMenuItem.Text = "Компоненты"; - componentsToolStripMenuItem.Click += componentsToolStripMenuItem_Click; - // - // JobTypeToolStripMenuItem - // - JobTypeToolStripMenuItem.Name = "JobTypeToolStripMenuItem"; - JobTypeToolStripMenuItem.Size = new Size(149, 22); - JobTypeToolStripMenuItem.Text = "Вид работы"; - JobTypeToolStripMenuItem.Click += JobTypeToolStripMenuItem_Click; - // - // ClientsToolStripMenuItem - // - ClientsToolStripMenuItem.Name = "ClientsToolStripMenuItem"; - ClientsToolStripMenuItem.Size = new Size(149, 22); - ClientsToolStripMenuItem.Text = "Клиенты"; - ClientsToolStripMenuItem.Click += ClientsToolStripMenuItem_Click; - // - // ImplementersToolStripMenuItem - // - ImplementersToolStripMenuItem.Name = "ImplementersToolStripMenuItem"; - ImplementersToolStripMenuItem.Size = new Size(149, 22); - ImplementersToolStripMenuItem.Text = "Исполнители"; - ImplementersToolStripMenuItem.Click += ImplementersToolStripMenuItem_Click; - // - // отчетыToolStripMenuItem - // - отчетыToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { listComponentsToolStripMenuItem, componentRepairsПоИзделиямToolStripMenuItem, OrdersToolStripMenuItem }); - отчетыToolStripMenuItem.Name = "отчетыToolStripMenuItem"; - отчетыToolStripMenuItem.Size = new Size(60, 20); - отчетыToolStripMenuItem.Text = "Отчеты"; - // - // listComponentsToolStripMenuItem - // - listComponentsToolStripMenuItem.Name = "listComponentsToolStripMenuItem"; - listComponentsToolStripMenuItem.Size = new Size(218, 22); - listComponentsToolStripMenuItem.Text = "Список изделий"; - listComponentsToolStripMenuItem.Click += listComponentsToolStripMenuItem_Click; - // - // componentRepairsПоИзделиямToolStripMenuItem - // - componentRepairsПоИзделиямToolStripMenuItem.Name = "componentRepairsПоИзделиямToolStripMenuItem"; - componentRepairsПоИзделиямToolStripMenuItem.Size = new Size(218, 22); - componentRepairsПоИзделиямToolStripMenuItem.Text = "Компоненты по изделиям"; - componentRepairsПоИзделиямToolStripMenuItem.Click += componentRepairsПоИзделиямToolStripMenuItem_Click; - // - // OrdersToolStripMenuItem - // - OrdersToolStripMenuItem.Name = "OrdersToolStripMenuItem"; - OrdersToolStripMenuItem.Size = new Size(218, 22); - OrdersToolStripMenuItem.Text = "Список заказов"; - OrdersToolStripMenuItem.Click += OrdersToolStripMenuItem_Click; - // - // StartWorkingToolStripMenuItem - // - StartWorkingToolStripMenuItem.Name = "StartWorkingToolStripMenuItem"; - StartWorkingToolStripMenuItem.Size = new Size(92, 20); - StartWorkingToolStripMenuItem.Text = "Запуск работ"; - StartWorkingToolStripMenuItem.Click += StartWorkingToolStripMenuItem_Click_1; - // - // dataGridView - // - dataGridView.BackgroundColor = SystemColors.ControlLightLight; - dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; - dataGridView.Location = new Point(12, 27); - dataGridView.Name = "dataGridView"; - dataGridView.RowTemplate.Height = 25; - dataGridView.Size = new Size(942, 341); - dataGridView.TabIndex = 1; - // - // buttonCreateOrder - // - buttonCreateOrder.Location = new Point(960, 42); - buttonCreateOrder.Name = "buttonCreateOrder"; - buttonCreateOrder.Size = new Size(157, 23); - buttonCreateOrder.TabIndex = 2; - buttonCreateOrder.Text = "Создать заказ"; - buttonCreateOrder.UseVisualStyleBackColor = true; - buttonCreateOrder.Click += buttonCreateOrder_Click; - // - // buttonTakeOrderInWork - // - buttonTakeOrderInWork.Location = new Point(960, 71); - buttonTakeOrderInWork.Name = "buttonTakeOrderInWork"; - buttonTakeOrderInWork.Size = new Size(157, 23); - buttonTakeOrderInWork.TabIndex = 3; - buttonTakeOrderInWork.Text = "Отладить на выполнение"; - buttonTakeOrderInWork.UseVisualStyleBackColor = true; - buttonTakeOrderInWork.Click += buttonTakeOrderInWork_Click; - // - // buttonOrderReady - // - buttonOrderReady.Location = new Point(960, 100); - buttonOrderReady.Name = "buttonOrderReady"; - buttonOrderReady.Size = new Size(157, 23); - buttonOrderReady.TabIndex = 4; - buttonOrderReady.Text = "Заказ готов"; - buttonOrderReady.UseVisualStyleBackColor = true; - buttonOrderReady.Click += buttonOrderReady_Click; - // - // buttonIssuedOrder - // - buttonIssuedOrder.Location = new Point(960, 129); - buttonIssuedOrder.Name = "buttonIssuedOrder"; - buttonIssuedOrder.Size = new Size(157, 23); - buttonIssuedOrder.TabIndex = 5; - buttonIssuedOrder.Text = "Заказ выдан"; - buttonIssuedOrder.UseVisualStyleBackColor = true; - buttonIssuedOrder.Click += buttonIssuedOrder_Click; - // - // buttonRef - // - buttonRef.Location = new Point(960, 158); - buttonRef.Name = "buttonRef"; - buttonRef.Size = new Size(157, 23); - buttonRef.TabIndex = 6; - buttonRef.Text = "Обновить список"; - buttonRef.UseVisualStyleBackColor = true; - buttonRef.Click += buttonRef_Click; - // - // FormMain - // - AutoScaleDimensions = new SizeF(7F, 15F); - AutoScaleMode = AutoScaleMode.Font; - ClientSize = new Size(1129, 370); - Controls.Add(buttonRef); - Controls.Add(buttonIssuedOrder); - Controls.Add(buttonOrderReady); - Controls.Add(buttonTakeOrderInWork); - Controls.Add(buttonCreateOrder); - Controls.Add(dataGridView); - Controls.Add(menuStrip); - MainMenuStrip = menuStrip; - Name = "FormMain"; - Text = "Ремонтные работы"; - Load += FormMain_Load; - menuStrip.ResumeLayout(false); - menuStrip.PerformLayout(); - ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit(); - ResumeLayout(false); - PerformLayout(); - } + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + menuStrip = new MenuStrip(); + refbooksToolStripMenuItem = new ToolStripMenuItem(); + componentsToolStripMenuItem = new ToolStripMenuItem(); + JobTypeToolStripMenuItem = new ToolStripMenuItem(); + ClientsToolStripMenuItem = new ToolStripMenuItem(); + ImplementersToolStripMenuItem = new ToolStripMenuItem(); + отчетыToolStripMenuItem = new ToolStripMenuItem(); + listComponentsToolStripMenuItem = new ToolStripMenuItem(); + componentRepairsПоИзделиямToolStripMenuItem = new ToolStripMenuItem(); + OrdersToolStripMenuItem = new ToolStripMenuItem(); + StartWorkingToolStripMenuItem = new ToolStripMenuItem(); + dataGridView = new DataGridView(); + buttonCreateOrder = new Button(); + buttonTakeOrderInWork = new Button(); + buttonOrderReady = new Button(); + buttonIssuedOrder = new Button(); + buttonRef = new Button(); + mailToolStripMenuItem = new ToolStripMenuItem(); + menuStrip.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit(); + SuspendLayout(); + // + // menuStrip + // + menuStrip.Items.AddRange(new ToolStripItem[] { refbooksToolStripMenuItem, отчетыToolStripMenuItem, StartWorkingToolStripMenuItem, mailToolStripMenuItem }); + menuStrip.Location = new Point(0, 0); + menuStrip.Name = "menuStrip"; + menuStrip.Size = new Size(1129, 24); + menuStrip.TabIndex = 0; + menuStrip.Text = "menuStrip1"; + // + // refbooksToolStripMenuItem + // + refbooksToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { componentsToolStripMenuItem, JobTypeToolStripMenuItem, ClientsToolStripMenuItem, ImplementersToolStripMenuItem }); + refbooksToolStripMenuItem.Name = "refbooksToolStripMenuItem"; + refbooksToolStripMenuItem.Size = new Size(94, 20); + refbooksToolStripMenuItem.Text = "Справочники"; + // + // componentsToolStripMenuItem + // + componentsToolStripMenuItem.Name = "componentsToolStripMenuItem"; + componentsToolStripMenuItem.Size = new Size(149, 22); + componentsToolStripMenuItem.Text = "Компоненты"; + componentsToolStripMenuItem.Click += componentsToolStripMenuItem_Click; + // + // JobTypeToolStripMenuItem + // + JobTypeToolStripMenuItem.Name = "JobTypeToolStripMenuItem"; + JobTypeToolStripMenuItem.Size = new Size(149, 22); + JobTypeToolStripMenuItem.Text = "Вид работы"; + JobTypeToolStripMenuItem.Click += JobTypeToolStripMenuItem_Click; + // + // ClientsToolStripMenuItem + // + ClientsToolStripMenuItem.Name = "ClientsToolStripMenuItem"; + ClientsToolStripMenuItem.Size = new Size(149, 22); + ClientsToolStripMenuItem.Text = "Клиенты"; + ClientsToolStripMenuItem.Click += ClientsToolStripMenuItem_Click; + // + // ImplementersToolStripMenuItem + // + ImplementersToolStripMenuItem.Name = "ImplementersToolStripMenuItem"; + ImplementersToolStripMenuItem.Size = new Size(149, 22); + ImplementersToolStripMenuItem.Text = "Исполнители"; + ImplementersToolStripMenuItem.Click += ImplementersToolStripMenuItem_Click; + // + // отчетыToolStripMenuItem + // + отчетыToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { listComponentsToolStripMenuItem, componentRepairsПоИзделиямToolStripMenuItem, OrdersToolStripMenuItem }); + отчетыToolStripMenuItem.Name = "отчетыToolStripMenuItem"; + отчетыToolStripMenuItem.Size = new Size(60, 20); + отчетыToolStripMenuItem.Text = "Отчеты"; + // + // listComponentsToolStripMenuItem + // + listComponentsToolStripMenuItem.Name = "listComponentsToolStripMenuItem"; + listComponentsToolStripMenuItem.Size = new Size(218, 22); + listComponentsToolStripMenuItem.Text = "Список изделий"; + listComponentsToolStripMenuItem.Click += listComponentsToolStripMenuItem_Click; + // + // componentRepairsПоИзделиямToolStripMenuItem + // + componentRepairsПоИзделиямToolStripMenuItem.Name = "componentRepairsПоИзделиямToolStripMenuItem"; + componentRepairsПоИзделиямToolStripMenuItem.Size = new Size(218, 22); + componentRepairsПоИзделиямToolStripMenuItem.Text = "Компоненты по изделиям"; + componentRepairsПоИзделиямToolStripMenuItem.Click += componentRepairsПоИзделиямToolStripMenuItem_Click; + // + // OrdersToolStripMenuItem + // + OrdersToolStripMenuItem.Name = "OrdersToolStripMenuItem"; + OrdersToolStripMenuItem.Size = new Size(218, 22); + OrdersToolStripMenuItem.Text = "Список заказов"; + OrdersToolStripMenuItem.Click += OrdersToolStripMenuItem_Click; + // + // StartWorkingToolStripMenuItem + // + StartWorkingToolStripMenuItem.Name = "StartWorkingToolStripMenuItem"; + StartWorkingToolStripMenuItem.Size = new Size(92, 20); + StartWorkingToolStripMenuItem.Text = "Запуск работ"; + StartWorkingToolStripMenuItem.Click += StartWorkingToolStripMenuItem_Click_1; + // + // dataGridView + // + dataGridView.BackgroundColor = SystemColors.ControlLightLight; + dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dataGridView.Location = new Point(12, 27); + dataGridView.Name = "dataGridView"; + dataGridView.RowTemplate.Height = 25; + dataGridView.Size = new Size(942, 341); + dataGridView.TabIndex = 1; + // + // buttonCreateOrder + // + buttonCreateOrder.Location = new Point(960, 42); + buttonCreateOrder.Name = "buttonCreateOrder"; + buttonCreateOrder.Size = new Size(157, 23); + buttonCreateOrder.TabIndex = 2; + buttonCreateOrder.Text = "Создать заказ"; + buttonCreateOrder.UseVisualStyleBackColor = true; + buttonCreateOrder.Click += buttonCreateOrder_Click; + // + // buttonTakeOrderInWork + // + buttonTakeOrderInWork.Location = new Point(960, 71); + buttonTakeOrderInWork.Name = "buttonTakeOrderInWork"; + buttonTakeOrderInWork.Size = new Size(157, 23); + buttonTakeOrderInWork.TabIndex = 3; + buttonTakeOrderInWork.Text = "Отладить на выполнение"; + buttonTakeOrderInWork.UseVisualStyleBackColor = true; + buttonTakeOrderInWork.Click += buttonTakeOrderInWork_Click; + // + // buttonOrderReady + // + buttonOrderReady.Location = new Point(960, 100); + buttonOrderReady.Name = "buttonOrderReady"; + buttonOrderReady.Size = new Size(157, 23); + buttonOrderReady.TabIndex = 4; + buttonOrderReady.Text = "Заказ готов"; + buttonOrderReady.UseVisualStyleBackColor = true; + buttonOrderReady.Click += buttonOrderReady_Click; + // + // buttonIssuedOrder + // + buttonIssuedOrder.Location = new Point(960, 129); + buttonIssuedOrder.Name = "buttonIssuedOrder"; + buttonIssuedOrder.Size = new Size(157, 23); + buttonIssuedOrder.TabIndex = 5; + buttonIssuedOrder.Text = "Заказ выдан"; + buttonIssuedOrder.UseVisualStyleBackColor = true; + buttonIssuedOrder.Click += buttonIssuedOrder_Click; + // + // buttonRef + // + buttonRef.Location = new Point(960, 158); + buttonRef.Name = "buttonRef"; + buttonRef.Size = new Size(157, 23); + buttonRef.TabIndex = 6; + buttonRef.Text = "Обновить список"; + buttonRef.UseVisualStyleBackColor = true; + buttonRef.Click += buttonRef_Click; + // + // mailToolStripMenuItem + // + mailToolStripMenuItem.Name = "mailToolStripMenuItem"; + mailToolStripMenuItem.Size = new Size(62, 20); + mailToolStripMenuItem.Text = "Письма"; + mailToolStripMenuItem.Click += mailToolStripMenuItem_Click; + // + // FormMain + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(1129, 370); + Controls.Add(buttonRef); + Controls.Add(buttonIssuedOrder); + Controls.Add(buttonOrderReady); + Controls.Add(buttonTakeOrderInWork); + Controls.Add(buttonCreateOrder); + Controls.Add(dataGridView); + Controls.Add(menuStrip); + MainMenuStrip = menuStrip; + Name = "FormMain"; + Text = "Ремонтные работы"; + Load += FormMain_Load; + menuStrip.ResumeLayout(false); + menuStrip.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit(); + ResumeLayout(false); + PerformLayout(); + } - #endregion + #endregion - private MenuStrip menuStrip; - private ToolStripMenuItem refbooksToolStripMenuItem; - private ToolStripMenuItem componentsToolStripMenuItem; - private ToolStripMenuItem JobTypeToolStripMenuItem; - private DataGridView dataGridView; - private Button buttonCreateOrder; - private Button buttonTakeOrderInWork; - private Button buttonOrderReady; - private Button buttonIssuedOrder; - private Button buttonRef; - private ToolStripMenuItem отчетыToolStripMenuItem; - private ToolStripMenuItem listComponentsToolStripMenuItem; - private ToolStripMenuItem componentRepairsПоИзделиямToolStripMenuItem; - private ToolStripMenuItem OrdersToolStripMenuItem; - private ToolStripMenuItem ClientsToolStripMenuItem; - private ToolStripMenuItem ImplementersToolStripMenuItem; - private ToolStripMenuItem StartWorkingToolStripMenuItem; - } + private MenuStrip menuStrip; + private ToolStripMenuItem refbooksToolStripMenuItem; + private ToolStripMenuItem componentsToolStripMenuItem; + private ToolStripMenuItem JobTypeToolStripMenuItem; + private DataGridView dataGridView; + private Button buttonCreateOrder; + private Button buttonTakeOrderInWork; + private Button buttonOrderReady; + private Button buttonIssuedOrder; + private Button buttonRef; + private ToolStripMenuItem отчетыToolStripMenuItem; + private ToolStripMenuItem listComponentsToolStripMenuItem; + private ToolStripMenuItem componentRepairsПоИзделиямToolStripMenuItem; + private ToolStripMenuItem OrdersToolStripMenuItem; + private ToolStripMenuItem ClientsToolStripMenuItem; + private ToolStripMenuItem ImplementersToolStripMenuItem; + private ToolStripMenuItem StartWorkingToolStripMenuItem; + private ToolStripMenuItem mailToolStripMenuItem; + } } \ No newline at end of file diff --git a/RenovationWork/FormMain.cs b/RenovationWork/FormMain.cs index 7f92ffd..a05011b 100644 --- a/RenovationWork/FormMain.cs +++ b/RenovationWork/FormMain.cs @@ -14,211 +14,220 @@ using RenovationWorkBusinessLogic.BusinessLogics; namespace RenovationWorkView { - public partial class FormMain : Form - { - private readonly ILogger _logger; - private readonly IOrderLogic _orderLogic; - private readonly IReportLogic _reportLogic; - private readonly IWorkProcess _workProcess; - public FormMain(ILogger logger, IOrderLogic orderLogic, IReportLogic reportLogic, IWorkProcess workProcess) - { - InitializeComponent(); - _logger = logger; - _orderLogic = orderLogic; - _reportLogic = reportLogic; - _workProcess = workProcess; - } + public partial class FormMain : Form + { + private readonly ILogger _logger; + private readonly IOrderLogic _orderLogic; + private readonly IReportLogic _reportLogic; + private readonly IWorkProcess _workProcess; + public FormMain(ILogger logger, IOrderLogic orderLogic, IReportLogic reportLogic, IWorkProcess workProcess) + { + InitializeComponent(); + _logger = logger; + _orderLogic = orderLogic; + _reportLogic = reportLogic; + _workProcess = workProcess; + } - private void FormMain_Load(object sender, EventArgs e) - { - LoadData(); - } - private void LoadData() - { - _logger.LogInformation("Загрузка заказов"); - try - { - var list = _orderLogic.ReadList(null); - if (list != null) - { - dataGridView.DataSource = list; - dataGridView.Columns["RepairId"].Visible = false; - dataGridView.Columns["ImplementerId"].Visible = false; - dataGridView.Columns["ClientId"].Visible = false; - dataGridView.Columns["RepairName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; - dataGridView.Columns["ClientFIO"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; - dataGridView.Columns["ImplementerFIO"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; - } - } - catch (Exception ex) - { - _logger.LogError(ex, "Ошибка загрузки заказов"); - MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); - } - } + private void FormMain_Load(object sender, EventArgs e) + { + LoadData(); + } + private void LoadData() + { + _logger.LogInformation("Загрузка заказов"); + try + { + var list = _orderLogic.ReadList(null); + if (list != null) + { + dataGridView.DataSource = list; + dataGridView.Columns["RepairId"].Visible = false; + dataGridView.Columns["ImplementerId"].Visible = false; + dataGridView.Columns["ClientId"].Visible = false; + dataGridView.Columns["RepairName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; + dataGridView.Columns["ClientFIO"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; + dataGridView.Columns["ImplementerFIO"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; + } + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка загрузки заказов"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } - private void componentsToolStripMenuItem_Click(object sender, EventArgs e) - { - var service = Program.ServiceProvider?.GetService(typeof(FormComponents)); - if (service is FormComponents form) - { - form.ShowDialog(); - } - } + private void componentsToolStripMenuItem_Click(object sender, EventArgs e) + { + var service = Program.ServiceProvider?.GetService(typeof(FormComponents)); + if (service is FormComponents form) + { + form.ShowDialog(); + } + } - private void JobTypeToolStripMenuItem_Click(object sender, EventArgs e) - { - var service = Program.ServiceProvider?.GetService(typeof(FormRepairs)); - if (service is FormRepairs form) - { - form.ShowDialog(); - } - } + private void JobTypeToolStripMenuItem_Click(object sender, EventArgs e) + { + var service = Program.ServiceProvider?.GetService(typeof(FormRepairs)); + if (service is FormRepairs form) + { + form.ShowDialog(); + } + } - private void buttonCreateOrder_Click(object sender, EventArgs e) - { - var service = Program.ServiceProvider?.GetService(typeof(FormCreateOrder)); - if (service is FormCreateOrder form) - { - form.ShowDialog(); - LoadData(); - } - } + private void buttonCreateOrder_Click(object sender, EventArgs e) + { + var service = Program.ServiceProvider?.GetService(typeof(FormCreateOrder)); + if (service is FormCreateOrder form) + { + form.ShowDialog(); + LoadData(); + } + } - private void buttonTakeOrderInWork_Click(object sender, EventArgs e) - { - if (dataGridView.SelectedRows.Count == 1) - { - int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); - _logger.LogInformation("Заказ №{id}. Меняется статус на 'В работе'", id); - try - { - var operationResult = _orderLogic.TakeOrderInWork(new OrderBindingModel { Id = id }); - if (!operationResult) - { - throw new Exception("Ошибка при сохранении. Дополнительная информация в логах."); - } - LoadData(); - } - catch (Exception ex) - { - _logger.LogError(ex, "Ошибка передачи заказа в работу"); - MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); - } - } - } + private void buttonTakeOrderInWork_Click(object sender, EventArgs e) + { + if (dataGridView.SelectedRows.Count == 1) + { + int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); + _logger.LogInformation("Заказ №{id}. Меняется статус на 'В работе'", id); + try + { + var operationResult = _orderLogic.TakeOrderInWork(new OrderBindingModel { Id = id }); + if (!operationResult) + { + throw new Exception("Ошибка при сохранении. Дополнительная информация в логах."); + } + LoadData(); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка передачи заказа в работу"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + } - private void buttonOrderReady_Click(object sender, EventArgs e) - { - if (dataGridView.SelectedRows.Count == 1) - { - int id = - Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); - _logger.LogInformation("Заказ №{id}. Меняется статус на 'Готов'", id); - try - { - var operationResult = _orderLogic.FinishOrder(new - OrderBindingModel - { Id = id }); - if (!operationResult) - { - throw new Exception("Ошибка при сохранении. Дополнительная информация в логах."); - } - LoadData(); - } - catch (Exception ex) - { - _logger.LogError(ex, "Ошибка отметки о готовности заказа"); - MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); - } - } - } + private void buttonOrderReady_Click(object sender, EventArgs e) + { + if (dataGridView.SelectedRows.Count == 1) + { + int id = + Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); + _logger.LogInformation("Заказ №{id}. Меняется статус на 'Готов'", id); + try + { + var operationResult = _orderLogic.FinishOrder(new + OrderBindingModel + { Id = id }); + if (!operationResult) + { + throw new Exception("Ошибка при сохранении. Дополнительная информация в логах."); + } + LoadData(); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка отметки о готовности заказа"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + } - private void buttonIssuedOrder_Click(object sender, EventArgs e) - { - if (dataGridView.SelectedRows.Count == 1) - { - int id = - Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); - _logger.LogInformation("Заказ №{id}. Меняется статус на 'Выдан'", id); - try - { - var operationResult = _orderLogic.DeliveryOrder(new OrderBindingModel { Id = id }); - if (!operationResult) - { - throw new Exception("Ошибка при сохранении. Дополнительная информация в логах."); - } - _logger.LogInformation("Заказ №{id} выдан", id); - LoadData(); - } - catch (Exception ex) - { - _logger.LogError(ex, "Ошибка отметки о выдачи заказа"); - MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); - } - } - } + private void buttonIssuedOrder_Click(object sender, EventArgs e) + { + if (dataGridView.SelectedRows.Count == 1) + { + int id = + Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); + _logger.LogInformation("Заказ №{id}. Меняется статус на 'Выдан'", id); + try + { + var operationResult = _orderLogic.DeliveryOrder(new OrderBindingModel { Id = id }); + if (!operationResult) + { + throw new Exception("Ошибка при сохранении. Дополнительная информация в логах."); + } + _logger.LogInformation("Заказ №{id} выдан", id); + LoadData(); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка отметки о выдачи заказа"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + } - private void buttonRef_Click(object sender, EventArgs e) - { - LoadData(); - } + private void buttonRef_Click(object sender, EventArgs e) + { + LoadData(); + } - private void listComponentsToolStripMenuItem_Click(object sender, EventArgs e) - { - using var dialog = new SaveFileDialog { Filter = "docx|*.docx" }; - if (dialog.ShowDialog() == DialogResult.OK) - { - _reportLogic.SaveRepairsToWordFile(new ReportBindingModel - { - FileName = dialog.FileName - }); - MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK, - MessageBoxIcon.Information); - } - } + private void listComponentsToolStripMenuItem_Click(object sender, EventArgs e) + { + using var dialog = new SaveFileDialog { Filter = "docx|*.docx" }; + if (dialog.ShowDialog() == DialogResult.OK) + { + _reportLogic.SaveRepairsToWordFile(new ReportBindingModel + { + FileName = dialog.FileName + }); + MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK, + MessageBoxIcon.Information); + } + } - private void componentRepairsПоИзделиямToolStripMenuItem_Click(object sender, EventArgs e) - { - var service = Program.ServiceProvider?.GetService(typeof(FormReportRepairComponents)); - if (service is FormReportRepairComponents form) - { - form.ShowDialog(); - } - } + private void componentRepairsПоИзделиямToolStripMenuItem_Click(object sender, EventArgs e) + { + var service = Program.ServiceProvider?.GetService(typeof(FormReportRepairComponents)); + if (service is FormReportRepairComponents form) + { + form.ShowDialog(); + } + } - private void OrdersToolStripMenuItem_Click(object sender, EventArgs e) - { - var service = Program.ServiceProvider?.GetService(typeof(FormReportOrders)); - if (service is FormReportOrders form) - { - form.ShowDialog(); - } - } + private void OrdersToolStripMenuItem_Click(object sender, EventArgs e) + { + var service = Program.ServiceProvider?.GetService(typeof(FormReportOrders)); + if (service is FormReportOrders form) + { + form.ShowDialog(); + } + } - private void ClientsToolStripMenuItem_Click(object sender, EventArgs e) - { - var service = Program.ServiceProvider?.GetService(typeof(FormClients)); - if (service is FormClients form) - { - form.ShowDialog(); - } - } + private void ClientsToolStripMenuItem_Click(object sender, EventArgs e) + { + var service = Program.ServiceProvider?.GetService(typeof(FormClients)); + if (service is FormClients form) + { + form.ShowDialog(); + } + } - private void ImplementersToolStripMenuItem_Click(object sender, EventArgs e) - { - var service = Program.ServiceProvider?.GetService(typeof(FormImplementers)); - if (service is FormImplementers form) - { - form.ShowDialog(); - } - } + private void ImplementersToolStripMenuItem_Click(object sender, EventArgs e) + { + var service = Program.ServiceProvider?.GetService(typeof(FormImplementers)); + if (service is FormImplementers form) + { + form.ShowDialog(); + } + } - private void StartWorkingToolStripMenuItem_Click_1(object sender, EventArgs e) - { - _workProcess.DoWork((Program.ServiceProvider?.GetService(typeof(IImplementerLogic)) as IImplementerLogic)!, _orderLogic); - MessageBox.Show("Процесс обработки запущен", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information); - } - } + private void StartWorkingToolStripMenuItem_Click_1(object sender, EventArgs e) + { + _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(FormMail)); + if (service is FormMail form) + { + form.ShowDialog(); + } + } + } } diff --git a/RenovationWork/FormReportOrders.Designer.cs b/RenovationWork/FormReportOrders.Designer.cs index 2e064af..d1cdeb3 100644 --- a/RenovationWork/FormReportOrders.Designer.cs +++ b/RenovationWork/FormReportOrders.Designer.cs @@ -31,8 +31,6 @@ panel = new Panel(); buttonToPdf = new Button(); buttonMake = new Button(); - labelTo = new Label(); - labelFrom = new Label(); dateTimePickerTo = new DateTimePicker(); dateTimePickerFrom = new DateTimePicker(); labelTo = new Label(); @@ -44,8 +42,6 @@ // panel.Controls.Add(buttonToPdf); panel.Controls.Add(buttonMake); - panel.Controls.Add(labelTo); - panel.Controls.Add(labelFrom); panel.Controls.Add(dateTimePickerTo); panel.Controls.Add(dateTimePickerFrom); panel.Controls.Add(labelTo); @@ -108,20 +104,6 @@ labelFrom.TabIndex = 0; labelFrom.Text = "С"; // - // dateTimePickerTo - // - dateTimePickerTo.Location = new Point(264, 6); - dateTimePickerTo.Name = "dateTimePickerTo"; - dateTimePickerTo.Size = new Size(200, 23); - dateTimePickerTo.TabIndex = 1; - // - // dateTimePickerFrom - // - dateTimePickerFrom.Location = new Point(31, 5); - dateTimePickerFrom.Name = "dateTimePickerFrom"; - dateTimePickerFrom.Size = new Size(200, 23); - dateTimePickerFrom.TabIndex = 0; - // // FormReportOrders // AutoScaleDimensions = new SizeF(7F, 15F); @@ -144,6 +126,5 @@ private Button buttonToPdf; private Button buttonMake; private DateTimePicker dateTimePickerTo; - private DateTimePicker dateTimePickerFrom; } } \ No newline at end of file diff --git a/RenovationWork/FormReportOrders.cs b/RenovationWork/FormReportOrders.cs index 2e5df93..cbc6ff2 100644 --- a/RenovationWork/FormReportOrders.cs +++ b/RenovationWork/FormReportOrders.cs @@ -11,11 +11,6 @@ using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; -using RenovationWorkContracts.BindingModels; -using RenovationWorkContracts.BusinessLogicsContracts; -using Microsoft.Extensions.Logging; -using Microsoft.Reporting.WinForms; - namespace RenovationWorkView { @@ -103,4 +98,3 @@ namespace RenovationWorkView } } } - diff --git a/RenovationWork/FormReportRepairComponents.cs b/RenovationWork/FormReportRepairComponents.cs index 82d6411..c92179e 100644 --- a/RenovationWork/FormReportRepairComponents.cs +++ b/RenovationWork/FormReportRepairComponents.cs @@ -10,9 +10,6 @@ using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; -using Microsoft.Extensions.Logging; -using RenovationWorkContracts.BindingModels; -using RenovationWorkContracts.BusinessLogicsContracts; namespace RenovationWorkView { diff --git a/RenovationWork/Program.cs b/RenovationWork/Program.cs index a65e4c4..4e0a0f2 100644 --- a/RenovationWork/Program.cs +++ b/RenovationWork/Program.cs @@ -1,3 +1,5 @@ +using RenovationWorkBusinessLogic.MailWorker; +using RenovationWorkContracts.BindingModels; using RenovationWorkBusinessLogic.BusinessLogics; using RenovationWorkBusinessLogic.OfficePackage.Implements; using RenovationWorkBusinessLogic.OfficePackage; @@ -12,25 +14,48 @@ using System; namespace RenovationWorkView { - internal static class Program - { - private static ServiceProvider? _serviceProvider; - public static ServiceProvider? ServiceProvider => _serviceProvider; - /// - /// The main entry point for the application. - /// - [STAThread] - static void Main() - { - // To customize application configuration such as set high DPI settings or default font, - // see https://aka.ms/applicationconfiguration. - ApplicationConfiguration.Initialize(); - var services = new ServiceCollection(); - ConfigureServices(services); - _serviceProvider = services.BuildServiceProvider(); - Application.Run(_serviceProvider.GetRequiredService()); - } - private static void ConfigureServices(ServiceCollection services) + internal static class Program + { + private static ServiceProvider? _serviceProvider; + public static ServiceProvider? ServiceProvider => _serviceProvider; + /// + /// The main entry point for the application. + /// + [STAThread] + static void Main() + { + // To customize application configuration such as set high DPI settings or default font, + // see https://aka.ms/applicationconfiguration. + ApplicationConfiguration.Initialize(); + var services = new ServiceCollection(); + ConfigureServices(services); + _serviceProvider = services.BuildServiceProvider(); + 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) { services.AddLogging(option => { @@ -51,7 +76,10 @@ namespace RenovationWorkView services.AddTransient(); services.AddTransient(); services.AddTransient(); - services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddSingleton(); + services.AddTransient(); services.AddTransient(); services.AddTransient(); services.AddTransient(); @@ -64,6 +92,8 @@ namespace RenovationWorkView services.AddTransient(); services.AddTransient(); services.AddTransient(); - } - } + services.AddTransient(); + } + private static void MailCheck(object obj) => ServiceProvider?.GetService()?.MailCheck(); + } } \ No newline at end of file diff --git a/RenovationWork/RenovationWorkView.csproj b/RenovationWork/RenovationWorkView.csproj index a16925b..5e3ee9b 100644 --- a/RenovationWork/RenovationWorkView.csproj +++ b/RenovationWork/RenovationWorkView.csproj @@ -16,7 +16,6 @@ - @@ -47,10 +46,4 @@ - - - Always - - - \ No newline at end of file diff --git a/RenovationWork/ReportOrders.rdlc b/RenovationWork/ReportOrders.rdlc index 828ff74..58944c4 100644 --- a/RenovationWork/ReportOrders.rdlc +++ b/RenovationWork/ReportOrders.rdlc @@ -1,599 +1,599 @@ - 0 - - - - System.Data.DataSet - /* Local Connection */ - - 47cb53f0-7dde-4717-ba03-866a0bc4f4dd - - - - - - RenovationWorkContractsViewModels - /* Local Query */ - - - - Id - System.Int32 - - - DateCreate - System.DateTime - + 0 + + + + System.Data.DataSet + /* Local Connection */ + + 47cb53f0-7dde-4717-ba03-866a0bc4f4dd + + + + + + RenovationWorkContractsViewModels + /* Local Query */ + + + + Id + System.Int32 + + + DateCreate + System.DateTime + RepairName - System.String - - - Sum - System.Decimal - + System.String + + + Sum + System.Decimal + Status RenovationWorkDataModels.Status - - - - RenovationWorkContracts.ViewModels - ReportOrderViewModel - RenovationWorkContracts.ViewModels.ReportOrderViewModel, RenovationWorkContracts, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null - - - - - - - - - true - true - - - - - =Parameters!ReportParameterPeriod.Value - - - - - - - ReportParameterPeriod - 1cm - 1cm - 21cm - - - Middle - 2pt - 2pt - 2pt - 2pt - - - - true - true - - - - - Список заказов - - - - - - - 1cm - 21cm - 1 - - - Middle - 2pt - 2pt - 2pt - 2pt - - - - - - - 2.5cm - - - 3.21438cm - - - 8.23317cm - - - 2.5cm - - - 2.5cm - - - - - 0.6cm - - - - - true - true - - - - - Номер - - - - - - 2pt - 2pt - 2pt - 2pt - - - - - - - - true - true - - - - - Дата заказа - - - - - - 2pt - 2pt - 2pt - 2pt - - - - - - - - true - true - - - - - Изделие - - - - - - 2pt - 2pt - 2pt - 2pt - - - - - - - - true - true - - - - - Сумма - - - - - - 2pt - 2pt - 2pt - 2pt - - - - - - - - true - true - - - - - Статус - - - - - - 2pt - 2pt - 2pt - 2pt - - - - - - - - 0.6cm - - - - - true - true - - - - - =Fields!Id.Value - - - 2pt - 2pt - 2pt - 2pt - - - - - - - - true - true - - - - - =Fields!DateCreate.Value - - - - - - 2pt - 2pt - 2pt - 2pt - - - - - - + + + + RenovationWorkContracts.ViewModels + ReportOrderViewModel + RenovationWorkContracts.ViewModels.ReportOrderViewModel, RenovationWorkContracts, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null + + + + + + + + + true + true + + + + + =Parameters!ReportParameterPeriod.Value + + + + + + + ReportParameterPeriod + 1cm + 1cm + 21cm + + + Middle + 2pt + 2pt + 2pt + 2pt + + + + true + true + + + + + Список заказов + + + + + + + 1cm + 21cm + 1 + + + Middle + 2pt + 2pt + 2pt + 2pt + + + + + + + 2.5cm + + + 3.21438cm + + + 8.23317cm + + + 2.5cm + + + 2.5cm + + + + + 0.6cm + + + + + true + true + + + + + Номер + + + + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + Дата заказа + + + + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + Изделие + + + + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + Сумма + + + + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + Статус + + + + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + 0.6cm + + + + + true + true + + + + + =Fields!Id.Value + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + =Fields!DateCreate.Value + + + + + + 2pt + 2pt + 2pt + 2pt + + + + + + - true - true - - - - - =Fields!RepairName.Value - - - 2pt - 2pt - 2pt - 2pt - - - - - - - - true - true - - - - - =Fields!Sum.Value - - - 2pt - 2pt - 2pt - 2pt - - - - - - + true + true + + + + + =Fields!RepairName.Value + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + =Fields!Sum.Value + + + 2pt + 2pt + 2pt + 2pt + + + + + + - true - true - - - - + true + true + + + + =Fields!Status.Value - - - 2pt - 2pt - 2pt - 2pt - - - - - - - - - - - - - - - - - - - - - After - - - - - - - DataSetOrders - 2.48391cm - 0.55245cm - 1.2cm - 18.94755cm - 2 - - - - - - true - true - - - - - Итого: - - - - - - - 4cm - 12cm - 0.6cm - 2.5cm - 3 - - - 2pt - 2pt - 2pt - 2pt - - - - true - true - - - - - =Sum(Fields!Sum.Value, "DataSetOrders") - - - - - - - 4cm - 14.5cm - 0.6cm - 2.5cm - 4 - - - 2pt - 2pt - 2pt - 2pt - - - - 5.72875cm - + + 2pt + 2pt + 2pt + 2pt + + + + + + + + + + + + + + + + + + + + + After + + + + + + + DataSetOrders + 2.48391cm + 0.55245cm + 1.2cm + 18.94755cm + 2 + + + + + + true + true + + + + + Итого: + + + + + + + 4cm + 12cm + 0.6cm + 2.5cm + 3 + + + 2pt + 2pt + 2pt + 2pt + + + + true + true + + + + + =Sum(Fields!Sum.Value, "DataSetOrders") + + + + + + + 4cm + 14.5cm + 0.6cm + 2.5cm + 4 + + + 2pt + 2pt + 2pt + 2pt + + + + 5.72875cm +