public TestReportService(IDatabaseProvider dbProvider, ILogger logger = null) { DatabaseProvider = dbProvider; logger = logger ?? Log.Default; TestingRepository repo = new TestingRepository(); DatabaseProvider.SetDatabases(repo); repo.SchemaWarning += (s, e) => { logger.AddEntry("SchemaWarning: {0}", LogEventType.Warning, e.TryPropertiesToString()); }; repo.CreateFailed += (s, e) => { logger.AddEntry("CreateFailed: {0}", LogEventType.Error, e.TryPropertiesToString()); }; repo.RetrieveFailed += (s, e) => { logger.AddEntry("RetrieveFailed: {0}", LogEventType.Error, e.TryPropertiesToString()); }; repo.UpdateFailed += (s, e) => { logger.AddEntry("UpdateFailed: {0}", LogEventType.Error, e.TryPropertiesToString()); }; Logger = logger; TestingRepository = repo; }
public virtual SaveTestExecutionResponse FinishTest(long executionId) { TestExecution execution = TestingRepository.OneTestExecutionWhere(c => c.Id == executionId); execution.FinishedTime = DateTime.UtcNow; return(SaveTestExecution(execution)); }
public virtual NotificationSubscriptionResponse UnsubscribeFromNotifications(string emailAddress) { try { NotificationSubscription subscription = TestingRepository.Query <NotificationSubscription>(Query.Where(nameof(NotificationSubscription.EmailAddress)) == emailAddress).FirstOrDefault(); string uuid = string.Empty; SubscriptionStatus status = SubscriptionStatus.NotFound; if (subscription != null) { subscription.IsActive = false; subscription = TestingRepository.Save(subscription); uuid = subscription.Uuid; status = SubscriptionStatus.NotActive; } return(new NotificationSubscriptionResponse { Success = true, SubscriptionStatus = status, Uuid = uuid }); } catch (Exception ex) { return(new NotificationSubscriptionResponse { Success = false, Message = ex.Message }); } }
public virtual NotificationSubscriptionResponse SubscribeToNotifications(string emailAddress) { try { NotificationSubscription subscription = TestingRepository.Query <NotificationSubscription>(Query.Where(nameof(NotificationSubscription.EmailAddress)) == emailAddress).FirstOrDefault(); if (subscription == null) { subscription = new NotificationSubscription() { EmailAddress = emailAddress }; } subscription.IsActive = true; subscription = TestingRepository.Save(subscription); return(new NotificationSubscriptionResponse { Success = true, Data = subscription, SubscriptionStatus = SubscriptionStatus.Active, Uuid = subscription.Uuid }); } catch (Exception ex) { return(new NotificationSubscriptionResponse { Success = false, Message = ex.Message }); } }
public virtual RetrieveTestExecutionResponse RetrieveTestExecutionById(long id) { try { TestExecution retrieved = TestingRepository.Retrieve <TestExecution>(id); return(new RetrieveTestExecutionResponse { Success = true, Data = retrieved, CreateStatus = CreateStatus.Existing }); } catch (Exception ex) { return(new RetrieveTestExecutionResponse { Success = false, Message = ex.Message }); } }
public virtual RetrieveNotificationSubscriptionsResponse RetrieveNotificationSubscribers() { try { NotificationSubscription[] subscriptions = TestingRepository.Query <NotificationSubscription>(Query.Where("IsActive") == true).ToArray(); return(new RetrieveNotificationSubscriptionsResponse { Success = true, Data = subscriptions }); } catch (Exception ex) { return(new RetrieveNotificationSubscriptionsResponse { Success = false, Message = ex.Message }); } }
public virtual SearchTestExecutionResponse SearchTestExecutionsByTestDefinitionId(long testId) { try { List <TestExecution> results = TestingRepository.Query <TestExecution>( QueryFilter.Where(nameof(TestExecution.TestDefinitionId)) == testId).ToList(); return(new SearchTestExecutionResponse { Success = true, Data = results }); } catch (Exception ex) { return(new SearchTestExecutionResponse { Success = false, Message = ex.Message }); } }
public virtual SaveTestExecutionResponse SaveTestExecution(TestExecution execution) { try { Meta.SetAuditFields(execution); TestExecution exec = TestingRepository.Save(execution); return(new SaveTestExecutionResponse { Success = true, Data = exec }); } catch (Exception ex) { return(new SaveTestExecutionResponse { Success = false, Message = ex.Message }); } }
public virtual SaveTestSuiteExecutionSummaryResponse SaveTestSuiteExecutionSummary(TestSuiteExecutionSummary toCreate = null) { try { toCreate = toCreate ?? new TestSuiteExecutionSummary(); Meta.SetAuditFields(toCreate); TestSuiteExecutionSummary sum = TestingRepository.Save(toCreate).ToDynamicData().CopyAs <TestSuiteExecutionSummary>(); return(new SaveTestSuiteExecutionSummaryResponse { Success = true, Data = sum, CreateStatus = toCreate.Id > 0 ? CreateStatus.Existing : CreateStatus.Created }); } catch (Exception ex) { return(new SaveTestSuiteExecutionSummaryResponse { Success = false, Message = ex.Message }); } }
public virtual RetrieveTestExecutionResponse RetrieveFailedTestExecutions(string tag) { try { List <TestExecution> failedTestRuns = TestingRepository.Query <TestExecution>(Filter.Where("Passed") == 0 && Filter.Where("Tag") == tag).ToList(); return(new RetrieveTestExecutionResponse { Success = true, Data = failedTestRuns.Select(te => new { te.TestDefinition.AssemblyFullName, te.TestDefinition.MethodName, te.TestDefinition.Description, te.Exception, te.StackTrace }).ToArray() }); } catch (Exception ex) { return(new RetrieveTestExecutionResponse { Success = false, Message = ex.Message }); } }
public virtual SearchTestExecutionResponse SearchTestExecutionsByDate(DateTime from, DateTime to) { try { List <TestExecution> results = TestingRepository.Query <TestExecution>( QueryFilter.Where(nameof(TestExecution.StartedTime)) > from && QueryFilter.Where(nameof(TestExecution.StartedTime)) > to).ToList(); return(new SearchTestExecutionResponse { Success = true, Data = results }); } catch (Exception ex) { return(new SearchTestExecutionResponse { Success = false, Message = ex.Message }); } }
public virtual RetrieveTestExecutionResponse RetrieveTestExecutionByUuid(string uuid) { try { TestExecution queried = TestingRepository.Query <TestExecution>(Query.Where("Uuid") == uuid).FirstOrDefault(); if (queried == null) { Args.Throw <ArgumentException>("TestExecution with the specified Uuid was not found: {0}", uuid); } TestExecution retrieved = TestingRepository.Retrieve <TestExecution>(queried.Id); return(new RetrieveTestExecutionResponse { Success = true, Data = retrieved }); } catch (Exception ex) { return(new RetrieveTestExecutionResponse { Success = false, Message = ex.Message }); } }
public async Task <ActionResult <AthenaQueryResultModel> > TestingByDateRunAndGo(DateTime date) { try { var result = await TestingRepository.ProgressAsync(date); return(Ok(new AthenaQueryResultModel { QueryId = result, IsStillRunning = true })); } catch (Exception ex) { var msg = $"{ERROR_MSG}:{Guid.NewGuid()}"; _logger.LogError(ex, msg); return(BadRequest(new AppErrorModel { ErrorMessage = msg })); } }
public Task <IEnumerable <CovidTestingStatesDaily> > TestingResult(string queryId) { return(TestingRepository.GetTestingQueryResultAsync(queryId)); }
public override void Subscribe(Loggable loggable) { TestingRepository.Subscribe(loggable); }
public override void Subscribe(ILogger logger) { TestingRepository.Subscribe(logger); }