Exemplo n.º 1
0
        // 异步已发送SQL查询数据
        public static bool SendSqlQuery(SocketAsyncEventArgs e)
        {
            QueryPacketProParam param = (QueryPacketProParam)((AsyncUserToken)e.UserToken).Param;

            if (param.SendType == 1)
            {
                param.DownOffsert += e.BytesTransferred;
            }
            if (param.dt.btData.Length <= param.DownOffsert)
            {
                // 发送完成
                param.DownOffsert = 0;
                param.dt          = null;
            }
            else
            {
                param.SendType = 1;
                int nLen = param.GetBuf(e.Buffer, e.Offset, param.DownOffsert);
                if (nLen > 0)
                {
                    e.SetBuffer(e.Offset, nLen);
                    return(true);
                }
            }
            return(false);
        }
Exemplo n.º 2
0
        // 处理插入和更新请求
        public static void RecvInsertAndUpdate(SocketAsyncEventArgs e, Packet fp, ref bool IsSend)
        {
            AsyncUserToken      token = (AsyncUserToken)e.UserToken;
            QueryPacketProParam param = new QueryPacketProParam();

            token.Param      = param;
            param.ActionCode = fp.ActionCode;
            int nResult = DBMgr.Instance.QueryNoRet(((PacketInsertORUpdate)fp).strSql);

            PacketInsertORUpdateAck ack = new PacketInsertORUpdateAck();

            ack.CreatePIUAckPacket(nResult);
            fp.PacketToBuf(e.Buffer, e.Offset);
            e.SetBuffer(e.Offset, ack.GetPacketLen());
        }
Exemplo n.º 3
0
        // 处理查询请求
        public static void RecvLocation(SocketAsyncEventArgs e, Packet fp, ref bool IsSend)
        {
            AsyncUserToken      token = (AsyncUserToken)e.UserToken;
            QueryPacketProParam param = new QueryPacketProParam();

            token.Param      = param;
            param.ActionCode = fp.ActionCode;
            param.dt         = DBMgr.Instance.Query(((PacketQuery)fp).strSql);

            PacketQueryAck ack = new PacketQueryAck();

            ack.CreatePQAckPacket(param.dt.ColCount, param.dt.RowCount, param.dt.ColNames);
            fp.PacketToBuf(e.Buffer, e.Offset);
            param.SendType = 0;
            e.SetBuffer(e.Offset, ack.GetPacketLen());
        }