@@ -78,15 +78,17 @@ bool CInfoReport_APIMachine::InfoReport_APIMachine_Send(LPCXSTR lpszAPIUrl, LPCX
7878 Json::StreamWriterBuilder st_JsonBuilder;
7979 Json::CharReaderBuilder st_JsonReader;
8080
81- XCHAR tszMachineText[2048 ] = {};
82- InfoReport_APIMachine_GetText (tszMachineText);
81+ XCHAR tszMachineSoftware[8192 ] = {};
82+ XCHAR tszMachineHardware[8192 ] = {};
83+ InfoReport_APIMachine_Hardware (tszMachineHardware);
84+ InfoReport_APIMachine_Software (tszMachineSoftware);
8385
8486 st_JsonRoot[" tszServiceName" ] = lpszServiceName;
8587 st_JsonRoot[" tszMachineName" ] = tszOSName;
8688 st_JsonRoot[" tszMachineUser" ] = tszUserName;
8789 st_JsonRoot[" tszMachineSystem" ] = tszComputerName;
88- st_JsonRoot[" tszMachineText " ] = tszMachineText ;
89-
90+ st_JsonRoot[" tszMachineSoftware " ] = tszMachineSoftware ;
91+ st_JsonRoot[ " tszMachineHardware " ] = tszMachineHardware;
9092 st_JsonBuilder[" emitUTF8" ] = true ;
9193
9294 XCHAR* ptszMsgBuffer = NULL ;
@@ -277,46 +279,212 @@ bool CInfoReport_APIMachine::InfoReport_APIMachine_Delete(LPCXSTR lpszAPIUrl, LP
277279 }
278280 return true ;
279281}
280- // ////////////////////////////////////////////////////////////////////////
281- // 保护函数
282- // ////////////////////////////////////////////////////////////////////////
283- bool CInfoReport_APIMachine::InfoReport_APIMachine_GetText (XCHAR* ptszMSGBuffer)
282+ /* *******************************************************************
283+ 函数名称:InfoReport_APIMachine_Hardware
284+ 函数功能:获取硬件信息
285+ 参数.一:ptszHWInfo
286+ In/Out:Out
287+ 类型:字符指针
288+ 可空:N
289+ 意思:导出获取到的数据,这个数据是JSON格式
290+ 参数.二:pInt_Len
291+ In/Out:Out
292+ 类型:整数型指针
293+ 可空:Y
294+ 意思:导出数据的长度
295+ 返回值
296+ 类型:逻辑型
297+ 意思:是否成功
298+ 备注:
299+ *********************************************************************/
300+ bool CInfoReport_APIMachine::InfoReport_APIMachine_Hardware (XCHAR* ptszSWInfo, int * pInt_Len /* = NULL */ )
284301{
285302 InfoReport_IsErrorOccur = false ;
286303
287- XCHAR tszOSName[128 ] = {};
288- XCHAR tszOSVersion[128 ] = {};
289- XCHAR tszOSBuild[128 ] = {};
290- XLONG nOSArch = 0 ;
291- int nProcessCount = 0 ;
304+ if ((NULL == ptszSWInfo))
305+ {
306+ InfoReport_IsErrorOccur = true ;
307+ InfoReport_dwErrorCode = ERROR_XENGINE_THIRDPART_INFOREPORT_CODE;
308+ return false ;
309+ }
310+ int nDiskNumber = 0 ;
311+ XCHAR** pptszRootName;
312+ SYSTEMAPI_DISK_INFOMATION st_DiskInfo = {};
292313 SYSTEMAPI_CPU_INFOMATION st_CPUInfo = {};
293314 SYSTEMAPI_MEMORY_INFOMATION st_MemoryInfo = {};
315+ SYSTEMAPI_SERIAL_INFOMATION st_SDKSerial = {};
316+
317+ if (!SystemApi_HardWare_GetDiskNumber (&pptszRootName, &nDiskNumber))
318+ {
319+ InfoReport_IsErrorOccur = true ;
320+ InfoReport_dwErrorCode = SystemApi_GetLastError ();
321+ return false ;
322+ }
323+ BaseLib_Memory_Free ((XPPPMEM)&pptszRootName, nDiskNumber);
324+
325+ XCHAR tszDriveStr[XPATH_MAX];
326+ memset (tszDriveStr, ' \0 ' , XPATH_MAX);
327+ #ifdef _MSC_BUILD
328+ GetLogicalDriveStringsA (XPATH_MAX, tszDriveStr);
329+ #else
330+ LPCXSTR lpszDir = _X (" /" );
331+ strcpy (tszDriveStr, lpszDir);
332+ #endif
333+
334+ if (!SystemApi_HardWare_GetDiskInfomation (tszDriveStr, &st_DiskInfo, XENGINE_SYSTEMSDK_API_SYSTEM_SIZE_MB))
335+ {
336+ InfoReport_IsErrorOccur = true ;
337+ InfoReport_dwErrorCode = SystemApi_GetLastError ();
338+ return false ;
339+ }
340+ if (!SystemApi_HardWare_GetCpuInfomation (&st_CPUInfo))
341+ {
342+ InfoReport_IsErrorOccur = true ;
343+ InfoReport_dwErrorCode = SystemApi_GetLastError ();
344+ return false ;
345+ }
346+ if (!SystemApi_System_GetMemoryUsage (&st_MemoryInfo, XENGINE_SYSTEMSDK_API_SYSTEM_SIZE_MB))
347+ {
348+ InfoReport_IsErrorOccur = true ;
349+ InfoReport_dwErrorCode = SystemApi_GetLastError ();
350+ return false ;
351+ }
352+ if (!SystemApi_HardWare_GetSerial (&st_SDKSerial))
353+ {
354+ InfoReport_IsErrorOccur = true ;
355+ InfoReport_dwErrorCode = SystemApi_GetLastError ();
356+ return false ;
357+ }
294358
295359 Json::Value st_JsonRoot;
296- Json::Value st_JsonCPUObject;
297- Json::Value st_JsonOSObject;
298- Json::Value st_JsonMEMObject;
299- Json::StreamWriterBuilder st_JsonBuilder;
360+ Json::Value st_JsonDisk;
361+ Json::Value st_JsonCpu;
362+ Json::Value st_JsonSerial;
363+ Json::Value st_JsonMemory;
364+ Json::Value st_JsonNetCard;
365+
366+ st_JsonDisk[" DiskNumber" ] = nDiskNumber;
367+ st_JsonDisk[" DiskFree" ] = (Json::UInt64)st_DiskInfo.dwDiskFree ;
368+ st_JsonDisk[" DiskTotal" ] = (Json::UInt64)st_DiskInfo.dwDiskTotal ;
369+ st_JsonDisk[" DiskName" ] = tszDriveStr;
370+
371+ st_JsonCpu[" CpuNumber" ] = st_CPUInfo.nCPUNumber ;
372+ st_JsonCpu[" CpuSpeed" ] = st_CPUInfo.nCPUSpeed ;
373+ st_JsonCpu[" CpuName" ] = st_CPUInfo.tszCPUName ;
374+
375+ st_JsonMemory[" MemoryFree" ] = (Json::UInt64)st_MemoryInfo.dwMemory_Free ;
376+ st_JsonMemory[" MemoryTotal" ] = (Json::UInt64)st_MemoryInfo.dwMemory_Total ;
377+
378+ st_JsonSerial[" DiskSerial" ] = st_SDKSerial.tszDiskSerial ;
379+ st_JsonSerial[" CpuSerial" ] = st_SDKSerial.tszCPUSerial ;
380+ st_JsonSerial[" BoardSerial" ] = st_SDKSerial.tszBoardSerial ;
381+ st_JsonSerial[" SystemSerial" ] = st_SDKSerial.tszSystemSerial ;
382+
383+ int nListCount = 0 ;
384+ XSOCKET_CARDINFO** ppSt_ListIFInfo;
385+ XSocket_Api_GetCardInfo (&ppSt_ListIFInfo, &nListCount);
386+ for (int i = 0 ; i < nListCount; i++)
387+ {
388+ Json::Value st_JsonIPAddr;
389+ st_JsonIPAddr[" tszIFName" ] = ppSt_ListIFInfo[i]->tszIFName ;
390+ st_JsonIPAddr[" tszIPAddr" ] = ppSt_ListIFInfo[i]->tszIPAddr ;
391+ st_JsonIPAddr[" tszBroadAddr" ] = ppSt_ListIFInfo[i]->tszBroadAddr ;
392+ st_JsonIPAddr[" tszDnsAddr" ] = ppSt_ListIFInfo[i]->tszDnsAddr ;
393+ st_JsonIPAddr[" tszMacAddr" ] = ppSt_ListIFInfo[i]->tszMacAddr ;
394+ st_JsonNetCard.append (st_JsonIPAddr);
395+ }
396+ BaseLib_Memory_Free ((XPPPMEM)&ppSt_ListIFInfo, nListCount);
300397
301- SystemApi_System_GetSystemVer (tszOSName, tszOSVersion, tszOSBuild, &nOSArch);
302- SystemApi_HardWare_GetCpuInfomation (&st_CPUInfo);
303- SystemApi_System_GetMemoryUsage (&st_MemoryInfo, XENGINE_SYSTEMSDK_API_SYSTEM_SIZE_MB);
304- SystemApi_System_GetProcessCount (&nProcessCount);
398+ st_JsonRoot[" Disk" ] = st_JsonDisk;
399+ st_JsonRoot[" Cpu" ] = st_JsonCpu;
400+ st_JsonRoot[" Memory" ] = st_JsonMemory;
401+ st_JsonRoot[" Serial" ] = st_JsonSerial;
402+ st_JsonRoot[" NetCard" ] = st_JsonNetCard;
403+
404+ if (NULL != pInt_Len)
405+ {
406+ *pInt_Len = st_JsonRoot.toStyledString ().length ();
407+ }
408+ memcpy (ptszSWInfo, st_JsonRoot.toStyledString ().c_str (), st_JsonRoot.toStyledString ().length ());
409+
410+ return true ;
411+ }
412+ /* *******************************************************************
413+ 函数名称:InfoReport_APIMachine_Software
414+ 函数功能:获取软件系统信息
415+ 参数.一:ptszSWInfo
416+ In/Out:Out
417+ 类型:字符指针
418+ 可空:N
419+ 意思:导出系统信息JSON结构
420+ 参数.二:pInt_Len
421+ In/Out:Out
422+ 类型:整数型指针
423+ 可空:Y
424+ 意思:导出系统信息长度
425+ 返回值
426+ 类型:逻辑型
427+ 意思:是否成功
428+ 备注:
429+ *********************************************************************/
430+ bool CInfoReport_APIMachine::InfoReport_APIMachine_Software (XCHAR* ptszSWInfo, int * pInt_Len /* = NULL */ )
431+ {
432+ InfoReport_IsErrorOccur = false ;
433+
434+ if ((NULL == ptszSWInfo))
435+ {
436+ InfoReport_IsErrorOccur = true ;
437+ InfoReport_dwErrorCode = ERROR_XENGINE_THIRDPART_INFOREPORT_PARAMENT;
438+ return false ;
439+ }
440+ int nProcessCount = 0 ;
441+ XLONG nOSProcessor = 0 ;
442+ XCHAR tszOSBuild[256 ] = {};
443+ XCHAR tszOSVersion[256 ] = {};
444+ XCHAR tszOSInfo[256 ] = {};
445+ XCHAR tszUPTime[256 ] = {};
446+ XCHAR tszServicePacket[256 ] = {};
447+ XENGINE_LIBTIME st_LibTimer = {};
448+ SYSTEMAPI_CPU_INFOMATION st_CPUInfo = {};
305449
306- st_JsonCPUObject[" nCPUNumber" ] = st_CPUInfo.nCPUNumber ;
307- st_JsonCPUObject[" nCPUSpeed" ] = st_CPUInfo.nCPUSpeed ;
308- st_JsonOSObject[" OSArch" ] = (Json::Value::Int)nOSArch;
309- st_JsonOSObject[" OSVersion" ] = tszOSVersion;
310- st_JsonOSObject[" tszOSBuild" ] = tszOSBuild;
450+ if (!SystemApi_System_GetSystemVer (tszOSInfo, tszOSVersion, tszOSBuild, &nOSProcessor))
451+ {
452+ InfoReport_IsErrorOccur = true ;
453+ InfoReport_dwErrorCode = SystemApi_GetLastError ();
454+ return false ;
455+ }
456+ if (!SystemApi_System_GetProcessCount (&nProcessCount))
457+ {
458+ InfoReport_IsErrorOccur = true ;
459+ InfoReport_dwErrorCode = SystemApi_GetLastError ();
460+ return false ;
461+ }
462+ if (!SystemApi_System_GetUpTime (&st_LibTimer))
463+ {
464+ InfoReport_IsErrorOccur = true ;
465+ InfoReport_dwErrorCode = SystemApi_GetLastError ();
466+ return false ;
467+ }
311468
312- st_JsonMEMObject[" nTotal" ] = (Json::Value::UInt64)st_MemoryInfo.dwMemory_Total ;
313- st_JsonMEMObject[" nFree" ] = (Json::Value::UInt64)st_MemoryInfo.dwMemory_Free ;
469+ sprintf (tszUPTime, " %04d-%02d-%02d %02d:%02d:%02d" , st_LibTimer.wYear , st_LibTimer.wMonth , st_LibTimer.wDay , st_LibTimer.wHour , st_LibTimer.wMinute , st_LibTimer.wSecond );
314470
315- st_JsonRoot[" nProcessCount" ] = nProcessCount;
316- st_JsonRoot[" st_CPUObject" ] = st_JsonCPUObject;
317- st_JsonRoot[" st_OSObject" ] = st_JsonOSObject;
318- st_JsonRoot[" st_MEMObject" ] = st_JsonMEMObject;
471+ Json::Value st_JsonRoot;
472+ Json::Value st_JsonSystem;
473+
474+ st_JsonSystem[" OSUPTime" ] = tszUPTime;
475+ st_JsonSystem[" OSVersion" ] = tszOSInfo;
476+ st_JsonSystem[" OSVersion" ] = tszOSVersion;
477+ st_JsonSystem[" OSBuild" ] = tszOSBuild;
478+ st_JsonSystem[" OSArch" ] = (Json::Value::Int)nOSProcessor;
479+ st_JsonSystem[" OSProcessCount" ] = nProcessCount;
480+
481+ st_JsonRoot[" OSInfo" ] = st_JsonSystem;
482+
483+ if (NULL != pInt_Len)
484+ {
485+ *pInt_Len = st_JsonRoot.toStyledString ().length ();
486+ }
487+ memcpy (ptszSWInfo, st_JsonRoot.toStyledString ().c_str (), st_JsonRoot.toStyledString ().length ());
319488
320- _tcsxcpy (ptszMSGBuffer, st_JsonRoot.toStyledString ().c_str ());
321489 return true ;
322490}
0 commit comments