public async Task ExposureDetectedAsync(ExposureConfiguration exposureConfiguration, long enVersion, ExposureSummary exposureSummary, IList <ExposureInformation> exposureInformations) { _loggerService.Info("ExposureDetected: Legacy-V1"); ExposureConfiguration.GoogleExposureConfiguration configurationV1 = exposureConfiguration.GoogleExposureConfig; bool isNewExposureDetected = _exposureDataRepository.AppendExposureData( exposureSummary, exposureInformations.ToList(), configurationV1.MinimumRiskScore ); if (isNewExposureDetected) { _ = _localNotificationService.ShowExposureNotificationAsync(); bool enableSendEventExposureNotificationNotified = _sendEventLogStateRepository .GetSendEventLogState(EventType.ExposureNotified) == SendEventLogState.Enable; if (enableSendEventExposureNotificationNotified) { await _eventLogRepository.AddEventNotifiedAsync(); } } else { _loggerService.Info($"MatchedKeyCount: {exposureSummary.MatchedKeyCount}, but no new exposure detected"); } }
public void TestDeserializeFromJson() { var expected = new ExposureConfiguration.GoogleExposureConfiguration(); var googleExposureConfiguration = Utils .ReadObjectFromJsonPath <ExposureConfiguration.GoogleExposureConfiguration>(PATH_JSON); Assert.True(expected.Equals(googleExposureConfiguration)); }
public async Task ExposureDetectedAsync(ExposureConfiguration exposureConfiguration, long enVersion, ExposureSummary exposureSummary, IList <ExposureInformation> exposureInformations) { _loggerService.Info("ExposureDetected: Legacy-V1"); var enVersionStr = enVersion.ToString(); ExposureConfiguration.GoogleExposureConfiguration configurationV1 = exposureConfiguration.GoogleExposureConfig; bool isNewExposureDetected = _exposureDataRepository.AppendExposureData( exposureSummary, exposureInformations.ToList(), configurationV1.MinimumRiskScore ); if (isNewExposureDetected) { _ = _localNotificationService.ShowExposureNotificationAsync(); } else { _loggerService.Info($"MatchedKeyCount: {exposureSummary.MatchedKeyCount}, but no new exposure detected"); } try { await _exposureDataCollectServer.UploadExposureDataAsync( exposureConfiguration, _deviceInfoUtility.Model, enVersionStr, exposureSummary, exposureInformations ); } catch (Exception e) { _loggerService.Exception("UploadExposureDataAsync", e); } string idempotencyKey = Guid.NewGuid().ToString(); try { await _eventLogService.SendExposureDataAsync( idempotencyKey, exposureConfiguration, _deviceInfoUtility.Model, enVersionStr, exposureSummary, exposureInformations ); } catch (Exception e) { _loggerService.Exception("SendExposureDataAsync", e); } }
public void TestNotEquals() { var expected = new ExposureConfiguration.GoogleExposureConfiguration { AttenuationWeight = 0 }; var googleExposureConfiguration = Utils .ReadObjectFromJsonPath <ExposureConfiguration.GoogleExposureConfiguration>(PATH_JSON); Assert.False(expected.Equals(googleExposureConfiguration)); }
public void TestSerializeToJson() { var googleExposureConfiguration = new ExposureConfiguration.GoogleExposureConfiguration(); var jsonStr = JsonConvert.SerializeObject(googleExposureConfiguration, Formatting.Indented); //Logger.D(jsonStr); using (var sr = new StreamReader(File.OpenRead(Utils.GetFullPath(PATH_JSON)))) { var expected = sr.ReadToEnd(); Assert.AreEqual(expected, jsonStr); } }