private void DoVote() { if (!MultiChainVm.Connected) { throw new Exception("Not connected"); } // Get userbar to temporarily disable logout var userBar = GetVm <UserBarViewModel>(); // Reset vote progress VoteProgress = new VoteProgressViewModel(); Ui(() => { userBar.LogoutDisabled = true; Voting = true; ErrorMessage = ""; }); Task.Run(async() => { try { var words = await MultiChainVm.Vote(Questions.ToList(), _currentDetails, VoteProgress.Progress); Ui(() => { Voting = false; VoteProgress = null; userBar.LogoutDisabled = false; var postVoteVm = GetVm <PostVoteViewModel>(); postVoteVm.Voted(_currentDetails, words); MainVm.ChangeView(EvotoView.PostVote); }); } catch (CouldNotVoteException) { Ui(() => { Voting = false; VoteProgress = null; userBar.LogoutDisabled = false; ErrorMessage = "An error occurred while voting. Please try again or contact a system administrator"; }); } }); }
private async Task ConnectToBlockchain(BlockchainDetails blockchain) { if (MultiChainVm.Connected) { if (MultiChainVm.Model.Name != blockchain.ChainString) { await MultiChainVm.Disconnect(); } else { return; } } await MultiChainVm.Connect(blockchain.Host, blockchain.Port, blockchain.ChainString); }
private async Task ConnectToBlockchain(BlockchainDetails blockchain) { if (MultiChainVm.Connected) { if (MultiChainVm.Model.Name != blockchain.ChainString) { await MultiChainVm.Disconnect(); } else { return; } } await MultiChainVm.Connect(blockchain.Host, blockchain.Port, blockchain.ChainString); // Ensure our questions have been loaded. Connection may be slow await MultiChainVm.Model.WaitUntilBlockchainSynced(3, new Progress <BlockchainSyncProgress>()); }