private async void AddQuote() { string quote = contractTextBox.SelectedItem == null ? contractTextBox.Filter : contractTextBox.SelectedItem.ToString(); if (!FutureOptionList.Any((c) => string.Compare(c.Contract, quote, true) == 0)) { MessageBox.Show("输入合约" + quote + "不存在"); contractTextBox.Filter = string.Empty; return; } ClientDbContext.SaveMarketContract(MarketDataHandler.MessageWrapper.User.Id, quote, FilterSettingsWin.FilterId); var item = QuoteVMCollection.FirstOrDefault(c => c.Contract == quote); if (item != null) { quoteListView.SelectedItem = item; } else { var mktDataVM = await MarketDataHandler.SubMarketDataAsync(quote); if (mktDataVM != null) { QuoteVMCollection.Add(mktDataVM); } } }
public virtual async void LoadUserContracts() { var userId = MarketDataHandler.MessageWrapper?.User?.Id; if (userId == null) { return; } var contracts = ClientDbContext.GetUserContracts(userId, FilterSettingsWin.FilterId).Select(c => new ContractKeyVM(string.Empty, c)); if (contracts.Any()) { try { var list = await MarketDataHandler.SubMarketDataAsync(contracts); foreach (var mktVM in list) { Dispatcher.Invoke(() => QuoteVMCollection.Add(mktVM)); } } catch { } } }