public async Task ExposureDetectedAsync(ExposureConfiguration exposureConfiguration, long enVersion, IList <DailySummary> dailySummaries, IList <ExposureWindow> exposureWindows) { _loggerService.Debug("ExposureDetected: ExposureWindows"); var(newDailySummaries, newExposureWindows) = await _exposureDataRepository.SetExposureDataAsync( dailySummaries.ToList(), exposureWindows.ToList() ); var exposureRiskCalculationConfiguration = await _exposureRiskCalculationConfigurationRepository .GetExposureRiskCalculationConfigurationAsync(preferCache : false); _loggerService.Info(exposureRiskCalculationConfiguration.ToString()); long expectOldestDateMillisSinceEpoch = _dateTimeUtility.UtcNow .AddDays(AppConstants.TermOfExposureRecordValidityInDays) .ToUnixEpochMillis(); bool isHighRiskExposureDetected = newDailySummaries .Where(ds => ds.DateMillisSinceEpoch >= expectOldestDateMillisSinceEpoch) .Select(ds => _exposureRiskCalculationService.CalcRiskLevel( ds, newExposureWindows.Where(ew => ew.DateMillisSinceEpoch == ds.DateMillisSinceEpoch).ToList(), exposureRiskCalculationConfiguration ) ) .Any(riskLevel => riskLevel >= RiskLevel.High); if (isHighRiskExposureDetected) { _ = _localNotificationService.ShowExposureNotificationAsync(); bool enableSendEventExposureNotificationNotified = _sendEventLogStateRepository .GetSendEventLogState(EventType.ExposureNotified) == SendEventLogState.Enable; if (enableSendEventExposureNotificationNotified) { await _eventLogRepository.AddEventNotifiedAsync(); } } else { _loggerService.Info($"DailySummary: {dailySummaries.Count}, but no high-risk exposure detected"); } }