• 2267阅读
  • 0回复

网狐6603游戏-部分源码 [复制链接]

上一主题 下一主题
离线啊冲
 

只看楼主 倒序阅读 使用道具 楼主  发表于: 2016-12-05
— 本帖被 啊冲 执行加亮操作(2016-12-06) —
Microsoft Visual Studio Solution File, Format Version 8.00


#include "StdAfx.h"
#include "ServiceUnits.h"
#include "DataBaseEngineSink.h"

//////////////////////////////////////////////////////////////////////////////////

//构造函数
CDataBaseEngineSink::CDataBaseEngineSink()
{
    //配置变量
    m_pGameParameter=NULL;
    m_pInitParameter=NULL;
    m_pDataBaseParameter=NULL;
    m_pGameServiceAttrib=NULL;
    m_pGameServiceOption=NULL;

    //组件变量
    m_pIDataBaseEngine=NULL;
    m_pIGameServiceManager=NULL;
    m_pIDataBaseEngineEvent=NULL;
    m_pIGameDataBaseEngineSink=NULL;
    m_pIDBCorrespondManager=NULL;

    //辅助变量
    ZeroMemory(&m_LogonFailure,sizeof(m_LogonFailure));
    ZeroMemory(&m_LogonSuccess,sizeof(m_LogonSuccess));

    return;
}

//析构函数
CDataBaseEngineSink::~CDataBaseEngineSink()
{
    //释放对象
    SafeRelease(m_pIGameDataBaseEngineSink);

    return;
}

//接口查询
VOID * CDataBaseEngineSink::QueryInterface(REFGUID Guid, DWORD dwQueryVer)
{
    QUERYINTERFACE(IDataBaseEngineSink,Guid,dwQueryVer);
    QUERYINTERFACE(IGameDataBaseEngine,Guid,dwQueryVer);
    QUERYINTERFACE_IUNKNOWNEX(IDataBaseEngineSink,Guid,dwQueryVer);
    return NULL;
}

//获取对象
VOID * CDataBaseEngineSink::GetDataBase(REFGUID Guid, DWORD dwQueryVer)
{
    //效验状态
    ASSERT(m_GameDBModule.GetInterface()!=NULL);
    if (m_GameDBModule.GetInterface()==NULL) return NULL;

    //查询对象
    IDataBase * pIDataBase=m_GameDBModule.GetInterface();
    VOID * pIQueryObject=pIDataBase->QueryInterface(Guid,dwQueryVer);

    return pIQueryObject;
}

//获取对象
VOID * CDataBaseEngineSink::GetDataBaseEngine(REFGUID Guid, DWORD dwQueryVer)
{
    //效验状态
    ASSERT(m_pIDataBaseEngine!=NULL);
    if (m_pIDataBaseEngine==NULL) return NULL;

    //查询对象
    VOID * pIQueryObject=m_pIDataBaseEngine->QueryInterface(Guid,dwQueryVer);

    return pIQueryObject;
}

//投递结果
bool CDataBaseEngineSink::PostGameDataBaseResult(WORD wRequestID, VOID * pData, WORD wDataSize)
{
    return true;
}

//启动事件
bool CDataBaseEngineSink::OnDataBaseEngineStart(IUnknownEx * pIUnknownEx)
{
    //查询对象
    ASSERT(QUERY_OBJECT_PTR_INTERFACE(pIUnknownEx,IDataBaseEngine)!=NULL);
    m_pIDataBaseEngine=QUERY_OBJECT_PTR_INTERFACE(pIUnknownEx,IDataBaseEngine);

    //创建对象
    if ((m_GameDBModule.GetInterface()==NULL)&&(m_GameDBModule.CreateInstance()==false))
    {
        ASSERT(FALSE);
        return false;
    }

    //创建对象
    if ((m_TreasureDBModule.GetInterface()==NULL)&&(m_TreasureDBModule.CreateInstance()==false))
    {
        ASSERT(FALSE);
        return false;
    }

    //连接游戏
    try
    {
        //连接信息
        tagDataBaseParameter * pTreasureDBParameter=&m_pInitParameter->m_TreasureDBParameter;

        //设置连接
        m_GameDBModule->SetConnectionInfo(m_pDataBaseParameter->szDataBaseAddr,m_pDataBaseParameter->wDataBasePort,
            m_pDataBaseParameter->szDataBaseName,m_pDataBaseParameter->szDataBaseUser,m_pDataBaseParameter->szDataBasePass);

        //设置连接
        m_TreasureDBModule->SetConnectionInfo(pTreasureDBParameter->szDataBaseAddr,pTreasureDBParameter->wDataBasePort,
            pTreasureDBParameter->szDataBaseName,pTreasureDBParameter->szDataBaseUser,pTreasureDBParameter->szDataBasePass);

        //发起连接
        m_GameDBModule->OpenConnection();
        m_GameDBAide.SetDataBase(m_GameDBModule.GetInterface());

        //发起连接
        m_TreasureDBModule->OpenConnection();
        m_TreasureDBAide.SetDataBase(m_TreasureDBModule.GetInterface());

        //数据钩子
        ASSERT(m_pIGameServiceManager!=NULL);
        m_pIGameDataBaseEngineSink=(IGameDataBaseEngineSink *)m_pIGameServiceManager->CreateGameDataBaseEngineSink(IID_IGameDataBaseEngineSink,VER_IGameDataBaseEngineSink);

        //配置对象
        if ((m_pIGameDataBaseEngineSink!=NULL)&&(m_pIGameDataBaseEngineSink->InitializeSink(QUERY_ME_INTERFACE(IUnknownEx))==false))
        {
            //错误断言
            ASSERT(FALSE);

            //输出信息
            CTraceService::TraceString(TEXT("游戏数据库扩展钩子引擎对象配置失败"),TraceLevel_Exception);

            return false;
        }

        return true;
    }
    catch (IDataBaseException * pIException)
    {
        //错误信息
        CTraceService::TraceString(pIException->GetExceptionDescribe(),TraceLevel_Exception);

        return false;
    }

    return true;
}

//停止事件
bool CDataBaseEngineSink::OnDataBaseEngineConclude(IUnknownEx * pIUnknownEx)
{
    //配置变量
    m_pInitParameter=NULL;
    m_pGameServiceAttrib=NULL;
    m_pGameServiceOption=NULL;

    //组件变量
    m_pIGameServiceManager=NULL;
    m_pIDataBaseEngineEvent=NULL;

    //设置对象
    m_GameDBAide.SetDataBase(NULL);

    //释放对象
    SafeRelease(m_pIGameDataBaseEngineSink);

    //关闭连接
    if (m_GameDBModule.GetInterface()!=NULL)
    {
        m_GameDBModule->CloseConnection();
        m_GameDBModule.CloseInstance();
    }

    //关闭连接
    if (m_TreasureDBModule.GetInterface()!=NULL)
    {
        m_TreasureDBModule->CloseConnection();
        m_TreasureDBModule.CloseInstance();
    }

    return true;
}

//时间事件
bool CDataBaseEngineSink::OnDataBaseEngineTimer(DWORD dwTimerID, WPARAM dwBindParameter)
{
    return false;
}

//控制事件
bool CDataBaseEngineSink::OnDataBaseEngineControl(WORD wControlID, VOID * pData, WORD wDataSize)
{
    return false;
}

//请求事件
bool CDataBaseEngineSink::OnDataBaseEngineRequest(WORD wRequestID, DWORD dwContextID, VOID * pData, WORD wDataSize)
{
    //变量定义
    bool bSucceed = false;
    DWORD dwUserID = 0L;

    //请求处理
    switch (wRequestID)
    {
    case DBR_GR_LOGON_USERID:            //I D 登录
        {
            bSucceed = OnRequestLogonUserID(dwContextID,pData,wDataSize,dwUserID);
        }
        break;
    case DBR_GR_LOGON_MOBILE:            //手机登录
        {
            bSucceed = OnRequestLogonMobile(dwContextID,pData,wDataSize,dwUserID);
        }
        break;
    case DBR_GR_LOGON_ACCOUNTS:            //帐号登录
        {
            bSucceed = OnRequestLogonAccounts(dwContextID,pData,wDataSize,dwUserID);
        }
        break;
    case DBR_GR_WRITE_GAME_SCORE:        //游戏写分
        {
            bSucceed = OnRequestWriteGameScore(dwContextID,pData,wDataSize,dwUserID);
        }
        break;
    case DBR_GR_LEAVE_GAME_SERVER:        //离开房间
        {
            bSucceed = OnRequestLeaveGameServer(dwContextID,pData,wDataSize,dwUserID);
        }
        break;
    case DBR_GR_GAME_SCORE_RECORD:        //游戏记录
        {
            bSucceed = OnRequestGameScoreRecord(dwContextID,pData,wDataSize,dwUserID);
        }
        break;
    case DBR_GR_LOAD_PARAMETER:            //加载参数
        {
            bSucceed = OnRequestLoadParameter(dwContextID,pData,wDataSize,dwUserID);
        }
        break;
    case DBR_GR_LOAD_GAME_COLUMN:        //加载列表
        {
            bSucceed = OnRequestLoadGameColumn(dwContextID,pData,wDataSize,dwUserID);
        }
        break;
    case DBR_GR_LOAD_ANDROID_USER:        //加载机器
        {
            bSucceed = OnRequestLoadAndroidUser(dwContextID,pData,wDataSize,dwUserID);
        }
        break;
    case DBR_GR_LOAD_GAME_PROPERTY:        //加载道具
        {
            bSucceed = OnRequestLoadGameProperty(dwContextID,pData,wDataSize,dwUserID);
        }
        break;
    case DBR_GR_USER_SAVE_SCORE:        //存入金币
        {
            bSucceed = OnRequestUserSaveScore(dwContextID,pData,wDataSize,dwUserID);
        }
        break;
    case DBR_GR_USER_TAKE_SCORE:        //提取金币
        {
            bSucceed = OnRequestUserTakeScore(dwContextID,pData,wDataSize,dwUserID);
        }
        break;
    case DBR_GR_USER_TRANSFER_SCORE:    //转账金币
        {
            bSucceed = OnRequestUserTransferScore(dwContextID,pData,wDataSize,dwUserID);
        }
        break;
    case DBR_GR_QUERY_INSURE_INFO:        //查询银行
        {
            bSucceed = OnRequestQueryInsureInfo(dwContextID,pData,wDataSize,dwUserID);
        }
        break;
    case DBR_GR_PROPERTY_REQUEST:        //道具请求
        {
            bSucceed = OnRequestPropertyRequest(dwContextID,pData,wDataSize,dwUserID);
        }
        break;
    case DBR_GR_MANAGE_USER_RIGHT:        //用户权限
        {
            bSucceed = OnRequestManageUserRight(dwContextID,pData,wDataSize,dwUserID);
        }
        break;
    case DBR_GR_MATCH_FEE:                //比赛费用
        {
            bSucceed = OnRequestMatchFee(dwContextID,pData,wDataSize,dwUserID);
        }
        break;
    case DBR_GR_MATCH_START:            //比赛开始
        {
            bSucceed = OnRequestMatchStart(dwContextID,pData,wDataSize,dwUserID);
        }
        break;
    case DBR_GR_MATCH_OVER:                //比赛结束
        {
            bSucceed = OnRequestMatchOver(dwContextID,pData,wDataSize,dwUserID);
        }
        break;
    case DBR_GR_MATCH_REWARD:            //比赛奖励
        {
            bSucceed = OnRequestMatchReward(dwContextID,pData,wDataSize,dwUserID);
        }
        break;
    case DBR_GR_MATCH_QUIT:                //退出比赛
        {
            bSucceed = OnRequestMatchQuit(dwContextID,pData,wDataSize,dwUserID);
        }
        break;
    }

    //协调通知
    if(m_pIDBCorrespondManager) m_pIDBCorrespondManager->OnPostRequestComplete(dwUserID, bSucceed);

    return bSucceed;
}

