소스 검색

update web db [StationMachine] Protocol version when EVSE connected

shayne_lo 4 달 전
부모
커밋
ba7b7ea95d
2개의 변경된 파일24개의 추가작업 그리고 1개의 파일을 삭제
  1. 1 1
      EVCB_OCPP.WSServer/ProtalServer.cs
  2. 23 0
      EVCB_OCPP.WSServer/Service/DbService/WebDbService.cs

+ 1 - 1
EVCB_OCPP.WSServer/ProtalServer.cs

@@ -285,7 +285,7 @@ namespace EVCB_OCPP.WSServer
                 WriteMachineLog(session, "NewSessionConnected", "Connection", "");
 
                 await mainDbService.UpdateMachineConnectionType(session.ChargeBoxId, session.UriScheme.Contains("wss") ? 2 : 1);
-
+                await webDbService.UpdateProtocalVersion(session.ChargeBoxId, session.DisconnetCancellationToken);
             }
             catch (Exception ex)
             {

+ 23 - 0
EVCB_OCPP.WSServer/Service/DbService/WebDbService.cs

@@ -275,4 +275,27 @@ public class WebDbService
             return true;
         }
     }
+
+    internal async Task UpdateProtocalVersion(string chargeBoxId, CancellationToken token = default)
+    {
+        string setSql = """
+                UPDATE [dbo].[StationMachine]
+                SET [ChargerProtocol] = '1.6'
+                WHERE [ChargeBoxId] = @ChargeBoxId
+                """;
+
+        var parameters = new DynamicParameters();
+        parameters.Add("@ChargeBoxId", chargeBoxId, direction: ParameterDirection.Input);
+
+        using SqlConnection conn = await webDbConnectionFactory.CreateAsync();
+        try
+        {
+            bool? isPeriodEnergyRequired = await conn.QueryFirstOrDefaultAsync<bool?>(new CommandDefinition(setSql, parameters, cancellationToken: token));
+        }
+        catch (Exception e)
+        {
+            logger.LogWarning(e.Message);
+            logger.LogWarning(e.StackTrace);
+        }
+    }
 }