コード例 #1
0
        // this will be called when the user is submitting a diagnosis and the local keys need to go to the server
        public async Task UploadSelfExposureKeysToServerAsync(IEnumerable <TemporaryExposureKey> temporaryExposureKeys)
        {
            var pendingDiagnosis = userData.PendingDiagnosis;

            if (pendingDiagnosis == null || string.IsNullOrEmpty(pendingDiagnosis.DiagnosisUid))
            {
                throw new InvalidOperationException();
            }

            var selfDiag = await CreateSubmissionAsync(temporaryExposureKeys, pendingDiagnosis);

            HttpStatusCode httpStatusCode = await httpDataService.PutSelfExposureKeysAsync(selfDiag);

            if (httpStatusCode == HttpStatusCode.NotAcceptable)
            {
                await UserDialogs.Instance.AlertAsync(
                    "",
                    AppResources.ExposureNotificationHandler1ErrorMessage,
                    Resources.AppResources.ButtonOk);

                throw new InvalidOperationException();
            }
            else if (httpStatusCode == HttpStatusCode.ServiceUnavailable || httpStatusCode == HttpStatusCode.InternalServerError)
            {
                await UserDialogs.Instance.AlertAsync(
                    "",
                    AppResources.ExposureNotificationHandler2ErrorMessage,
                    Resources.AppResources.ButtonOk);

                throw new InvalidOperationException();
            }
            // Update pending status
            pendingDiagnosis.Shared = true;
            await userDataService.SetAsync(userData);
        }
コード例 #2
0
        // this will be called when the user is submitting a diagnosis and the local keys need to go to the server
        public async Task UploadSelfExposureKeysToServerAsync(IEnumerable <TemporaryExposureKey> temporaryExposureKeys)
        {
            var pendingDiagnosis = userData.PendingDiagnosis;

            if (pendingDiagnosis == null || string.IsNullOrEmpty(pendingDiagnosis.DiagnosisUid))
            {
                throw new InvalidOperationException();
            }

            var selfDiag = await CreateSubmissionAsync(temporaryExposureKeys, pendingDiagnosis);

            await httpDataService.PutSelfExposureKeysAsync(selfDiag);

            // Update pending status
            pendingDiagnosis.Shared = true;
            await userDataService.SetAsync(userData);
        }