Skip to content

Commit 8e1604b

Browse files
committed
added:list xlog database table supported
1 parent d9a4562 commit 8e1604b

File tree

11 files changed

+181
-0
lines changed

11 files changed

+181
-0
lines changed

XEngine_Source/XEngine_ModuleDatabase/ModuleDB_Define.h

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,25 @@ extern "C" bool ModuleDatabase_XLog_Query(XENGINE_XLOGINFO*** pppSt_XLogInfo, in
255255
备注:
256256
*********************************************************************/
257257
extern "C" bool ModuleDatabase_XLog_Delete(LPCXSTR lpszTableName);
258+
/********************************************************************
259+
函数名称:ModuleDatabase_XLog_Show
260+
函数功能:日志表列举
261+
参数.一:ppptszList
262+
In/Out:Out
263+
类型:三级指针
264+
可空:N
265+
意思:输出日志数据库里面的表列
266+
参数.二:pInt_ListCount
267+
In/Out:Out
268+
类型:整数型指针
269+
可空:N
270+
意思:输出列个数
271+
返回值
272+
类型:逻辑型
273+
意思:是否成功
274+
备注:
275+
*********************************************************************/
276+
extern "C" bool ModuleDatabase_XLog_Show(XCHAR*** ppptszList, int* pInt_ListCount);
258277
/************************************************************************/
259278
/* 导出的短连接数据库函数 */
260279
/************************************************************************/

XEngine_Source/XEngine_ModuleDatabase/ModuleDatabase_XLog/ModuleDatabase_XLog.cpp

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,4 +282,57 @@ bool CModuleDatabase_XLog::ModuleDatabase_XLog_Delete(LPCXSTR lpszTableName)
282282
return false;
283283
}
284284
return true;
285+
}
286+
/********************************************************************
287+
函数名称:ModuleDatabase_XLog_Show
288+
函数功能:日志表列举
289+
参数.一:ppptszList
290+
In/Out:Out
291+
类型:三级指针
292+
可空:N
293+
意思:输出日志数据库里面的表列
294+
参数.二:pInt_ListCount
295+
In/Out:Out
296+
类型:整数型指针
297+
可空:N
298+
意思:输出列个数
299+
返回值
300+
类型:逻辑型
301+
意思:是否成功
302+
备注:
303+
*********************************************************************/
304+
bool CModuleDatabase_XLog::ModuleDatabase_XLog_Show(XCHAR*** ppptszList, int* pInt_ListCount)
305+
{
306+
DBModule_IsErrorOccur = false;
307+
308+
//查询
309+
XNETHANDLE xhTable = 0;
310+
__int64u nllLine = 0;
311+
__int64u nllRow = 0;
312+
313+
XCHAR tszSQLStatement[1024];
314+
memset(tszSQLStatement, '\0', sizeof(tszSQLStatement));
315+
//名称为,消息名为必填
316+
_xstprintf(tszSQLStatement, _X("SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = 'XEngine_APILog'"));
317+
if (!DataBase_MySQL_ExecuteQuery(xhDBSQL, &xhTable, tszSQLStatement, &nllLine, &nllRow))
318+
{
319+
DBModule_IsErrorOccur = true;
320+
DBModule_dwErrorCode = DataBase_GetLastError();
321+
return false;
322+
}
323+
if (nllLine <= 0)
324+
{
325+
DBModule_IsErrorOccur = true;
326+
DBModule_dwErrorCode = ERROR_APISERVICE_MODULE_DATABASE_NOTFOUND;
327+
return false;
328+
}
329+
*pInt_ListCount = (int)nllLine;
330+
BaseLib_OperatorMemory_Malloc((XPPPMEM)ppptszList, (int)nllLine, MAX_PATH);
331+
for (__int64u i = 0; i < nllLine; i++)
332+
{
333+
XCHAR** pptszResult = DataBase_MySQL_GetResult(xhDBSQL, xhTable);
334+
_tcsxcpy((*ppptszList)[i], pptszResult[0]);
335+
}
336+
DataBase_MySQL_FreeResult(xhDBSQL, xhTable);
337+
return true;
285338
}

XEngine_Source/XEngine_ModuleDatabase/ModuleDatabase_XLog/ModuleDatabase_XLog.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ class CModuleDatabase_XLog
2424
bool ModuleDatabase_XLog_Insert(XENGINE_XLOGINFO* pSt_XLogInfo);
2525
bool ModuleDatabase_XLog_Query(XENGINE_XLOGINFO*** pppSt_XLogInfo, int* pInt_ListCount, LPCXSTR lpszTableName, LPCXSTR lpszTimeStart, LPCXSTR lpszTimeEnd);
2626
bool ModuleDatabase_XLog_Delete(LPCXSTR lpszTableName);
27+
bool ModuleDatabase_XLog_Show(XCHAR*** ppptszList, int* pInt_ListCount);
2728
protected:
2829
private:
2930
XNETHANDLE xhDBSQL;

