//网络定时获取数据委托测试 public void NetDataControllerStartRefreshTest() { NetDataController NDC = new NetDataController(); NetDataController.sync s=new NetDataController.sync(sync); NDC.StockRefreshAdd("0600001",ref s);//添加委托 NDC.StartRefresh(1);//刷新时间1s Thread.Sleep(3000);//等待3s看是否成功 Assert.AreEqual("邯郸钢铁", SIE.name); }
//网络定时获取数据委托测试 public void NetDataControllerStartRefreshTest() { NetDataController NDC = new NetDataController(); NetDataController.sync s = new NetDataController.sync(sync); NDC.StockRefreshAdd("0600001", ref s); //添加委托 NDC.StartRefresh(1); //刷新时间1s Thread.Sleep(3000); //等待3s看是否成功 Assert.AreEqual("邯郸钢铁", SIE.name); }
public bool Add(string id, string name, int hold, double money) { double height = -5; if (StockStateBox.pre != null) { height = StockStateBox.pre.Margin.Top + StockStateBox.pre.Height; } StockStateBox box = new StockStateBox(new StockStateBox.ChangeValues(ID.change)); box.Margin = new Thickness(5, height + 10, 0, 0); box.stockid = id; string StockID = ""; string netname; if (NetState.CheckName("0" + id, out netname) == NET_ERROR.NET_REQ_OK) { StockID = "0" + id; box.StockName.Text = netname.Insert(2, "\r\n"); } else if (NetState.CheckName("1" + id, out netname) == NET_ERROR.NET_REQ_OK) { StockID = "1" + id; box.StockName.Text = netname.Insert(2, "\r\n"); } else { MessageBox.Show("股票编号:" + id + "错误!"); box.StockName.Text = name.Insert(2, "\r\n"); return(false); } box.hold.Text = hold.ToString(); box.basemoney = money; NetDataController.sync s = new NetDataController.sync(box.UpdataSync); if (!NetSyncController.Handler().StockRefreshAdd(StockID, ref s)) { NetSyncController.Handler().StockRefreshDelete(StockID); NetSyncController.Handler().StockRefreshAdd(StockID, ref s); } canvas.Children.Add(box); canvasbox.Add(box); return(true); }
private void Window_Loaded(object sender, RoutedEventArgs e) { if (stockList.Contains(StockID)) { MessageBox.Show("已经打开了一个股票编号为:" + StockID + "的窗口\n请勿重复开启"); stockList.Add(StockID); this.Close(); return; } else { stockList.Add(StockID); } string S_StockID; if (NetState.CheckName("0" + StockID, out StockName) == NET_ERROR.NET_REQ_OK) { S_StockID = "sh" + StockID; C_StockID = "0" + StockID; } else if (NetState.CheckName("1" + StockID, out StockName) == NET_ERROR.NET_REQ_OK) { S_StockID = "sz" + StockID; C_StockID = "1" + StockID; } else { MessageBox.Show("股票编号不存在或者网络异常!"); this.Close(); return; } this.Left = (SystemParameters.PrimaryScreenWidth - this.ActualWidth) / 2; this.Top = (SystemParameters.PrimaryScreenHeight - this.ActualHeight) / 2; StockTitle.Text = "股票:" + StockName + "(" + S_StockID + ")"; NetDataController.backimage bimage = new NetDataController.backimage(UpdataImage); kchart k = kchart.time; NetSyncController.Handler().KchartImageGet(C_StockID, k, bimage); NetDataController.sync s = new NetDataController.sync(UpdataSync); NetSyncController.Handler().StockTempRefreshAdd(C_StockID, ref s); }
public bool Add(string id,string name,int hold,double money) { double height = -5; if (StockStateBox.pre != null) height = StockStateBox.pre.Margin.Top + StockStateBox.pre.Height; StockStateBox box = new StockStateBox(new StockStateBox.ChangeValues(ID.change)); box.Margin = new Thickness(5, height + 10, 0, 0); box.stockid = id; string StockID = ""; string netname; if (NetState.CheckName("0" + id, out netname) == NET_ERROR.NET_REQ_OK) { StockID = "0" + id; box.StockName.Text = netname.Insert(2, "\r\n"); } else if (NetState.CheckName("1" + id, out netname) == NET_ERROR.NET_REQ_OK) { StockID = "1" + id; box.StockName.Text = netname.Insert(2, "\r\n"); } else { MessageBox.Show("股票编号:" + id + "错误!"); box.StockName.Text = name.Insert(2, "\r\n"); return false; } box.hold.Text = hold.ToString(); box.basemoney = money; NetDataController.sync s = new NetDataController.sync(box.UpdataSync); if (!NetSyncController.Handler().StockRefreshAdd(StockID, ref s)) { NetSyncController.Handler().StockRefreshDelete(StockID); NetSyncController.Handler().StockRefreshAdd(StockID, ref s); } canvas.Children.Add(box); canvasbox.Add(box); return true; }
private void Window_Loaded(object sender, RoutedEventArgs e) { if (stockList.Contains(StockID)) { MessageBox.Show("已经打开了一个股票编号为:" + StockID + "的窗口\n请勿重复开启"); stockList.Add(StockID); this.Close(); return; } else stockList.Add(StockID); string S_StockID; if (NetState.CheckName("0" + StockID, out StockName) == NET_ERROR.NET_REQ_OK) { S_StockID = "sh" + StockID; C_StockID = "0" + StockID; } else if (NetState.CheckName("1" + StockID, out StockName) == NET_ERROR.NET_REQ_OK) { S_StockID = "sz" + StockID; C_StockID = "1" + StockID; } else { MessageBox.Show("股票编号不存在或者网络异常!"); this.Close(); return; } this.Left = (SystemParameters.PrimaryScreenWidth - this.ActualWidth) / 2; this.Top = (SystemParameters.PrimaryScreenHeight - this.ActualHeight) / 2; StockTitle.Text = "股票:" + StockName + "(" + S_StockID + ")"; NetDataController.backimage bimage = new NetDataController.backimage(UpdataImage); kchart k = kchart.time; NetSyncController.Handler().KchartImageGet(C_StockID, k, bimage); NetDataController.sync s = new NetDataController.sync(UpdataSync); NetSyncController.Handler().StockTempRefreshAdd(C_StockID, ref s); }