/// <summary> /// Add a SocketAsyncEventArg instance to the pool. /// </summary> /// <param name="item">DBCommand instance to add to the pool.</param> internal void Push(DBCommand item) { if (item == null) { throw new ArgumentNullException("添加到DBCommandPool 的item不能是空(null)"); } lock (this.pool) { this.pool.Push(item); } }
private void AddDBCmd(int cmdID, string cmdText, DBCommandEventHandler dbCommandEvent, int serverId) { DBCommand dbCmd = this._DBCmdPool.Pop(); if (null == dbCmd) { dbCmd = new DBCommand(); } dbCmd.DBCommandID = cmdID; dbCmd.DBCommandText = cmdText; dbCmd.ServerId = serverId; if (null != dbCommandEvent) { dbCmd.DBCommandEvent += dbCommandEvent; } lock (this._DBCmdQueue) { this._DBCmdQueue.Enqueue(dbCmd); } }
/// <summary> /// 添加一个新的数据库命令到队列中 /// </summary> /// <param name="cmdID"></param> /// <param name="cmdText"></param> private void AddDBCmd(int cmdID, string cmdText, DBCommandEventHandler dbCommandEvent) { DBCommand dbCmd = _DBCmdPool.Pop(); if (null == dbCmd) { dbCmd = new DBCommand(); } dbCmd.DBCommandID = cmdID; dbCmd.DBCommandText = cmdText; if (null != dbCommandEvent) { dbCmd.DBCommandEvent += dbCommandEvent; } lock (_DBCmdQueue) { _DBCmdQueue.Enqueue(dbCmd); } }
/// <summary> /// 添加一个新的数据库命令到队列中 /// </summary> /// <param name="cmdID"></param> /// <param name="cmdText"></param> public void AddDBCmd(int cmdID, string cmdText, DBCommandEventHandler dbCommandEvent) { Global.ExecuteDBCmd(cmdID, cmdText); return; DBCommand dbCmd = _DBCmdPool.Pop(); if (null == dbCmd) { dbCmd = new DBCommand(); } dbCmd.DBCommandID = cmdID; dbCmd.DBCommandText = cmdText; if (null != dbCommandEvent) { dbCmd.DBCommandEvent += dbCommandEvent; } lock (_DBCmdQueue) { _DBCmdQueue.Enqueue(dbCmd); } }
/// <summary> /// 执行数据库命令 /// </summary> /// <param name="tcpClientPool"></param> /// <param name="pool"></param> /// <param name="dbCmd"></param> /// <returns></returns> private TCPProcessCmdResults DoDBCmd(TCPClientPool tcpClientPool, TCPOutPacketPool pool, DBCommand dbCmd, out byte[] bytesData) { bytesData = Global.SendAndRecvData(dbCmd.DBCommandID, dbCmd.DBCommandText, dbCmd.ServerId, 1); if (null == bytesData || bytesData.Length <= 0) { return(TCPProcessCmdResults.RESULT_FAILED); } return(TCPProcessCmdResults.RESULT_OK); }
private TCPProcessCmdResults DoDBCmd(TCPClientPool tcpClientPool, TCPOutPacketPool pool, DBCommand dbCmd, out byte[] bytesData) { bytesData = Global.SendAndRecvData <string>(dbCmd.DBCommandID, dbCmd.DBCommandText, dbCmd.ServerId, 0); TCPProcessCmdResults result; if (bytesData == null || bytesData.Length <= 0) { result = TCPProcessCmdResults.RESULT_FAILED; } else { result = TCPProcessCmdResults.RESULT_OK; } return(result); }