XEngine_Source/XEngine_ModuleDatabase/XEngine_ModuleDatabase.def

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ EXPORTS
2222
ModuleDatabase_XLog_Insert
2323
ModuleDatabase_XLog_Query
2424
ModuleDatabase_XLog_Delete
25+
ModuleDatabase_XLog_Show
2526

2627
ModuleDatabase_ShortLink_Init
2728
ModuleDatabase_ShortLink_Destory

XEngine_Source/XEngine_ModuleDatabase/pch.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,10 @@ extern "C" bool ModuleDatabase_XLog_Delete(LPCXSTR lpszTableName)
112112
{
113113
return m_XLog.ModuleDatabase_XLog_Delete(lpszTableName);
114114
}
115+
extern "C" bool ModuleDatabase_XLog_Show(XCHAR * **ppptszList, int* pInt_ListCount)
116+
{
117+
return m_XLog.ModuleDatabase_XLog_Show(ppptszList, pInt_ListCount);
118+
}
115119
/************************************************************************/
116120
/* 导出的短连接数据库函数 */
117121
/************************************************************************/

XEngine_Source/XEngine_ModuleProtocol/ModuleProtocol_Define.h

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -410,6 +410,35 @@ extern "C" bool ModuleProtocol_Packet_P2PWList(XCHAR* ptszMsgBuffer, int* pInt_M
410410
*********************************************************************/
411411
extern "C" bool ModuleProtocol_Packet_Log(XCHAR* ptszMsgBuffer, int* pInt_MsgLen, XENGINE_XLOGINFO*** pppSt_XLogList, int nListCount);
412412
/********************************************************************
413+
函数名称:ModuleProtocol_Packet_LogShow
414+
函数功能:日志表名打包
415+
参数.一:ptszMsgBuffer
416+
In/Out:Out
417+
类型:字符指针
418+
可空:N
419+
意思:输出打包的数据信息
420+
参数.二:pInt_MsgLen
421+
In/Out:Out
422+
类型:整数型指针
423+
可空:N
424+
意思:输出打包大小
425+
参数.三:ppptszList
426+
In/Out:In
427+
类型:三级指针
428+
可空:N
429+
意思:输入要打包的数据
430+
参数.四:nListCount
431+
In/Out:In
432+
类型:整数型
433+
可空:N
434+
意思:输入打包数据个数
435+
返回值
436+
类型:逻辑型
437+
意思:是否成功
438+
备注:
439+
*********************************************************************/
440+
extern "C" bool ModuleProtocol_Packet_LogShow(XCHAR* ptszMsgBuffer, int* pInt_MsgLen, XCHAR*** ppptszList, int nListCount);
441+
/********************************************************************
413442
函数名称:ModuleProtocol_Packet_ShortLink
414443
函数功能:短连接生成协议打包函数
415444
参数.一:ptszMsgBuffer

XEngine_Source/XEngine_ModuleProtocol/ModuleProtocol_Packet/ModuleProtocol_Packet.cpp

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -502,6 +502,64 @@ bool CModuleProtocol_Packet::ModuleProtocol_Packet_Log(XCHAR* ptszMsgBuffer, int
502502
return true;
503503
}
504504
/********************************************************************
505+
函数名称:ModuleProtocol_Packet_LogShow
506+
函数功能:日志表名打包
507+
参数.一:ptszMsgBuffer
508+
In/Out:Out
509+
类型:字符指针
510+
可空:N
511+
意思:输出打包的数据信息
512+
参数.二:pInt_MsgLen
513+
In/Out:Out
514+
类型:整数型指针
515+
可空:N
516+
意思:输出打包大小
517+
参数.三:ppptszList
518+
In/Out:In
519+
类型:三级指针
520+
可空:N
521+
意思:输入要打包的数据
522+
参数.四:nListCount
523+
In/Out:In
524+
类型:整数型
525+
可空:N
526+
意思:输入打包数据个数
527+
返回值
528+
类型:逻辑型
529+
意思:是否成功
530+
备注:
531+
*********************************************************************/
532+
bool CModuleProtocol_Packet::ModuleProtocol_Packet_LogShow(XCHAR* ptszMsgBuffer, int* pInt_MsgLen, XCHAR*** ppptszList, int nListCount)
533+
{
534+
ModuleProtocol_IsErrorOccur = false;
535+
536+
if ((NULL == ptszMsgBuffer) || (NULL == pInt_MsgLen))
537+
{
538+
ModuleProtocol_IsErrorOccur = true;
539+
ModuleProtocol_dwErrorCode = ERROR_XENGINE_APISERVICE_MODULE_PROTOCOL_PACKET_PARAMENT;
540+
return false;
541+
}
542+
Json::Value st_JsonRoot;
543+
Json::Value st_JsonArray;
544+
Json::StreamWriterBuilder st_JsonBuilder;
545+
546+
for (int i = 0; i < nListCount; i++)
547+
{
548+
Json::Value st_JsonObject;
549+
550+
st_JsonObject["tszTableName"] = (*ppptszList)[i];
551+
st_JsonArray.append(st_JsonObject);
552+
}
553+
st_JsonRoot["code"] = 0;
554+
st_JsonRoot["msg"] = "success";
555+
st_JsonRoot["data"] = st_JsonArray;
556+
st_JsonBuilder["emitUTF8"] = true;
557+
558+
*pInt_MsgLen = Json::writeString(st_JsonBuilder, st_JsonRoot).length();
559+
memcpy(ptszMsgBuffer, Json::writeString(st_JsonBuilder, st_JsonRoot).c_str(), *pInt_MsgLen);
560+
return true;
561+
}
562+
/********************************************************************
505563
函数名称:ModuleProtocol_Packet_TestReport
506564
函数功能:套接字测试信息打包
507565
参数.一:ptszMsgBuffer

XEngine_Source/XEngine_ModuleProtocol/ModuleProtocol_Packet/ModuleProtocol_Packet.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ class CModuleProtocol_Packet
2929
bool ModuleProtocol_Packet_Locker(XCHAR* ptszMsgBuffer, int* pInt_MsgLen, XNETHANDLE xhToken, int nCode = 0, LPCXSTR lpszMsgBuffer = NULL);
3030
bool ModuleProtocol_Packet_ZIPCode(XCHAR* ptszMsgBuffer, int* pInt_MsgLen, XENGINE_ZIPINFO* pSt_ZIPInfo, int nCode = 0, LPCXSTR lpszMsgBuffer = NULL);
3131
bool ModuleProtocol_Packet_Log(XCHAR* ptszMsgBuffer, int* pInt_MsgLen, XENGINE_XLOGINFO*** pppSt_XLogList, int nListCount);
32+
bool ModuleProtocol_Packet_LogShow(XCHAR* ptszMsgBuffer, int* pInt_MsgLen, XCHAR*** ppptszList, int nListCount);
3233
bool ModuleProtocol_Packet_TestReport(XCHAR* ptszMsgBuffer, int* pInt_MsgLen, XNETHANDLE xhToken, LPCXSTR lpszIPAddr, int nIPPort, __int64x nNumber, __int64x nFailed, __int64x nSuccess, int nStatus);
3334
bool ModuleProtocol_Packet_TestReply(XCHAR* ptszMsgBuffer, int* pInt_MsgLen, XNETHANDLE xhToken);
3435
bool ModuleProtocol_Packet_ShortLink(XCHAR* ptszMsgBuffer, int* pInt_MsgLen, XENGINE_SHORTLINK* pSt_ShortLink);

XEngine_Source/XEngine_ModuleProtocol/XEngine_ModuleProtocol.def

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ EXPORTS
1010
ModuleProtocol_Packet_Locker
1111
ModuleProtocol_Packet_ZIPCode
1212
ModuleProtocol_Packet_Log
13+
ModuleProtocol_Packet_LogShow
1314
ModuleProtocol_Packet_TestReport
1415
ModuleProtocol_Packet_TestReply
1516
ModuleProtocol_Packet_ShortLink

XEngine_Source/XEngine_ModuleProtocol/pch.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,10 @@ extern "C" bool ModuleProtocol_Packet_Log(XCHAR * ptszMsgBuffer, int* pInt_MsgLe
5959
{
6060
return m_ProtocolPacket.ModuleProtocol_Packet_Log(ptszMsgBuffer, pInt_MsgLen, pppSt_XLogList, nListCount);
6161
}
62+
extern "C" bool ModuleProtocol_Packet_LogShow(XCHAR * ptszMsgBuffer, int* pInt_MsgLen, XCHAR * **ppptszList, int nListCount)
63+
{
64+
return m_ProtocolPacket.ModuleProtocol_Packet_LogShow(ptszMsgBuffer, pInt_MsgLen, ppptszList, nListCount);
65+
}
6266
extern "C" bool ModuleProtocol_Packet_TestReport(XCHAR * ptszMsgBuffer, int* pInt_MsgLen, XNETHANDLE xhToken, LPCXSTR lpszIPAddr, int nIPPort, __int64x nNumber, __int64x nFailed, __int64x nSuccess, int nStatus)
6367
{
6468
return m_ProtocolPacket.ModuleProtocol_Packet_TestReport(ptszMsgBuffer, pInt_MsgLen, xhToken, lpszIPAddr, nIPPort, nNumber, nFailed, nSuccess, nStatus);

0 commit comments

Comments
 (0)