private async void btnCreateReport_Click(object sender, EventArgs e) { Server server = (Server)cbServers.SelectedItem; ReportType reportType = (ReportType)cbReports.SelectedItem; IEnumerable <dynamic> rows = null; DynamicParameters dynamicParameters = new DynamicParameters(); Place place = (Place)cbPlaces.SelectedItem; var reportQuery = AppSettings.ReportQueries.FirstOrDefault(x => x.ReportSysName == reportType.SysName); dynamicParameters.Add("@PlaceID", place.ID); dynamicParameters.Add("@BeginDate", dtBegin.Value.Date, DbType.DateTime); dynamicParameters.Add("@EndDate", dtEnd.Value.Date, DbType.DateTime); lblStatus.Text = "Формирование отчета. Ожидайте"; rows = await Query.ExecuteAsync(reportQuery.Query, dynamicParameters); lblStatus.Text = "Экспорт отчета в Excel..."; string fileName = await Export.ExecuteAsync(rows, reportType.SysName, reportType.Name, server.Name, AppSettings.ReportsFolder, reportQuery.Commands, AppSettings); lblStatus.Text = $"Отчет сохранен"; }