/// <summary> /// Downloads a statement from the net and then parses it. /// </summary> /// <param name="name">The name of the parser and downloader.</param> public async Task LoadFromWeb(string name) { var downloader = await GetDownloaderByName(name); if (downloader == null) { return; } var parser = await GetParserByName(name); if (parser == null) { return; } ProgressDialogController progress = await _dialogService.ShowProgressAsync("Load Statement from Web", "Downloading"); Exception ex = null; var flex = await Task.Run(() => { try { return(downloader.DownloadStatement()); } catch (Exception caughtException) { ex = caughtException; return(""); } }); if (flex == "" || ex != null) { await progress.CloseAsync(); await _dialogService.ShowMessageAsync("Error downloading statement", ex.Message); return; } await Task.Run(() => parser.Parse(flex, progress)); progress.SetMessage("Updating open trades"); _tradeRepository.UpdateOpenTrades(); _tradeRepository.Save(); progress.CloseAsync().Forget(); }
private void TradePickerNewTradeTextBox_KeyDown(object sender, KeyEventArgs e) { if (e.Key == Key.Enter && !String.IsNullOrEmpty(TradePickerNewTradeTextBox.Text)) { var selectedOrder = (Order)OrdersGrid.SelectedItem; var newTrade = new Trade { Name = TradePickerNewTradeTextBox.Text, Open = true }; Context.Trades.Add(newTrade); newTrade.Tags = new List <Tag>(); Task.Run(() => { TradesRepository.AddOrder(newTrade, selectedOrder); TradesRepository.Save(); }); TradePickerNewTradeTextBox.Text = ""; OrdersGridTradePickerPopup.IsOpen = false; OrdersGrid.CommitEdit(); } }