void grid_policy_MouseClick(object sender, MouseEventArgs e) { int col = grid_policy.Col; int row = grid_policy.Row; if (row > grid_policy.Rows.Fixed - 1) { if (col == 4) { string sdkname = this.grid_policy.Rows[row][2].ToString();// .Rows[e.RowIndex].Cells[1].Value.ToString(); string sdkdesc = this.grid_policy.Rows[row][3].ToString(); //string strSql = string.Format("delete from dll_mstr where dll_name = '{0}'", programname); if (MessageBox.Show(string.Format("是否要删除插件'{0}'?", sdkdesc), "确认", MessageBoxButtons.OKCancel) == System.Windows.Forms.DialogResult.OK) { try { TradeSDK.DeleteDLL(sdkname); RefreshGrid(); } catch { MessageBox.Show("有错误发生,请稍后再试"); } } else { grid_policy.Select(row, col - 1); } } } }
private void StartGetData() { ServerLog.ClearList(); for (int i = 0; i < SiArray.Count; i++) { if (!RunningST.ContainsKey(SiArray[i].Market)) { string market = SiArray[i].Market; string dllname = TradeSDK.getDllName(market); Assembly assembly = Assembly.Load(TradeSDK.getSDK(dllname)); Type ClassTradeAPI = assembly.GetType(string.Format("{0}.TradeAPI", dllname.Substring(0, dllname.Length - 4))); Object ObjectTradeAPI = assembly.CreateInstance(ClassTradeAPI.FullName, true, BindingFlags.CreateInstance, null, new object[] { }, null, null); BaseTradeAPI bta = ((BaseTradeAPI)ObjectTradeAPI); RunningST.Add(market, bta); TraderAccount sa = new TraderAccount(bta); bta.queryDataArrival += queryArrival; if (showTradeView) { CurrentBalances.Insert(market); Trader trader = Trader.CreateTrader(sa); traders.Add(market, trader); frm_TradeMonitor tradeform = new frm_TradeMonitor(trader); tradeform.tradePolicyResult_Arrival += PolicyResultArraival; tradeform.tradeFunPolicyResult_Arrival += PolicyFunArraival; tradeform.Left = 0; tradeform.Top = 3 * logform.Height; tradeform.Show(); tradeform.ConnectTrade(); } } foreach (var st in RunningST) { BaseTradeAPI bta = ((BaseTradeAPI)st.Value); if (bta.AbortedWs) { bta.InitWebSocket(); } if (bta.market == SiArray[i].Market) { if (!bta.DicSi.ContainsKey(SiArray[i].Code)) { bta.DicSi.Add(SiArray[i].Code, SiArray[i]); CurrentTicker.Insert(SiArray[i].Market + SiArray[i].Code); } bta.Subscribe(SiArray[i].Code, "marketDepth", SiArray[i].Type); bta.Subscribe(SiArray[i].Code, "trade", SiArray[i].Type); if (showTradeView) { bta.Subscribe(SiArray[i].Code, "order", SiArray[i].Type); bta.Subscribe(SiArray[i].Code, "account", SiArray[i].Type); if (SiArray[i].Type != "spot") { bta.Subscribe(SiArray[i].Code, "position", SiArray[i].Type); } } } } } }
public frm_MainX() { InitializeComponent(); SiArray = new List <SecurityInfo>(); da = new DataMonitor(); this.rbt_stop.Enabled = false; GlobalValue.Initialize(); PolicyProgram.Load(); TradeSDK.Load(); CheckDirectory(); _dataQueue = new ConcurrentQueue <TickData>(); RunningST = new Dictionary <string, BaseTradeAPI>(); traders = new Dictionary <string, Trader>(); }
private void bt_upload_Click(object sender, EventArgs e) { string filename = this.tx_filename.Text.Trim(); string desc = this.tx_name.Text.Trim(); if (desc == string.Empty) { MessageBox.Show("请输入插件名称"); return; } if (filename != string.Empty) { try { FileInfo fi = new FileInfo(filename); FileStream fs = fi.OpenRead(); byte[] bfs = new byte[fs.Length]; fs.Read(bfs, 0, (int)fs.Length); string fname = fi.Name; if (TradeSDK.exists(fname)) { TradeSDK.UpdateDLL(fname, bfs, desc); } else { TradeSDK.InsertDLL(fname, bfs, desc); } fs.Close(); RefreshGrid(); MessageBox.Show("上传成功"); } catch { MessageBox.Show("上传失败"); } } }
private void RefreshGrid() { if (grid_policy.Rows.Count > grid_policy.Rows.Fixed) { grid_policy.Rows.RemoveRange(grid_policy.Rows.Fixed, grid_policy.Rows.Count - grid_policy.Rows.Fixed);//.Rows.Clear(); } DataTable dt = TradeSDK.getSDKList(); for (int i = 0; i < dt.Rows.Count; i++) { grid_policy.Rows.Add(1); grid_policy.Rows[i + grid_policy.Rows.Fixed][1] = (i + 1).ToString(); //this.grid_programlist.Rows.Add(); //this.grid_programlist[0, i].Value = (i + 1).ToString(); grid_policy.Rows[i + grid_policy.Rows.Fixed][2] = dt.Rows[i][0].ToString(); grid_policy.Rows[i + grid_policy.Rows.Fixed][3] = dt.Rows[i][1].ToString(); grid_policy.SetCellImage(i + grid_policy.Rows.Fixed, 4, global::GeneralForm.Properties.Resources.Ext_Net_Build_Ext_Net_icons_cancel); //this.grid_programlist[3, i].Value = "Delete"; //this.grid_programlist[4, i].Value = "Run"; //this.grid_programlist[5, i].Value = "Download"; } }