@@ -33,7 +33,7 @@ CInfoReport_APIMachine::~CInfoReport_APIMachine()
3333返回值
3434 类型:逻辑型
3535 意思:是否成功
36- 备注:lpszAPIUrl = _X("http://127.0.0.1:5501/api?function=machine¶ms1=0 ");
36+ 备注:lpszAPIUrl = _X("http://127.0.0.1:5501/api?function=machine");
3737*********************************************************************/
3838bool CInfoReport_APIMachine::InfoReport_APIMachine_Send (LPCXSTR lpszAPIUrl)
3939{
@@ -48,6 +48,7 @@ bool CInfoReport_APIMachine::InfoReport_APIMachine_Send(LPCXSTR lpszAPIUrl)
4848 int nLen = 0 ;
4949 int nCode = 0 ;
5050
51+ XCHAR tszAPIUrl[MAX_PATH] = {};
5152 XCHAR tszOSName[128 ] = {};
5253 XCHAR tszOSVersion[128 ] = {};
5354 XCHAR tszOSBuild[128 ] = {};
@@ -57,6 +58,8 @@ bool CInfoReport_APIMachine::InfoReport_APIMachine_Send(LPCXSTR lpszAPIUrl)
5758 XCLIENT_APIHTTP st_HTTPParam = {};
5859 SYSTEMAPI_SERIAL_INFOMATION st_SDKSerial = {};
5960
61+ _xstprintf (tszAPIUrl, _X (" %s¶ms1=0" ), lpszAPIUrl);
62+
6063 SystemApi_System_GetSystemVer (tszOSName, tszOSVersion, tszOSBuild, &nOSArch);
6164 SystemApi_System_GetSysName (NULL , tszComputerName);
6265 SystemApi_HardWare_GetSerial (&st_SDKSerial);
@@ -76,7 +79,7 @@ bool CInfoReport_APIMachine::InfoReport_APIMachine_Send(LPCXSTR lpszAPIUrl)
7679
7780 XCHAR* ptszMsgBuffer = NULL ;
7881 st_HTTPParam.nTimeConnect = 2 ;
79- if (!APIClient_Http_Request (_X (" POST" ), lpszAPIUrl , Json::writeString (st_JsonBuilder, st_JsonRoot).c_str (), &nCode, &ptszMsgBuffer, &nLen, NULL , NULL , &st_HTTPParam))
82+ if (!APIClient_Http_Request (_X (" POST" ), tszAPIUrl , Json::writeString (st_JsonBuilder, st_JsonRoot).c_str (), &nCode, &ptszMsgBuffer, &nLen, NULL , NULL , &st_HTTPParam))
8083 {
8184 InfoReport_IsErrorOccur = true ;
8285 InfoReport_dwErrorCode = APIClient_GetLastError ();
@@ -86,6 +89,88 @@ bool CInfoReport_APIMachine::InfoReport_APIMachine_Send(LPCXSTR lpszAPIUrl)
8689
8790 return true ;
8891}
92+ /* *******************************************************************
93+ 函数名称:InfoReport_APIMachine_GetTime
94+ 函数功能:获取报告次数
95+ 参数.一:lpszAPIUrl
96+ In/Out:In
97+ 类型:常量字符指针
98+ 可空:N
99+ 意思:输入请求地址
100+ 参数.二:pInt_TimeNumber
101+ In/Out:Out
102+ 类型:整数型指针
103+ 可空:N
104+ 意思:输出报告次数
105+ 返回值
106+ 类型:逻辑型
107+ 意思:是否成功
108+ 备注:
109+ *********************************************************************/
110+ bool CInfoReport_APIMachine::InfoReport_APIMachine_GetTime (LPCXSTR lpszAPIUrl, __int64x* pInt_TimeNumber)
111+ {
112+ InfoReport_IsErrorOccur = false ;
113+
114+ if (NULL == lpszAPIUrl)
115+ {
116+ InfoReport_IsErrorOccur = true ;
117+ InfoReport_dwErrorCode = ERROR_XENGINE_STORAGE_INFOREPORT_PARAMENT;
118+ return false ;
119+ }
120+ int nLen = 0 ;
121+ int nCode = 0 ;
122+ XCHAR tszAPIUrl[MAX_PATH] = {};
123+ XCLIENT_APIHTTP st_HTTPParam = {};
124+ SYSTEMAPI_SERIAL_INFOMATION st_SDKSerial = {};
125+
126+ _xstprintf (tszAPIUrl, _X (" %s¶ms1=2" ), lpszAPIUrl);
127+
128+ SystemApi_HardWare_GetSerial (&st_SDKSerial);
129+
130+ Json::Value st_JsonRoot;
131+ JSONCPP_STRING st_JsonError;
132+ Json::StreamWriterBuilder st_JsonBuilder;
133+ Json::CharReaderBuilder st_JsonReader;
134+
135+ st_JsonRoot[" tszMachineCode" ] = st_SDKSerial.tszSystemSerial ;
136+ st_JsonBuilder[" emitUTF8" ] = true ;
137+
138+ XCHAR* ptszMsgBuffer = NULL ;
139+ st_HTTPParam.nTimeConnect = 2 ;
140+ if (!APIClient_Http_Request (_X (" POST" ), tszAPIUrl, Json::writeString (st_JsonBuilder, st_JsonRoot).c_str (), &nCode, &ptszMsgBuffer, &nLen, NULL , NULL , &st_HTTPParam))
141+ {
142+ InfoReport_IsErrorOccur = true ;
143+ InfoReport_dwErrorCode = APIClient_GetLastError ();
144+ return false ;
145+ }
146+ st_JsonRoot.clear ();
147+ // 开始解析配置文件
148+ std::unique_ptr<Json::CharReader> const pSt_JsonReader (st_JsonReader.newCharReader ());
149+ if (!pSt_JsonReader->parse (ptszMsgBuffer, ptszMsgBuffer + nLen, &st_JsonRoot, &st_JsonError))
150+ {
151+ InfoReport_IsErrorOccur = true ;
152+ InfoReport_dwErrorCode = ERROR_XENGINE_STORAGE_INFOREPORT_PARSE;
153+ return false ;
154+ }
155+ BaseLib_OperatorMemory_FreeCStyle ((XPPMEM)&ptszMsgBuffer);
156+
157+ if (0 != st_JsonRoot[" code" ].asInt ())
158+ {
159+ InfoReport_IsErrorOccur = true ;
160+ InfoReport_dwErrorCode = ERROR_XENGINE_STORAGE_INFOREPORT_CODE;
161+ return false ;
162+ }
163+ Json::Value st_JsonObject = st_JsonRoot[" data" ];
164+ // 老版本
165+ if (st_JsonObject.isArray ())
166+ {
167+ InfoReport_IsErrorOccur = true ;
168+ InfoReport_dwErrorCode = ERROR_XENGINE_STORAGE_INFOREPORT_VERSION;
169+ return false ;
170+ }
171+ *pInt_TimeNumber = st_JsonObject[" nTimeNumber" ].asInt64 ();
172+ return true ;
173+ }
89174// ////////////////////////////////////////////////////////////////////////
90175// 保护函数
91176// ////////////////////////////////////////////////////////////////////////
0 commit comments