public string AddOrder(string account, string market, string stockID, string price, string qty, string tradeSide, out string clientID) { clientID = ClientID;//应自动生成,根据帐号,每个帐号配置一个自动取的信息。 try { ClientIDTime[clientID] = DateTime.Now; //string table = @"instructions.dbf"; string symbol = Utils.GetSymbol(market, stockID); string ordertype = "0"; string catsTradeSide = Entities.CATSTypeInfo.GetTradeSide(tradeSide); OledbAdapter o = new OledbAdapter(); //string sql = string.Format("insert into {0} (inst_type, client_id, acct_type, acct, symbol, tradeside, ord_qty, ord_price, ord_type) values('{1}', '{2}', '{3}', '{4}', '{5}', '{6}', '{7}', '{8}', '{9}')", table, "O", // clientID, accType, account, symbol, tradeSide, qty, price, ordertype); var count = OledbAdapter.SetAddInstruction(clientID, Acc_Type, account, symbol, catsTradeSide, qty.ToString(), price.ToString(), ordertype); //if (count <= 0) //{ // Utils.logger.LogInfo("下单返回影响行数: {0}", count); //} return(clientID); } catch (Exception ex) { Utils.logger.LogInfo("InstructionMain Exception, Message:{0}", ex.Message); return(null); } }
private void OrderScanMain(object obj) { string table = @"order_updates.dbf"; int lastOrderNum = 0; while (true) { try { var dt = OledbAdapter.GetDataTable("select * from " + table); if (dtOrderNewst == null || dtOrderNewst.Rows.Count < dt.Rows.Count) { dtOrderNewst = dt; needRefreshOrder = true; isUpdatingOrder = true; } for (int i = lastOrderNum; i < dt.Rows.Count; i++) { UpdateOrderRow(dt.Rows[i]); } lastOrderNum = dt.Rows.Count; isUpdatingOrder = false; } catch (Exception ex) { Utils.logger.LogInfo("OrderScanMain Exception, Message:{0}", ex.Message); } Thread.Sleep(100); } }
private void InstructionMain() { int lasRowCount = 0; while (true) { try { OledbAdapter o = new OledbAdapter(); var dt = OledbAdapter.GetInstruction("select * from instructions.dbf"); if (dt != null && dt.Rows.Count > lasRowCount) { bool needRefreshAdd = false; bool needRefreshCancel = false; for (int i = lasRowCount; i < dt.Rows.Count; i++) { RefreshInstructionItem(dt.Rows[i], ref needRefreshAdd, ref needRefreshCancel); } if (_clientID == -1) { int addMax = -1; int canMax = -1; if (AddInstructionDict.Count > 0) { addMax = AddInstructionDict.Values.Max(_ => int.Parse(_.ClientId)); } if (CancelInstructionDict.Count > 0) { canMax = CancelInstructionDict.Values.Max(_ => int.Parse(_.ClientId)); } _clientID = Math.Max(addMax, canMax) + 1; } if (needRefreshAdd && OnAddInstructionChange != null) { OnAddInstructionChange.Invoke(); } //if (needRefreshCancel && OnCancelInstructionChange != null) //{ // OnCancelInstructionChange.Invoke(); //} lasRowCount = dt.Rows.Count; } else if (_clientID == -1) { _clientID = 0; } } catch (Exception ex) { Utils.logger.LogInfo("InstructionMain Exception, Message:{0}", ex.Message); } Thread.Sleep(200); } }
public bool ExistDBFData() { var insTable = OledbAdapter.GetInstruction("select * from instructions.dbf"); if (insTable != null && insTable.Rows.Count > 0) { return(true); } var ordTable = OledbAdapter.GetDataTable("select * from order_updates.dbf"); if (ordTable != null && ordTable.Rows.Count > 0) { return(true); } return(false); }
private void ASSetScanMain() { string table = @"asset.dbf"; while (true) { try { OledbAdapter o = new OledbAdapter(); var dt = OledbAdapter.GetDataTable("select * from " + table); if (FSetTable == null) { FSetTable = dt.Copy(); } if (PSetTable == null) { PSetTable = dt.Copy(); } PSetTable.Clear(); FSetTable.Clear(); if (dt.Rows.Count > 0) { //将两种数据分别记录到两个表中 foreach (DataRow row in dt.Rows) { var type = row["a_type"].ToString(); if (type == "F") { FSetTable.ImportRow(row); } else if (type == "P") { PSetTable.ImportRow(row); } } } } catch (Exception ex) { Utils.logger.LogInfo("ASSetScanMain Exception, Message:{0}", ex.Message); } Thread.Sleep(1000); } }
public int CancelOrder(string account, string orderNo) { try { //string table = @"instructions.dbf"; string clientID = ClientID;//应自动生成,根据帐号,每个帐号配置一个自动取的信息。 OledbAdapter o = new OledbAdapter(); //string sql = string.Format("insert into {0} (inst_type, client_id, acct_type, acct, order_no) values('{1}', '{2}', '{3}', '{4}', '{5}')", table, "1", clientID, Acc_Type, account, orderNo); var count = OledbAdapter.SetCancelInstruction(clientID, Acc_Type, account, orderNo); return(count); } catch (Exception ex) { Utils.logger.LogInfo("InstructionMain Exception, Message:{0}", ex.Message); } return(0); }