//I D 登录
bool CDataBaseEngineSink::OnRequestLogonUserID(DWORD dwContextID, VOID * pData, WORD wDataSize, DWORD &dwUserID)
{
    //执行查询
    DBR_GR_LogonUserID * pLogonUserID=(DBR_GR_LogonUserID *)pData;
    dwUserID = pLogonUserID->dwUserID;

    //效验参数
    ASSERT(wDataSize==sizeof(DBR_GR_LogonUserID));
    if (wDataSize!=sizeof(DBR_GR_LogonUserID)) return false;

    try
    {
        //转化地址
        TCHAR szClientAddr[16]=TEXT("");
        BYTE * pClientAddr=(BYTE *)&pLogonUserID->dwClientAddr;
        _sntprintf(szClientAddr,CountArray(szClientAddr),TEXT("%d.%d.%d.%d"),pClientAddr[0],pClientAddr[1],pClientAddr[2],pClientAddr[3]);

        //构造参数
        m_GameDBAide.ResetParameter();
        m_GameDBAide.AddParameter(TEXT("@dwUserID"),pLogonUserID->dwUserID);
        m_GameDBAide.AddParameter(TEXT("@strPassword"),pLogonUserID->szPassword);
        m_GameDBAide.AddParameter(TEXT("@strClientIP"),szClientAddr);
        m_GameDBAide.AddParameter(TEXT("@strMachineID"),pLogonUserID->szMachineID);
        m_GameDBAide.AddParameter(TEXT("@wKindID"),m_pGameServiceOption->wKindID);
        m_GameDBAide.AddParameter(TEXT("@wServerID"),m_pGameServiceOption->wServerID);
        m_GameDBAide.AddParameterOutput(TEXT("@strErrorDescribe"),m_LogonFailure.szDescribeString,sizeof(m_LogonFailure.szDescribeString),adParamOutput);

        //执行查询
        LONG lResultCode=m_GameDBAide.ExecuteProcess(TEXT("GSP_GR_EfficacyUserID"),true);

        //用户信息
        lstrcpyn(m_LogonSuccess.szPassword,pLogonUserID->szPassword,CountArray(m_LogonSuccess.szPassword));
        lstrcpyn(m_LogonSuccess.szMachineID,pLogonUserID->szMachineID,CountArray(m_LogonSuccess.szMachineID));
    
        //结果处理
        CDBVarValue DBVarValue;
        m_GameDBModule->GetParameter(TEXT("@strErrorDescribe"),DBVarValue);
        OnLogonDisposeResult(dwContextID,lResultCode,CW2CT(DBVarValue.bstrVal),false);

        return true;
    }
    catch (IDataBaseException * pIException)
    {
        //错误信息
        CTraceService::TraceString(pIException->GetExceptionDescribe(),TraceLevel_Exception);

        //错误处理
        OnLogonDisposeResult(dwContextID,DB_ERROR,TEXT("由于数据库操作异常,请您稍后重试或选择另一服务器登录!"),false);

        return false;
    }

    return true;
}

//I D 登录
bool CDataBaseEngineSink::OnRequestLogonMobile(DWORD dwContextID, VOID * pData, WORD wDataSize, DWORD &dwUserID)
{
    //执行查询
    DBR_GR_LogonMobile * pLogonMobile=(DBR_GR_LogonMobile *)pData;
    dwUserID = pLogonMobile->dwUserID;

    try
    {
        //效验参数
        ASSERT(wDataSize==sizeof(DBR_GR_LogonMobile));
        if (wDataSize!=sizeof(DBR_GR_LogonMobile)) return false;

        //转化地址
        TCHAR szClientAddr[16]=TEXT("");
        BYTE * pClientAddr=(BYTE *)&pLogonMobile->dwClientAddr;
        _sntprintf(szClientAddr,CountArray(szClientAddr),TEXT("%d.%d.%d.%d"),pClientAddr[0],pClientAddr[1],pClientAddr[2],pClientAddr[3]);

        //构造参数
        m_GameDBAide.ResetParameter();
        m_GameDBAide.AddParameter(TEXT("@dwUserID"),pLogonMobile->dwUserID);
        m_GameDBAide.AddParameter(TEXT("@strPassword"),pLogonMobile->szPassword);
        m_GameDBAide.AddParameter(TEXT("@strClientIP"),szClientAddr);
        m_GameDBAide.AddParameter(TEXT("@strMachineID"),pLogonMobile->szMachineID);
        m_GameDBAide.AddParameter(TEXT("@wKindID"),m_pGameServiceOption->wKindID);
        m_GameDBAide.AddParameter(TEXT("@wServerID"),m_pGameServiceOption->wServerID);
        m_GameDBAide.AddParameterOutput(TEXT("@strErrorDescribe"),m_LogonFailure.szDescribeString,sizeof(m_LogonFailure.szDescribeString),adParamOutput);

        //执行查询
        LONG lResultCode=m_GameDBAide.ExecuteProcess(TEXT("GSP_GR_EfficacyMobile"),true);

        //用户信息
        lstrcpyn(m_LogonSuccess.szPassword,pLogonMobile->szPassword,CountArray(m_LogonSuccess.szPassword));
        lstrcpyn(m_LogonSuccess.szMachineID,pLogonMobile->szMachineID,CountArray(m_LogonSuccess.szMachineID));
        m_LogonSuccess.cbDeviceType=pLogonMobile->cbDeviceType;
        m_LogonSuccess.wBehaviorFlags=pLogonMobile->wBehaviorFlags;
        m_LogonSuccess.wPageTableCount=pLogonMobile->wPageTableCount;
    
        //结果处理
        CDBVarValue DBVarValue;
        m_GameDBModule->GetParameter(TEXT("@strErrorDescribe"),DBVarValue);
        OnLogonDisposeResult(dwContextID,lResultCode,CW2CT(DBVarValue.bstrVal),true,pLogonMobile->cbDeviceType,pLogonMobile->wBehaviorFlags,pLogonMobile->wPageTableCount);

        return true;
    }
    catch (IDataBaseException * pIException)
    {
        //错误信息
        CTraceService::TraceString(pIException->GetExceptionDescribe(),TraceLevel_Exception);

        //错误处理
        OnLogonDisposeResult(dwContextID,DB_ERROR,TEXT("由于数据库操作异常,请您稍后重试或选择另一服务器登录!"),true);

        return false;
    }

    return true;
}

//帐号登录
bool CDataBaseEngineSink::OnRequestLogonAccounts(DWORD dwContextID, VOID * pData, WORD wDataSize, DWORD &dwUserID)
{
    try
    {
        //效验参数
        ASSERT(wDataSize==sizeof(DBR_GR_LogonAccounts));
        if (wDataSize!=sizeof(DBR_GR_LogonAccounts)) return false;

        //请求处理
        DBR_GR_LogonAccounts * pLogonAccounts=(DBR_GR_LogonAccounts *)pData;

        //转化地址
        TCHAR szClientAddr[16]=TEXT("");
        BYTE * pClientAddr=(BYTE *)&pLogonAccounts->dwClientAddr;
        _sntprintf(szClientAddr,CountArray(szClientAddr),TEXT("%d.%d.%d.%d"),pClientAddr[0],pClientAddr[1],pClientAddr[2],pClientAddr[3]);

        //构造参数
        m_GameDBAide.ResetParameter();
        m_GameDBAide.AddParameter(TEXT("@strAccounts"),pLogonAccounts->szAccounts);
        m_GameDBAide.AddParameter(TEXT("@strPassword"),pLogonAccounts->szPassword);
        m_GameDBAide.AddParameter(TEXT("@strClientIP"),szClientAddr);
        m_GameDBAide.AddParameter(TEXT("@strMachineID"),pLogonAccounts->szMachineID);
        m_GameDBAide.AddParameter(TEXT("@wKindID"),m_pGameServiceOption->wKindID);
        m_GameDBAide.AddParameter(TEXT("@wServerID"),m_pGameServiceOption->wServerID);
        m_GameDBAide.AddParameterOutput(TEXT("@strErrorDescribe"),m_LogonFailure.szDescribeString,sizeof(m_LogonFailure.szDescribeString),adParamOutput);

        //执行查询
        LONG lResultCode=m_GameDBAide.ExecuteProcess(TEXT("GSP_GR_EfficacyAccounts"),true);

        //用户信息
        lstrcpyn(m_LogonSuccess.szPassword,pLogonAccounts->szPassword,CountArray(m_LogonSuccess.szPassword));
        lstrcpyn(m_LogonSuccess.szMachineID,pLogonAccounts->szMachineID,CountArray(m_LogonSuccess.szMachineID));

        //结果处理
        CDBVarValue DBVarValue;
        m_GameDBModule->GetParameter(TEXT("@strErrorDescribe"),DBVarValue);
        OnLogonDisposeResult(dwContextID,lResultCode,CW2CT(DBVarValue.bstrVal),false);

        return true;
    }
    catch (IDataBaseException * pIException)
    {
        //错误信息
        CTraceService::TraceString(pIException->GetExceptionDescribe(),TraceLevel_Exception);

        //错误处理
        OnLogonDisposeResult(dwContextID,DB_ERROR,TEXT("由于数据库操作异常,请您稍后重试或选择另一服务器登录!"),false);

        return false;
    }

    return true;
}

