11using System . Text ;
22using GameFrameX . Core . Actors . Impl ;
3+ using GameFrameX . Utility ;
34using GameFrameX . Utility . Extensions ;
45
56namespace GameFrameX . Core . Utility ;
@@ -9,10 +10,9 @@ namespace GameFrameX.Core.Utility;
910/// </summary>
1011public sealed class StatisticsTool
1112{
12- private const string Format = "yyyy-MM-dd HH:mm" ;
13- private readonly Dictionary < string , Dictionary < string , int > > countDic = new ( ) ;
13+ private readonly Dictionary < string , Dictionary < string , int > > _countDic = new ( ) ;
1414
15- private readonly WorkerActor workerActor = new ( ) ;
15+ private readonly WorkerActor _workerActor = new ( ) ;
1616
1717 /// <summary>
1818 /// 统计
@@ -21,10 +21,10 @@ public sealed class StatisticsTool
2121 /// <returns></returns>
2222 public async Task < string > CountRecord ( int limit = 10 )
2323 {
24- return await workerActor . SendAsync ( ( ) =>
24+ return await _workerActor . SendAsync ( ( ) =>
2525 {
2626 var sb = new StringBuilder ( ) ;
27- foreach ( var kv in countDic )
27+ foreach ( var kv in _countDic )
2828 {
2929 var time = kv . Key ;
3030
@@ -48,7 +48,7 @@ public async Task<string> CountRecord(int limit = 10)
4848 /// </summary>
4949 public void ClearCount ( )
5050 {
51- workerActor . Tell ( countDic . Clear ) ;
51+ _workerActor . Tell ( _countDic . Clear ) ;
5252 }
5353
5454 /// <summary>
@@ -57,10 +57,10 @@ public void ClearCount()
5757 /// <param name="time"></param>
5858 public void ClearCount ( DateTime time )
5959 {
60- workerActor . Tell ( ( ) =>
60+ _workerActor . Tell ( ( ) =>
6161 {
62- var timeStr = time . ToString ( Format ) ;
63- countDic . RemoveIf ( ( k , v ) => k . CompareTo ( timeStr ) < 0 ) ;
62+ var timeStr = TimeHelper . CurrentDateTimeWithUtcFormat ( ) ;
63+ _countDic . RemoveIf ( ( k , v ) => string . Compare ( k , timeStr , StringComparison . Ordinal ) < 0 ) ;
6464 } ) ;
6565 }
6666
@@ -76,13 +76,13 @@ public void Count(string key, int num = 1)
7676 return ;
7777 }
7878
79- workerActor . Tell ( ( ) =>
79+ _workerActor . Tell ( ( ) =>
8080 {
81- var timeStr = DateTime . Now . ToString ( Format ) ;
82- if ( ! countDic . TryGetValue ( timeStr , out var cd ) )
81+ var timeStr = TimeHelper . CurrentDateTimeWithUtcFullString ( ) ;
82+ if ( ! _countDic . TryGetValue ( timeStr , out var cd ) )
8383 {
8484 cd = new Dictionary < string , int > ( ) ;
85- countDic [ timeStr ] = cd ;
85+ _countDic [ timeStr ] = cd ;
8686 }
8787
8888 var old = cd . GetValueOrDefault ( key , 0 ) ;
0 commit comments