diff --git a/RenovationWork/DataGridViewExtension.cs b/RenovationWork/DataGridViewExtension.cs new file mode 100644 index 0000000..05ce16b --- /dev/null +++ b/RenovationWork/DataGridViewExtension.cs @@ -0,0 +1,51 @@ +using RenovationWorkContracts.Attributes; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace RenovationWorkView +{ + internal static class DataGridViewExtension + { + public static void FillAndConfigGrid(this DataGridView grid, List? data) + { + if (data == null) + { + return; + } + grid.DataSource = data; + + var type = typeof(T); + var properties = type.GetProperties(); + foreach (DataGridViewColumn column in grid.Columns) + { + var property = properties.FirstOrDefault(x => x.Name == column.Name); + if (property == null) + { + throw new InvalidOperationException($"В типе {type.Name} не найдено свойство с именем {column.Name}"); + } + var attribute = property.GetCustomAttributes(typeof(ColumnAttribute), true)?.SingleOrDefault(); + if (attribute == null) + { + throw new InvalidOperationException($"Не найден атрибут типа ColumnAttribute для свойства {property.Name}"); + } + + if (attribute is ColumnAttribute columnAttr) + { + column.HeaderText = columnAttr.Title; + column.Visible = columnAttr.Visible; + if (columnAttr.IsUseAutoSize) + { + column.AutoSizeMode = (DataGridViewAutoSizeColumnMode)Enum.Parse(typeof(DataGridViewAutoSizeColumnMode), columnAttr.GridViewAutoSize.ToString()); + } + else + { + column.Width = columnAttr.Width; + } + } + } + } + } +} \ No newline at end of file diff --git a/RenovationWork/FormClients.cs b/RenovationWork/FormClients.cs index 736f8c1..d13fc39 100644 --- a/RenovationWork/FormClients.cs +++ b/RenovationWork/FormClients.cs @@ -31,16 +31,8 @@ namespace RenovationWorkView { try { - var list = _logic.ReadList(null); - if (list != null) - { - dataGridView.DataSource = list; - dataGridView.Columns["Id"].Visible = false; - dataGridView.Columns["ClientFIO"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; - dataGridView.Columns["Email"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; - dataGridView.Columns["Password"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; - } - _logger.LogInformation("Загрузка клиентов"); + dataGridView.FillAndConfigGrid(_logic.ReadList(null)); + _logger.LogInformation("Загрузка клиентов"); } catch (Exception ex) { diff --git a/RenovationWork/FormComponents.cs b/RenovationWork/FormComponents.cs index 3d741cf..fbbfaf7 100644 --- a/RenovationWork/FormComponents.cs +++ b/RenovationWork/FormComponents.cs @@ -10,6 +10,7 @@ using System.Windows.Forms; using RenovationWorkContracts.BindingModels; using RenovationWorkContracts.BusinessLogicsContracts; using Microsoft.Extensions.Logging; +using RenovationWorkContracts.DI; namespace RenovationWorkView { @@ -51,29 +52,24 @@ namespace RenovationWorkView private void buttonAdd_Click(object sender, EventArgs e) { - var service = Program.ServiceProvider?.GetService(typeof(FormComponent)); - if (service is FormComponent form) - { - if (form.ShowDialog() == DialogResult.OK) - { - LoadData(); - } - } + var form = DependencyManager.Instance.Resolve(); + if (form.ShowDialog() == DialogResult.OK) + { + LoadData(); + } } private void buttonUpd_Click(object sender, EventArgs e) { if (dataGridView.SelectedRows.Count == 1) { - var service = Program.ServiceProvider?.GetService(typeof(FormComponent)); - if (service is FormComponent form) - { - form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); - if (form.ShowDialog() == DialogResult.OK) - { - LoadData(); - } - } + var form = DependencyManager.Instance.Resolve(); + + form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); + if (form.ShowDialog() == DialogResult.OK) + { + LoadData(); + } } } diff --git a/RenovationWork/FormImplementers.cs b/RenovationWork/FormImplementers.cs index 3e99842..ec9bda0 100644 --- a/RenovationWork/FormImplementers.cs +++ b/RenovationWork/FormImplementers.cs @@ -32,17 +32,8 @@ namespace RenovationWorkView { try { - var list = _logic.ReadList(null); - if (list != null) - { - dataGridView.DataSource = list; - dataGridView.Columns["Id"].Visible = false; - dataGridView.Columns["ImplementerFIO"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; - dataGridView.Columns["Password"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; - dataGridView.Columns["Qualification"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; - dataGridView.Columns["WorkExperience"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; - } - _logger.LogInformation("Загрузка компонентов"); + dataGridView.FillAndConfigGrid(_logic.ReadList(null)); + _logger.LogInformation("Загрузка компонентов"); } catch (Exception ex) { diff --git a/RenovationWork/FormMail.cs b/RenovationWork/FormMail.cs index 125ecff..588bf38 100644 --- a/RenovationWork/FormMail.cs +++ b/RenovationWork/FormMail.cs @@ -27,14 +27,7 @@ namespace RenovationWorkView { 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; - } + dataGridView.FillAndConfigGrid(_logic.ReadList(null)); _logger.LogInformation("Загрузка списка писем"); } catch (Exception ex) diff --git a/RenovationWork/FormMain.Designer.cs b/RenovationWork/FormMain.Designer.cs index 4470da3..43aa5f1 100644 --- a/RenovationWork/FormMain.Designer.cs +++ b/RenovationWork/FormMain.Designer.cs @@ -39,23 +39,24 @@ componentRepairsПоИзделиямToolStripMenuItem = new ToolStripMenuItem(); OrdersToolStripMenuItem = new ToolStripMenuItem(); StartWorkingToolStripMenuItem = new ToolStripMenuItem(); + mailToolStripMenuItem = new ToolStripMenuItem(); + createBackUpToolStripMenuItem = 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.Items.AddRange(new ToolStripItem[] { refbooksToolStripMenuItem, отчетыToolStripMenuItem, StartWorkingToolStripMenuItem, mailToolStripMenuItem, createBackUpToolStripMenuItem }); menuStrip.Location = new Point(0, 0); menuStrip.Name = "menuStrip"; - menuStrip.Size = new Size(1129, 24); + menuStrip.Size = new Size(1236, 24); menuStrip.TabIndex = 0; menuStrip.Text = "menuStrip1"; // @@ -129,6 +130,20 @@ StartWorkingToolStripMenuItem.Text = "Запуск работ"; StartWorkingToolStripMenuItem.Click += StartWorkingToolStripMenuItem_Click_1; // + // mailToolStripMenuItem + // + mailToolStripMenuItem.Name = "mailToolStripMenuItem"; + mailToolStripMenuItem.Size = new Size(62, 20); + mailToolStripMenuItem.Text = "Письма"; + mailToolStripMenuItem.Click += mailToolStripMenuItem_Click; + // + // createBackUpToolStripMenuItem + // + createBackUpToolStripMenuItem.Name = "createBackUpToolStripMenuItem"; + createBackUpToolStripMenuItem.Size = new Size(97, 20); + createBackUpToolStripMenuItem.Text = "Создать бекап"; + createBackUpToolStripMenuItem.Click += createBackUpToolStripMenuItem_Click; + // // dataGridView // dataGridView.BackgroundColor = SystemColors.ControlLightLight; @@ -136,12 +151,13 @@ dataGridView.Location = new Point(12, 27); dataGridView.Name = "dataGridView"; dataGridView.RowTemplate.Height = 25; - dataGridView.Size = new Size(942, 341); + dataGridView.Size = new Size(1049, 341); dataGridView.TabIndex = 1; // // buttonCreateOrder // - buttonCreateOrder.Location = new Point(960, 42); + buttonCreateOrder.ImageAlign = ContentAlignment.MiddleRight; + buttonCreateOrder.Location = new Point(1067, 42); buttonCreateOrder.Name = "buttonCreateOrder"; buttonCreateOrder.Size = new Size(157, 23); buttonCreateOrder.TabIndex = 2; @@ -151,7 +167,8 @@ // // buttonTakeOrderInWork // - buttonTakeOrderInWork.Location = new Point(960, 71); + buttonTakeOrderInWork.ImageAlign = ContentAlignment.MiddleRight; + buttonTakeOrderInWork.Location = new Point(1067, 71); buttonTakeOrderInWork.Name = "buttonTakeOrderInWork"; buttonTakeOrderInWork.Size = new Size(157, 23); buttonTakeOrderInWork.TabIndex = 3; @@ -161,7 +178,8 @@ // // buttonOrderReady // - buttonOrderReady.Location = new Point(960, 100); + buttonOrderReady.ImageAlign = ContentAlignment.MiddleRight; + buttonOrderReady.Location = new Point(1067, 100); buttonOrderReady.Name = "buttonOrderReady"; buttonOrderReady.Size = new Size(157, 23); buttonOrderReady.TabIndex = 4; @@ -171,7 +189,8 @@ // // buttonIssuedOrder // - buttonIssuedOrder.Location = new Point(960, 129); + buttonIssuedOrder.ImageAlign = ContentAlignment.MiddleRight; + buttonIssuedOrder.Location = new Point(1067, 129); buttonIssuedOrder.Name = "buttonIssuedOrder"; buttonIssuedOrder.Size = new Size(157, 23); buttonIssuedOrder.TabIndex = 5; @@ -181,7 +200,8 @@ // // buttonRef // - buttonRef.Location = new Point(960, 158); + buttonRef.ImageAlign = ContentAlignment.MiddleRight; + buttonRef.Location = new Point(1067, 158); buttonRef.Name = "buttonRef"; buttonRef.Size = new Size(157, 23); buttonRef.TabIndex = 6; @@ -189,18 +209,11 @@ 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); + ClientSize = new Size(1236, 370); Controls.Add(buttonRef); Controls.Add(buttonIssuedOrder); Controls.Add(buttonOrderReady); @@ -239,5 +252,6 @@ private ToolStripMenuItem ImplementersToolStripMenuItem; private ToolStripMenuItem StartWorkingToolStripMenuItem; private ToolStripMenuItem mailToolStripMenuItem; + private ToolStripMenuItem createBackUpToolStripMenuItem; } } \ No newline at end of file diff --git a/RenovationWork/FormMain.cs b/RenovationWork/FormMain.cs index a05011b..6ed43d1 100644 --- a/RenovationWork/FormMain.cs +++ b/RenovationWork/FormMain.cs @@ -11,6 +11,7 @@ using RenovationWorkContracts.BindingModels; using RenovationWorkContracts.BusinessLogicsContracts; using Microsoft.Extensions.Logging; using RenovationWorkBusinessLogic.BusinessLogics; +using RenovationWorkContracts.DI; namespace RenovationWorkView { @@ -20,13 +21,15 @@ namespace RenovationWorkView private readonly IOrderLogic _orderLogic; private readonly IReportLogic _reportLogic; private readonly IWorkProcess _workProcess; - public FormMain(ILogger logger, IOrderLogic orderLogic, IReportLogic reportLogic, IWorkProcess workProcess) + private readonly IBackUpLogic _backUpLogic; + public FormMain(ILogger logger, IOrderLogic orderLogic, IReportLogic reportLogic, IWorkProcess workProcess, IBackUpLogic backUpLogic) { InitializeComponent(); _logger = logger; _orderLogic = orderLogic; _reportLogic = reportLogic; _workProcess = workProcess; + _backUpLogic = backUpLogic; } private void FormMain_Load(object sender, EventArgs e) @@ -35,20 +38,10 @@ namespace RenovationWorkView } 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; - } + dataGridView.FillAndConfigGrid(_orderLogic.ReadList(null)); + _logger.LogInformation("Загрузка заказов"); } catch (Exception ex) { @@ -59,30 +52,21 @@ namespace RenovationWorkView private void componentsToolStripMenuItem_Click(object sender, EventArgs e) { - var service = Program.ServiceProvider?.GetService(typeof(FormComponents)); - if (service is FormComponents form) - { - form.ShowDialog(); - } + var form = DependencyManager.Instance.Resolve(); + form.ShowDialog(); } private void JobTypeToolStripMenuItem_Click(object sender, EventArgs e) { - var service = Program.ServiceProvider?.GetService(typeof(FormRepairs)); - if (service is FormRepairs form) - { - form.ShowDialog(); - } + var form = DependencyManager.Instance.Resolve(); + 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(); - } + var form = DependencyManager.Instance.Resolve(); + form.ShowDialog(); + LoadData(); } private void buttonTakeOrderInWork_Click(object sender, EventArgs e) @@ -180,54 +164,63 @@ namespace RenovationWorkView private void componentRepairsПоИзделиямToolStripMenuItem_Click(object sender, EventArgs e) { - var service = Program.ServiceProvider?.GetService(typeof(FormReportRepairComponents)); - if (service is FormReportRepairComponents form) - { - form.ShowDialog(); - } + var form = DependencyManager.Instance.Resolve(); + form.ShowDialog(); } private void OrdersToolStripMenuItem_Click(object sender, EventArgs e) { - var service = Program.ServiceProvider?.GetService(typeof(FormReportOrders)); - if (service is FormReportOrders form) - { - form.ShowDialog(); - } + var form = DependencyManager.Instance.Resolve(); + form.ShowDialog(); } private void ClientsToolStripMenuItem_Click(object sender, EventArgs e) { - var service = Program.ServiceProvider?.GetService(typeof(FormClients)); - if (service is FormClients form) - { - form.ShowDialog(); - } + var form = DependencyManager.Instance.Resolve(); + form.ShowDialog(); } private void ImplementersToolStripMenuItem_Click(object sender, EventArgs e) { - var service = Program.ServiceProvider?.GetService(typeof(FormImplementers)); - if (service is FormImplementers form) - { - form.ShowDialog(); - } + var form = DependencyManager.Instance.Resolve(); + form.ShowDialog(); } private void StartWorkingToolStripMenuItem_Click_1(object sender, EventArgs e) { - _workProcess.DoWork((Program.ServiceProvider?.GetService(typeof(IImplementerLogic)) as IImplementerLogic)!, _orderLogic); + _workProcess.DoWork(DependencyManager.Instance.Resolve(), _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) + var form = DependencyManager.Instance.Resolve(); + form.ShowDialog(); + } + + private void createBackUpToolStripMenuItem_Click(object sender, EventArgs e) + { + try { - form.ShowDialog(); + if (_backUpLogic != null) + { + var fbd = new FolderBrowserDialog(); + if (fbd.ShowDialog() == DialogResult.OK) + { + _backUpLogic.CreateBackUp(new BackUpSaveBinidngModel + { + FolderName = fbd.SelectedPath + }); + MessageBox.Show("Бекап создан", "Сообщение", + MessageBoxButtons.OK, MessageBoxIcon.Information); + } + } + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка создания бэкапа", MessageBoxButtons.OK, + MessageBoxIcon.Error); } } } } - diff --git a/RenovationWork/FormRepair.cs b/RenovationWork/FormRepair.cs index 777b6cf..bf741be 100644 --- a/RenovationWork/FormRepair.cs +++ b/RenovationWork/FormRepair.cs @@ -12,6 +12,7 @@ using RenovationWorkContracts.BusinessLogicsContracts; using RenovationWorkContracts.SearchModels; using RenovationWorkDataModels.Models; using Microsoft.Extensions.Logging; +using RenovationWorkContracts.DI; namespace RenovationWorkView { @@ -78,51 +79,43 @@ namespace RenovationWorkView private void buttonAdd_Click(object sender, EventArgs e) { - var service = - Program.ServiceProvider?.GetService(typeof(FormRepairComponent)); - if (service is FormRepairComponent form) - if (form.ShowDialog() == DialogResult.OK) - { - if (form.ComponentModel == null) - { - return; - } - _logger.LogInformation("Добавление нового компонента: { ComponentName} - { Count}", form.ComponentModel.ComponentName, form.Count); - if (_repairComponents.ContainsKey(form.Id)) - { - _repairComponents[form.Id] = (form.ComponentModel, - form.Count); - } - else - { - _repairComponents.Add(form.Id, (form.ComponentModel, - form.Count)); - } - LoadData(); - } - } + var form = DependencyManager.Instance.Resolve(); + if (form.ShowDialog() == DialogResult.OK) + { + return; + } + _logger.LogInformation("Добавление нового компонента:{ ComponentName}-{ Count}", form.ComponentModel.ComponentName, form.Count); + if (_repairComponents.ContainsKey(form.Id)) + { + _repairComponents[form.Id] = (form.ComponentModel, + form.Count); + } + else + { + _repairComponents.Add(form.Id, (form.ComponentModel, + form.Count)); + } + LoadData(); + } - private void buttonUpd_Click(object sender, EventArgs e) + private void buttonUpd_Click(object sender, EventArgs e) { if (dataGridView.SelectedRows.Count == 1) { - var service = Program.ServiceProvider?.GetService(typeof(FormRepairComponent)); - if (service is FormRepairComponent form) - { - int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells[0].Value); - form.Id = id; - form.Count = _repairComponents[id].Item2; - if (form.ShowDialog() == DialogResult.OK) - { - if (form.ComponentModel == null) - { - return; - } - _logger.LogInformation("Изменение компонента: { ComponentName} - { Count} ", form.ComponentModel.ComponentName, form.Count); - _repairComponents[form.Id] = (form.ComponentModel, form.Count); - LoadData(); - } - } + var form = DependencyManager.Instance.Resolve(); + int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells[0].Value); + form.Id = id; + form.Count = _repairComponents[id].Item2; + if (form.ShowDialog() == DialogResult.OK) + { + if (form.ComponentModel == null) + { + return; + } + _logger.LogInformation("Изменение компонента:{ ComponentName}-{ Count}", form.ComponentModel.ComponentName, form.Count); + _repairComponents[form.Id] = (form.ComponentModel, form.Count); + LoadData(); + } } } diff --git a/RenovationWork/FormRepairs.cs b/RenovationWork/FormRepairs.cs index dc8d7f4..c19626f 100644 --- a/RenovationWork/FormRepairs.cs +++ b/RenovationWork/FormRepairs.cs @@ -10,6 +10,7 @@ using System.Windows.Forms; using RenovationWorkContracts.BindingModels; using RenovationWorkContracts.BusinessLogicsContracts; using Microsoft.Extensions.Logging; +using RenovationWorkContracts.DI; namespace RenovationWorkView { @@ -32,48 +33,35 @@ namespace RenovationWorkView { try { - var list = _logic.ReadList(null); - if (list != null) - { - dataGridView.DataSource = list; - dataGridView.Columns["Id"].Visible = false; - dataGridView.Columns["RepairName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; - dataGridView.Columns["RepairComponents"].Visible = false; - } - _logger.LogInformation("Загрузка компьютеров"); + dataGridView.FillAndConfigGrid(_logic.ReadList(null)); + _logger.LogInformation("Загрузка ремонтных работ"); } catch (Exception ex) { - _logger.LogError(ex, "Ошибка загрузки компьютеров"); + _logger.LogError(ex, "Ошибка загрузки ремонтных работ"); MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); } } private void buttonAdd_Click(object sender, EventArgs e) { - var service = Program.ServiceProvider?.GetService(typeof(FormRepair)); - if (service is FormRepair form) - { - if (form.ShowDialog() == DialogResult.OK) - { - LoadData(); - } - } + var form = DependencyManager.Instance.Resolve(); + if (form.ShowDialog() == DialogResult.OK) + { + LoadData(); + } } private void buttonUpd_Click(object sender, EventArgs e) { if (dataGridView.SelectedRows.Count == 1) { - var service = Program.ServiceProvider?.GetService(typeof(FormRepair)); - if (service is FormRepair form) - { - form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); - if (form.ShowDialog() == DialogResult.OK) - { - LoadData(); - } - } + var form = DependencyManager.Instance.Resolve(); + form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); + if (form.ShowDialog() == DialogResult.OK) + { + LoadData(); + } } } diff --git a/RenovationWork/Program.cs b/RenovationWork/Program.cs index 4e0a0f2..ec3a39d 100644 --- a/RenovationWork/Program.cs +++ b/RenovationWork/Program.cs @@ -9,6 +9,7 @@ using RenovationWorkDatabaseImplement.Implements; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; using NLog.Extensions.Logging; +using RenovationWorkContracts.DI; using System; @@ -27,12 +28,10 @@ namespace RenovationWorkView // 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(); + InitDependency(); try { - var mailSender = _serviceProvider.GetService(); + var mailSender = DependencyManager.Instance.Resolve(); mailSender?.MailConfig(new MailConfigBindingModel { MailLogin = System.Configuration.ConfigurationManager.AppSettings["MailLogin"] @@ -50,50 +49,51 @@ namespace RenovationWorkView } catch (Exception ex) { - var logger = _serviceProvider.GetService(); + var logger = DependencyManager.Instance.Resolve(); logger?.LogError(ex, " "); } - Application.Run(_serviceProvider.GetRequiredService()); + Application.Run(DependencyManager.Instance.Resolve()); } - private static void ConfigureServices(ServiceCollection services) - { - services.AddLogging(option => - { + private static void InitDependency() + { + DependencyManager.InitDependency(); + + DependencyManager.Instance.AddLogging(option => + { 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.AddSingleton(); - 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(); + + DependencyManager.Instance.RegisterType(); + DependencyManager.Instance.RegisterType(); + DependencyManager.Instance.RegisterType(); + DependencyManager.Instance.RegisterType(); + DependencyManager.Instance.RegisterType(); + DependencyManager.Instance.RegisterType(); + DependencyManager.Instance.RegisterType(); + DependencyManager.Instance.RegisterType(); + + DependencyManager.Instance.RegisterType(); + DependencyManager.Instance.RegisterType(); + DependencyManager.Instance.RegisterType(); + DependencyManager.Instance.RegisterType(true); + + DependencyManager.Instance.RegisterType(); + + DependencyManager.Instance.RegisterType(); + DependencyManager.Instance.RegisterType(); + DependencyManager.Instance.RegisterType(); + DependencyManager.Instance.RegisterType(); + DependencyManager.Instance.RegisterType(); + DependencyManager.Instance.RegisterType(); + DependencyManager.Instance.RegisterType(); + DependencyManager.Instance.RegisterType(); + DependencyManager.Instance.RegisterType(); + DependencyManager.Instance.RegisterType(); + DependencyManager.Instance.RegisterType(); + DependencyManager.Instance.RegisterType(); + DependencyManager.Instance.RegisterType(); } - private static void MailCheck(object obj) => ServiceProvider?.GetService()?.MailCheck(); + private static void MailCheck(object obj) => DependencyManager.Instance.Resolve()?.MailCheck(); } } \ No newline at end of file diff --git a/RenovationWork/ReportOrders.rdlc b/RenovationWork/ReportOrders.rdlc index 58944c4..828ff74 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 +