public async Task <List <CertificateRequestIndexApiModel> > RefreshDataAsync() { var appDictionary = new Dictionary <string, ApplicationRecordApiModel>(); var indexRequests = new List <CertificateRequestIndexApiModel>(); string nextPageLink = null; const int PageSize = 1000; try { var requests = await this._opcVaultServiceClient.QueryCertificateRequestsAsync(pageSize : PageSize); while (requests != null) { foreach (var request in requests.Requests) { if (request.State.ToString() == "New" || request.State.ToString() == "Approved" || request.State.ToString() == "Rejected") { var indexRequest = new CertificateRequestIndexApiModel(); indexRequest.RequestId = request.RequestId; indexRequest.CertificateGroupId = request.CertificateGroupId; indexRequest.CertificateTypeId = request.CertificateTypeId; indexRequest.State = request.State; indexRequest.ApplicationId = request.ApplicationId; ApplicationRecordApiModel application; if (!appDictionary.TryGetValue(request.ApplicationId, out application)) { application = await this._opcVaultServiceClient.GetApplicationAsync(request.ApplicationId); } if (application != null) { appDictionary[request.ApplicationId] = application; indexRequest.ApplicationName = application.ApplicationName; indexRequest.ApplicationUri = application.ApplicationUri; indexRequest.DiscoveryUrls = application.DiscoveryUrls; } indexRequests.Add(indexRequest); } } if (requests.NextPageLink == null) { break; } requests = await this._opcVaultServiceClient.QueryCertificateRequestsAsync(nextPageLink, pageSize : PageSize); } } catch (Exception ex) { await Xamarin.Forms.Application.Current.MainPage.DisplayAlert("Failed to load the certificate requests.", "Exception message: " + ex.Message, "Dismiss"); } return(indexRequests); }
public async Task <ActionResult> IndexAsync() { var appDictionary = new Dictionary <string, ApplicationRecordApiModel>(); AuthorizeClient(); string nextPageLink = null; var indexRequests = new List <CertificateRequestIndexApiModel>(); try { var requests = await _opcVault.QueryCertificateRequestsAsync(); while (requests != null) { foreach (var request in requests.Requests) { var indexRequest = new CertificateRequestIndexApiModel(request); ApplicationRecordApiModel application; if (!appDictionary.TryGetValue(request.ApplicationId, out application)) { application = await _opcVault.GetApplicationAsync(request.ApplicationId); } if (application != null) { appDictionary[request.ApplicationId] = application; indexRequest.ApplicationName = application.ApplicationName; indexRequest.ApplicationUri = application.ApplicationUri; } indexRequests.Add(indexRequest); } if (requests.NextPageLink == null) { break; } nextPageLink = requests.NextPageLink; requests = await _opcVault.QueryCertificateRequestsAsync(nextPageLink); } } catch (Exception ex) { ViewData["ErrorMessage"] = "Failed to load all the certificate requests. " + "Message:" + ex.Message; } return(View(indexRequests)); }