Exemple #1
0
        // 处理上传文件请求
        public static void RecvUploadFile(SocketAsyncEventArgs e, Packet fp, ref bool IsSend)
        {
            AsyncUserToken token = (AsyncUserToken)e.UserToken;

            if (null == token.Param)
            {
                UploadFilePacketProParam param = new UploadFilePacketProParam();
                token.Param = param;
                ((PacketUploadFile)fp).ParseToParam(param);
                IsSend = false;
            }
            else
            {
                UploadFilePacketProParam param = (UploadFilePacketProParam)token.Param;
                param.dt.Write(e.Buffer, e.Offset, e.BytesTransferred);
                if (param.dt.Length >= param.FileLen)
                {
                    param.dt.Close();
                    param.dt = null;
                    int nResult = 1;
                    PacketInsertORUpdateAck ack = new PacketInsertORUpdateAck();
                    ack.CreatePIUAckPacket(nResult);
                    fp.PacketToBuf(e.Buffer, e.Offset);
                    e.SetBuffer(e.Offset, ack.GetPacketLen());
                    //IsSend = true;
                }
                else
                {
                    IsSend = false;
                }
            }
        }
Exemple #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());
        }