//游戏写分
bool CDataBaseEngineSink::OnRequestWriteGameScore(DWORD dwContextID, VOID * pData, WORD wDataSize, DWORD &dwUserID)
{
    //请求处理
    DBR_GR_WriteGameScore * pWriteGameScore=(DBR_GR_WriteGameScore *)pData;
    dwUserID=pWriteGameScore->dwUserID;

    try
    {
        //效验参数
        ASSERT(wDataSize==sizeof(DBR_GR_WriteGameScore));
        if (wDataSize!=sizeof(DBR_GR_WriteGameScore)) return false;

        //转化地址
        TCHAR szClientAddr[16]=TEXT("");
        BYTE * pClientAddr=(BYTE *)&pWriteGameScore->dwClientAddr;
        _sntprintf(szClientAddr,CountArray(szClientAddr),TEXT("%d.%d.%d.%d"),pClientAddr[0],pClientAddr[1],pClientAddr[2],pClientAddr[3]);

        //构造参数
        m_GameDBAide.ResetParameter();

        //系统信息
        m_GameDBAide.AddParameter(TEXT("@dwUserID"),pWriteGameScore->dwUserID);

        //变更成绩
        m_GameDBAide.AddParameter(TEXT("@lScore"),pWriteGameScore->VariationInfo.lScore);
        m_GameDBAide.AddParameter(TEXT("@lGrade"),pWriteGameScore->VariationInfo.lGrade);
        m_GameDBAide.AddParameter(TEXT("@lInsure"),pWriteGameScore->VariationInfo.lInsure);
        m_GameDBAide.AddParameter(TEXT("@lRevenue"),pWriteGameScore->VariationInfo.lRevenue);
        m_GameDBAide.AddParameter(TEXT("@lWinCount"),pWriteGameScore->VariationInfo.dwWinCount);
        m_GameDBAide.AddParameter(TEXT("@lLostCount"),pWriteGameScore->VariationInfo.dwLostCount);
        m_GameDBAide.AddParameter(TEXT("@lDrawCount"),pWriteGameScore->VariationInfo.dwDrawCount);
        m_GameDBAide.AddParameter(TEXT("@lFleeCount"),pWriteGameScore->VariationInfo.dwFleeCount);
        m_GameDBAide.AddParameter(TEXT("@lUserMedal"),pWriteGameScore->VariationInfo.dwUserMedal);
        m_GameDBAide.AddParameter(TEXT("@lExperience"),pWriteGameScore->VariationInfo.dwExperience);
        m_GameDBAide.AddParameter(TEXT("@lLoveLiness"),pWriteGameScore->VariationInfo.lLoveLiness);
        m_GameDBAide.AddParameter(TEXT("@dwPlayTimeCount"),pWriteGameScore->VariationInfo.dwPlayTimeCount);

        //属性信息
        m_GameDBAide.AddParameter(TEXT("@wKindID"),m_pGameServiceOption->wKindID);
        m_GameDBAide.AddParameter(TEXT("@wServerID"),m_pGameServiceOption->wServerID);
        m_GameDBAide.AddParameter(TEXT("@strClientIP"),szClientAddr);

        //执行查询
        LONG lResultCode=m_GameDBAide.ExecuteProcess(TEXT("GSP_GR_WriteGameScore"),false);

        return true;
    }
    catch (IDataBaseException * pIException)
    {
        //输出错误
        CTraceService::TraceString(pIException->GetExceptionDescribe(),TraceLevel_Exception);

        return false;
    }

    return true;
}

//离开房间
bool CDataBaseEngineSink::OnRequestLeaveGameServer(DWORD dwContextID, VOID * pData, WORD wDataSize, DWORD &dwUserID)
{
    //请求处理
    DBR_GR_LeaveGameServer * pLeaveGameServer=(DBR_GR_LeaveGameServer *)pData;
    dwUserID=pLeaveGameServer->dwUserID;

    try
    {
        //效验参数
        ASSERT(wDataSize==sizeof(DBR_GR_LeaveGameServer));
        if (wDataSize!=sizeof(DBR_GR_LeaveGameServer)) return false;

        //转化地址
        TCHAR szClientAddr[16]=TEXT("");
        BYTE * pClientAddr=(BYTE *)&pLeaveGameServer->dwClientAddr;
        _sntprintf(szClientAddr,CountArray(szClientAddr),TEXT("%d.%d.%d.%d"),pClientAddr[0],pClientAddr[1],pClientAddr[2],pClientAddr[3]);

        //构造参数
        m_GameDBAide.ResetParameter();

        //用户信息
        m_GameDBAide.AddParameter(TEXT("@dwUserID"),pLeaveGameServer->dwUserID);
        m_GameDBAide.AddParameter(TEXT("@dwOnLineTimeCount"),pLeaveGameServer->dwOnLineTimeCount);

        //系统信息
        m_GameDBAide.AddParameter(TEXT("@dwInoutIndex"),pLeaveGameServer->dwInoutIndex);
        m_GameDBAide.AddParameter(TEXT("@dwLeaveReason"),pLeaveGameServer->dwLeaveReason);

        //记录成绩
        m_GameDBAide.AddParameter(TEXT("@lRecordScore"),pLeaveGameServer->RecordInfo.lScore);
        m_GameDBAide.AddParameter(TEXT("@lRecordGrade"),pLeaveGameServer->RecordInfo.lGrade);
        m_GameDBAide.AddParameter(TEXT("@lRecordInsure"),pLeaveGameServer->RecordInfo.lInsure);
        m_GameDBAide.AddParameter(TEXT("@lRecordRevenue"),pLeaveGameServer->RecordInfo.lRevenue);
        m_GameDBAide.AddParameter(TEXT("@lRecordWinCount"),pLeaveGameServer->RecordInfo.dwWinCount);
        m_GameDBAide.AddParameter(TEXT("@lRecordLostCount"),pLeaveGameServer->RecordInfo.dwLostCount);
        m_GameDBAide.AddParameter(TEXT("@lRecordDrawCount"),pLeaveGameServer->RecordInfo.dwDrawCount);
        m_GameDBAide.AddParameter(TEXT("@lRecordFleeCount"),pLeaveGameServer->RecordInfo.dwFleeCount);
        m_GameDBAide.AddParameter(TEXT("@lRecordUserMedal"),pLeaveGameServer->RecordInfo.dwUserMedal);
        m_GameDBAide.AddParameter(TEXT("@lRecordExperience"),pLeaveGameServer->RecordInfo.dwExperience);
        m_GameDBAide.AddParameter(TEXT("@lRecordLoveLiness"),pLeaveGameServer->RecordInfo.lLoveLiness);
        m_GameDBAide.AddParameter(TEXT("@dwRecordPlayTimeCount"),pLeaveGameServer->RecordInfo.dwPlayTimeCount);

        //变更成绩
        m_GameDBAide.AddParameter(TEXT("@lVariationScore"),pLeaveGameServer->VariationInfo.lScore);
        m_GameDBAide.AddParameter(TEXT("@lVariationGrade"),pLeaveGameServer->VariationInfo.lGrade);
        m_GameDBAide.AddParameter(TEXT("@lVariationInsure"),pLeaveGameServer->VariationInfo.lInsure);
        m_GameDBAide.AddParameter(TEXT("@lVariationRevenue"),pLeaveGameServer->VariationInfo.lRevenue);
        m_GameDBAide.AddParameter(TEXT("@lVariationWinCount"),pLeaveGameServer->VariationInfo.dwWinCount);
        m_GameDBAide.AddParameter(TEXT("@lVariationLostCount"),pLeaveGameServer->VariationInfo.dwLostCount);
        m_GameDBAide.AddParameter(TEXT("@lVariationDrawCount"),pLeaveGameServer->VariationInfo.dwDrawCount);
        m_GameDBAide.AddParameter(TEXT("@lVariationFleeCount"),pLeaveGameServer->VariationInfo.dwFleeCount);
        m_GameDBAide.AddParameter(TEXT("@lVariationUserMedal"),pLeaveGameServer->VariationInfo.dwUserMedal);
        m_GameDBAide.AddParameter(TEXT("@lVariationExperience"),pLeaveGameServer->VariationInfo.dwExperience);
        m_GameDBAide.AddParameter(TEXT("@lVariationLoveLiness"),pLeaveGameServer->VariationInfo.lLoveLiness);
        m_GameDBAide.AddParameter(TEXT("@dwVariationPlayTimeCount"),pLeaveGameServer->VariationInfo.dwPlayTimeCount);

        //其他参数
        m_GameDBAide.AddParameter(TEXT("@wKindID"),m_pGameServiceOption->wKindID);
        m_GameDBAide.AddParameter(TEXT("@wServerID"),m_pGameServiceOption->wServerID);
        m_GameDBAide.AddParameter(TEXT("@strClientIP"),szClientAddr);
        m_GameDBAide.AddParameter(TEXT("@strMachineID"),pLeaveGameServer->szMachineID);

        //执行查询
        LONG lResultCode=m_GameDBAide.ExecuteProcess(TEXT("GSP_GR_LeaveGameServer"),false);

        return true;
    }
    catch (IDataBaseException * pIException)
    {
        //输出错误
        CTraceService::TraceString(pIException->GetExceptionDescribe(),TraceLevel_Exception);

        return false;
    }

    return true;
}

//游戏记录
bool CDataBaseEngineSink::OnRequestGameScoreRecord(DWORD dwContextID, VOID * pData, WORD wDataSize, DWORD &dwUserID)
{
    try
    {
        //变量定义
        DBR_GR_GameScoreRecord * pGameScoreRecord=(DBR_GR_GameScoreRecord *)pData;
        dwUserID=INVALID_DWORD;

        //效验参数
        ASSERT(wDataSize<=sizeof(DBR_GR_GameScoreRecord));
        ASSERT(wDataSize>=(sizeof(DBR_GR_GameScoreRecord)-sizeof(pGameScoreRecord->GameScoreRecord)));
        ASSERT(wDataSize==(sizeof(DBR_GR_GameScoreRecord)-sizeof(pGameScoreRecord->GameScoreRecord)+pGameScoreRecord->wRecordCount*sizeof(pGameScoreRecord->GameScoreRecord[0])));

        //效验参数
        if (wDataSize>sizeof(DBR_GR_GameScoreRecord)) return false;
        if (wDataSize<(sizeof(DBR_GR_GameScoreRecord)-sizeof(pGameScoreRecord->GameScoreRecord))) return false;
        if (wDataSize!=(sizeof(DBR_GR_GameScoreRecord)-sizeof(pGameScoreRecord->GameScoreRecord)+pGameScoreRecord->wRecordCount*sizeof(pGameScoreRecord->GameScoreRecord[0]))) return false;

        //房间信息
        m_GameDBAide.ResetParameter();
        m_GameDBAide.AddParameter(TEXT("@wKindID"),m_pGameServiceOption->wKindID);
        m_GameDBAide.AddParameter(TEXT("@wServerID"),m_pGameServiceOption->wServerID);

        //桌子信息
        m_GameDBAide.AddParameter(TEXT("@wTableID"),pGameScoreRecord->wTableID);
        m_GameDBAide.AddParameter(TEXT("@wUserCount"),pGameScoreRecord->wUserCount);
        m_GameDBAide.AddParameter(TEXT("@wAndroidCount"),pGameScoreRecord->wAndroidCount);

        //税收损耗
        m_GameDBAide.AddParameter(TEXT("@lWasteCount"),pGameScoreRecord->lWasteCount);
        m_GameDBAide.AddParameter(TEXT("@lRevenueCount"),pGameScoreRecord->lRevenueCount);

        //统计信息
        m_GameDBAide.AddParameter(TEXT("@dwUserMemal"),pGameScoreRecord->dwUserMemal);
        m_GameDBAide.AddParameter(TEXT("@dwPlayTimeCount"),pGameScoreRecord->dwPlayTimeCount);

        //时间信息
        m_GameDBAide.AddParameter(TEXT("@SystemTimeStart"),pGameScoreRecord->SystemTimeStart);
        m_GameDBAide.AddParameter(TEXT("@SystemTimeConclude"),pGameScoreRecord->SystemTimeConclude);

        //执行查询
        LONG lResultCode=m_GameDBAide.ExecuteProcess(TEXT("GSP_GR_RecordDrawInfo"),true);

        //写入记录
        if (lResultCode==DB_SUCCESS)
        {
            //获取标识
            DWORD dwDrawID=m_GameDBAide.GetValue_DWORD(TEXT("DrawID"));

            //写入记录
            for (WORD i=0;i<pGameScoreRecord->wRecordCount;i++)
            {
                //重置参数
                m_GameDBAide.ResetParameter();
                
                //房间信息
                m_GameDBAide.AddParameter(TEXT("@dwDrawID"),dwDrawID);
                m_GameDBAide.AddParameter(TEXT("@dwUserID"),pGameScoreRecord->GameScoreRecord.dwUserID);
                m_GameDBAide.AddParameter(TEXT("@wChairID"),pGameScoreRecord->GameScoreRecord.wChairID);

                //成绩信息
                m_GameDBAide.AddParameter(TEXT("@lScore"),pGameScoreRecord->GameScoreRecord.lScore);
                m_GameDBAide.AddParameter(TEXT("@lGrade"),pGameScoreRecord->GameScoreRecord.lGrade);
                m_GameDBAide.AddParameter(TEXT("@lRevenue"),pGameScoreRecord->GameScoreRecord.lRevenue);
                m_GameDBAide.AddParameter(TEXT("@dwUserMedal"),pGameScoreRecord->GameScoreRecord.dwUserMemal);
                m_GameDBAide.AddParameter(TEXT("@dwPlayTimeCount"),pGameScoreRecord->GameScoreRecord.dwPlayTimeCount);

                //执行查询
                m_GameDBAide.ExecuteProcess(TEXT("GSP_GR_RecordDrawScore"),false);
            }
        }
    }
    catch (IDataBaseException * pIException)
    {
        //输出错误
        CTraceService::TraceString(pIException->GetExceptionDescribe(),TraceLevel_Exception);

        return false;
    }

    return true;
}

