public async Task <IActionResult> DeleteOldTestRunsDataAsync() { try { var testRuns = (await _meissaRepository.GetAllQueryWithRefreshAsync <TestRun>()).Where(r => r.Status != TestRunStatus.InProgress || (r.Status == TestRunStatus.InProgress && r.DateStarted < DateTime.Now.AddDays(1))); foreach (var testRun in testRuns) { var testRunOutputs = _meissaRepository.GetAllQuery <TestRunOutput>().Where(x => x.TestRunId.Equals(testRun.TestRunId)); _meissaRepository.DeleteRange(testRunOutputs); var testRunCustomArguments = _meissaRepository.GetAllQuery <TestRunCustomArgument>().Where(x => x.TestRunId.Equals(testRun.TestRunId)); _meissaRepository.DeleteRange(testRunCustomArguments); var testAgentRuns = _meissaRepository.GetAllQuery <TestAgentRun>().Where(x => x.TestRunId.Equals(testRun.TestRunId)); DeleteTestAgentRunAvailabilitiesForTestAgentRuns(testAgentRuns); _meissaRepository.DeleteRange(testAgentRuns); var testRunLogs = _meissaRepository.GetAllQuery <TestRunLog>().Where(x => x.TestRunId.Equals(testRun.TestRunId)); _meissaRepository.DeleteRange(testRunLogs); var testRunAvailabilities = _meissaRepository.GetAllQuery <TestRunAvailability>().Where(x => x.TestRunId.Equals(testRun.TestRunId)); _meissaRepository.DeleteRange(testRunLogs); } _meissaRepository.DeleteRange(testRuns); await _meissaRepository.SaveAsync(); } catch (DbUpdateConcurrencyException ex) { // Ignore. } return(NoContent()); }
public async Task <IActionResult> GetTestRunAsync([FromBody] Guid id) { try { var testRun = (await _meissaRepository.GetAllQueryWithRefreshAsync <TestRun>()).FirstOrDefault(x => x.TestRunId.Equals(id)); if (testRun == null) { return(NotFound()); } var testRunDto = Mapper.Map <TestRunDto>(testRun); return(Ok(testRunDto)); } catch (Exception ex) { _logger.LogCritical($"Exception while getting test run with id {id}.", ex); return(StatusCode(500, "A problem happened while handling your request.")); } }
public async Task <IActionResult> GetLastTestRunAvailabilityForTestRun([FromBody] Guid id) { try { var testRunAvailability = (await _meissaRepository.GetAllQueryWithRefreshAsync <TestRunAvailability>()).LastOrDefault(x => x.TestRunId.Equals(id)); if (testRunAvailability == null) { _logger.LogInformation($"Test Run Availability with testRunId {id} wasn't found."); return(NotFound()); } var testRunAvailabilityDto = Mapper.Map <TestRunAvailabilityDto>(testRunAvailability); return(Ok(testRunAvailabilityDto)); } catch (Exception ex) { _logger.LogCritical($"Exception while getting test run availability with id {id}.", ex); return(StatusCode(500, "A problem happened while handling your request.")); } }
public async Task <IActionResult> GetTestAgents() { try { var testAgents = await _meissaRepository.GetAllQueryWithRefreshAsync <TestAgent>().ConfigureAwait(false); var testAgentDtos = Mapper.Map <IEnumerable <TestAgentDto> >(testAgents); return(Ok(testAgentDtos)); } catch (Exception ex) { _logger.LogCritical("Exception while getting test runs.", ex); return(StatusCode(500, "A problem happened while handling your request.")); } }
public async Task <IActionResult> GetTestAgentRunsAsync() { try { var logs = await _meissaRepository.GetAllQueryWithRefreshAsync <TestAgentRun>(); var logDto = Mapper.Map <IEnumerable <TestAgentRunDto> >(logs); return(Ok(logDto)); } catch (Exception ex) { _logger.LogCritical("Exception while getting logs.", ex); return(StatusCode(500, "A problem happened while handling your request.")); } }
public async Task <IActionResult> GetAndDeleteNewTestRunLogsAsync() { try { var testRunLogs = (await _meissaRepository.GetAllQueryWithRefreshAsync <TestRunLog>()).Where(x => x.Status == TestRunLogStatus.New); var testRunLogDtos = Mapper.Map <IEnumerable <TestRunLogDto> >(testRunLogs); await _meissaRepository.DeleteRangeWithSaveAsync(testRunLogs); return(Ok(testRunLogDtos)); } catch (Exception ex) { _logger.LogCritical("Exception while getting testRunLogs.", ex); return(StatusCode(500, "A problem happened while handling your request.")); } }