private async Task RejectProofRequest() { var loadingDialog = DialogService.Loading("Proccessing"); try { this.IsBusy = true; var context = await _agentProvider.GetContextAsync(); // var (message, proofRecord) = await _proofService.CreatePresentationAsync(context, ProofRequestRecord.Id, RequestedCredentials); await _proofService.RejectProofRequestAsync(context, ProofRequestRecord.Id); _eventAggregator.Publish(new ApplicationEvent() { Type = ApplicationEventType.CredentialsUpdated }); loadingDialog.Hide(); await NavigationService.NavigateBackAsync(); this.IsBusy = false; var toastConfig = new ToastConfig("Rejected successfully!"); toastConfig.BackgroundColor = Color.Green; toastConfig.Position = ToastPosition.Top; toastConfig.SetDuration(3000); DialogService.Toast(toastConfig); } catch (Exception e) { this.IsBusy = false; loadingDialog.Hide(); DialogService.Alert("Error while Reject Proof Request"); } }
/// <summary> /// Reference https://github.com/hyperledger/aries-framework-dotnet/blob/master/test/Hyperledger.Aries.Tests/Protocols/ProofTests.cs#L644 /// </summary> public async Task GetRequestedAttributes() { try { RequestedAttributes.Clear(); if (ProofRequest.RequestedAttributes == null) { return; } var context = await agentContextProvider.GetContextAsync(); //Get any Available Credentials for each requested attribute foreach (var requestedAttribute in ProofRequest.RequestedAttributes) { List <Credential> attributeCredentials = await proofService.ListCredentialsForProofRequestAsync(context, ProofRequest, requestedAttribute.Key); var attribute = scope.Resolve <ProofRequestAttributeViewModel>( new NamedParameter("name", requestedAttribute.Value.Name ?? string.Join(", ", requestedAttribute.Value.Names)), new NamedParameter("isPredicate", false), new NamedParameter("attributeCredentials", attributeCredentials), new NamedParameter("referent", requestedAttribute.Key) ); RequestedAttributes.Add(attribute); } //TODO: Implement Predicate and Restrictions related functionlity } catch (Exception xx) { DialogService.Alert(xx.Message); } }
async Task AcceptCredential() { var dialog = UserDialogs.Instance.Loading("Requesting..."); try { IsBusy = true; var context = await agentContextProvider.GetContextAsync(); var(request, _) = await credentialService.CreateRequestAsync(context, _credential.Id); await messageService.SendAsync(context, request, _connection); eventAggregator.Publish(new ApplicationEvent() { Type = ApplicationEventType.CredentialsUpdated }); await NavigationService.PopModalAsync(); } catch (Exception xx) { DialogService.Alert(xx.Message); } finally { IsBusy = false; dialog?.Hide(); dialog?.Dispose(); } }
private async Task CreateAgent() { Preferences.Set(Constants.PoolConfigurationName, _walletConfiguration.PoolConfigurationName); var dialog = UserDialogs.Instance.Loading("Creating wallet"); IsBusy = true; try { _options.AgentName = DeviceInfo.Name; _options.WalletConfiguration.Id = Constants.LocalWalletIdKey; _options.WalletCredentials.Key = await SyncedSecureStorage.GetOrCreateSecureAsync( key : Constants.LocalWalletCredentialKey, value : Utils.Utils.GenerateRandomAsync(32)); await _edgeProvisioningService.ProvisionAsync(_options); Preferences.Set("LocalWalletProvisioned", true); await NavigationService.NavigateToAsync <MainViewModel>(); dialog?.Hide(); dialog?.Dispose(); DialogService.Alert("Wallet created successfully", "Info", "OK"); } catch (Exception ex) { Debug.WriteLine(ex, "Wasn't able to provision the agent"); dialog?.Hide(); dialog?.Dispose(); DialogService.Alert("Failed to create wallet!"); } finally { IsBusy = false; } }
private async void Save() { try { DialogService.ShowLoading("Saving..."); var result = await PredictionService.SavePredictionAsync(new SavePredictionModel() { PredictionId = Prediction.PredictionId, WeekId = Prediction.WeekId, GameId = Prediction.GameId, AwayPrediction = AwayPredictedScore.AsInt(0), HomePrediction = HomePredictedScore.AsInt(0) }); if (result != null && Prediction != null) { MessageBus.Publish(new RefreshPredictionsMessage(result.PredictionId, Prediction.HomeTeam, Prediction.AwayTeam, AwayPredictedScore.AsInt(0), HomePredictedScore.AsInt(0))); await Navigation.PopModalAsync(true); } } catch (Exception ex) { DialogService.Alert("Failed to save Prediction"); } finally { DialogService.HideLoading(); } }
private async void LoginWithFacebook() { try { var result = await LoginUserService.LoginWithFacebookAsync(); if (result == null) { throw new LoginException("Failed to Login in with Facebook"); } string username = await GetUsernameService.GetUsernameAsync(result.UserId); if (string.IsNullOrEmpty(username)) { await Navigation.PushAsync(new EnterUsernamePage(result)); return; } result.Username = username; SaveUserSecurityService.SaveUser(result); MessageBus.Publish(new LoginCompleteMessage()); await Navigation.PushModalAsync(new ScorePredictNavigationPage(new MainPage())); } catch (LoginException lex) { DialogService.Alert(lex.Message); } catch (Exception ex) { DialogService.Alert("Login Failed. Please try again."); } }
private void LoginCore(Func <Task <Credentials> > getCredentialsFunc) { PerformTask(async() => { _realm.Write(() => { Details.ServerUrl = Details.ServerUrl.Replace("http://", string.Empty) .Replace("https://", string.Empty) .Replace("realm://", string.Empty) .Replace("realms://", string.Empty); }); Constants.RosUrl = Details.ServerUrl; var credentials = await getCredentialsFunc(); var user = await User.LoginAsync(credentials, Constants.AuthServerUri); Success(user); }, onError: async ex => { await Task.Delay(500); DialogService.Alert("Unable to login", ex.Message); HandleException(ex); }, progressMessage: "Logging in..."); }
private async Task CreateInvitation() { IsBusy = true; try { var context = await _agentContextProvider.GetContextAsync(); var(invitation, _) = await _connectionService.CreateInvitationAsync(context); // null because the base64 string of the image is too large to convert to qrcode, // so we don't send the image in this step invitation.ImageUrl = null; string barcodeValue = invitation.ServiceEndpoint + "?c_i=" + Uri.EscapeDataString(invitation.ToByteArray().ToBase64String()); string linkValue = invitation.ServiceEndpoint + "?c_i=" + invitation.ToJson().ToBase64(); QrCodeValue = barcodeValue; LinkValue = linkValue; HasQrCodeValue = !string.IsNullOrEmpty(QrCodeValue); } catch (Exception ex) { DialogService.Alert(ex.Message); } finally { IsBusy = false; } }
private async void CreateUser() { try { var result = await CreateUserService.CreateUserAsync( Username, Password, ConfirmPassword); if (result == null) { throw new CreateUserException("An error occured creating your user. Please try again"); } SaveUserSecurityService.SaveUser(result); await Navigation.PushModalAsync(new ScorePredictNavigationPage(new MainPage())); await Navigation.PopToRootAsync(false); } catch (CreateUserException ex) { DialogService.Alert(ex.Message); } catch { DialogService.Alert("An unknown error occurred. Please try again"); } }
async Task AcceptCredential() { try { IsBusy = true; var context = await agentContextProvider.GetContextAsync(); var(request, _) = await credentialService.CreateRequestAsync(context, _credential.Id); await messageService.SendAsync(context.Wallet, request, _connection); eventAggregator.Publish(new ApplicationEvent() { Type = ApplicationEventType.CredentialsUpdated }); await NavigationService.PopModalAsync(); } catch (Exception xx) { DialogService.Alert(xx.Message); } finally { IsBusy = false; } }
async Task RejectCredential() { var isConfirmed = await Application.Current.MainPage.DisplayAlert("Confirm", "Are you sure you want to reject this credential offer?", "Yes", "No"); if (!isConfirmed) { return; } try { IsBusy = true; var context = await agentContextProvider.GetContextAsync(); await credentialService.RejectOfferAsync(context, _credential.Id); eventAggregator.Publish(new ApplicationEvent() { Type = ApplicationEventType.CredentialsUpdated }); await NavigationService.PopModalAsync(); } catch (Exception xx) { DialogService.Alert(xx.Message); } finally { IsBusy = false; } }
public async Task ScanProofRequest() { var expectedFormat = ZXing.BarcodeFormat.QR_CODE; var opts = new ZXing.Mobile.MobileBarcodeScanningOptions { PossibleFormats = new List <ZXing.BarcodeFormat> { expectedFormat } }; var scanner = new ZXing.Mobile.MobileBarcodeScanner(); var result = await scanner.Scan(opts); if (result == null) { return; } RequestPresentationMessage presentationMessage; try { presentationMessage = await MessageDecoder.ParseMessageAsync(result.Text) as RequestPresentationMessage ?? throw new Exception("Unknown message type"); } catch (Exception) { DialogService.Alert("Invalid Proof Request!"); return; } if (presentationMessage == null) { return; } try { var request = presentationMessage.Requests?.FirstOrDefault((Attachment x) => x.Id == "libindy-request-presentation-0"); if (request == null) { DialogService.Alert("scanned qr code does not look like a proof request", "Error"); return; } var proofRequest = request.Data.Base64.GetBytesFromBase64().GetUTF8String().ToObject <ProofRequest>(); if (proofRequest == null) { return; } var proofRequestViewModel = _scope.Resolve <ProofRequestViewModel>(new NamedParameter("proofRequest", proofRequest), new NamedParameter("requestPresentationMessage", presentationMessage)); await NavigationService.NavigateToAsync(proofRequestViewModel); } catch (Exception xx) { DialogService.Alert(xx.Message); } }
protected override void AdditionalSetup() { OnboardingStorage .CompletedCalendarOnboarding() .Returns(true); PermissionsService .CalendarPermissionGranted .Returns(Observable.Return(true)); NavigationService .Navigate <SelectUserCalendarsViewModel, bool, string[]>(Arg.Any <bool>()) .Returns(new string[0]); InteractorFactory .GetUserCalendars() .Execute() .Returns(Observable.Return(new UserCalendar().Yield())); DialogService .Alert(Arg.Any <string>(), Arg.Any <string>(), Arg.Any <string>()) .Returns(Observable.Return(Unit.Default)); TestScheduler.AdvanceBy(1); }
public CreateOfferViewModel(ICanService canService, IWantService wantService, ICategoryService categoryService, IDialogService dialogService, IMessengerService messenger) : base(canService, wantService, categoryService, dialogService, messenger) { Offer = new OfferModel(); if (Categories == null || Categories.Count == 0) { var mtDispatcher = Mvx.Resolve <IMvxMainThreadDispatcher>(); mtDispatcher.RequestMainThreadAction(() => { DialogService.Alert( Constants.DialogNoNetwork, Constants.DialogTitleError, Constants.DialogButtonOk, () => Close(this)); }); return; } Category = -1; }
public override async void OnShow() { if (IsLoaded) { return; } if (ReadUserSecurityService.ReadUser() != null) { try { ShowLoading("Loading Predictions..."); await LoadPredictionsAsync(); IsLoaded = true; } catch (Exception ex) { DialogService.Alert("Failed to load Predictions. Please refresh"); } finally { HideLoading(); } } }
async Task VerifyProof() { var dialog = UserDialogs.Instance.Loading("Verifying"); try { var context = await agentContextProvider.GetContextAsync(); bool success = await proofService.VerifyProofAsync(context, proofRecord.Id); if (dialog.IsShowing) { dialog.Hide(); dialog.Dispose(); } DialogService.Alert( success ? "Verified" : "Failed" ); } catch (Exception ex) { if (dialog.IsShowing) { dialog.Hide(); dialog.Dispose(); } DialogService.Alert(ex.Message); } }
public async Task ScanInvite() { ConnectionInvitationMessage invitation = null; bool isEmulated = false; //ONLY FOR TESTING if (!isEmulated) { var expectedFormat = ZXing.BarcodeFormat.QR_CODE; var opts = new ZXing.Mobile.MobileBarcodeScanningOptions { PossibleFormats = new List <ZXing.BarcodeFormat> { expectedFormat } }; var scanner = new ZXing.Mobile.MobileBarcodeScanner(); var result = await scanner.Scan(opts); if (result == null) { return; } try { invitation = await MessageDecoder.ParseMessageAsync(result.Text) as ConnectionInvitationMessage ?? throw new Exception("Unknown message type"); } catch (Exception) { DialogService.Alert("Invalid invitation!"); return; } } else { invitation = new ConnectionInvitationMessage() { Id = "453b0d8e-50d0-4a18-bf44-7d7369a0c31f", Label = "Verifier", Type = "did:sov:BzCbsNYhMrjHiqZDTUASHg;spec/connections/1.0/invitation", ImageUrl = "", RecipientKeys = new List <string>() { "DPqj1fdVajDYdVgeT36NUSoVghjkapaHpVUdwbL1z6ye" }, RoutingKeys = new List <string>() { "9RUPb4jPtR2S1P9yVy85ugwiywqqzDfxRrDZnKCTQCtH" }, ServiceEndpoint = "http://mylocalhost:5002" }; } Device.BeginInvokeOnMainThread(async() => { await NavigationService.NavigateToAsync <AcceptInviteViewModel>(invitation, NavigationType.Modal); }); }
private async Task ScanInvite() { var expectedFormat = ZXing.BarcodeFormat.QR_CODE; var opts = new ZXing.Mobile.MobileBarcodeScanningOptions { PossibleFormats = new List <ZXing.BarcodeFormat> { expectedFormat } }; var context = await _agentContextProvider.GetContextAsync(); var scanner = new ZXing.Mobile.MobileBarcodeScanner(); var result = await scanner.Scan(opts); if (result == null) { return; } AgentMessage message = await MessageDecoder.ParseMessageAsync(result.Text); switch (message) { case ConnectionInvitationMessage invitation: break; case RequestPresentationMessage presentation: RequestPresentationMessage proofRequest = (RequestPresentationMessage)presentation; var service = message.GetDecorator <ServiceDecorator>(DecoratorNames.ServiceDecorator); ProofRecord proofRecord = await _proofService.ProcessRequestAsync(context, proofRequest, null); proofRecord.SetTag("RecipientKey", service.RecipientKeys.ToList()[0]); proofRecord.SetTag("ServiceEndpoint", service.ServiceEndpoint); await _recordService.UpdateAsync(context.Wallet, proofRecord); _eventAggregator.Publish(new ApplicationEvent { Type = ApplicationEventType.ProofRequestUpdated }); break; default: DialogService.Alert("Invalid invitation!"); return; } Device.BeginInvokeOnMainThread(async() => { if (message is ConnectionInvitationMessage) { await NavigationService.NavigateToAsync <AcceptInviteViewModel>(message as ConnectionInvitationMessage, NavigationType.Modal); } }); }
private async Task DeleteCredential() { var result = await UserDialogs.Instance.ConfirmAsync("This credential will be removed and can not undo?", "Alert"); if (result) { var dialog = DialogService.Loading("Deleting"); try { var context = await _agentProvider.GetContextAsync(); await _credentialService.DeleteCredentialAsync(context, this._credential.Id); _eventAggregator.Publish(new ApplicationEvent() { Type = ApplicationEventType.CredentialRemoved }); if (dialog.IsShowing) { dialog.Hide(); dialog.Dispose(); } await NavigationService.NavigateBackAsync(); } catch (AriesFrameworkException e) { if (dialog.IsShowing) { dialog.Hide(); dialog.Dispose(); } DialogService.Alert("Some thing with Aries!", "Error", "OK"); } catch (IndyException e) { if (dialog.IsShowing) { dialog.Hide(); dialog.Dispose(); } DialogService.Alert("Some thing with Indy!", "Error", "OK"); } catch (Exception e) { if (dialog.IsShowing) { dialog.Hide(); dialog.Dispose(); } DialogService.Alert("Some thing wrong!", "Error", "OK"); } } }
private void OpenPage(int page) { if (ConnectivityService.IsConnected()) { Loading = true; DownloadService.DownloadComics(page); } else { DialogService.Alert("There is no network connection", "No Network Connection", "Ok"); } }
private async Task AcceptProofRequest() { var loadingDialog = DialogService.Loading("Proccessing"); try { this.IsBusy = true; var context = await _agentProvider.GetContextAsync(); var(message, proofRecord) = await _proofService.CreatePresentationAsync(context, ProofRequestRecord.Id, RequestedCredentials); var connectionRecord = await _connectionService.GetAsync(context, proofRecord.ConnectionId); await _messageService.SendAsync(context.Wallet, message, connectionRecord); _eventAggregator.Publish(new ApplicationEvent() { Type = ApplicationEventType.NotificationUpdated }); loadingDialog.Hide(); this.IsBusy = false; await NavigationService.NavigateBackAsync(); var toastConfig = new ToastConfig("Accepted Proof!"); toastConfig.BackgroundColor = Color.Green; toastConfig.Position = ToastPosition.Top; toastConfig.SetDuration(3000); DialogService.Toast(toastConfig); } catch (IndyException e) { this.IsBusy = false; loadingDialog.Hide(); if (e.SdkErrorCode == 212) { DialogService.Alert("You don't have any suitable credential to present", "Error", "OK"); } else { Console.WriteLine("Indy Error: " + e.Message); DialogService.Alert("Some error with libindy. We're working on it", "Error", "OK"); } } catch (Exception e) { this.IsBusy = false; loadingDialog.Hide(); Console.WriteLine("Error: " + e.Message); DialogService.Alert("Error while accept Proof Request"); } }
private async Task AcceptInvitation() { var loadingDialog = DialogService.Loading("Proccessing"); this.IsBusy = true; if (_invitation != null) { try { var agentContext = await _mobileAgentProvider.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); } loadingDialog.Hide(); await NavigationService.CloseAllPopupsAsync(); var toastConfig = new ToastConfig("Connection Saved!"); toastConfig.BackgroundColor = Color.Green; toastConfig.Position = ToastPosition.Top; toastConfig.SetDuration(3000); DialogService.Toast(toastConfig); _eventAggregator.Publish(new ApplicationEvent() { Type = ApplicationEventType.ConnectionsUpdated }); } catch (Exception e) { System.Diagnostics.Debug.WriteLine(e.ToString()); loadingDialog.Hide(); DialogService.Alert("Something went wrong!"); } } }
public async Task AcceptConnectionButton() { ConnectionInvitationMessage invitation; try { invitation = MessageUtils.DecodeMessageFromUrlFormat <ConnectionInvitationMessage>(InvitationMessageUrl); } catch (Exception) { DialogService.Alert("Invalid invitation!"); Device.BeginInvokeOnMainThread(async() => await NavigationService.PopModalAsync()); return; } }
public async Task <bool> RegisterProcess() { bool result = true; //TLPWEBServices.GetUser_JSON("JDddd"); if (registrationNumber.Length == 0) { if (App.DeviceType == "droid" || App.DeviceType == "IOS") { DialogService.Alert("Please enter your Registration Number.", null, "OK"); } else { //UserDialogs.Instance.Alert("Please enter your Registration Number."); } result = false; } App.token = registrationNumber; if (App.DeviceType == "droid" || App.DeviceType == "IOS") { DialogService.ShowLoading("Loading...", Acr.UserDialogs.MaskType.Black); } //MessageDialog msgbox_ = new MessageDialog("Loading..."); //msgbox_.ShowAsync(); try { //TODO: Call async method. if (App.DeviceType == "droid" || App.DeviceType == "IOS") { var resultAPI = await deviceAPItManager.PostRegistration(registrationNumber); // TODO : Perform the result accordly API Result. DialogService.HideLoading(); } } catch (Exception ex) { if (App.DeviceType == "droid" || App.DeviceType == "IOS") { DialogService.HideLoading(); DialogService.Alert("Something went wrong, please try again", null, "OK"); result = false; } } return(result); }
private async void Refresh() { try { ShowLoading("Refreshing..."); await LoadRankingsAsync(); } catch (Exception ex) { DialogService.Alert("Failed to reload Rankings. Please try again"); } finally { HideLoading(); } }
private async void Refresh() { try { ShowLoading("Refreshing..."); await LoadPredictionYearsAsync(); } catch { DialogService.Alert("Failed to refresh Predictions. Please try again."); } finally { HideLoading(); } }
protected async Task Refresh() { try { ShowLoading("Refreshing..."); await LoadPredictionHistoryAsync(); } catch { DialogService.Alert("Failed to reload Predictions. Please try again"); } finally { HideLoading(); } }
public async override void OnShow() { try { ShowLoading("Loading History Detail..."); await LoadPredictionHistoryAsync(); } catch { DialogService.Alert("Failed to load Predictions for Selected Year"); } finally { HideLoading(); } }
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); } }
public void DownloadHandler(DownloadInformation info) { if (info.Status == DownloadStatus.Success) { Comics = DownloadService.Comics; Loading = false; } else if (info.Status == DownloadStatus.Failed) { DialogService.Alert("Downloading failed", "", "Ok"); } else { DialogService.Alert("This page doesn't exist", "", "Ok"); } }