private void LoadTransactionHistory() { BackgroundWork <List <XDagTransaction> > .CreateWork( this, () => { ////biTransactionHistoryLoading.IsBusy = true; this.grdBusyIndicator.Visibility = Visibility.Visible; this.tabItemHistory.IsEnabled = false; }, () => { List <XDagTransaction> transactions = XDagTransactionProvider.GetTransactionHistory(xdagWallet.Address); return(transactions); }, (taskResult) => { ////biTransactionHistoryLoading.IsBusy = false; this.grdBusyIndicator.Visibility = Visibility.Hidden; this.tabItemHistory.IsEnabled = true; if (taskResult.HasError) { // Do nothing return; } List <XDagTransaction> transactions = taskResult.Result; // Merge the Transaction results into the current history foreach (XDagTransaction tran in transactions) { if (!transactionHistory.Any(t => (t.BlockAddress == tran.BlockAddress))) { transactionHistory.Add(tran); } else { XDagTransaction existing = transactionHistory.FirstOrDefault(t => (t.BlockAddress == tran.BlockAddress)); existing.MergeWith(tran); } } /* * foreach(XDagTransaction transaction in transactionHistory) * { * LoadTransactionDataAsync(transaction); * } */ } ).Execute(); }
private void OnFillTransactionHistoryData(object sender, ElapsedEventArgs e) { DateTime startTime = e.SignalTime; foreach (XDagTransaction transaction in transactionHistory) { if (startTime + TimeSpan.FromSeconds(15) < DateTime.Now) { return; } if (!string.IsNullOrWhiteSpace(transaction.PartnerAddress)) { continue; } if (fillingTransactionHistory.Contains(transaction)) { continue; } try { fillingTransactionHistory.Add(transaction); XDagTransactionProvider.FillTransactionData(xdagWallet.Address, transaction); this.Dispatcher.Invoke(() => { this.dgdTransactionHistorySimple.Items.Refresh(); }); } catch (Exception) { // Ignore the exception } finally { try { fillingTransactionHistory.Remove(transaction); } catch (Exception) { // Ignore the exception } } } }
private void btnTest_Click(object sender, RoutedEventArgs e) { try { List <XDagTransaction> transactions = XDagTransactionProvider.GetTransactionHistory("1Nwa0TCr5umw5ZLAvKmHCl+SJDP21dyL"); MessageBox.Show(transactions[0].Amount.ToString()); XDagTransactionProvider.FillTransactionData(xdagWallet.Address, transactions[0]); MessageBox.Show(transactions[0].Status.ToString()); MessageBox.Show(transactions[0].PartnerAddress); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
private void LoadTransactionDataAsync(XDagTransaction transaction) { if (!string.IsNullOrWhiteSpace(transaction.PartnerAddress)) { return; } BackgroundWork.CreateWork( this, () => { }, () => { XDagTransactionProvider.FillTransactionData(xdagWallet.Address, transaction); return(0); }, (taskResult) => { this.dgdTransactionHistorySimple.Items.Refresh(); } ).Execute(); }