//加载参数
bool CDataBaseEngineSink::OnRequestLoadParameter(DWORD dwContextID, VOID * pData, WORD wDataSize, DWORD &dwUserID)
{
    try
    {
        //变量定义
        DBO_GR_GameParameter GameParameter;
        ZeroMemory(&GameParameter,sizeof(GameParameter));

        //执行查询
        m_GameDBAide.ResetParameter();
        m_GameDBAide.AddParameter(TEXT("@wKindID"),m_pGameServiceOption->wKindID);
        m_GameDBAide.AddParameter(TEXT("@wServerID"),m_pGameServiceOption->wServerID);

        //执行查询
        LONG lResultCode=m_GameDBAide.ExecuteProcess(TEXT("GSP_GR_LoadParameter"),true);

        //读取信息
        if (lResultCode==DB_SUCCESS)
        {
            //汇率信息
            GameParameter.wMedalRate=m_GameDBAide.GetValue_WORD(TEXT("MedalRate"));
            GameParameter.wRevenueRate=m_GameDBAide.GetValue_WORD(TEXT("RevenueRate"));

            //版本信息
            GameParameter.dwClientVersion=m_GameDBAide.GetValue_DWORD(TEXT("ClientVersion"));
            GameParameter.dwServerVersion=m_GameDBAide.GetValue_DWORD(TEXT("ServerVersion"));
        
            //发送信息
            m_pIDataBaseEngineEvent->OnEventDataBaseResult(DBO_GR_GAME_PARAMETER,dwContextID,&GameParameter,sizeof(GameParameter));
        }

        return true;
    }
    catch (IDataBaseException * pIException)
    {
        //输出错误
        CTraceService::TraceString(pIException->GetExceptionDescribe(),TraceLevel_Exception);

        return false;
    }

    return true;
}

//加载列表
bool CDataBaseEngineSink::OnRequestLoadGameColumn(DWORD dwContextID, VOID * pData, WORD wDataSize, DWORD &dwUserID)
{
    try
    {
        //变量定义
        DBO_GR_GameColumnInfo GameColumnInfo;
        ZeroMemory(&GameColumnInfo,sizeof(GameColumnInfo));

        //执行查询
        m_GameDBAide.ResetParameter();
        GameColumnInfo.lResultCode=m_GameDBAide.ExecuteProcess(TEXT("GSP_GR_GameColumnItem"),true);

        //读取信息
        for (WORD i=0;i<CountArray(GameColumnInfo.ColumnItemInfo);i++)
        {
            //结束判断
            if (m_GameDBModule->IsRecordsetEnd()==true) break;

            //溢出效验
            ASSERT(GameColumnInfo.cbColumnCount<CountArray(GameColumnInfo.ColumnItemInfo));
            if (GameColumnInfo.cbColumnCount>=CountArray(GameColumnInfo.ColumnItemInfo)) break;

            //读取数据
            GameColumnInfo.cbColumnCount++;
            GameColumnInfo.ColumnItemInfo.cbColumnWidth=m_GameDBAide.GetValue_BYTE(TEXT("ColumnWidth"));
            GameColumnInfo.ColumnItemInfo.cbDataDescribe=m_GameDBAide.GetValue_BYTE(TEXT("DataDescribe"));
            m_GameDBAide.GetValue_String(TEXT("ColumnName"),GameColumnInfo.ColumnItemInfo.szColumnName,CountArray(GameColumnInfo.ColumnItemInfo.szColumnName));

            //移动记录
            m_GameDBModule->MoveToNext();
        }

        //发送信息
        WORD wHeadSize=sizeof(GameColumnInfo)-sizeof(GameColumnInfo.ColumnItemInfo);
        WORD wPacketSize=wHeadSize+GameColumnInfo.cbColumnCount*sizeof(GameColumnInfo.ColumnItemInfo[0]);
        m_pIDataBaseEngineEvent->OnEventDataBaseResult(DBO_GR_GAME_COLUMN_INFO,dwContextID,&GameColumnInfo,wPacketSize);

        return true;
    }
    catch (IDataBaseException * pIException)
    {
        //输出错误
        CTraceService::TraceString(pIException->GetExceptionDescribe(),TraceLevel_Exception);

        //变量定义
        DBO_GR_GameColumnInfo GameColumnInfo;
        ZeroMemory(&GameColumnInfo,sizeof(GameColumnInfo));

        //构造变量
        GameColumnInfo.cbColumnCount=0L;
        GameColumnInfo.lResultCode=pIException->GetExceptionResult();

        //发送信息
        WORD wPacketSize=sizeof(GameColumnInfo)-sizeof(GameColumnInfo.ColumnItemInfo);
        m_pIDataBaseEngineEvent->OnEventDataBaseResult(DBO_GR_GAME_COLUMN_INFO,dwContextID,&GameColumnInfo,wPacketSize);

        return false;
    }

    return true;
}

//加载机器
bool CDataBaseEngineSink::OnRequestLoadAndroidUser(DWORD dwContextID, VOID * pData, WORD wDataSize, DWORD &dwUserID)
{
    try
    {
        //变量定义
        DBO_GR_GameAndroidInfo GameAndroidInfo;
        ZeroMemory(&GameAndroidInfo,sizeof(GameAndroidInfo));

        //用户帐户
        m_GameDBAide.ResetParameter();
        m_GameDBAide.AddParameter(TEXT("@wKindID"),m_pGameServiceAttrib->wKindID);
        m_GameDBAide.AddParameter(TEXT("@wServerID"),m_pGameServiceOption->wServerID);

        //执行查询
        GameAndroidInfo.lResultCode=m_GameDBAide.ExecuteProcess(TEXT("GSP_GR_LoadAndroidUser"),true);

        //读取信息
        for (WORD i=0;i<CountArray(GameAndroidInfo.AndroidParameter);i++)
        {
            //结束判断
            if (m_GameDBModule->IsRecordsetEnd()==true) break;

            //溢出效验
            ASSERT(GameAndroidInfo.wAndroidCount<CountArray(GameAndroidInfo.AndroidParameter));
            if (GameAndroidInfo.wAndroidCount>=CountArray(GameAndroidInfo.AndroidParameter)) break;

            //读取数据
            GameAndroidInfo.wAndroidCount++;
            GameAndroidInfo.AndroidParameter.dwUserID=m_GameDBAide.GetValue_DWORD(TEXT("UserID"));
            GameAndroidInfo.AndroidParameter.dwServiceTime=m_GameDBAide.GetValue_DWORD(TEXT("ServiceTime"));
            GameAndroidInfo.AndroidParameter.dwMinPlayDraw=m_GameDBAide.GetValue_DWORD(TEXT("MinPlayDraw"));
            GameAndroidInfo.AndroidParameter.dwMaxPlayDraw=m_GameDBAide.GetValue_DWORD(TEXT("MaxPlayDraw"));
            GameAndroidInfo.AndroidParameter.dwMinReposeTime=m_GameDBAide.GetValue_DWORD(TEXT("MinReposeTime"));
            GameAndroidInfo.AndroidParameter.dwMaxReposeTime=m_GameDBAide.GetValue_DWORD(TEXT("MaxReposeTime"));
            GameAndroidInfo.AndroidParameter.dwServiceGender=m_GameDBAide.GetValue_DWORD(TEXT("ServiceGender"));
            GameAndroidInfo.AndroidParameter.lMinTakeScore=m_GameDBAide.GetValue_LONGLONG(TEXT("MinTakeScore"));
            GameAndroidInfo.AndroidParameter.lMaxTakeScore=m_GameDBAide.GetValue_LONGLONG(TEXT("MaxTakeScore"));

            //移动记录
            m_GameDBModule->MoveToNext();
        }

        //发送信息
        WORD wHeadSize=sizeof(GameAndroidInfo)-sizeof(GameAndroidInfo.AndroidParameter);
        WORD wDataSize=GameAndroidInfo.wAndroidCount*sizeof(GameAndroidInfo.AndroidParameter[0]);
        m_pIDataBaseEngineEvent->OnEventDataBaseResult(DBR_GR_GAME_ANDROID_INFO,dwContextID,&GameAndroidInfo,wHeadSize+wDataSize);

        return true;
    }
    catch (IDataBaseException * pIException)
    {
        //输出错误
        CTraceService::TraceString(pIException->GetExceptionDescribe(),TraceLevel_Exception);

        //变量定义
        DBO_GR_GameAndroidInfo GameAndroidInfo;
        ZeroMemory(&GameAndroidInfo,sizeof(GameAndroidInfo));

        //构造变量
        GameAndroidInfo.wAndroidCount=0L;
        GameAndroidInfo.lResultCode=DB_ERROR;

        //发送信息
        WORD wHeadSize=sizeof(GameAndroidInfo)-sizeof(GameAndroidInfo.AndroidParameter);
        m_pIDataBaseEngineEvent->OnEventDataBaseResult(DBR_GR_GAME_ANDROID_INFO,dwContextID,&GameAndroidInfo,wHeadSize);
    }

    return false;
}

