private void EachDealHandleBack(IAsyncResult iar) { if (iar == null) { return; } Func <List <EachDealHistoryModel> > EachDealHandle = (Func <List <EachDealHistoryModel> >)iar.AsyncState; List <EachDealHistoryModel> list = EachDealHandle.EndInvoke(iar); foreach (var item in list) { EachDealViewModel eachViewModel = new EachDealViewModel(); eachViewModel.EachDealTime = string.IsNullOrEmpty(item.time) ? "" : Convert.ToDateTime(item.time).ToString("HH:mm:ss"); eachViewModel.EachDealPrice = item.lastPrice; eachViewModel.EachDealColor = item.lastPrice >= PreClosePrice ? "Red" : "#00ff00"; var varietyModel = TradeInfoHelper.VarietyModelList.FirstOrDefault(o => string.Equals(o.productCode, _futuresViewModel.ProductCode)); if (varietyModel != null) { int precy = varietyModel.precy ?? 2; eachViewModel.EachDealKeepDigits = "F" + precy; } eachViewModel.EachDealSize = item.lastSize; eachViewModel.EachDealSizeColor = item.lastPrice <= BidP1 ? "#00ff00" : "Red"; eachViewModel.OrderByTime = string.IsNullOrEmpty(item.time) ? new DateTime() : Convert.ToDateTime(item.time); if (Application.Current != null) //判断不为空 { Application.Current.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, new Action( () => { _EachDealList.Add(eachViewModel); })); } } IsRequestEachDeal = false; }
public void SetEachDealList() { //_EachDealList.Clear(); var list = httpHelper.GetEachDealHistory(_futuresViewModel.ContractCode, _futuresViewModel.ProductCode, TradeInfoHelper.EachDealCount).OrderBy(o => (string.IsNullOrEmpty(o.time) ? new DateTime() : Convert.ToDateTime(o.time))).ToList(); foreach (var item in list) { EachDealViewModel eachViewModel = new EachDealViewModel(); eachViewModel.EachDealTime = string.IsNullOrEmpty(item.time) ? "" : Convert.ToDateTime(item.time).ToString("HH:mm:ss"); eachViewModel.EachDealPrice = item.lastPrice; eachViewModel.EachDealColor = item.lastPrice >= PreClosePrice ? "Red" : "#00ff00"; var varietyModel = TradeInfoHelper.VarietyModelList.FirstOrDefault(o => string.Equals(o.productCode, _futuresViewModel.ProductCode)); if (varietyModel != null) { int precy = varietyModel.precy ?? 2; eachViewModel.EachDealKeepDigits = "F" + precy; } eachViewModel.EachDealSize = item.lastSize; eachViewModel.EachDealSizeColor = item.lastPrice <= BidP1 ? "#00ff00" : "Red"; eachViewModel.OrderByTime = string.IsNullOrEmpty(item.time) ? new DateTime() : Convert.ToDateTime(item.time); _EachDealList.Add(eachViewModel); } }