public override void RefreshDatasetMetadataAsync(AmazonCognitoCallback callback, object state)
        {
            AmazonCognitoResult callbackResult = new AmazonCognitoResult(state);

            cognitoCredentials.GetCredentialsAsync(delegate(AmazonServiceResult getCredentialsResult) {
                if (getCredentialsResult.Exception != null)
                {
                    callbackResult.Exception = getCredentialsResult.Exception;
                    AmazonMainThreadDispatcher.ExecCallback(callback, callbackResult);
                    return;
                }
                remote.GetDatasetsAsync(delegate(AmazonCognitoResult result)
                {
                    if (result.Exception != null)
                    {
                        callbackResult.Exception = result.Exception;
                    }
                    else
                    {
                        GetDatasetsResponse response = result.Response as GetDatasetsResponse;
                        local.UpdateDatasetMetadata(GetIdentityId(), response.Datasets);
                        callbackResult.Response = response;
                    }
                    AmazonMainThreadDispatcher.ExecCallback(callback, callbackResult);
                }, state);
            }, null);
        }
コード例 #2
0
ファイル: NoisController.cs プロジェクト: hpphat92/dineplan
        private GetDatasetsResponse GetDatasetIds(string token)
        {
            // execute api
            var client  = new RestClient(_powerBiDataset);
            var request = new RestRequest(Method.GET);

            request.AddHeader("Authorization", string.Format("Bearer {0}", token));
            // deserialize reponse
            var response   = client.Execute(request);
            var resContent = new GetDatasetsResponse();

            if (!string.IsNullOrEmpty(response.Content))
            {
                resContent = JsonConvert.DeserializeObject <GetDatasetsResponse>(response.Content);
            }

            return(resContent);
        }
        private void PopulateGetDatasets(string nextToken, List <DatasetMetadata> datasets, AmazonCognitoCallback callback, object state)
        {
            ListDatasetsRequest request = new ListDatasetsRequest();

            //appendUserAgent(request, userAgent);
            request.IdentityPoolId = identityPoolId;
            request.IdentityId     = this.GetCurrentIdentityId();
            // a large enough number to reduce # of requests
            request.MaxResults = 64;
            request.NextToken  = nextToken;

            client.ListDatasetsAsync(request, delegate(AmazonServiceResult result)
            {
                if (result.Exception != null)
                {
                    AmazonMainThreadDispatcher.ExecCallback(callback, new AmazonCognitoResult(null,
                                                                                              HandleException(result.Exception, "Failed to list dataset metadata"), state));
                    return;
                }

                ListDatasetsResponse response = result.Response as ListDatasetsResponse;
                foreach (Amazon.CognitoSync.Model.Dataset dataset in response.Datasets)
                {
                    datasets.Add(ModelToDatasetMetadata(dataset));
                }

                nextToken = response.NextToken;

                if (nextToken == null)
                {
                    GetDatasetsResponse getDatasetsResponse = new GetDatasetsResponse
                    {
                        Datasets = datasets
                    };
                    AmazonMainThreadDispatcher.ExecCallback(callback, new AmazonCognitoResult(getDatasetsResponse, null, state));
                    return;
                }
                PopulateGetDatasets(nextToken, datasets, callback, state);
            }, null);
        }