//加载道具
bool CDataBaseEngineSink::OnRequestLoadGameProperty(DWORD dwContextID, VOID * pData, WORD wDataSize, DWORD &dwUserID)
{
    try
    {
        //变量定义
        DBO_GR_GamePropertyInfo GamePropertyInfo;
        ZeroMemory(&GamePropertyInfo,sizeof(GamePropertyInfo));

        //构造参数
        m_GameDBAide.ResetParameter();
        m_GameDBAide.AddParameter(TEXT("@wKindID"),m_pGameServiceOption->wKindID);
        m_GameDBAide.AddParameter(TEXT("@wServerID"),m_pGameServiceOption->wServerID);

        //执行查询
        GamePropertyInfo.lResultCode=m_GameDBAide.ExecuteProcess(TEXT("GSP_GR_LoadGameProperty"),true);

        //读取信息
        for (WORD i=0;i<CountArray(GamePropertyInfo.PropertyInfo);i++)
        {
            //结束判断
            if (m_GameDBModule->IsRecordsetEnd()==true) break;

            //溢出效验
            ASSERT(GamePropertyInfo.cbPropertyCount<CountArray(GamePropertyInfo.PropertyInfo));
            if (GamePropertyInfo.cbPropertyCount>=CountArray(GamePropertyInfo.PropertyInfo)) break;

            //读取数据
            GamePropertyInfo.cbPropertyCount++;
            GamePropertyInfo.PropertyInfo.wIndex=m_GameDBAide.GetValue_WORD(TEXT("ID"));
            GamePropertyInfo.PropertyInfo.wDiscount=m_GameDBAide.GetValue_WORD(TEXT("Discount"));
            GamePropertyInfo.PropertyInfo.wIssueArea=m_GameDBAide.GetValue_WORD(TEXT("IssueArea"));
            GamePropertyInfo.PropertyInfo.dPropertyCash=m_GameDBAide.GetValue_DOUBLE(TEXT("Cash"));
            GamePropertyInfo.PropertyInfo.lPropertyGold=m_GameDBAide.GetValue_LONGLONG(TEXT("Gold"));
            GamePropertyInfo.PropertyInfo.lSendLoveLiness=m_GameDBAide.GetValue_LONGLONG(TEXT("SendLoveLiness"));
            GamePropertyInfo.PropertyInfo.lRecvLoveLiness=m_GameDBAide.GetValue_LONGLONG(TEXT("RecvLoveLiness"));

            //移动记录
            m_GameDBModule->MoveToNext();
        }

        //发送信息
        WORD wHeadSize=sizeof(GamePropertyInfo)-sizeof(GamePropertyInfo.PropertyInfo);
        WORD wDataSize=GamePropertyInfo.cbPropertyCount*sizeof(GamePropertyInfo.PropertyInfo[0]);
        m_pIDataBaseEngineEvent->OnEventDataBaseResult(DBO_GR_GAME_PROPERTY_INFO,dwContextID,&GamePropertyInfo,wHeadSize+wDataSize);
    }
    catch (IDataBaseException * pIException)
    {
        //输出错误
        CTraceService::TraceString(pIException->GetExceptionDescribe(),TraceLevel_Exception);

        //变量定义
        DBO_GR_GamePropertyInfo GamePropertyInfo;
        ZeroMemory(&GamePropertyInfo,sizeof(GamePropertyInfo));

        //构造变量
        GamePropertyInfo.cbPropertyCount=0L;
        GamePropertyInfo.lResultCode=DB_ERROR;

        //发送信息
        WORD wHeadSize=sizeof(GamePropertyInfo)-sizeof(GamePropertyInfo.PropertyInfo);
        m_pIDataBaseEngineEvent->OnEventDataBaseResult(DBO_GR_GAME_PROPERTY_INFO,dwContextID,&GamePropertyInfo,wHeadSize);

        return false;
    }

    return true;
}

//存入金币
bool CDataBaseEngineSink::OnRequestUserSaveScore(DWORD dwContextID, VOID * pData, WORD wDataSize, DWORD &dwUserID)
{
    //效验参数
    ASSERT(wDataSize==sizeof(DBR_GR_UserSaveScore));
    if (wDataSize!=sizeof(DBR_GR_UserSaveScore)) return false;

    //变量定义
    DBR_GR_UserSaveScore * pUserSaveScore=(DBR_GR_UserSaveScore *)pData;
    dwUserID=pUserSaveScore->dwUserID;

    //请求处理
    try
    {
        //转化地址
        TCHAR szClientAddr[16]=TEXT("");
        BYTE * pClientAddr=(BYTE *)&pUserSaveScore->dwClientAddr;
        _sntprintf(szClientAddr,CountArray(szClientAddr),TEXT("%d.%d.%d.%d"),pClientAddr[0],pClientAddr[1],pClientAddr[2],pClientAddr[3]);

        //构造参数
        m_TreasureDBAide.ResetParameter();
        m_TreasureDBAide.AddParameter(TEXT("@dwUserID"),pUserSaveScore->dwUserID);
        m_TreasureDBAide.AddParameter(TEXT("@lSaveScore"),pUserSaveScore->lSaveScore);
        m_TreasureDBAide.AddParameter(TEXT("@wKindID"),m_pGameServiceOption->wKindID);
        m_TreasureDBAide.AddParameter(TEXT("@wServerID"),m_pGameServiceOption->wServerID);
        m_TreasureDBAide.AddParameter(TEXT("@strClientIP"),szClientAddr);
        m_TreasureDBAide.AddParameter(TEXT("@strMachineID"),pUserSaveScore->szMachineID);

        //输出参数
        TCHAR szDescribeString[128]=TEXT("");
        m_TreasureDBAide.AddParameterOutput(TEXT("@strErrorDescribe"),szDescribeString,sizeof(szDescribeString),adParamOutput);

        //执行查询
        LONG lResultCode=m_TreasureDBAide.ExecuteProcess(TEXT("GSP_GR_UserSaveScore"),true);

        //结果处理
        CDBVarValue DBVarValue;
        m_TreasureDBModule->GetParameter(TEXT("@strErrorDescribe"),DBVarValue);
        OnInsureDisposeResult(dwContextID,lResultCode,pUserSaveScore->lSaveScore,CW2CT(DBVarValue.bstrVal),false,pUserSaveScore->cbActivityGame);
    
        return true;
    }
    catch (IDataBaseException * pIException)
    {
        //错误信息
        CTraceService::TraceString(pIException->GetExceptionDescribe(),TraceLevel_Exception);

        //错误处理
        OnInsureDisposeResult(dwContextID,DB_ERROR,pUserSaveScore->lSaveScore,TEXT("由于数据库操作异常,请您稍后重试!"),false,pUserSaveScore->cbActivityGame);

        return false;
    }

    return true;
}

//提取金币
bool CDataBaseEngineSink::OnRequestUserTakeScore(DWORD dwContextID, VOID * pData, WORD wDataSize, DWORD &dwUserID)
{
    //效验参数
    ASSERT(wDataSize==sizeof(DBR_GR_UserTakeScore));
    if (wDataSize!=sizeof(DBR_GR_UserTakeScore)) return false;

    //变量定义
    DBR_GR_UserTakeScore * pUserTakeScore=(DBR_GR_UserTakeScore *)pData;
    dwUserID=pUserTakeScore->dwUserID;

    //请求处理
    try
    {
        //转化地址
        TCHAR szClientAddr[16]=TEXT("");
        BYTE * pClientAddr=(BYTE *)&pUserTakeScore->dwClientAddr;
        _sntprintf(szClientAddr,CountArray(szClientAddr),TEXT("%d.%d.%d.%d"),pClientAddr[0],pClientAddr[1],pClientAddr[2],pClientAddr[3]);

        //构造参数
        m_TreasureDBAide.ResetParameter();
        m_TreasureDBAide.AddParameter(TEXT("@dwUserID"),pUserTakeScore->dwUserID);
        m_TreasureDBAide.AddParameter(TEXT("@lTakeScore"),pUserTakeScore->lTakeScore);
        m_TreasureDBAide.AddParameter(TEXT("@strPassword"),pUserTakeScore->szPassword);
        m_TreasureDBAide.AddParameter(TEXT("@wKindID"),m_pGameServiceOption->wKindID);
        m_TreasureDBAide.AddParameter(TEXT("@wServerID"),m_pGameServiceOption->wServerID);
        m_TreasureDBAide.AddParameter(TEXT("@strClientIP"),szClientAddr);
        m_TreasureDBAide.AddParameter(TEXT("@strMachineID"),pUserTakeScore->szMachineID);

        //输出参数
        TCHAR szDescribeString[128]=TEXT("");
        m_TreasureDBAide.AddParameterOutput(TEXT("@strErrorDescribe"),szDescribeString,sizeof(szDescribeString),adParamOutput);

        //执行查询
        LONG lResultCode=m_TreasureDBAide.ExecuteProcess(TEXT("GSP_GR_UserTakeScore"),true);

        //结果处理
        CDBVarValue DBVarValue;
        m_TreasureDBModule->GetParameter(TEXT("@strErrorDescribe"),DBVarValue);
        OnInsureDisposeResult(dwContextID,lResultCode,0L,CW2CT(DBVarValue.bstrVal),false,pUserTakeScore->cbActivityGame);
    
        return true;
    }
    catch (IDataBaseException * pIException)
    {
        //错误信息
        CTraceService::TraceString(pIException->GetExceptionDescribe(),TraceLevel_Exception);

        //错误处理
        OnInsureDisposeResult(dwContextID,DB_ERROR,0L,TEXT("由于数据库操作异常,请您稍后重试!"),false,pUserTakeScore->cbActivityGame);

        return false;
    }

    return true;
}

//转账金币
bool CDataBaseEngineSink::OnRequestUserTransferScore(DWORD dwContextID, VOID * pData, WORD wDataSize, DWORD &dwUserID)
{
    //效验参数
    ASSERT(wDataSize==sizeof(DBR_GR_UserTransferScore));
    if (wDataSize!=sizeof(DBR_GR_UserTransferScore)) return false;

    //变量定义
    DBR_GR_UserTransferScore * pUserTransferScore=(DBR_GR_UserTransferScore *)pData;
    dwUserID=pUserTransferScore->dwUserID;

    //请求处理
    try
    {
        //转化地址
        TCHAR szClientAddr[16]=TEXT("");
        BYTE * pClientAddr=(BYTE *)&pUserTransferScore->dwClientAddr;
        _sntprintf(szClientAddr,CountArray(szClientAddr),TEXT("%d.%d.%d.%d"),pClientAddr[0],pClientAddr[1],pClientAddr[2],pClientAddr[3]);

        //构造参数
        m_TreasureDBAide.ResetParameter();
        m_TreasureDBAide.AddParameter(TEXT("@dwUserID"),pUserTransferScore->dwUserID);
        m_TreasureDBAide.AddParameter(TEXT("@cbByNickName"),pUserTransferScore->cbByNickName);
        m_TreasureDBAide.AddParameter(TEXT("@lTransferScore"),pUserTransferScore->lTransferScore);
        m_TreasureDBAide.AddParameter(TEXT("@strPassword"),pUserTransferScore->szPassword);
        m_TreasureDBAide.AddParameter(TEXT("@strNickName"),pUserTransferScore->szNickName);
        m_TreasureDBAide.AddParameter(TEXT("@wKindID"),m_pGameServiceOption->wKindID);
        m_TreasureDBAide.AddParameter(TEXT("@wServerID"),m_pGameServiceOption->wServerID);
        m_TreasureDBAide.AddParameter(TEXT("@strClientIP"),szClientAddr);
        m_TreasureDBAide.AddParameter(TEXT("@strMachineID"),pUserTransferScore->szMachineID);

        //输出参数
        TCHAR szDescribeString[128]=TEXT("");
        m_TreasureDBAide.AddParameterOutput(TEXT("@strErrorDescribe"),szDescribeString,sizeof(szDescribeString),adParamOutput);

        //执行查询
        LONG lResultCode=m_TreasureDBAide.ExecuteProcess(TEXT("GSP_GR_UserTransferScore"),true);

        //结果处理
        CDBVarValue DBVarValue;
        m_TreasureDBModule->GetParameter(TEXT("@strErrorDescribe"),DBVarValue);
        OnInsureDisposeResult(dwContextID,lResultCode,0L,CW2CT(DBVarValue.bstrVal),false,pUserTransferScore->cbActivityGame);
    
        return true;
    }
    catch (IDataBaseException * pIException)
    {
        //错误信息
        CTraceService::TraceString(pIException->GetExceptionDescribe(),TraceLevel_Exception);

        //错误处理
        OnInsureDisposeResult(dwContextID,DB_ERROR,0L,TEXT("由于数据库操作异常,请您稍后重试!"),false,pUserTransferScore->cbActivityGame);

        return false;
    }

    return true;
}

