Skip to content

Commit 0cfeefa

Browse files
committed
added:info report module
1 parent bd02f89 commit 0cfeefa

18 files changed

+609
-0
lines changed

XEngine_Source/StorageModule_Config/Config_Define.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,11 @@ typedef struct tag_XEngine_ServerConfig
103103
bool bUPEnable;
104104
bool bCHEnable;
105105
}st_XCert;
106+
struct
107+
{
108+
XCHAR tszAPIUrl[MAX_PATH];
109+
bool bEnable;
110+
}st_XReport;
106111
struct
107112
{
108113
list<string> *pStl_ListStorage;

XEngine_Source/StorageModule_Config/Config_Error.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#define ERROR_XENGINE_BLOGIC_CONFIG_JSON_P2XP 0x002000A
2626
#define ERROR_XENGINE_BLOGIC_CONFIG_JSON_CERT 0x002000B
2727
#define ERROR_XENGINE_BLOGIC_CONFIG_JSON_XAUTH 0x002000C
28+
#define ERROR_XENGINE_BLOGIC_CONFIG_JSON_CREPORT 0x002000D
2829

2930
#define ERROR_XENGINE_BLOGIC_CONFIG_JSON_LBDISTRIBUTED 0x0020010
3031
#define ERROR_XENGINE_BLOGIC_CONFIG_JSON_LBLOCATION 0x0020011

XEngine_Source/StorageModule_Config/Config_Json/Config_Json.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,16 @@ bool CConfig_Json::Config_Json_File(LPCXSTR lpszConfigFile, XENGINE_SERVERCONFIG
222222
_tcsxcpy(pSt_ServerConfig->st_XCert.tszCertKey, st_JsonP2xp["tszCertKey"].asCString());
223223
}
224224

225+
if (st_JsonRoot["XReport"].empty() || (2 != st_JsonRoot["XReport"].size()))
226+
{
227+
Config_IsErrorOccur = true;
228+
Config_dwErrorCode = ERROR_XENGINE_BLOGIC_CONFIG_JSON_CREPORT;
229+
return false;
230+
}
231+
Json::Value st_JsonReport = st_JsonRoot["XReport"];
232+
pSt_ServerConfig->st_XReport.bEnable = st_JsonReport["bEnable"].asBool();
233+
_tcsxcpy(pSt_ServerConfig->st_XReport.tszAPIUrl, st_JsonReport["tszAPIUrl"].asCString());
234+
225235
if (st_JsonRoot["XVer"].empty())
226236
{
227237
Config_IsErrorOccur = true;
Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
#include "pch.h"
2+
#include "InfoReport_APIMachine.h"
3+
/********************************************************************
4+
// Created: 2024/04/15 14:54:19
5+
// File Name: D:\XEngine_Storage\XEngine_Source\StorageModule_InfoReport\InfoReport_APIMachine\InfoReport_APIMachine.cpp
6+
// File Path: D:\XEngine_Storage\XEngine_Source\StorageModule_InfoReport\InfoReport_APIMachine
7+
// File Base: InfoReport_APIMachine
8+
// File Ext: cpp
9+
// Project: XEngine(网络通信引擎)
10+
// Author: qyt
11+
// Purpose: 信息收集报告类
12+
// History:
13+
*********************************************************************/
14+
CInfoReport_APIMachine::CInfoReport_APIMachine()
15+
{
16+
17+
}
18+
CInfoReport_APIMachine::~CInfoReport_APIMachine()
19+
{
20+
21+
}
22+
//////////////////////////////////////////////////////////////////////////
23+
// 公有函数
24+
//////////////////////////////////////////////////////////////////////////
25+
/********************************************************************
26+
函数名称:InfoReport_APIMachine_Send
27+
函数功能:发送一条信息报告给API服务器
28+
参数.一:lpszAPIUrl
29+
In/Out:In
30+
类型:常量字符指针
31+
可空:N
32+
意思:输入请求地址
33+
返回值
34+
类型:逻辑型
35+
意思:是否成功
36+
备注:lpszAPIUrl = _X("http://127.0.0.1:5501/api?function=machine&params1=0");
37+
*********************************************************************/
38+
bool CInfoReport_APIMachine::InfoReport_APIMachine_Send(LPCXSTR lpszAPIUrl)
39+
{
40+
InfoReport_IsErrorOccur = false;
41+
42+
if (NULL == lpszAPIUrl)
43+
{
44+
InfoReport_IsErrorOccur = true;
45+
InfoReport_dwErrorCode = ERROR_XENGINE_STORAGE_INFOREPORT_PARAMENT;
46+
return false;
47+
}
48+
int nLen = 0;
49+
int nCode = 0;
50+
51+
XCHAR tszOSName[128] = {};
52+
XCHAR tszOSVersion[128] = {};
53+
XCHAR tszOSBuild[128] = {};
54+
XCHAR tszComputerName[128] = {};
55+
XLONG nOSArch = 0;
56+
SYSTEMAPI_SERIAL_INFOMATION st_SDKSerial = {};
57+
SystemApi_System_GetSystemVer(tszOSName, tszOSVersion, tszOSBuild, &nOSArch);
58+
SystemApi_System_GetSysName(NULL, tszComputerName);
59+
SystemApi_HardWare_GetSerial(&st_SDKSerial);
60+
61+
Json::Value st_JsonRoot;
62+
Json::StreamWriterBuilder st_JsonBuilder;
63+
64+
XCHAR tszMachineText[1024] = {};
65+
InfoReport_APIMachine_GetText(tszMachineText);
66+
67+
st_JsonRoot["tszMachineName"] = tszOSName;
68+
st_JsonRoot["tszMachineCode"] = st_SDKSerial.tszSystemSerial;
69+
st_JsonRoot["tszMachineSystem"] = tszComputerName;
70+
st_JsonRoot["tszMachineText"] = tszMachineText;
71+
72+
st_JsonBuilder["emitUTF8"] = true;
73+
74+
XCHAR* ptszMsgBuffer = NULL;
75+
if (!APIClient_Http_Request(_X("POST"), lpszAPIUrl, Json::writeString(st_JsonBuilder, st_JsonRoot).c_str(), &nCode, &ptszMsgBuffer, &nLen))
76+
{
77+
InfoReport_IsErrorOccur = true;
78+
InfoReport_dwErrorCode = APIClient_GetLastError();
79+
return false;
80+
}
81+
BaseLib_OperatorMemory_FreeCStyle((XPPMEM)&ptszMsgBuffer);
82+
83+
return true;
84+
}
85+
bool CInfoReport_APIMachine::InfoReport_APIMachine_GetText(XCHAR* ptszMSGBuffer)
86+
{
87+
InfoReport_IsErrorOccur = false;
88+
89+
XCHAR tszOSName[128] = {};
90+
XCHAR tszOSVersion[128] = {};
91+
XCHAR tszOSBuild[128] = {};
92+
XLONG nOSArch = 0;
93+
int nProcessCount = 0;
94+
SYSTEMAPI_CPU_INFOMATION st_CPUInfo = {};
95+
SYSTEMAPI_MEMORY_INFOMATION st_MemoryInfo = {};
96+
97+
Json::Value st_JsonRoot;
98+
Json::Value st_JsonCPUObject;
99+
Json::Value st_JsonOSObject;
100+
Json::Value st_JsonMEMObject;
101+
Json::StreamWriterBuilder st_JsonBuilder;
102+
103+
SystemApi_System_GetSystemVer(tszOSName, tszOSVersion, tszOSBuild, &nOSArch);
104+
SystemApi_HardWare_GetCpuInfomation(&st_CPUInfo);
105+
SystemApi_System_GetMemoryUsage(&st_MemoryInfo, XENGINE_SYSTEMSDK_API_SYSTEM_SIZE_MB);
106+
SystemApi_System_GetProcessCount(&nProcessCount);
107+
108+
st_JsonCPUObject["nCPUNumber"] = st_CPUInfo.nCpuNumber;
109+
st_JsonCPUObject["nCPUSpeed"] = st_CPUInfo.nCpuSpeed;
110+
111+
st_JsonOSObject["OSArch"] = (Json::Value::Int)nOSArch;
112+
st_JsonOSObject["OSVersion"] = tszOSVersion;
113+
st_JsonOSObject["tszOSBuild"] = tszOSBuild;
114+
115+
st_JsonMEMObject["nTotal"] = st_MemoryInfo.dwMemory_Total;
116+
st_JsonMEMObject["nFree"] = st_MemoryInfo.dwMemory_Free;
117+
118+
st_JsonRoot["bAdmin"] = SystemApi_Process_IsAdmin();
119+
st_JsonRoot["nProcessCount"] = nProcessCount;
120+
st_JsonRoot["st_CPUObject"] = st_JsonCPUObject;
121+
st_JsonRoot["st_OSObject"] = st_JsonOSObject;
122+
st_JsonRoot["st_MEMObject"] = st_JsonMEMObject;
123+
124+
_tcsxcpy(ptszMSGBuffer, st_JsonRoot.toStyledString().c_str());
125+
return true;
126+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#pragma once
2+
/********************************************************************
3+
// Created: 2024/04/15 14:54:08
4+
// File Name: D:\XEngine_Storage\XEngine_Source\StorageModule_InfoReport\InfoReport_APIMachine\InfoReport_APIMachine.h
5+
// File Path: D:\XEngine_Storage\XEngine_Source\StorageModule_InfoReport\InfoReport_APIMachine
6+
// File Base: InfoReport_APIMachine
7+
// File Ext: h
8+
// Project: XEngine(网络通信引擎)
9+
// Author: qyt
10+
// Purpose: 信息收集报告类
11+
// History:
12+
*********************************************************************/
13+
14+
class CInfoReport_APIMachine
15+
{
16+
public:
17+
CInfoReport_APIMachine();
18+
~CInfoReport_APIMachine();
19+
public:
20+
bool InfoReport_APIMachine_Send(LPCXSTR lpszAPIUrl);
21+
protected:
22+
bool InfoReport_APIMachine_GetText(XCHAR *ptszMSGBuffer);
23+
};
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#pragma once
2+
/********************************************************************
3+
// Created: 2024/04/15 15:39:50
4+
// File Name: D:\XEngine_Storage\XEngine_Source\StorageModule_InfoReport\InfoReport_Define.h
5+
// File Path: D:\XEngine_Storage\XEngine_Source\StorageModule_InfoReport
6+
// File Base: InfoReport_Define
7+
// File Ext: h
8+
// Project: XEngine(网络通信引擎)
9+
// Author: qyt
10+
// Purpose: 信息报告导出定义
11+
// History:
12+
*********************************************************************/
13+
//////////////////////////////////////////////////////////////////////////
14+
// 导出函数
15+
//////////////////////////////////////////////////////////////////////////
16+
extern "C" XLONG InfoReport_GetLastError(int *pInt_ErrorCode = NULL);
17+
/************************************************************************/
18+
/* APIMachine报告 */
19+
/************************************************************************/
20+
/********************************************************************
21+
函数名称:InfoReport_APIMachine_Send
22+
函数功能:发送一条信息报告给API服务器
23+
参数.一:lpszAPIUrl
24+
In/Out:In
25+
类型:常量字符指针
26+
可空:N
27+
意思:输入请求地址
28+
返回值
29+
类型:逻辑型
30+
意思:是否成功
31+
备注:lpszAPIUrl = _X("http://127.0.0.1:5501/api?function=machine&params1=0");
32+
*********************************************************************/
33+
extern "C" bool InfoReport_APIMachine_Send(LPCXSTR lpszAPIUrl);
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#pragma once
2+
/********************************************************************
3+
// Created: 2024/04/15 15:41:43
4+
// File Name: D:\XEngine_Storage\XEngine_Source\StorageModule_InfoReport\InfoReport_Error.h
5+
// File Path: D:\XEngine_Storage\XEngine_Source\StorageModule_InfoReport
6+
// File Base: InfoReport_Error
7+
// File Ext: h
8+
// Project: XEngine(网络通信引擎)
9+
// Author: qyt
10+
// Purpose: 信息报告错误码
11+
// History:
12+
*********************************************************************/
13+
#define ERROR_XENGINE_STORAGE_INFOREPORT_PARAMENT 0x01A0001
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
LIBRARY
2+
3+
EXPORTS
4+
InfoReport_GetLastError
5+
6+
InfoReport_APIMachine_Send

0 commit comments

Comments
 (0)