public async Task RefreshTransactions() { RefreshingTransactions = true; var context = await _agentContextProvider.GetContextAsync(); var message = _discoveryService.CreateQuery(context, "*"); DiscoveryDiscloseMessage protocols = null; try { var response = await SendMessage(context.Wallet, message); protocols = response.GetMessage <DiscoveryDiscloseMessage>(); } catch (Exception) { //Swallow exception //TODO more granular error protection } IList <TransactionItem> transactions = new List <TransactionItem>(); Transactions.Clear(); if (protocols == null) { HasTransactions = false; RefreshingTransactions = false; return; } foreach (var protocol in protocols.Protocols) { switch (protocol.ProtocolId) { case MessageTypes.TrustPingMessageType: transactions.Add(new TransactionItem() { Title = "Trust Ping", Subtitle = "Version 1.0", PrimaryActionTitle = "Ping", PrimaryActionCommand = new Command(async() => { await PingConnectionAsync(); }, () => true), Type = TransactionItemType.Action.ToString("G") }); break; } } Transactions.InsertRange(transactions); HasTransactions = transactions.Any(); RefreshingTransactions = false; }
public async Task RefreshWallet() { RefreshingRecords = true; var context = await _agentContextProvider.GetContextAsync(); var wallet = context.Wallet; var provisioningRecords = await _recordService.SearchAsync <ProvisioningRecord>(wallet, null, null, 100); var connectionRecords = await _recordService.SearchAsync <ConnectionRecord>(wallet, null, null, 100); connectionRecords.Sort((a, b) => a.CreatedAtUtc.GetValueOrDefault(DateTime.MinValue) < b.CreatedAtUtc.GetValueOrDefault(DateTime.MinValue) ? -1 : a.CreatedAtUtc.GetValueOrDefault(DateTime.MinValue) > b.CreatedAtUtc.GetValueOrDefault(DateTime.MinValue) ? 1 : 0 ); var messageRecords = await _recordService.SearchAsync <BasicMessageRecord>(wallet, null, null, 100); messageRecords.Sort((a, b) => a.CreatedAtUtc.GetValueOrDefault(DateTime.MinValue) < b.CreatedAtUtc.GetValueOrDefault(DateTime.MinValue) ? -1 : a.CreatedAtUtc.GetValueOrDefault(DateTime.MinValue) > b.CreatedAtUtc.GetValueOrDefault(DateTime.MinValue) ? 1 : 0 ); IList <RecordViewModel> recordVms = new List <RecordViewModel>(); foreach (var record in provisioningRecords) { var connection = _scope.Resolve <RecordViewModel>(new NamedParameter("record", record)); recordVms.Add(connection); } foreach (var record in connectionRecords) { var connection = _scope.Resolve <RecordViewModel>(new NamedParameter("record", record)); recordVms.Add(connection); } foreach (var record in messageRecords) { var connection = _scope.Resolve <RecordViewModel>(new NamedParameter("record", record)); recordVms.Add(connection); } //TODO need to compare with the currently displayed connections rather than disposing all of them Records.Clear(); Records.InsertRange(recordVms); HasRecords = recordVms.Any(); this.RaisePropertyChanged(nameof(Records)); RefreshingRecords = false; }
public async Task RefreshCredentials() { RefreshingCredentials = true; var context = await _agentContextProvider.GetContextAsync(); var credentialsRecords = await _credentialService.ListAsync(context); #if DEBUG credentialsRecords.Add(new CredentialRecord { ConnectionId = Guid.NewGuid().ToString().ToLowerInvariant(), CredentialDefinitionId = Guid.NewGuid().ToString().ToLowerInvariant(), CredentialId = Guid.NewGuid().ToString().ToLowerInvariant(), CredentialRevocationId = Guid.NewGuid().ToString().ToLowerInvariant(), State = CredentialState.Issued, }); credentialsRecords.Add(new CredentialRecord { ConnectionId = Guid.NewGuid().ToString().ToLowerInvariant(), CredentialDefinitionId = Guid.NewGuid().ToString().ToLowerInvariant(), CredentialId = Guid.NewGuid().ToString().ToLowerInvariant(), CredentialRevocationId = Guid.NewGuid().ToString().ToLowerInvariant(), State = CredentialState.Issued, }); credentialsRecords.Add(new CredentialRecord { ConnectionId = Guid.NewGuid().ToString().ToLowerInvariant(), CredentialDefinitionId = Guid.NewGuid().ToString().ToLowerInvariant(), CredentialId = Guid.NewGuid().ToString().ToLowerInvariant(), CredentialRevocationId = Guid.NewGuid().ToString().ToLowerInvariant(), State = CredentialState.Issued, }); #endif IList <CredentialViewModel> credentialsVms = new List <CredentialViewModel>(); foreach (var credentialRecord in credentialsRecords) { CredentialViewModel credential = _scope.Resolve <CredentialViewModel>(new NamedParameter("credential", credentialRecord)); credentialsVms.Add(credential); } var filteredCredentialVms = FilterCredentials(SearchTerm, credentialsVms); var groupedVms = GroupCredentials(filteredCredentialVms); CredentialsGrouped = groupedVms; Credentials.Clear(); Credentials.InsertRange(filteredCredentialVms); HasCredentials = Credentials.Any(); RefreshingCredentials = false; }
private async Task CreateInvitation() { try { var context = await _agentContextProvider.GetContextAsync(); var(invitation, _) = await _connectionService.CreateInvitationAsync(context); string barcodeValue = invitation.ServiceEndpoint + "?c_i=" + invitation.ToJson().ToBase64(); QrCodeValue = barcodeValue; } catch (Exception ex) { DialogService.Alert(ex.Message); } }
private async Task AcceptInvitation() { var loadingDialog = _userDialogs.Loading("Proccessing"); if (_invitation != null) { try { var agentContext = await _agentContextProvider.GetContextAsync(); if (agentContext == null) { loadingDialog.Hide(); DialogService.Alert("Failed to decode invitation!"); return; } var(requestMessage, connectionRecord) = await _connectionService.CreateRequestAsync(agentContext, _invitation); var provisioningRecord = await _provisioningService.GetProvisioningAsync(agentContext.Wallet); var isEndpointUriAbsent = provisioningRecord.Endpoint.Uri == null; var respone = await _messageService.SendReceiveAsync <ConnectionResponseMessage>(agentContext.Wallet, requestMessage, connectionRecord); if (isEndpointUriAbsent) { string processRes = await _connectionService.ProcessResponseAsync(agentContext, respone, connectionRecord); } } catch (Exception e) { System.Diagnostics.Debug.WriteLine(e.ToString()); } loadingDialog.Hide(); await _navigationService.CloseAllPopupsAsync(); var toastConfig = new ToastConfig("Connection Saved!"); toastConfig.BackgroundColor = Color.Green; toastConfig.Position = ToastPosition.Top; toastConfig.SetDuration(3000); _userDialogs.Toast(toastConfig); } }
public async Task RefreshConnections() { RefreshingConnections = true; var context = await _agentContextProvider.GetContextAsync(); var records = await _connectionService.ListAsync(context); IList <ConnectionViewModel> connectionVms = new List <ConnectionViewModel>(); foreach (var record in records) { var connection = _scope.Resolve <ConnectionViewModel>(new NamedParameter("record", record)); connectionVms.Add(connection); } //TODO need to compare with the currently displayed connections rather than disposing all of them Connections.Clear(); Connections.InsertRange(connectionVms); HasConnections = connectionVms.Any(); RefreshingConnections = false; }