@@ -273,122 +273,6 @@ bool CDBModule_MQData::DBModule_MQData_Modify(XENGINE_DBMESSAGEQUEUE* pSt_DBInfo
273273 return true ;
274274}
275275/* *******************************************************************
276- 函数名称:DBModule_MQData_List
277- 函数功能:枚举指定主题序列号后的数据
278- 参数.一:lpszQueueName
279- In/Out:In
280- 类型:常量字符指针
281- 可空:N
282- 意思:输入要处理的主题
283- 参数.二:nSerial
284- In/Out:In
285- 类型:整数型
286- 可空:N
287- 意思:输入主题序列号
288- 参数.三:pppSt_DBMessage
289- In/Out:Out
290- 类型:三级指针
291- 可空:N
292- 意思:输出数据队列信息
293- 参数.四:pInt_ListCount
294- In/Out:Out
295- 类型:整数型
296- 可空:N
297- 意思:输出数据队列大小
298- 返回值
299- 类型:逻辑型
300- 意思:是否成功
301- 备注:
302- *********************************************************************/
303- bool CDBModule_MQData::DBModule_MQData_List (LPCXSTR lpszQueueName, __int64x nSerial, XENGINE_DBMESSAGEQUEUE*** pppSt_DBMessage, int * pInt_ListCount)
304- {
305- DBModule_IsErrorOccur = false ;
306-
307- if (NULL == lpszQueueName)
308- {
309- DBModule_IsErrorOccur = true ;
310- DBModule_dwErrorCode = ERROR_XENGINE_MQCORE_DATABASE_PARAMENT;
311- return false ;
312- }
313- // 查询
314- XNETHANDLE xhTable = 0 ;
315- __int64u nllLine = 0 ;
316- __int64u nllRow = 0 ;
317-
318- XCHAR tszSQLStatement[1024 ];
319- memset (tszSQLStatement, ' \0 ' , sizeof (tszSQLStatement));
320- // 名称为,消息名为必填
321- _xstprintf (tszSQLStatement, _X (" SELECT * FROM `%s` WHERE nQueueSerial >= %lld" ), lpszQueueName, nSerial);
322- if (!DataBase_MySQL_ExecuteQuery (xhDBSQL, &xhTable, tszSQLStatement, &nllLine, &nllRow))
323- {
324- DBModule_IsErrorOccur = true ;
325- DBModule_dwErrorCode = DataBase_GetLastError ();
326- return false ;
327- }
328- if (nllLine <= 0 )
329- {
330- DBModule_IsErrorOccur = true ;
331- DBModule_dwErrorCode = ERROR_XENGINE_MQCORE_DATABASE_EMPTY;
332- return false ;
333- }
334- *pInt_ListCount = (int )nllLine;
335- BaseLib_OperatorMemory_Malloc ((XPPPMEM)pppSt_DBMessage, (int )nllLine, sizeof (XENGINE_DBMESSAGEQUEUE));
336- for (__int64u i = 0 ; i < nllLine; i++)
337- {
338- XCHAR** pptszResult = DataBase_MySQL_GetResult (xhDBSQL, xhTable);
339- XLONG* pInt_Length = DataBase_MySQL_GetLength (xhDBSQL, xhTable);
340-
341- int nPos = 1 ;
342- if (NULL != pptszResult[nPos])
343- {
344- _tcsxcpy ((*pppSt_DBMessage)[i]->tszUserName , pptszResult[nPos]);
345- }
346- nPos++;
347- if (NULL != pptszResult[nPos])
348- {
349- _tcsxcpy ((*pppSt_DBMessage)[i]->tszQueueName , pptszResult[nPos]);
350- }
351- nPos++;
352- if (NULL != pptszResult[nPos])
353- {
354- (*pppSt_DBMessage)[i]->nQueueSerial = _ttxoll (pptszResult[nPos]);
355- }
356- nPos++;
357- if (NULL != pptszResult[nPos])
358- {
359- _tcsxcpy ((*pppSt_DBMessage)[i]->tszQueueLeftTime , pptszResult[nPos]);
360- }
361- nPos++;
362- if (NULL != pptszResult[nPos])
363- {
364- _tcsxcpy ((*pppSt_DBMessage)[i]->tszQueuePublishTime , pptszResult[nPos]);
365- }
366- nPos++;
367- if (NULL != pptszResult[nPos])
368- {
369- (*pppSt_DBMessage)[i]->nMsgLen = pInt_Length[nPos];
370- memcpy ((*pppSt_DBMessage)[i]->tszMsgBuffer , pptszResult[nPos], (*pppSt_DBMessage)[i]->nMsgLen );
371- }
372- nPos++;
373- if (NULL != pptszResult[nPos])
374- {
375- (*pppSt_DBMessage)[i]->byMsgType = _ttxoi (pptszResult[nPos]);
376- }
377- nPos++;
378- if (NULL != pptszResult[nPos])
379- {
380- (*pppSt_DBMessage)[i]->nMsgAttr = _ttxoi (pptszResult[nPos]);
381- }
382- nPos++;
383- if (NULL != pptszResult[nPos])
384- {
385- _tcsxcpy ((*pppSt_DBMessage)[i]->tszQueueCreateTime , pptszResult[nPos]);
386- }
387- }
388- DataBase_MySQL_FreeResult (xhDBSQL, xhTable);
389- return true ;
390- }
391- /* *******************************************************************
392276函数名称:DBModule_MQData_GetSerial
393277函数功能:获取序列号
394278 参数.一:lpszName
@@ -800,4 +684,67 @@ bool CDBModule_MQData::DBModule_MQData_ShowTable(XCHAR*** pppszTableName, int* p
800684 }
801685 DataBase_MySQL_FreeResult (xhDBSQL, xhTable);
802686 return true ;
687+ }
688+ /* *******************************************************************
689+ 函数名称:DBModule_MQData_GetLeftCount
690+ 函数功能:获取剩余个数
691+ 参数.一:lpszTableName
692+ In/Out:In
693+ 类型:常量字符指针
694+ 可空:N
695+ 意思:输入表名称
696+ 参数.二:nSerial
697+ In/Out:In
698+ 类型:整数型
699+ 可空:N
700+ 意思:输入开始的序列号
701+ 参数.三:pInt_Count
702+ In/Out:Out
703+ 类型:整数型指针
704+ 可空:N
705+ 意思:输出统计信息
706+ 返回值
707+ 类型:逻辑型
708+ 意思:是否成功
709+ 备注:
710+ *********************************************************************/
711+ bool CDBModule_MQData::DBModule_MQData_GetLeftCount (LPCXSTR lpszTableName, int nSerial, int * pInt_Count)
712+ {
713+ DBModule_IsErrorOccur = false ;
714+
715+ if (NULL == pInt_Count)
716+ {
717+ DBModule_IsErrorOccur = true ;
718+ DBModule_dwErrorCode = ERROR_XENGINE_MQCORE_DATABASE_PARAMENT;
719+ return false ;
720+ }
721+ // 查询
722+ XNETHANDLE xhTable = 0 ;
723+ __int64u nllLine = 0 ;
724+ __int64u nllRow = 0 ;
725+
726+ XCHAR tszSQLStatement[1024 ];
727+ memset (tszSQLStatement, ' \0 ' , sizeof (tszSQLStatement));
728+
729+ _xstprintf (tszSQLStatement, _X (" SELECT COUNT(*) FROM %s WHERE nQueueSerial > %d" ), lpszTableName, nSerial);
730+ if (!DataBase_MySQL_ExecuteQuery (xhDBSQL, &xhTable, tszSQLStatement, &nllLine, &nllRow))
731+ {
732+ DBModule_IsErrorOccur = true ;
733+ DBModule_dwErrorCode = DataBase_GetLastError ();
734+ return false ;
735+ }
736+ if (nllLine <= 0 )
737+ {
738+ DBModule_IsErrorOccur = true ;
739+ DBModule_dwErrorCode = ERROR_XENGINE_MQCORE_DATABASE_EMPTY;
740+ return false ;
741+ }
742+ XCHAR** pptszResult = DataBase_MySQL_GetResult (xhDBSQL, xhTable);
743+
744+ if (NULL != pptszResult[0 ])
745+ {
746+ *pInt_Count = _ttxoi (pptszResult[0 ]);
747+ }
748+ DataBase_MySQL_FreeResult (xhDBSQL, xhTable);
749+ return true ;
803750}
0 commit comments