//查询银行
bool CDataBaseEngineSink::OnRequestQueryInsureInfo(DWORD dwContextID, VOID * pData, WORD wDataSize, DWORD &dwUserID)
{
    //效验参数
    ASSERT(wDataSize==sizeof(DBR_GR_QueryInsureInfo));
    if (wDataSize!=sizeof(DBR_GR_QueryInsureInfo)) return false;

    //请求处理
    DBR_GR_QueryInsureInfo * pQueryInsureInfo=(DBR_GR_QueryInsureInfo *)pData;
    dwUserID=pQueryInsureInfo->dwUserID;

    try
    {
        //转化地址
        TCHAR szClientAddr[16]=TEXT("");
        BYTE * pClientAddr=(BYTE *)&pQueryInsureInfo->dwClientAddr;
        _sntprintf(szClientAddr,CountArray(szClientAddr),TEXT("%d.%d.%d.%d"),pClientAddr[0],pClientAddr[1],pClientAddr[2],pClientAddr[3]);

        //构造参数
        m_TreasureDBAide.ResetParameter();
        m_TreasureDBAide.AddParameter(TEXT("@dwUserID"),pQueryInsureInfo->dwUserID);
        m_TreasureDBAide.AddParameter(TEXT("@strClientIP"),szClientAddr);

        //输出参数
        TCHAR szDescribeString[128]=TEXT("");
        m_TreasureDBAide.AddParameterOutput(TEXT("@strErrorDescribe"),szDescribeString,sizeof(szDescribeString),adParamOutput);

        //结果处理
        if (m_TreasureDBAide.ExecuteProcess(TEXT("GSP_GR_QueryUserInsureInfo"),true)==DB_SUCCESS)
        {
            //变量定义
            DBO_GR_UserInsureInfo UserInsureInfo;
            ZeroMemory(&UserInsureInfo,sizeof(UserInsureInfo));

            //银行信息
            UserInsureInfo.cbActivityGame=pQueryInsureInfo->cbActivityGame;
            UserInsureInfo.wRevenueTake=m_TreasureDBAide.GetValue_WORD(TEXT("RevenueTake"));
            UserInsureInfo.wRevenueTransfer=m_TreasureDBAide.GetValue_WORD(TEXT("RevenueTransfer"));
            UserInsureInfo.wServerID=m_TreasureDBAide.GetValue_WORD(TEXT("ServerID"));
            UserInsureInfo.lUserScore=m_TreasureDBAide.GetValue_LONGLONG(TEXT("Score"));
            UserInsureInfo.lUserInsure=m_TreasureDBAide.GetValue_LONGLONG(TEXT("Insure"));

            //发送结果
            m_pIDataBaseEngineEvent->OnEventDataBaseResult(DBO_GR_USER_INSURE_INFO,dwContextID,&UserInsureInfo,sizeof(UserInsureInfo));
        }
        else
        {
            //获取参数
            CDBVarValue DBVarValue;
            m_TreasureDBModule->GetParameter(TEXT("@strErrorDescribe"),DBVarValue);

            //错误处理
            OnInsureDisposeResult(dwContextID,m_TreasureDBAide.GetReturnValue(),0L,CW2CT(DBVarValue.bstrVal),false,pQueryInsureInfo->cbActivityGame);
        }

        return true;
    }
    catch (IDataBaseException * pIException)
    {
        //输出错误
        CTraceService::TraceString(pIException->GetExceptionDescribe(),TraceLevel_Exception);

        //结果处理
        OnInsureDisposeResult(dwContextID,DB_ERROR,0L,TEXT("由于数据库操作异常,请您稍后重试!"),false,pQueryInsureInfo->cbActivityGame);

        return false;
    }

    return true;
}

//道具请求
bool CDataBaseEngineSink::OnRequestPropertyRequest(DWORD dwContextID, VOID * pData, WORD wDataSize, DWORD &dwUserID)
{
    try
    {
        //效验参数
        ASSERT(wDataSize==sizeof(DBR_GR_PropertyRequest));
        if (wDataSize!=sizeof(DBR_GR_PropertyRequest)) return false;

        //请求处理
        DBR_GR_PropertyRequest * pPropertyRequest=(DBR_GR_PropertyRequest *)pData;
        dwUserID=pPropertyRequest->dwSourceUserID;

        //转化地址
        TCHAR szClientAddr[16]=TEXT("");
        BYTE * pClientAddr=(BYTE *)&pPropertyRequest->dwClientAddr;
        _sntprintf(szClientAddr,CountArray(szClientAddr),TEXT("%d.%d.%d.%d"),pClientAddr[0],pClientAddr[1],pClientAddr[2],pClientAddr[3]);

        //构造参数
        m_GameDBAide.ResetParameter();

        //消费信息
        m_GameDBAide.AddParameter(TEXT("@dwSourceUserID"),pPropertyRequest->dwSourceUserID);
        m_GameDBAide.AddParameter(TEXT("@dwTargetUserID"),pPropertyRequest->dwTargetUserID);
        m_GameDBAide.AddParameter(TEXT("@wPropertyID"),pPropertyRequest->wPropertyIndex);
        m_GameDBAide.AddParameter(TEXT("@wPropertyCount"),pPropertyRequest->wItemCount);

        //消费区域
        m_GameDBAide.AddParameter(TEXT("@wKindID"),m_pGameServiceOption->wKindID);
        m_GameDBAide.AddParameter(TEXT("@wServerID"),m_pGameServiceOption->wServerID);
        m_GameDBAide.AddParameter(TEXT("@wTableID"),pPropertyRequest->wTableID);

        //购买方式
        m_GameDBAide.AddParameter(TEXT("@cbConsumeScore"),pPropertyRequest->cbConsumeScore);
        m_GameDBAide.AddParameter(TEXT("@lFrozenedScore"),pPropertyRequest->lFrozenedScore);

        //系统信息
        m_GameDBAide.AddParameter(TEXT("@dwEnterID"),pPropertyRequest->dwInoutIndex);
        m_GameDBAide.AddParameter(TEXT("@strClientIP"),szClientAddr);
        m_GameDBAide.AddParameter(TEXT("@strMachineID"),pPropertyRequest->szMachineID);

        //输出参数
        TCHAR szDescribeString[128]=TEXT("");
        m_GameDBAide.AddParameterOutput(TEXT("@strErrorDescribe"),szDescribeString,sizeof(szDescribeString),adParamOutput);

        //结果处理
        if (m_GameDBAide.ExecuteProcess(TEXT("GSP_GR_ConsumeProperty"),true)==DB_SUCCESS)
        {
            //变量定义
            DBO_GR_S_PropertySuccess PresentSuccess;
            ZeroMemory(&PresentSuccess,sizeof(PresentSuccess));

            //道具信息
            PresentSuccess.cbRequestArea=pPropertyRequest->cbRequestArea;
            PresentSuccess.wItemCount=pPropertyRequest->wItemCount;
            PresentSuccess.wPropertyIndex=pPropertyRequest->wPropertyIndex;
            PresentSuccess.dwSourceUserID=pPropertyRequest->dwSourceUserID;
            PresentSuccess.dwTargetUserID=pPropertyRequest->dwTargetUserID;

            //消费模式
            PresentSuccess.cbConsumeScore=pPropertyRequest->cbConsumeScore;
            PresentSuccess.lFrozenedScore=pPropertyRequest->lFrozenedScore;

            //用户权限
            PresentSuccess.dwUserRight=pPropertyRequest->dwUserRight;

            //结果信息
            PresentSuccess.lConsumeGold=m_GameDBAide.GetValue_LONGLONG(TEXT("ConsumeGold"));
            PresentSuccess.lSendLoveLiness=m_GameDBAide.GetValue_LONG(TEXT("SendLoveLiness"));
            PresentSuccess.lRecvLoveLiness=m_GameDBAide.GetValue_LONG(TEXT("RecvLoveLiness"));
            PresentSuccess.cbMemberOrder=m_GameDBAide.GetValue_BYTE(TEXT("MemberOrder"));

            //发送结果
            m_pIDataBaseEngineEvent->OnEventDataBaseResult(DBO_GR_PROPERTY_SUCCESS,dwContextID,&PresentSuccess,sizeof(PresentSuccess));
        }
        else
        {
            //获取参数
            CDBVarValue DBVarValue;
            m_GameDBAide.GetParameter(TEXT("@strErrorDescribe"),DBVarValue);

            //变量定义
            DBO_GR_PropertyFailure PropertyFailure;
            ZeroMemory(&PropertyFailure,sizeof(PropertyFailure));

            //设置变量
            PropertyFailure.lResultCode=m_GameDBAide.GetReturnValue();
            PropertyFailure.lFrozenedScore=pPropertyRequest->lFrozenedScore;
            PropertyFailure.cbRequestArea=pPropertyRequest->cbRequestArea;
            lstrcpyn(PropertyFailure.szDescribeString,CW2CT(DBVarValue.bstrVal),CountArray(PropertyFailure.szDescribeString));

            //发送结果
            WORD wDataSize=CountStringBuffer(PropertyFailure.szDescribeString);
            WORD wHeadSize=sizeof(PropertyFailure)-sizeof(PropertyFailure.szDescribeString);
            m_pIDataBaseEngineEvent->OnEventDataBaseResult(DBO_GR_PROPERTY_FAILURE,dwContextID,&PropertyFailure,wHeadSize+wDataSize);
        }
    }
    catch (IDataBaseException * pIException)
    {
        //输出错误
        CTraceService::TraceString(pIException->GetExceptionDescribe(),TraceLevel_Exception);

        //变量定义
        DBO_GR_PropertyFailure PropertyFailure;
        ZeroMemory(&PropertyFailure,sizeof(PropertyFailure));

        //变量定义
        DBR_GR_PropertyRequest * pPropertyRequest=(DBR_GR_PropertyRequest *)pData;

        //设置变量
        PropertyFailure.lResultCode=DB_ERROR;
        PropertyFailure.lFrozenedScore=pPropertyRequest->lFrozenedScore;
        PropertyFailure.cbRequestArea=pPropertyRequest->cbRequestArea;
        lstrcpyn(PropertyFailure.szDescribeString,TEXT("由于数据库操作异常,请您稍后重试!"),CountArray(PropertyFailure.szDescribeString));

        //发送结果
        WORD wDataSize=CountStringBuffer(PropertyFailure.szDescribeString);
        WORD wHeadSize=sizeof(PropertyFailure)-sizeof(PropertyFailure.szDescribeString);
        m_pIDataBaseEngineEvent->OnEventDataBaseResult(DBO_GR_PROPERTY_FAILURE,dwContextID,&PropertyFailure,wHeadSize+wDataSize);

        return false;
    }

    return true;
}

