public async Task SendExposureDataAsync( string idempotencyKey, ExposureConfiguration exposureConfiguration, string deviceModel, string enVersion ) { var data = new ExposureData( exposureConfiguration ) { Device = deviceModel, EnVersion = enVersion, }; await SendExposureDataAsync(idempotencyKey, data); }
public async Task SendExposureDataAsync( string idempotencyKey, ExposureConfiguration exposureConfiguration, string deviceModel, string enVersion, IList <DailySummary> dailySummaries, IList <ExposureWindow> exposureWindows ) { var data = new ExposureData(exposureConfiguration, dailySummaries, exposureWindows ) { Device = deviceModel, EnVersion = enVersion, }; await SendExposureDataAsync(idempotencyKey, data); }
public async Task ExportAsync(string filePath) { _loggerService.StartMethod(); try { long enVersion = await _exposureNotificationApiService.GetVersionAsync(); List <DailySummary> dailySummaryList = await _exposureDataRepository.GetDailySummariesAsync(); List <ExposureWindow> exposureWindowList = await _exposureDataRepository.GetExposureWindowsAsync(); ExposureConfiguration exposureConfiguration = await _exposureConfigurationRepository.GetExposureConfigurationAsync(); var exposureData = new ExposureData( _essentialsService.Platform, _essentialsService.PlatformVersion, _essentialsService.Model, _essentialsService.DeviceType, _essentialsService.AppVersion, _essentialsService.BuildNumber, enVersion.ToString(), dailySummaryList, exposureWindowList, exposureConfiguration ); string exposureDataJson = JsonConvert.SerializeObject(exposureData, Formatting.Indented); await File.WriteAllTextAsync(filePath, exposureDataJson); } finally { _loggerService.EndMethod(); } }
private async Task SendExposureDataAsync( string idempotencyKey, ExposureData exposureData ) { _loggerService.StartMethod(); SendEventLogState sendEventLogState = _userDataRepository.GetSendEventLogState(); bool isEnabled = sendEventLogState == SendEventLogState.Enable; if (!isEnabled) { _loggerService.Debug($"Send event-log function is not enabled."); _loggerService.EndMethod(); return; } await _serverConfigurationRepository.LoadAsync(); string exposureDataCollectServerEndpoint = _serverConfigurationRepository.EventLogApiEndpoint; _loggerService.Debug($"exposureDataCollectServerEndpoint: {exposureDataCollectServerEndpoint}"); try { var contentJson = exposureData.ToJsonString(); var eventLog = new V1EventLogRequest.EventLog() { HasConsent = isEnabled, Epoch = _dateTimeUtility.UtcNow.ToUnixEpoch(), Type = "ExposureData", Subtype = "Debug", Content = contentJson, }; var eventLogs = new[] { eventLog }; var request = new V1EventLogRequest() { IdempotencyKey = idempotencyKey, Platform = _essentialsService.Platform, AppPackageName = _essentialsService.AppPackageName, EventLogs = eventLogs, }; request.DeviceVerificationPayload = await _deviceVerifier.VerifyAsync(request); var requestJson = request.ToJsonString(); var httpContent = new StringContent(requestJson, Encoding.UTF8, "application/json"); Uri uri = new Uri(exposureDataCollectServerEndpoint); HttpResponseMessage response = await _httpClient.PutAsync(uri, httpContent); if (response.IsSuccessStatusCode) { var responseJson = await response.Content.ReadAsStringAsync(); _loggerService.Debug($"{responseJson}"); } else { _loggerService.Info($"UploadExposureDataAsync {response.StatusCode}"); } } finally { _loggerService.EndMethod(); } }