22
22
using System . Management ;
23
23
using System . Threading ;
24
24
using System . Net . NetworkInformation ;
25
+ using System . Net . Sockets ;
26
+ using System . Security . Cryptography ;
25
27
26
28
using Behaviac . Design . Properties ;
27
29
@@ -213,6 +215,7 @@ private static string GetHarddiskID()
213
215
214
216
private static string _gatwway = "" ;
215
217
private static IPStatus _netWorkStatus = IPStatus . Unknown ;
218
+ private static UdpClient _udpClient = null ;
216
219
private static bool CheckNetWork ( )
217
220
{
218
221
try
@@ -277,7 +280,7 @@ private static bool ReportToTQOS(int intNum, string intList, int strNum, string
277
280
qosData += strList ;
278
281
qosData += "]}}}]}}}" ;
279
282
280
- using ( var client = new WebClient ( ) )
283
+ using ( var client = new WebClient ( ) )
281
284
{
282
285
Uri uri = new Uri ( qosData ) ;
283
286
client . OpenReadAsync ( uri ) ;
@@ -292,6 +295,44 @@ private static bool ReportToTQOS(int intNum, string intList, int strNum, string
292
295
return true ;
293
296
}
294
297
298
+ private static string _userInfo = "" ;
299
+ private static bool ReportToGStatistic ( OperationData operation )
300
+ {
301
+ try
302
+ {
303
+ if ( _udpClient == null )
304
+ {
305
+ _udpClient = new UdpClient ( ) ;
306
+ _udpClient . Connect ( "101.226.141.148" , 8080 ) ;
307
+ Thread . Sleep ( 2000 ) ;
308
+ }
309
+
310
+ string qosDataStr = string . Format ( "cmd=0&tag=gcloud.behavic.times&event={0}&OperationNum={1}" , operation . Type . ToString ( ) , operation . Count ) ;
311
+
312
+ if ( string . IsNullOrEmpty ( _userInfo ) )
313
+ {
314
+ HashAlgorithm algorithm = MD5 . Create ( ) ;
315
+ String EncryptedUserName = BitConverter . ToString ( algorithm . ComputeHash ( Encoding . UTF8 . GetBytes ( Dns . GetHostName ( ) + GetLocalMac ( ) ) ) ) ;
316
+
317
+ _userInfo = string . Format ( "&IP={0}&user_name={1}&version={2}" ,
318
+ GetLocalIP ( ) ,
319
+ EncryptedUserName ,
320
+ System . Reflection . Assembly . GetEntryAssembly ( ) . GetName ( ) . Version ) ;
321
+ }
322
+ qosDataStr += _userInfo ;
323
+
324
+ byte [ ] qosData = Encoding . UTF8 . GetBytes ( qosDataStr ) ;
325
+ _udpClient . Send ( qosData , qosData . Length ) ;
326
+ }
327
+ catch ( Exception e )
328
+ {
329
+ Console . WriteLine ( e . Message ) ;
330
+ return false ;
331
+ }
332
+
333
+ return true ;
334
+ }
335
+
295
336
[ Serializable ]
296
337
enum OperationTypes
297
338
{
@@ -425,13 +466,19 @@ private static bool SendOperations()
425
466
{
426
467
foreach ( OperationData operation in _allOperations )
427
468
{
428
- int intNum = 8 ;
429
- string intList = string . Format ( "0,0,0,0,0,0,{0},{1}" , ( int ) operation . Type , operation . Count ) ;
430
-
431
- int strNum = 8 ;
432
- string strList = getHeaderString ( ) ;
433
-
434
- if ( ! ReportToTQOS ( intNum , intList , strNum , strList ) )
469
+ //int intNum = 8;
470
+ //string intList = string.Format("0,0,0,0,0,0,{0},{1}", (int)operation.Type, operation.Count);
471
+
472
+ //int strNum = 8;
473
+ //string strList = getHeaderString();
474
+
475
+ //if (!ReportToTQOS(intNum, intList, strNum, strList))
476
+ //{
477
+ // sendSuccess = false;
478
+ // break;
479
+ //}
480
+
481
+ if ( ! ReportToGStatistic ( operation ) )
435
482
{
436
483
sendSuccess = false ;
437
484
break ;
0 commit comments