//比赛报名
bool CDataBaseEngineSink::OnRequestMatchFee(DWORD dwContextID, VOID * pData, WORD wDataSize, DWORD &dwUserID)
{
    //效验参数
    ASSERT(wDataSize==sizeof(DBR_GR_MatchFee));
    if (wDataSize!=sizeof(DBR_GR_MatchFee)) return false;

    //变量定义
    DBR_GR_MatchFee * pMatchFee=(DBR_GR_MatchFee *)pData;
    dwUserID=INVALID_DWORD;

    //请求处理
    try
    {
        //转化地址
        TCHAR szClientAddr[16]=TEXT("");
        BYTE * pClientAddr=(BYTE *)&pMatchFee->dwClientAddr;
        _sntprintf(szClientAddr,CountArray(szClientAddr),TEXT("%d.%d.%d.%d"),pClientAddr[0],pClientAddr[1],pClientAddr[2],pClientAddr[3]);

        //构造参数
        m_GameDBAide.ResetParameter();
        m_GameDBAide.AddParameter(TEXT("@dwUserID"),pMatchFee->dwUserID);
        m_GameDBAide.AddParameter(TEXT("@dwMatchFee"),pMatchFee->dwMatchFee);
        m_GameDBAide.AddParameter(TEXT("@wKindID"),m_pGameServiceOption->wKindID);
        m_GameDBAide.AddParameter(TEXT("@wServerID"),m_pGameServiceOption->wServerID);
        m_GameDBAide.AddParameter(TEXT("@strClientIP"),szClientAddr);
        m_GameDBAide.AddParameter(TEXT("@dwMatchID"),pMatchFee->dwMatchID);
        m_GameDBAide.AddParameter(TEXT("@strMachineID"),pMatchFee->szMachineID);

        //输出参数
        TCHAR szDescribeString[128]=TEXT("");
        m_GameDBAide.AddParameterOutput(TEXT("@strErrorDescribe"),szDescribeString,sizeof(szDescribeString),adParamOutput);

        //结果处理
        LONG lReturnValue=m_GameDBAide.ExecuteProcess(TEXT("GSP_GR_UserMatchFee"),true);

        //发送结果
        m_pIDataBaseEngineEvent->OnEventDataBaseResult(DBO_GR_MATCH_FEE_RESULT,dwContextID,&lReturnValue,sizeof(lReturnValue));

        return true;
    }
    catch (IDataBaseException * pIException)
    {
        //错误信息
        CTraceService::TraceString(pIException->GetExceptionDescribe(),TraceLevel_Exception);

        //错误处理
        OnInsureDisposeResult(dwContextID,DB_ERROR,0L,TEXT("由于数据库操作异常,请您稍后重试!"),false);

        return false;
    }

    return true;
}

//比赛开始
bool CDataBaseEngineSink::OnRequestMatchStart(DWORD dwContextID, VOID * pData, WORD wDataSize, DWORD &dwUserID)
{
    //效验参数
    ASSERT(wDataSize==sizeof(DBR_GR_MatchStart));
    if (wDataSize!=sizeof(DBR_GR_MatchStart)) return false;

    //变量定义
    DBR_GR_MatchStart * pMatchStart=(DBR_GR_MatchStart *)pData;
    dwUserID=INVALID_DWORD;

    //请求处理
    try
    {
        //构造参数
        m_GameDBAide.ResetParameter();
        m_GameDBAide.AddParameter(TEXT("@wMatchID"),pMatchStart->wMatchID);
        m_GameDBAide.AddParameter(TEXT("@wMatchNo"),pMatchStart->wMatchNo);
        m_GameDBAide.AddParameter(TEXT("@wMatchCount"),pMatchStart->wMatchCount);    
        m_GameDBAide.AddParameter(TEXT("@lInitScore"),pMatchStart->lInitScore);    

//         //输出参数
//         TCHAR szDescribeString[128]=TEXT("");
//         m_GameDBAide.AddParameterOutput(TEXT("@strErrorDescribe"),szDescribeString,sizeof(szDescribeString),adParamOutput);

        //结果处理
        LONG lReturnValue=m_GameDBAide.ExecuteProcess(TEXT("GSP_GR_MatchStart"),true);

        return true;
    }
    catch (IDataBaseException * pIException)
    {
        //错误信息
        CTraceService::TraceString(pIException->GetExceptionDescribe(),TraceLevel_Exception);

        //错误处理
        OnInsureDisposeResult(dwContextID,DB_ERROR,0L,TEXT("由于数据库操作异常,请您稍后重试!"),false);

        return false;
    }

    return true;
}

//比赛结束
bool CDataBaseEngineSink::OnRequestMatchOver(DWORD dwContextID, VOID * pData, WORD wDataSize, DWORD &dwUserID)
{
    //效验参数
    ASSERT(wDataSize==sizeof(DBR_GR_MatchOver));
    if (wDataSize!=sizeof(DBR_GR_MatchOver)) return false;

    //变量定义
    DBR_GR_MatchOver * pMatchOver=(DBR_GR_MatchOver *)pData;
    dwUserID=INVALID_DWORD;

    //请求处理
    try
    {
        //构造参数
        m_GameDBAide.ResetParameter();
        m_GameDBAide.AddParameter(TEXT("@wMatchID"),pMatchOver->wMatchID);
        m_GameDBAide.AddParameter(TEXT("@wMatchNo"),pMatchOver->wMatchNo);
        m_GameDBAide.AddParameter(TEXT("@wMatchCount"),pMatchOver->wMatchCount);        

//         //输出参数
//         TCHAR szDescribeString[128]=TEXT("");
//         m_GameDBAide.AddParameterOutput(TEXT("@strErrorDescribe"),szDescribeString,sizeof(szDescribeString),adParamOutput);

        //结果处理
        LONG lReturnValue=m_GameDBAide.ExecuteProcess(TEXT("GSP_GR_MatchOver"),true);

        if(lReturnValue==DB_SUCCESS)
        {
            LONG lCount=0;
            if(m_GameDBModule.GetInterface()!=NULL)
                lCount=m_GameDBModule->GetRecordCount();
            DBO_GR_MatchRank *pMatchRank=new DBO_GR_MatchRank[lCount];
            for(LONG i=0; i<lCount; i++)
            {
                pMatchRank.cbRank=(BYTE)i;
                m_GameDBAide.GetValue_String(TEXT("NickName"),pMatchRank.szNickName,CountArray(pMatchRank.szNickName));
                pMatchRank.lMatchScore=m_GameDBAide.GetValue_LONG(TEXT("HScore"));
                m_GameDBModule->MoveToNext();
                if(m_GameDBModule->IsRecordsetEnd()) break;
            }
            m_pIDataBaseEngineEvent->OnEventDataBaseResult(DBO_GR_MATCH_RANK,dwContextID,pMatchRank,(WORD)(sizeof(DBO_GR_MatchRank)*lCount));
            if(pMatchRank!=NULL)
                SafeDeleteArray(pMatchRank);
        }
    
        
        return true;
    }
    catch (IDataBaseException * pIException)
    {
        //错误信息
        CTraceService::TraceString(pIException->GetExceptionDescribe(),TraceLevel_Exception);

        //错误处理
        OnInsureDisposeResult(dwContextID,DB_ERROR,0L,TEXT("由于数据库操作异常,请您稍后重试!"),false);

        return false;
    }

    return true;
}

//比赛奖励
bool CDataBaseEngineSink::OnRequestMatchReward(DWORD dwContextID, VOID * pData, WORD wDataSize, DWORD &dwUserID)
{
    //效验参数
    ASSERT(wDataSize==sizeof(DBR_GR_MatchReward));
    if (wDataSize!=sizeof(DBR_GR_MatchReward)) return false;

    //变量定义
    DBR_GR_MatchReward * pMatchReward=(DBR_GR_MatchReward *)pData;
    dwUserID=INVALID_DWORD;

    //请求处理
    try
    {
        //转化地址
        TCHAR szClientAddr[16]=TEXT("");
        BYTE * pClientAddr=(BYTE *)&pMatchReward->dwClientAddr;
        _sntprintf(szClientAddr,CountArray(szClientAddr),TEXT("%d.%d.%d.%d"),pClientAddr[0],pClientAddr[1],pClientAddr[2],pClientAddr[3]);

        //构造参数
        m_GameDBAide.ResetParameter();
        m_GameDBAide.AddParameter(TEXT("@dwUserID"),pMatchReward->dwUserID);
        m_GameDBAide.AddParameter(TEXT("@dwMatchID"),pMatchReward->dwMatchID);
        m_GameDBAide.AddParameter(TEXT("@wRank"),pMatchReward->wRank);
        m_GameDBAide.AddParameter(TEXT("@lMatchScore"),pMatchReward->lMatchScore);
        m_GameDBAide.AddParameter(TEXT("@dwExperience"),pMatchReward->dwExperience);
        m_GameDBAide.AddParameter(TEXT("@dwGold"),pMatchReward->dwGold);
        m_GameDBAide.AddParameter(TEXT("@dwMedal"),pMatchReward->dwMedal);
        m_GameDBAide.AddParameter(TEXT("@wKindID"),m_pGameServiceOption->wKindID);
        m_GameDBAide.AddParameter(TEXT("@wServerID"),m_pGameServiceOption->wServerID);
        m_GameDBAide.AddParameter(TEXT("@strClientIP"),szClientAddr);

        //结果处理
        LONG lReturnValue=m_GameDBAide.ExecuteProcess(TEXT("GSP_GR_MatchReward"),true);

        return true;
    }
    catch (IDataBaseException * pIException)
    {
        //错误信息
        CTraceService::TraceString(pIException->GetExceptionDescribe(),TraceLevel_Exception);

        //错误处理
        OnInsureDisposeResult(dwContextID,DB_ERROR,0L,TEXT("由于数据库操作异常,请您稍后重试!"),false);

        return false;
    }

    return true;
}

//退出比赛
bool CDataBaseEngineSink::OnRequestMatchQuit(DWORD dwContextID, VOID * pData, WORD wDataSize, DWORD &dwUserID)
{
    //效验参数
    ASSERT(wDataSize==sizeof(DBR_GR_MatchFee));
    if (wDataSize!=sizeof(DBR_GR_MatchFee)) return false;

    //变量定义
    DBR_GR_MatchFee * pMatchFee=(DBR_GR_MatchFee *)pData;
    dwUserID=INVALID_DWORD;

    //请求处理
    try
    {
        //转化地址
        TCHAR szClientAddr[16]=TEXT("");
        BYTE * pClientAddr=(BYTE *)&pMatchFee->dwClientAddr;
        _sntprintf(szClientAddr,CountArray(szClientAddr),TEXT("%d.%d.%d.%d"),pClientAddr[0],pClientAddr[1],pClientAddr[2],pClientAddr[3]);

        //构造参数
        m_GameDBAide.ResetParameter();
        m_GameDBAide.AddParameter(TEXT("@dwUserID"),pMatchFee->dwUserID);
        m_GameDBAide.AddParameter(TEXT("@dwMatchFee"),pMatchFee->dwMatchFee);
        m_GameDBAide.AddParameter(TEXT("@wKindID"),m_pGameServiceOption->wKindID);
        m_GameDBAide.AddParameter(TEXT("@wServerID"),m_pGameServiceOption->wServerID);
        m_GameDBAide.AddParameter(TEXT("@strClientIP"),szClientAddr);
        m_GameDBAide.AddParameter(TEXT("@dwMatchID"),pMatchFee->dwMatchID);
        m_GameDBAide.AddParameter(TEXT("@strMachineID"),pMatchFee->szMachineID);

        //输出参数
        TCHAR szDescribeString[128]=TEXT("");
        m_GameDBAide.AddParameterOutput(TEXT("@strErrorDescribe"),szDescribeString,sizeof(szDescribeString),adParamOutput);

        //结果处理
        LONG lReturnValue=m_GameDBAide.ExecuteProcess(TEXT("GSP_GR_UserMatchQuit"),true);

        //发送结果
        m_pIDataBaseEngineEvent->OnEventDataBaseResult(DBO_GR_MATCH_QUIT_RESULT,dwContextID,&lReturnValue,sizeof(lReturnValue));

        return true;
    }
    catch (IDataBaseException * pIException)
    {
        //错误信息
        CTraceService::TraceString(pIException->GetExceptionDescribe(),TraceLevel_Exception);

        //错误处理
        OnInsureDisposeResult(dwContextID,DB_ERROR,0L,TEXT("由于数据库操作异常,请您稍后重试!"),false);

        return false;
    }
}

