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 FormReportHumans : Form { private readonly ILogger _logger; private readonly IVoyageLogic _logic; public FormReportHumans(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.GetTopDrivers(); stopwatch.Stop(); var time = stopwatch.ElapsedMilliseconds; Timelabel.Text = time.ToString(); if (list != null) { DataGridView.DataSource = list; DataGridView.Columns["Name"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; } _logger.LogInformation("Загрузка машин"); } catch (Exception ex) { _logger.LogError(ex, "Ошибка загрузки машин"); MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } }