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; using Contracts.BusinessLogic; using Contracts.BindingModels; using System.Diagnostics; namespace Forms { public partial class FormReportCompanies : Form { private readonly ILogger _logger; private readonly IVoyageLogic _logic; public FormReportCompanies(ILogger logger, IVoyageLogic logic) { InitializeComponent(); _logger = logger; _logic = logic; } private void FormReportHumans_Load(object sender, EventArgs e) { LoadData(); } private void LoadData() { try { Stopwatch stopwatch = new Stopwatch(); stopwatch.Start(); var list = _logic.GetCompanysPath(); stopwatch.Stop(); var time = stopwatch.ElapsedMilliseconds; timelabel.Text = time.ToString(); if (list != null) { DataGridView.DataSource = list; DataGridView.Columns["Title"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; } _logger.LogInformation("Загрузка машин"); } catch (Exception ex) { _logger.LogError(ex, "Ошибка загрузки машин"); MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } }