public async Task ExecuteAsync(DiagnosticTest test) { _logger.LogInformation($"Starting {nameof(PagingDiagnostic)}"); if (string.IsNullOrWhiteSpace(test.Table)) { throw new ConfigurationException($"{nameof(test.Table)} must be set."); } try { using (var client = new ServiceNowClient( _configuration.Credentials.ServiceNowAccount, _configuration.Credentials.ServiceNowUsername, _configuration.Credentials.ServiceNowPassword, new Options { ValidateCountItemsReturned = true, ValidateCountItemsReturnedTolerance = 0, PageSize = test.PageSize.Value, Logger = _logger })) { var results = await client.GetAllByQueryAsync(test.Table, test.Query, fieldList : test.Fields).ConfigureAwait(false); _logger.LogInformation($"Got {results.Count} results"); // Check for dupes var dupes = results.GroupBy(ci => ci["sys_id"]).Where(g => g.Count() > 1).Select(g => new { Id = g.First()["sys_id"], Count = g.Count() }).ToList(); var unique = results.GroupBy(ci => ci["sys_id"]).Select(ci => ci.First()).ToList(); _logger.LogInformation($"Found {dupes.Count} dupes - total retrieved = {results.Count} - unique = {unique.Count}"); } } catch (System.Exception e) { _logger.LogError(e, e.Message); } }
private async Task ExecuteTestAsync(DiagnosticTest test) { IDiagnostic diagnostic = test.Type switch { DiagnosticType.Paging => _serviceProvider.GetRequiredService <PagingDiagnostic>(), _ => throw new NotSupportedException($"Test type {test.Type} is not supported."), }; await diagnostic.ExecuteAsync(test).ConfigureAwait(false); }
public static DiagnosticTestViewModel ToDiagnosticTest(DiagnosticTest elem) { return(new DiagnosticTestViewModel { Id = elem.Id, TestNumber = elem.TestNumber, SeriesDiscriptionId = elem.SeriesDiscriptionId, DateTest = elem.DateTest, FileName = elem.FileName, Count = elem.Count }); }
public static DiagnosticTest ToDiagnosticTest(DiagnosticTestBindingModel model, DiagnosticTest elem = null) { if (elem == null) { elem = new DiagnosticTest(); } elem.TestNumber = model.TestNumber; elem.SeriesDiscriptionId = model.SeriesDiscriptionId; elem.DateTest = model.DateTest; elem.FileName = model.FileName; elem.Count = model.Count; return(elem); }
private async Task ExecuteTestAsync(DiagnosticTest test) { IDiagnostic diagnostic; switch (test.Type) { case DiagnosticType.Paging: diagnostic = _serviceProvider.GetRequiredService <PagingDiagnostic>(); break; default: throw new NotSupportedException($"Test type {test.Type} is not supported."); } await diagnostic.ExecuteAsync(test).ConfigureAwait(false); }