|
- #include "StdAfx.h"
- #include "ServiceUnits.h"
- #include "DataBaseEngineSink.h"
- #include "LogonServer.h"
- #include "LogonServerDlg.h"
- #include "AttemperEngineSink.h"
- #include <unordered_map>
- #include <strsafe.h>
- #include "BaiDuMap.h"
-
- extern CLogonServerApp theApp;
- //////////////////////////////////////////////////////////////////////////////////
- CMap<DWORD, DWORD, LONGLONG, LONGLONG> CDataBaseEngineSink::m_MapUserIDJuli;
- //构造函数
- CDataBaseEngineSink::CDataBaseEngineSink()
- {
- //组件变量
- m_pInitParameter = NULL;
- m_pIDataBaseEngineEvent = NULL;
-
- return;
- }
-
- //析构函数
- CDataBaseEngineSink::~CDataBaseEngineSink()
- {
- }
-
- //接口查询
- VOID * CDataBaseEngineSink::QueryInterface(REFGUID Guid, DWORD dwQueryVer)
- {
- QUERYINTERFACE(IDataBaseEngineSink, Guid, dwQueryVer);
- QUERYINTERFACE_IUNKNOWNEX(IDataBaseEngineSink, Guid, dwQueryVer);
- return NULL;
- }
-
- //启动事件
- bool CDataBaseEngineSink::OnDataBaseEngineStart(IUnknownEx * pIUnknownEx)
- {
- //创建对象
- if ((m_AccountsDBModule.GetInterface() == NULL) && (m_AccountsDBModule.CreateInstance() == false))
- {
- ASSERT(FALSE);
- return false;
- }
-
- //创建对象
- if ((m_TreasureDBModule.GetInterface() == NULL) && (m_TreasureDBModule.CreateInstance() == false))
- {
- ASSERT(FALSE);
- return false;
- }
-
- //创建对象
- if ((m_PlatformDBModule.GetInterface() == NULL) && (m_PlatformDBModule.CreateInstance() == false))
- {
- ASSERT(FALSE);
- return false;
- }
-
- try
- {
- //连接信息
- tagDataBaseParameter * pAccountsDBParameter = &m_pInitParameter->m_AccountsDBParameter;
- tagDataBaseParameter * pTreasureDBParameter = &m_pInitParameter->m_TreasureDBParameter;
- tagDataBaseParameter * pPlatformDBParameter = &m_pInitParameter->m_PlatformDBParameter;
-
- //设置连接
- m_AccountsDBModule->SetConnectionInfo(pAccountsDBParameter->szDataBaseAddr, pAccountsDBParameter->wDataBasePort,
- pAccountsDBParameter->szDataBaseName, pAccountsDBParameter->szDataBaseUser, pAccountsDBParameter->szDataBasePass);
- m_TreasureDBModule->SetConnectionInfo(pTreasureDBParameter->szDataBaseAddr, pTreasureDBParameter->wDataBasePort,
- pTreasureDBParameter->szDataBaseName, pTreasureDBParameter->szDataBaseUser, pTreasureDBParameter->szDataBasePass);
- m_PlatformDBModule->SetConnectionInfo(pPlatformDBParameter->szDataBaseAddr, pPlatformDBParameter->wDataBasePort,
- pPlatformDBParameter->szDataBaseName, pPlatformDBParameter->szDataBaseUser, pPlatformDBParameter->szDataBasePass);
-
- //发起连接
- m_AccountsDBModule->OpenConnection();
- m_AccountsDBAide.SetDataBase(m_AccountsDBModule.GetInterface());
-
- //发起连接
- m_TreasureDBModule->OpenConnection();
- m_TreasureDBAide.SetDataBase(m_TreasureDBModule.GetInterface());
-
- //发起连接
- m_PlatformDBModule->OpenConnection();
- m_PlatformDBAide.SetDataBase(m_PlatformDBModule.GetInterface());
-
- return true;
- }
- catch (IDataBaseException * pIException)
- {
- //错误信息
- LPCTSTR pszDescribe = pIException->GetExceptionDescribe();
- CTraceService::TraceString(pszDescribe, TraceLevel_Exception);
-
- return false;
- }
-
- return true;
- }
-
- //停止事件
- bool CDataBaseEngineSink::OnDataBaseEngineConclude(IUnknownEx * pIUnknownEx)
- {
- //设置对象
- m_AccountsDBAide.SetDataBase(NULL);
- m_TreasureDBAide.SetDataBase(NULL);
- m_PlatformDBAide.SetDataBase(NULL);
-
- //关闭连接
- if (m_AccountsDBModule.GetInterface() != NULL)
- {
- m_AccountsDBModule->CloseConnection();
- m_AccountsDBModule.CloseInstance();
- }
-
- //关闭连接
- if (m_TreasureDBModule.GetInterface() != NULL)
- {
- m_TreasureDBModule->CloseConnection();
- m_TreasureDBModule.CloseInstance();
- }
-
- //关闭连接
- if (m_PlatformDBModule.GetInterface() != NULL)
- {
- m_PlatformDBModule->CloseConnection();
- m_PlatformDBModule.CloseInstance();
- }
-
- //组件变量
- m_pInitParameter = NULL;
- m_pIDataBaseEngineEvent = NULL;
-
- 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)
- {
- switch (wRequestID)
- {
- //case DBR_GP_LOAD_PLATFORM_PARAMETER: //平台参数
- //{
- // return OnRequestPlatformParameter(dwContextID, pData, wDataSize);
- //}
- case DBR_GP_ONLINE_SERVICE:
- {
- //更新通道状态
- return OnRequestOnLineService(dwContextID, pData, wDataSize);
- }
- case DBR_GP_CLEARJULI: //清空距离
- {
- return OnRequestClearJuLi(dwContextID, pData, wDataSize);
- }
- case DBR_GP_CLEARJULIADD: //距离添加
- {
- return OnRequestAddJuLi(dwContextID, pData, wDataSize);
- }
- case DBR_GP_ONLINE_COUNT_INFO: //在线信息
- {
- return OnRequestOnLineCountInfo(dwContextID, pData, wDataSize);
- }
- case DBR_MB_LOGON_ACCOUNTS: //帐号登录,手机登录
- {
- return OnMobileLogonAccounts(dwContextID, pData, wDataSize);
- }
- case DBR_MB_LOGON_OTHERPLATFORM: //微信登录
- {
- return OnMobileLogonOtherPlatform(dwContextID, pData, wDataSize);
- }
- case DBR_MB_IPHONEYANZM: //获取验证码
- {
- return OnMobileLogonYanZhengMa(dwContextID, pData, wDataSize);
- }
- case DBR_MB_IPHONEMIMA: //落地密码
- {
- return OnMobileLogonVerfCodeToMiMa(dwContextID, pData, wDataSize);
- }
- case DBR_MB_HANDLE_IPHONEMIMA: //处理手机验证码出错
- {
- return OnMobileLogonHandleVerfCodeFail(dwContextID, pData, wDataSize);
- }
- }
-
- return false;
- }
- //帐号登录、手机登录
- bool CDataBaseEngineSink::OnMobileLogonAccounts(DWORD dwContextID, VOID * pData, WORD wDataSize)
- {
- CTraceService::TraceString(TEXT("CDataBaseEngineSink::OnMobileLogonAccounts"), TraceLevel_Debug);
- try
- {
- //效验参数
- ASSERT(wDataSize == sizeof(DBR_MB_LogonAccounts));
- if (wDataSize != sizeof(DBR_MB_LogonAccounts)) return false;
-
- //请求处理
- DBR_MB_LogonAccounts * pLogonAccounts = (DBR_MB_LogonAccounts *)pData;
-
- //账号名不能为空
- if (pLogonAccounts->szAccounts[0] == 0)
- {
- OnLogonDisposeResult(dwContextID, DB_ERROR, TEXT("账号名不能为空!"), 0, true);
- return false;
- }
- //执行判断
- tagBindParameter * pBindParameter = (tagBindParameter *)pLogonAccounts->pBindParameter;
- if (pBindParameter->dwSocketID != dwContextID) return true;
-
- //构造参数
- m_AccountsDBAide.ResetParameter();
- m_AccountsDBAide.AddParameter(TEXT("@LogonType"), pLogonAccounts->LogonType);
- m_AccountsDBAide.AddParameter(TEXT("@cbDeviceType"), pLogonAccounts->cbDeviceType);//设备类型
- m_AccountsDBAide.AddParameter(TEXT("@strAccounts"), pLogonAccounts->szAccounts);
- m_AccountsDBAide.AddParameter(TEXT("@strPassword"), pLogonAccounts->szPassword);
- m_AccountsDBAide.AddParameter(TEXT("@strMobilePhone"), pLogonAccounts->szMobilePhone);
- m_AccountsDBAide.AddParameter(TEXT("@strIPhonePassword"), pLogonAccounts->szIPhonePassword);
- m_AccountsDBAide.AddParameter(TEXT("@strMachineID"), pLogonAccounts->szMachineID);
- //输出参数
- TCHAR szDescribeString[128] = TEXT("");
- m_AccountsDBAide.AddParameterOutput(TEXT("@strErrorDescribe"), szDescribeString, sizeof(szDescribeString), adParamOutput);
-
- //执行查询
- LONG lResultCode = m_AccountsDBAide.ExecuteProcess(TEXT("GSP_MB_EfficacyAccounts"), true);
-
- //结果处理
- CDBVarValue DBVarValue;
- m_AccountsDBModule->GetParameter(TEXT("@strErrorDescribe"), DBVarValue);
- OnLogonDisposeResult(dwContextID, lResultCode, CW2CT(DBVarValue.bstrVal), 0, true);
-
- return true;
- }
- catch (IDataBaseException * pIException)
- {
- //错误信息
- CTraceService::TraceString(pIException->GetExceptionDescribe(), TraceLevel_Exception);
-
- //错误处理
- OnLogonDisposeResult(dwContextID, DB_ERROR, TEXT("由于数据库操作异常,请您稍后重试或选择另一服务器登录!"), 0, true);
-
- return false;
- }
-
- return true;
- }
-
- //获取验证码
- bool CDataBaseEngineSink::OnMobileLogonYanZhengMa(DWORD dwContextID, VOID * pData, WORD wDataSize)
- {
- CTraceService::TraceString(TEXT("CDataBaseEngineSink::OnMobileLogonYanZhengM"), TraceLevel_Debug);
- try
- {
- //效验参数
- ASSERT(wDataSize == sizeof(DBR_MB_LogonCheckVerifCode));
- if (wDataSize != sizeof(DBR_MB_LogonCheckVerifCode)) return false;
-
- //请求处理
- DBR_MB_LogonCheckVerifCode * pLogonAccounts = (DBR_MB_LogonCheckVerifCode *)pData;
-
- //构造参数
- m_AccountsDBAide.ResetParameter();
- m_AccountsDBAide.AddParameter(TEXT("@strMobilePhone"), pLogonAccounts->PhoneNum);
- //输出参数
- TCHAR szDescribeString[128] = TEXT("");
- m_AccountsDBAide.AddParameterOutput(TEXT("@strErrorDescribe"), szDescribeString, sizeof(szDescribeString), adParamOutput);
-
- //执行查询
- LONG lResultCode = m_AccountsDBAide.ExecuteProcess(TEXT("GSP_MB_LogonYanZhengMa"), true);
- CMD_MB_LogonCheckVerifCode strLogonReslut = { 0 };
- strLogonReslut.bResult = lResultCode;
- //获取信息
- lstrcpyn(strLogonReslut.PhoneNum, pLogonAccounts->PhoneNum, sizeof(pLogonAccounts->PhoneNum));
- //结果处理
- if (strLogonReslut.bResult != 0)
- {
- CDBVarValue DBVarValue;
- m_AccountsDBModule->GetParameter(TEXT("@strErrorDescribe"), DBVarValue);
- _sntprintf(strLogonReslut.strErrorDescribe, 127, TEXT("%s"), static_cast<LPCWSTR>(DBVarValue.bstrVal));
- }
- m_pIDataBaseEngineEvent->OnEventDataBaseResult(DBR_MB_IPHONEYANZM, dwContextID, &strLogonReslut, sizeof(CMD_MB_LogonCheckVerifCode));
- return true;
- }
- catch (IDataBaseException * pIException)
- {
- //错误信息
- CTraceService::TraceString(pIException->GetExceptionDescribe(), TraceLevel_Exception);
- return false;
- }
-
- return true;
- }
- //落地密码
- bool CDataBaseEngineSink::OnMobileLogonVerfCodeToMiMa(DWORD dwContextID, VOID * pData, WORD wDataSize)
- {
- try
- {
- //效验参数
- ASSERT(wDataSize == sizeof(DBR_MB_VerifCodeToMiMa));
- if (wDataSize != sizeof(DBR_MB_VerifCodeToMiMa)) return false;
-
- //请求处理
- DBR_MB_VerifCodeToMiMa * pLogonAccountsMiMa = (DBR_MB_VerifCodeToMiMa *)pData;
-
- //构造参数
- m_AccountsDBAide.ResetParameter();
- m_AccountsDBAide.AddParameter(TEXT("@strMobilePhone"), pLogonAccountsMiMa->PhoneNum);
- m_AccountsDBAide.AddParameter(TEXT("@strPassWord"), pLogonAccountsMiMa->VerifCode);
- //输出参数
- TCHAR szDescribeString[128] = TEXT("");
- m_AccountsDBAide.AddParameterOutput(TEXT("@strErrorDescribe"), szDescribeString, sizeof(szDescribeString), adParamOutput);
-
- //执行查询
- LONG lResultCode = m_AccountsDBAide.ExecuteProcess(TEXT("GSP_MB_LogonMiMa"), true);
- if (lResultCode != 0)
- {
- TCHAR szString[512] = TEXT("");
- _sntprintf(szString, CountArray(szString), TEXT("密码落地失败"));
- CTraceService::TraceString(szString, TraceLevel_Warning);
- }
- return true;
- }
- catch (IDataBaseException * pIException)
- {
- //错误信息
- CTraceService::TraceString(pIException->GetExceptionDescribe(), TraceLevel_Exception);
- return false;
- }
-
- return true;
- }
-
- //
- bool CDataBaseEngineSink::OnMobileLogonHandleVerfCodeFail(DWORD dwContextID, VOID * pData, WORD wDataSize)
- {
- try
- {
- //效验参数
- ASSERT(wDataSize == sizeof(DBR_MB_VerifCodeToMiMa));
- if (wDataSize != sizeof(DBR_MB_VerifCodeToMiMa)) return false;
-
- //请求处理
- DBR_MB_VerifCodeToMiMa * pLogonAccountsMiMa = (DBR_MB_VerifCodeToMiMa *)pData;
-
- //构造参数
- m_AccountsDBAide.ResetParameter();
- m_AccountsDBAide.AddParameter(TEXT("@strMobilePhone"), pLogonAccountsMiMa->PhoneNum);
- //输出参数
- TCHAR szDescribeString[128] = TEXT("");
- m_AccountsDBAide.AddParameterOutput(TEXT("@strErrorDescribe"), szDescribeString, sizeof(szDescribeString), adParamOutput);
-
- //执行查询
- LONG lResultCode = m_AccountsDBAide.ExecuteProcess(TEXT("GSP_GR_DELETE_PHONEACCOUNT"), true);
- if (lResultCode != 0)
- {
- TCHAR szString[512] = TEXT("");
- _sntprintf(szString, CountArray(szString), TEXT("处理清除绑定手机号失败"));
- CTraceService::TraceString(szString, TraceLevel_Warning);
- }
- return true;
- }
- catch (IDataBaseException * pIException)
- {
- //错误信息
- CTraceService::TraceString(pIException->GetExceptionDescribe(), TraceLevel_Exception);
- return false;
- }
-
- return true;
- }
- //其他登录
- bool CDataBaseEngineSink::OnMobileLogonOtherPlatform(DWORD dwContextID, VOID * pData, WORD wDataSize)
- {
- CTraceService::TraceString(TEXT("CDataBaseEngineSink::OnMobileLogonOtherPlatform"), TraceLevel_Debug);
- try
- {
- //效验参数
- ASSERT(wDataSize == sizeof(DBR_MB_LogonOtherPlatform));
- if (wDataSize != sizeof(DBR_MB_LogonOtherPlatform))
- {
- //构造提示
- TCHAR szString[512] = TEXT("");
- _sntprintf(szString, CountArray(szString), TEXT("客户端登录失败 [DBR_MB_LogonOtherPlatform验证失败]"));
-
- //提示消息
- CTraceService::TraceString(szString, TraceLevel_Normal);
- return true;
- }
-
- //请求处理
- DBR_MB_LogonOtherPlatform * pLogonOtherPlatform = (DBR_MB_LogonOtherPlatform *)pData;
-
- //账号名不能为空
- //if (pLogonOtherPlatform->szNickName[0] == 0 )
- //{
- // OnLogonDisposeResult(dwContextID, DB_ERROR, TEXT("账号名不能为空!"), 0, true);
- // return false;
- //}
-
- //转化地址
- TCHAR szClientAddr[16] = TEXT("");
- BYTE * pClientAddr = (BYTE *)&pLogonOtherPlatform->dwClientAddr;
- _sntprintf(szClientAddr, CountArray(szClientAddr), TEXT("%d.%d.%d.%d"), pClientAddr[0], pClientAddr[1], pClientAddr[2], pClientAddr[3]);
-
- //执行判断
- tagBindParameter * pBindParameter = (tagBindParameter *)pLogonOtherPlatform->pBindParameter;
- if (pBindParameter->dwSocketID != dwContextID)
- {
- //构造提示
- TCHAR szString[512] = TEXT("");
- _sntprintf(szString, CountArray(szString), TEXT("客户端[%s][%s]登录失败 [上次绑定SOCKET不是当前链接]"), pLogonOtherPlatform->szUserUin, szClientAddr);
-
- //提示消息
- CTraceService::TraceString(szString, TraceLevel_Normal);
- return true;
- }
-
- //参数过滤
- if (pLogonOtherPlatform->cbGender != 1
- && pLogonOtherPlatform->cbGender != 2
- && pLogonOtherPlatform->cbGender != 255)
- {
- pLogonOtherPlatform->cbGender = 2;
- }
-
- if (pLogonOtherPlatform->cbGender != 255)
- {
- //不为自动登录
- CString csName = pLogonOtherPlatform->szNickName;
- int Num = rand() % 10000;
- if (csName == _T(""))
- {
- csName.Format(_T("神秘大侠%d"), Num);
- }
- _sntprintf(pLogonOtherPlatform->szNickName, CountArray(szClientAddr), TEXT("%s"), csName);
-
- CString csHeadUrl = pLogonOtherPlatform->szHeadUrl;
- }
-
- TCHAR szBuffer[128] = { 0 };
- ZeroMemory(szBuffer, 128 * sizeof(TCHAR));
-
- int iRet = BASE64_Encode((const BYTE*) pLogonOtherPlatform->szNickName, 32, szBuffer);
-
- if (iRet < 0)
- {
- ZeroMemory(szBuffer, 128 * sizeof(TCHAR));
- _sntprintf(szBuffer, 128, TEXT("%s"), TEXT("麻将高手"));
- }
-
- CString csTest;
- BaiDuMap aa;
-
- //选点为重庆
- double dX1 = 106.554865;
- double dY1 = 29.557174;
-
- LONGLONG llx2 = pLogonOtherPlatform->x;
- LONGLONG lly2 = pLogonOtherPlatform->y;
- double dX2 = (double)llx2 / (double)1000000;
- double dY2 = (double)lly2 / (double)1000000;
- LONGLONG llRet = 0;
- if (dX2 != 0.0f && dY2 != 0.0f)
- {
- double dRet = aa.GetShortDistance(dX1, dY1, dX2, dY2);
- llRet = dRet * 1000000;
- csTest.Format(L"%lld", llRet);
- }
- else
- {
- llRet = 0;
- csTest = L"0";
- }
-
- CString Temp;
- Temp.Format(L"x:%lld,y:%lld 距离:%lld,是否在模拟器中:%d,是否4G:%d,当前电量:%d", llx2, lly2, llRet, pLogonOtherPlatform->isSimulator, pLogonOtherPlatform->networkType, pLogonOtherPlatform->dianliang);
- //提示消息
- CTraceService::TraceString(Temp, TraceLevel_Info);
- //计算距离
-
- //构造参数
- m_AccountsDBAide.ResetParameter();
- m_AccountsDBAide.AddParameter(TEXT("@cbPlatformID"), pLogonOtherPlatform->cbPlatformID);
- m_AccountsDBAide.AddParameter(TEXT("@cbDeviceType"), pLogonOtherPlatform->isSimulator);
- m_AccountsDBAide.AddParameter(TEXT("@strUserUin"), pLogonOtherPlatform->szUserUin);
- m_AccountsDBAide.AddParameter(TEXT("@strNickName"), szBuffer);
- m_AccountsDBAide.AddParameter(TEXT("@strCompellation"), pLogonOtherPlatform->szCompellation);
- m_AccountsDBAide.AddParameter(TEXT("@cbGender"), pLogonOtherPlatform->cbGender);
- m_AccountsDBAide.AddParameter(TEXT("@strClientIP"), szClientAddr);
- m_AccountsDBAide.AddParameter(TEXT("@strMachineID"), pLogonOtherPlatform->szMachineID);
- m_AccountsDBAide.AddParameter(TEXT("@strMobilePhone"), csTest.GetBuffer(0));
- m_AccountsDBAide.AddParameter(TEXT("@strHeadUrl"), pLogonOtherPlatform->szHeadUrl);
- csTest.ReleaseBuffer();
-
- //输出参数
- TCHAR szDescribeString[128] = TEXT("");
- m_AccountsDBAide.AddParameterOutput(TEXT("@strErrorDescribe"), szDescribeString, sizeof(szDescribeString), adParamOutput);
-
- DWORD dStart = GetTickCount();
- //执行查询
- LONG lResultCode = m_AccountsDBAide.ExecuteProcess(TEXT("GSP_MB_EfficacyOtherPlatform"), true);
-
- //结果处理
- CDBVarValue DBVarValue;
- m_AccountsDBModule->GetParameter(TEXT("@strErrorDescribe"), DBVarValue);
- OnLogonDisposeResult(dwContextID, lResultCode, CW2CT(DBVarValue.bstrVal), 0, true, llRet, pLogonOtherPlatform->isSimulator, pLogonOtherPlatform->networkType, pLogonOtherPlatform->dianliang);
-
- csTest.Format(L"数据时长:%ld毫秒", GetTickCount() - dStart);
- //提示消息
- CTraceService::TraceString(csTest, TraceLevel_Normal);
-
- return true;
- }
- catch (IDataBaseException * pIException)
- {
- //错误信息
- CTraceService::TraceString(pIException->GetExceptionDescribe(), TraceLevel_Exception);
-
- //错误处理
- OnLogonDisposeResult(dwContextID, DB_ERROR, TEXT("由于数据库操作异常,请您稍后重试或选择另一服务器登录!"), 0, true);
-
- return true;
- }
-
- return true;
- }
-
- //游客登录
- bool CDataBaseEngineSink::OnMobileLogonVisitor(DWORD dwContextID, VOID * pData, WORD wDataSize)
- {
- CTraceService::TraceString(TEXT("CDataBaseEngineSink::OnMobileLogonVisitor"), TraceLevel_Debug);
- try
- {
- //效验参数
- ASSERT(wDataSize == sizeof(DBR_MB_LogonVisitor));
- if (wDataSize != sizeof(DBR_MB_LogonVisitor)) return false;
-
- //请求处理
- DBR_MB_LogonVisitor * pVisitorLogon = (DBR_MB_LogonVisitor *)pData;
-
- //执行判断
- tagBindParameter * pBindParameter = (tagBindParameter *)pVisitorLogon->pBindParameter;
- if (pBindParameter->dwSocketID != dwContextID) return true;
-
- //转化地址
- TCHAR szClientAddr[16] = TEXT("");
- BYTE * pClientAddr = (BYTE *)&pVisitorLogon->dwClientAddr;
- _sntprintf(szClientAddr, CountArray(szClientAddr), TEXT("%d.%d.%d.%d"), pClientAddr[0], pClientAddr[1], pClientAddr[2], pClientAddr[3]);
-
- //构造参数
- m_AccountsDBAide.ResetParameter();
- m_AccountsDBAide.AddParameter(TEXT("@cbLogonMode"), pVisitorLogon->cbPlatformID);
- m_AccountsDBAide.AddParameter(TEXT("@strClientIP"), szClientAddr);
- m_AccountsDBAide.AddParameter(TEXT("@strMachineID"), pVisitorLogon->szMachineID);
- m_AccountsDBAide.AddParameter(TEXT("@strMobilePhone"), pVisitorLogon->szMobilePhone);
-
- //输出参数
- TCHAR szDescribeString[128] = TEXT("");
- m_AccountsDBAide.AddParameterOutput(TEXT("@strErrorDescribe"), szDescribeString, sizeof(szDescribeString), adParamOutput);
-
- //执行查询
- LONG lResultCode = m_AccountsDBAide.ExecuteProcess(TEXT("GSP_MB_EfficacyLogonVisitor"), true);
-
- //结果处理
- CDBVarValue DBVarValue;
- m_AccountsDBModule->GetParameter(TEXT("@strErrorDescribe"), DBVarValue);
- OnLogonDisposeResult(dwContextID, lResultCode, CW2CT(DBVarValue.bstrVal), 0, true);
-
- return true;
- }
- catch (IDataBaseException * pIException)
- {
- //错误信息
- CTraceService::TraceString(pIException->GetExceptionDescribe(), TraceLevel_Exception);
-
- //错误处理
- OnLogonDisposeResult(dwContextID, DB_ERROR, TEXT("由于数据库操作异常,请您稍后重试或选择另一服务器登录!"), 0, true);
-
- return false;
- }
-
- return true;
- }
-
- //加载列表
- bool CDataBaseEngineSink::OnRequestLoadGameList(DWORD dwContextID, VOID * pData, WORD wDataSize)
- {
- try
- {
- DBO_GP_GameListResult GameListResult;
- ZeroMemory(&GameListResult, sizeof(GameListResult));
-
- //设置变量
- GameListResult.cbSuccess = TRUE;
-
- //发送消息
- m_pIDataBaseEngineEvent->OnEventDataBaseResult(DBO_GP_GAME_LIST_RESULT, dwContextID, &GameListResult, sizeof(GameListResult));
-
- return true;
- }
- catch (IDataBaseException * pIException)
- {
- //输出错误
- LPCTSTR pszDescribe = pIException->GetExceptionDescribe();
- CTraceService::TraceString(pszDescribe, TraceLevel_Exception);
-
- //变量定义
- DBO_GP_GameListResult GameListResult;
- ZeroMemory(&GameListResult, sizeof(GameListResult));
-
- //设置变量
- GameListResult.cbSuccess = FALSE;
-
- //发送消息
- m_pIDataBaseEngineEvent->OnEventDataBaseResult(DBO_GP_GAME_LIST_RESULT, dwContextID, &GameListResult, sizeof(GameListResult));
-
- return false;
- }
-
- return true;
- }
-
- // 距离清除
- bool CDataBaseEngineSink::OnRequestClearJuLi(DWORD dwContextID, VOID * pData, WORD wDataSize)
- {
- CString str; //获取系统时间
-
- CTime tm; tm = CTime::GetCurrentTime();
-
- if (tm.GetHour() == 4
- && (tm.GetMinute() == 0
- || tm.GetMinute() == 1))
- {
- //清除
- m_MapUserIDJuli.RemoveAll();
- }
- return TRUE;
- }
-
- // 距离添加
- bool CDataBaseEngineSink::OnRequestAddJuLi(DWORD dwContextID, VOID * pData, WORD wDataSize)
- {
- ASSERT(wDataSize == sizeof(CMD_CS_C_JULI));
- if (wDataSize != sizeof(CMD_CS_C_JULI)) return false;
-
- //变量定义
- CMD_CS_C_JULI * pServerUserInfo = (CMD_CS_C_JULI *)pData;
- m_MapUserIDJuli[pServerUserInfo->dUserID] = pServerUserInfo->llJuLi;
-
- return TRUE;
- }
-
- // 更新服务器通道状态
- bool CDataBaseEngineSink::OnRequestOnLineService(DWORD dwContextID, VOID * pData, WORD wDataSize)
- {
-
- IPLIST* pIPLIST = (IPLIST*)pData;
- CLogonServerDlg *pCLogonServerDlg = (CLogonServerDlg *)theApp.m_pMainWnd;
- CServerListManager *pCServerListManager = &(pCLogonServerDlg->m_ServiceUnits.m_AttemperEngineSink.m_ServerListManager);
- CList<LianLu> ListLL;
-
- for (int i = 0; i < 64; i++)
- {
- std::wstring strTemp = pIPLIST->ST_LIST[i];
- if (strTemp == _T("")) continue;
-
- try
- {
- //构造参数
- m_PlatformDBAide.ResetParameter();
- m_PlatformDBAide.AddParameter(TEXT("@strIP"), strTemp.c_str());
- m_PlatformDBAide.AddParameter(TEXT("@strErrorDescribe"), _T(""));
-
- //执行查询
- LONG lResultCode = m_PlatformDBAide.ExecuteProcess(TEXT("GSP_MB_IP"), true);
-
- //写入记录
- if (lResultCode == DB_SUCCESS)
- {
- ListLL.RemoveAll();
- //节点
- while (m_PlatformDBModule->IsRecordsetEnd() == false)
- {
- INT ZhuangTai = m_PlatformDBAide.GetValue_INT(TEXT("ZhuangTai"));
- TCHAR szIP[32];
- ZeroMemory(szIP, sizeof(TCHAR) * 32);
-
- m_PlatformDBAide.GetValue_String(TEXT("MoreIp"), szIP, 32);
-
- SYSTEMTIME SystemTimeConclude;
- m_PlatformDBAide.GetValue_SystemTime(TEXT("LastAddTime"), SystemTimeConclude);
-
- //pGameServerItem->SetLLStat(szIP, ZhuangTai, SystemTimeConclude);
-
- LianLu myTemp;
- ZeroMemory(&myTemp, sizeof(LianLu));
- myTemp.iIsOk = ZhuangTai;
- myTemp.SystemTimeConclude = SystemTimeConclude;
- StringCchCat(myTemp.szIP, 32, szIP);
-
- ListLL.AddTail(myTemp);
-
- //移动记录
- m_PlatformDBModule->MoveToNext();
- }
-
- LianLuGroup Buffer;
- ZeroMemory(&Buffer, sizeof(LianLuGroup));
-
- StringCchCat(Buffer.szAdminIP, 32, strTemp.c_str());
- POSITION Pos = ListLL.GetHeadPosition();
- int j = 0;
- while (Pos)
- {
- LianLu wRet = ListLL.GetNext(Pos);
- Buffer.Data[j] = wRet;
- j++;
-
- if (j > (MAX_TONGDAO -1)) break;
- }
- ListLL.RemoveAll();
-
- //通知网络线程更新数据
- (pCLogonServerDlg->m_ServiceUnits.m_AttemperEngineSink.m_pITCPNetworkEngine)->OnTBDataEvent(218, 0, &Buffer, sizeof(LianLuGroup));
- }
- else
- {
-
- TCHAR szString[512] = TEXT("");
- _sntprintf(szString, CountArray(szString), TEXT("通道更新存储过程执行失败"));
-
- //提示消息
- CTraceService::TraceString(szString, TraceLevel_Warning);
- }
- }
- catch (IDataBaseException * pIException)
- {
- //输出错误
- CTraceService::TraceString(pIException->GetExceptionDescribe(), TraceLevel_Exception);
- }
- }
-
- return TRUE;
- }
-
- //在线信息
- bool CDataBaseEngineSink::OnRequestOnLineCountInfo(DWORD dwContextID, VOID * pData, WORD wDataSize)
- {
- try
- {
- //变量定义
- DBR_GP_OnLineCountInfo * pOnLineCountInfo = (DBR_GP_OnLineCountInfo *)pData;
- WORD wHeadSize = (sizeof(DBR_GP_OnLineCountInfo)-sizeof(pOnLineCountInfo->OnLineCountKind));
-
- //效验数据
- ASSERT((wDataSize >= wHeadSize) && (wDataSize == (wHeadSize + pOnLineCountInfo->wKindCount*sizeof(tagOnLineInfoKindEx))));
- if ((wDataSize < wHeadSize) || (wDataSize != (wHeadSize + pOnLineCountInfo->wKindCount*sizeof(tagOnLineInfoKindEx)))) return false;
-
- //机器标识
- TCHAR szMachineID[LEN_MACHINE_ID];
- CWHService::GetMachineID(szMachineID);
-
- //构造信息
- TCHAR szOnLineCountKind[2048] = TEXT("");
- for (WORD i = 0; i < pOnLineCountInfo->wKindCount; i++)
- {
- INT nLength = lstrlen(szOnLineCountKind);
- _sntprintf(&szOnLineCountKind[nLength], CountArray(szOnLineCountKind) - nLength, TEXT("%d:%ld;"), pOnLineCountInfo->OnLineCountKind[i].wKindID, pOnLineCountInfo->OnLineCountKind[i].dwOnLineCount);
- }
-
- //机器信息
- TCHAR szAndroidCountKind[2048] = TEXT("");
- for (WORD j = 0; j < pOnLineCountInfo->wKindCount; j++)
- {
- INT nLength = lstrlen(szAndroidCountKind);
- _sntprintf(&szAndroidCountKind[nLength], CountArray(szAndroidCountKind) - nLength, TEXT("%d:%ld;"), pOnLineCountInfo->OnLineCountKind[j].wKindID, pOnLineCountInfo->OnLineCountKind[j].wTableCount);
- }
-
- //构造参数
- m_PlatformDBAide.ResetParameter();
- m_PlatformDBAide.AddParameter(TEXT("@strMachineID"), szMachineID);
- m_PlatformDBAide.AddParameter(TEXT("@strMachineServer"), m_pInitParameter->m_szServerName);
- m_PlatformDBAide.AddParameter(TEXT("@dwOnLineCountSum"), pOnLineCountInfo->dwOnLineCountSum);
- m_PlatformDBAide.AddParameter(TEXT("@dwAndroidCountSum"), pOnLineCountInfo->dwAndroidCountSum);
- m_PlatformDBAide.AddParameter(TEXT("@strOnLineCountKind"), szOnLineCountKind);
- m_PlatformDBAide.AddParameter(TEXT("@strAndroidCountKind"), szAndroidCountKind);
-
- //执行命令
- m_PlatformDBAide.ExecuteProcess(TEXT("GSP_GP_OnLineCountInfo"), false);
-
- CLogonServerDlg::SetJiQi(CString(szMachineID));
- CLogonServerDlg::SetShangBao(pOnLineCountInfo->dwOnLineCountSum);
- return true;
- }
- catch (IDataBaseException * pIException)
- {
- //输出错误
- CTraceService::TraceString(pIException->GetExceptionDescribe(), TraceLevel_Exception);
-
- return false;
- }
-
- return true;
- }
-
- ////平台配置 兑换比率
- //bool CDataBaseEngineSink::OnRequestPlatformParameter(DWORD dwContextID, VOID * pData, WORD wDataSize)
- //{
- // try
- // {
- // //构造参数
- // m_PlatformDBAide.ResetParameter();
- //
- // //执行命令
- // LONG lResultCode = m_PlatformDBAide.ExecuteProcess(TEXT("GSP_GR_LoadPlatformParameter"), true);
- //
- // //构造结构
- // DBO_GP_PlatformParameter PlatformParameter;
- // ZeroMemory(&PlatformParameter, sizeof(PlatformParameter));
- //
- // //执行成功
- // if (lResultCode == DB_SUCCESS)
- // {
- // //记录判断
- // if (m_PlatformDBModule->IsRecordsetEnd() == false)
- // {
- // //读取数据
- // PlatformParameter.wExchangeRate = m_PlatformDBAide.GetValue_WORD(TEXT("ExchangeRate"));
- // }
- // }
- //
- // //发送数据
- // m_pIDataBaseEngineEvent->OnEventDataBaseResult(DBO_GP_PLATFORM_PARAMETER, dwContextID, &PlatformParameter, sizeof(PlatformParameter));
- //
- // return true;
- // }
- // catch (IDataBaseException * pIException)
- // {
- // //输出错误
- // CTraceService::TraceString(pIException->GetExceptionDescribe(), TraceLevel_Exception);
- //
- // return false;
- // }
- //
- // return true;
- //}
- //
- //登录成功
- VOID CDataBaseEngineSink::OnLogonDisposeResult(DWORD dwContextID, DWORD dwErrorCode, LPCTSTR pszErrorString, DWORD dwCheckUserRight, bool bMobileClient, LONGLONG llJuLi, byte isSimulator, byte networkType, byte dianliang)
- {
-
- if (dwErrorCode == DB_SUCCESS)
- {
- //变量定义
- DBO_MB_LogonSuccess LogonSuccess;
- ZeroMemory(&LogonSuccess, sizeof(LogonSuccess));
-
- //属性资料
- LogonSuccess.wFaceID = m_AccountsDBAide.GetValue_WORD(TEXT("FaceID"));
- LogonSuccess.cbGender = m_AccountsDBAide.GetValue_BYTE(TEXT("Gender"));
- LogonSuccess.dwCustomID = m_AccountsDBAide.GetValue_DWORD(TEXT("CustomID"));
- LogonSuccess.dwUserID = m_AccountsDBAide.GetValue_DWORD(TEXT("UserID"));
- LogonSuccess.dwGameID = m_AccountsDBAide.GetValue_DWORD(TEXT("GameID"));
- LogonSuccess.dwExperience = m_AccountsDBAide.GetValue_DWORD(TEXT("Experience"));
- LogonSuccess.dwLoveLiness = m_AccountsDBAide.GetValue_DWORD(TEXT("LoveLiness"));
- LogonSuccess.dwXinYong = m_AccountsDBAide.GetValue_DWORD(TEXT("xinyong"));
-
- TCHAR szBuffer[128] = { 0 };
- ZeroMemory(szBuffer, 128 * sizeof(TCHAR));
- m_AccountsDBAide.GetValue_String(TEXT("NickName"), szBuffer, CountArray(szBuffer));
-
- TCHAR szOutBuffer[128] = { 0 };
- ZeroMemory(szOutBuffer, 128 * sizeof(TCHAR));
- //解码
- int iRet = BASE64_Decode(szBuffer, 128, (BYTE*) szOutBuffer);
- if (iRet == -1)
- {
- szBuffer[32] = 0x0;
- _sntprintf(LogonSuccess.szNickName, 32, TEXT("%s"), szBuffer);
- }
- else
- {
- szOutBuffer[32] = 0x0;
- _sntprintf(LogonSuccess.szNickName, 32, TEXT("%s"), szOutBuffer);
- }
-
- //2019-9-18pm lyh add
- TCHAR szUnionID[33] = { 0 };
- memset(szUnionID, 0, 32 * sizeof(TCHAR));
- m_AccountsDBAide.GetValue_String(TEXT("UserUin"), szUnionID, CountArray(szUnionID));
- szUnionID[32] = 0x0;
- CString csUin(szUnionID);
- CString csUinTemp = csUin.Right(6);
- int nUserIDTemp = _ttoi(csUinTemp.GetBuffer());
- if (nUserIDTemp == LogonSuccess.dwUserID)
- {
- szBuffer[32] = 0x0;
- _sntprintf(LogonSuccess.szNickName, 32, TEXT("%s"), szBuffer);
- }
-
- m_AccountsDBAide.GetValue_String(TEXT("DynamicPass"), LogonSuccess.szDynamicPass, CountArray(LogonSuccess.szDynamicPass));
- LogonSuccess.BingDing = m_AccountsDBAide.GetValue_DWORD(TEXT("BingID"));
-
- //用户成绩
- LogonSuccess.lUserScore = m_AccountsDBAide.GetValue_LONGLONG(TEXT("Score"));
- LogonSuccess.lUserIngot = m_AccountsDBAide.GetValue_LONGLONG(TEXT("Ingot"));
- LogonSuccess.lUserInsure = m_AccountsDBAide.GetValue_LONGLONG(TEXT("Insure"));
- LogonSuccess.dUserBeans = m_AccountsDBAide.GetValue_DWORD(TEXT("Beans"));
- LogonSuccess.llJuLi = llJuLi;
-
- //扩展信息
- LogonSuccess.cbInsureEnabled = m_AccountsDBAide.GetValue_BYTE(TEXT("InsureEnabled"));
-
- m_AccountsDBAide.GetValue_String(TEXT("HeadUrl"), LogonSuccess.szHeadUrl, CountArray(LogonSuccess.szHeadUrl));
-
- //获取信息
- lstrcpyn(LogonSuccess.szDescribeString, pszErrorString, CountArray(LogonSuccess.szDescribeString));
-
- //发送结果
- WORD wDataSize = CountStringBuffer(LogonSuccess.szDescribeString);
- WORD wHeadSize = sizeof(LogonSuccess)-sizeof(LogonSuccess.szDescribeString);
- m_pIDataBaseEngineEvent->OnEventDataBaseResult(DBO_MB_LOGON_SUCCESS, dwContextID, &LogonSuccess, wHeadSize + wDataSize);
-
- }
- else
- {
- //变量定义
- DBO_MB_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_MB_LOGON_FAILURE, dwContextID, &LogonFailure, wHeadSize + wDataSize);
- }
-
-
- return;
- }
-
- //////////////////////////////////////////////////////////////////////////////////
|