Эх сурвалжийг харах

reenable business auth, connection log db service use EF

Robert 1 жил өмнө
parent
commit
c0110f5c1f

+ 1 - 1
EVCB_OCPP.WSServer/Jobs/DenyModelCheckJob.cs

@@ -37,7 +37,7 @@ public class DenyModelCheckJob : IJob
 
     public async Task Execute(IJobExecutionContext context)
     {
-        logger.LogDebug("{0} Started", nameof(DenyModelCheckJob));
+        //logger.LogDebug("{0} Started", nameof(DenyModelCheckJob));
         try
         {
             GlobalConfig.DenyModelNames = await webDbService.GetDenyModelNames();

+ 1 - 1
EVCB_OCPP.WSServer/Jobs/HealthCheckTriggerJob.cs

@@ -26,7 +26,7 @@ public class HealthCheckTriggerJob : IJob
 
     public Task Execute(IJobExecutionContext context)
     {
-        logger.LogDebug("{0} Started", nameof(HealthCheckTriggerJob));
+        //logger.LogDebug("{0} Started", nameof(HealthCheckTriggerJob));
 
         Dictionary<string, ClientData> _copyClientDic = protalServer.ClientDic;
 

+ 2 - 1
EVCB_OCPP.WSServer/Jobs/HeartBeatCheckJob.cs

@@ -36,7 +36,7 @@ public class HeartBeatCheckJob : IJob
 
     public async Task Execute(IJobExecutionContext context)
     {
-        logger.LogDebug("{0} Started", nameof(HeartBeatCheckJob));
+        //logger.LogDebug("{0} Started", nameof(HeartBeatCheckJob));
         try
         {
             Stopwatch watch = new Stopwatch();
@@ -51,6 +51,7 @@ public class HeartBeatCheckJob : IJob
             foreach (var session in clients)
             {
                 var machine = new Machine() { Id = session.MachineId, HeartbeatUpdatedOn = cdt, ConnectionType = session.UriScheme.Equals("wss") ? 2 : 1 };
+                datas.Add(machine);
             }
             await mainDbService.UpdateHeartBeats(datas);
 

+ 1 - 1
EVCB_OCPP.WSServer/Jobs/ServerSetFeeJob.cs

@@ -47,7 +47,7 @@ public class ServerSetFeeJob : IJob
 
     public async Task Execute(IJobExecutionContext context)
     {
-        logger.LogDebug("{0} Started", nameof(ServerSetFeeJob));
+        //logger.LogDebug("{0} Started", nameof(ServerSetFeeJob));
         //BasicMessageHandler msgAnalyser = new BasicMessageHandler();
         Dictionary<string, ClientData> _copyClientDic = protalServer.ClientDic;
         //using var db = maindbContextFactory.CreateDbContextAsync();

+ 1 - 1
EVCB_OCPP.WSServer/Jobs/ServerUpdateJob.cs

@@ -33,7 +33,7 @@ public class ServerUpdateJob : IJob
 
     public async Task Execute(IJobExecutionContext context)
     {
-        logger.LogDebug("{0} Started", nameof(ServerUpdateJob));
+        //logger.LogDebug("{0} Started", nameof(ServerUpdateJob));
         BasicMessageHandler msgAnalyser = new BasicMessageHandler();
         Dictionary<string, ClientData> _copyClientDic = protalServer.ClientDic;
         var checkUpdateDt = DateTime.UtcNow;

+ 1 - 1
EVCB_OCPP.WSServer/Jobs/SmartChargingJob.cs

@@ -38,7 +38,7 @@ public class SmartChargingJob : IJob
 
     public async Task Execute(IJobExecutionContext context)
     {
-        logger.LogDebug("{0} Started", nameof(SmartChargingJob));
+        //logger.LogDebug("{0} Started", nameof(SmartChargingJob));
         List<StationInfoDto> stations = null;
         using (SqlConnection conn = await webDbConnectionFactory.CreateAsync())
         {

+ 6 - 6
EVCB_OCPP.WSServer/Service/ConnectionLogdbService.cs

@@ -75,9 +75,9 @@ public class ConnectionLogdbService : IConnectionLogdbService
     {
         var log = new MachineLog(clientData, data, messageType, errorMsg, isSent);
         //queueHandler.Enqueue(log);
-        //WriteMachineLogEF(log);
+        _ = WriteMachineLogEF(log);
         //insertConnectonLogHandler.HandleAsync(log);
-        _ = InsertWithDapper(log);
+        //_ = InsertWithDapper(log);
     }
 
     private async Task InsertWithDapper(MachineLog log)
@@ -140,7 +140,7 @@ public class ConnectionLogdbService : IConnectionLogdbService
             BundleInsertWithDapper,
             //loggerFactory.CreateLogger("InsertMeterValueHandler")
             logger,
-            workerCnt: 1
+            workerCnt: 20
             );
     }
 
@@ -217,7 +217,7 @@ public class ConnectionLogdbService : IConnectionLogdbService
 
         t1 = watch.ElapsedMilliseconds;
         using SqlConnection sqlConnection = await sqlConnectionFactory.CreateAsync();
-        using var tans = await sqlConnection.BeginTransactionAsync();
+        using var trans = await sqlConnection.BeginTransactionAsync();
 
         t2 = watch.ElapsedMilliseconds;
         var tableName = GetTableName(workTime);
@@ -239,11 +239,11 @@ public class ConnectionLogdbService : IConnectionLogdbService
             parameters.Add("EVSEEndPoint", log.clientData.RemoteEndPoint == null ? "123" : log.clientData.RemoteEndPoint.ToString(), DbType.String, size: 25);
             parameters.Add("Session", log.clientData.SessionID == null ? "123" : log.clientData.SessionID, DbType.String, size: 36);
 
-            await sqlConnection.ExecuteAsync(command, parameters, tans);
+            await sqlConnection.ExecuteAsync(command, parameters, trans);
         }
 
         t3 = watch.ElapsedMilliseconds;
-        await tans.CommitAsync();
+        await trans.CommitAsync();
 
         watch.Stop();
         t4 = watch.ElapsedMilliseconds;

+ 1 - 0
EVCB_OCPP.WSServer/Service/MainDbService.cs

@@ -822,6 +822,7 @@ public class MainDbService : IMainDbService
         }
         return limit;
     }
+
     private int GetOpLimit(IConfiguration configuration)
     {
         var limitConfig = configuration["MainDbOpLimit"];

+ 5 - 5
EVCB_OCPP.WSServer/Service/OuterBusinessService.cs

@@ -94,11 +94,11 @@ namespace EVCB_OCPP.WSServer.Service
 
         async public Task<IdTokenInfo> Authorize(string chargeBoxId, string idTag)
         {
-            return new IdTokenInfo() { IdTagInfo = new IdTagInfo()
-            {
-                expiryDate = DateTime.UtcNow.AddDays(1),
-                status = AuthorizationStatus.Accepted 
-            } };
+            //return new IdTokenInfo() { IdTagInfo = new IdTagInfo()
+            //{
+            //    expiryDate = DateTime.UtcNow.AddDays(1),
+            //    status = AuthorizationStatus.Accepted 
+            //} };
 
             //await Task.Delay(10);
             IdTokenInfo result = new IdTokenInfo() { IdTagInfo = new IdTagInfo() { status = AuthorizationStatus.Invalid } };