//用户权限
bool CDataBaseEngineSink::OnRequestManageUserRight(DWORD dwContextID, VOID * pData, WORD wDataSize, DWORD &dwUserID)
{
    try
    {
        //效验参数
        ASSERT(wDataSize==sizeof(DBR_GR_ManageUserRight));
        if (wDataSize!=sizeof(DBR_GR_ManageUserRight)) return false;

        //请求处理
        DBR_GR_ManageUserRight * pManageUserRight=(DBR_GR_ManageUserRight *)pData;
        dwUserID=pManageUserRight->dwUserID;

        //构造参数
        m_GameDBAide.ResetParameter();
        m_GameDBAide.AddParameter(TEXT("@dwUserID"),pManageUserRight->dwUserID);
        m_GameDBAide.AddParameter(TEXT("@dwAddRight"),pManageUserRight->dwAddRight);
        m_GameDBAide.AddParameter(TEXT("@dwRemoveRight"),pManageUserRight->dwRemoveRight);

        //执行查询
        LONG lReturnValue=m_GameDBAide.ExecuteProcess(TEXT("GSP_GR_ManageUserRight"),false);

        return true;
    }
    catch (IDataBaseException * pIException)
    {
        //错误信息
        CTraceService::TraceString(pIException->GetExceptionDescribe(),TraceLevel_Exception);

        //错误处理
        OnInsureDisposeResult(dwContextID,DB_ERROR,0L,TEXT("由于数据库操作异常,请您稍后重试!"),false);

        return false;
    }

    return true;
}

//登录结果
VOID CDataBaseEngineSink::OnLogonDisposeResult(DWORD dwContextID, DWORD dwErrorCode, LPCTSTR pszErrorString, bool bMobileClient,BYTE cbDeviceType,WORD wBehaviorFlags,WORD wPageTableCount)
{
    if (dwErrorCode==DB_SUCCESS)
    {
        //属性资料
        m_LogonSuccess.wFaceID=m_GameDBAide.GetValue_WORD(TEXT("FaceID"));
        m_LogonSuccess.dwUserID=m_GameDBAide.GetValue_DWORD(TEXT("UserID"));
        m_LogonSuccess.dwGameID=m_GameDBAide.GetValue_DWORD(TEXT("GameID"));
        m_LogonSuccess.dwGroupID=m_GameDBAide.GetValue_DWORD(TEXT("GroupID"));
        m_LogonSuccess.dwCustomID=m_GameDBAide.GetValue_DWORD(TEXT("CustomID"));
        m_GameDBAide.GetValue_String(TEXT("NickName"),m_LogonSuccess.szNickName,CountArray(m_LogonSuccess.szNickName));
        m_GameDBAide.GetValue_String(TEXT("GroupName"),m_LogonSuccess.szGroupName,CountArray(m_LogonSuccess.szGroupName));

        //用户资料
        m_LogonSuccess.cbGender=m_GameDBAide.GetValue_BYTE(TEXT("Gender"));
        m_LogonSuccess.cbMemberOrder=m_GameDBAide.GetValue_BYTE(TEXT("MemberOrder"));
        m_LogonSuccess.cbMasterOrder=m_GameDBAide.GetValue_BYTE(TEXT("MasterOrder"));
        m_GameDBAide.GetValue_String(TEXT("UnderWrite"),m_LogonSuccess.szUnderWrite,CountArray(m_LogonSuccess.szUnderWrite));

        //积分信息
        m_LogonSuccess.lScore=m_GameDBAide.GetValue_LONGLONG(TEXT("Score"));
        m_LogonSuccess.lGrade=m_GameDBAide.GetValue_LONGLONG(TEXT("Grade"));
        m_LogonSuccess.lInsure=m_GameDBAide.GetValue_LONGLONG(TEXT("Insure"));

        //局数信息
        m_LogonSuccess.dwWinCount=m_GameDBAide.GetValue_LONG(TEXT("WinCount"));
        m_LogonSuccess.dwLostCount=m_GameDBAide.GetValue_LONG(TEXT("LostCount"));
        m_LogonSuccess.dwDrawCount=m_GameDBAide.GetValue_LONG(TEXT("DrawCount"));
        m_LogonSuccess.dwFleeCount=m_GameDBAide.GetValue_LONG(TEXT("FleeCount"));
        m_LogonSuccess.dwUserMedal=m_GameDBAide.GetValue_LONG(TEXT("UserMedal"));
        m_LogonSuccess.dwExperience=m_GameDBAide.GetValue_LONG(TEXT("Experience"));
        m_LogonSuccess.lLoveLiness=m_GameDBAide.GetValue_LONG(TEXT("LoveLiness"));

        //附加信息
        m_LogonSuccess.dwUserRight=m_GameDBAide.GetValue_DWORD(TEXT("UserRight"));
        m_LogonSuccess.dwMasterRight=m_GameDBAide.GetValue_DWORD(TEXT("MasterRight"));
        m_LogonSuccess.cbDeviceType=cbDeviceType;
        m_LogonSuccess.wBehaviorFlags=wBehaviorFlags;
        m_LogonSuccess.wPageTableCount=wPageTableCount;

        //索引变量
        m_LogonSuccess.dwInoutIndex=m_GameDBAide.GetValue_DWORD(TEXT("InoutIndex"));

        //获取信息
        lstrcpyn(m_LogonSuccess.szDescribeString,pszErrorString,CountArray(m_LogonSuccess.szDescribeString));

        //发送结果
        WORD wDataSize=CountStringBuffer(m_LogonSuccess.szDescribeString);
        WORD wHeadSize=sizeof(m_LogonSuccess)-sizeof(m_LogonSuccess.szDescribeString);
        m_pIDataBaseEngineEvent->OnEventDataBaseResult(DBO_GR_LOGON_SUCCESS,dwContextID,&m_LogonSuccess,wHeadSize+wDataSize);
    }
    else
    {
        //变量定义
        DBO_GR_LogonFailure LogonFailure;
        ZeroMemory(&LogonFailure,sizeof(LogonFailure));

        //构造数据
        LogonFailure.lResultCode=dwErrorCode;
        lstrcpyn(LogonFailure.szDescribeString,pszErrorString,CountArray(LogonFailure.szDescribeString));

        //发送结果
        WORD wDataSize=CountStringBuffer(LogonFailure.szDescribeString);
        WORD wHeadSize=sizeof(LogonFailure)-sizeof(LogonFailure.szDescribeString);
        m_pIDataBaseEngineEvent->OnEventDataBaseResult(DBO_GR_LOGON_FAILURE,dwContextID,&LogonFailure,wHeadSize+wDataSize);
    }

    return;
}

//银行结果
VOID CDataBaseEngineSink::OnInsureDisposeResult(DWORD dwContextID, DWORD dwErrorCode, SCORE lFrozenedScore, LPCTSTR pszErrorString, bool bMobileClient,BYTE cbActivityGame)
{
    if (dwErrorCode==DB_SUCCESS)
    {
        //变量定义
        DBO_GR_UserInsureSuccess UserInsureSuccess;
        ZeroMemory(&UserInsureSuccess,sizeof(UserInsureSuccess));

        //构造变量
        UserInsureSuccess.cbActivityGame=cbActivityGame;
        UserInsureSuccess.lFrozenedScore=lFrozenedScore;
        UserInsureSuccess.dwUserID=m_TreasureDBAide.GetValue_DWORD(TEXT("UserID"));
        UserInsureSuccess.lSourceScore=m_TreasureDBAide.GetValue_LONGLONG(TEXT("SourceScore"));
        UserInsureSuccess.lSourceInsure=m_TreasureDBAide.GetValue_LONGLONG(TEXT("SourceInsure"));
        UserInsureSuccess.lInsureRevenue=m_TreasureDBAide.GetValue_LONGLONG(TEXT("InsureRevenue"));
        UserInsureSuccess.lVariationScore=m_TreasureDBAide.GetValue_LONGLONG(TEXT("VariationScore"));
        UserInsureSuccess.lVariationInsure=m_TreasureDBAide.GetValue_LONGLONG(TEXT("VariationInsure"));
        lstrcpyn(UserInsureSuccess.szDescribeString,pszErrorString,CountArray(UserInsureSuccess.szDescribeString));

        //发送结果
        WORD wDataSize=CountStringBuffer(UserInsureSuccess.szDescribeString);
        WORD wHeadSize=sizeof(UserInsureSuccess)-sizeof(UserInsureSuccess.szDescribeString);
        m_pIDataBaseEngineEvent->OnEventDataBaseResult(DBO_GR_USER_INSURE_SUCCESS,dwContextID,&UserInsureSuccess,wHeadSize+wDataSize);
    }
    else
    {
        //变量定义
        DBO_GR_UserInsureFailure UserInsureFailure;
        ZeroMemory(&UserInsureFailure,sizeof(UserInsureFailure));

        //构造变量
        UserInsureFailure.cbActivityGame=cbActivityGame;
        UserInsureFailure.lResultCode=dwErrorCode;
        UserInsureFailure.lFrozenedScore=lFrozenedScore;
        lstrcpyn(UserInsureFailure.szDescribeString,pszErrorString,CountArray(UserInsureFailure.szDescribeString));

        //发送结果
        WORD wDataSize=CountStringBuffer(UserInsureFailure.szDescribeString);
        WORD wHeadSize=sizeof(UserInsureFailure)-sizeof(UserInsureFailure.szDescribeString);
        m_pIDataBaseEngineEvent->OnEventDataBaseResult(DBO_GR_USER_INSURE_FAILURE,dwContextID,&UserInsureFailure,wHeadSize+wDataSize);
    }

    return;
}

//////////////////////////////////////////////////////////////////////////////////



此帖售价 100 小风币,已有 0 人购买 [记录] [购买]
购买后,将显示帖子中所有出售内容。
若发现会员采用欺骗的方法获取财富,请立刻举报,我们会对会员处以2-N倍的罚金,严重者封掉ID!
此段为出售的内容,购买后显示


善者 慈悲心常在 无怨无恨 以苦为乐
默认压缩密码www.hifyl.com
文件分享密码问题:http://www.hifyl.com/read-htm-tid-4444.html
快速回复
限100 字节
如果您在写长篇帖子又不马上发表,建议存为草稿
 
上一个 下一个