Selaa lähdekoodia

fix logic might not send new station config

Robert 1 vuosi sitten
vanhempi
commit
f9b6050e71
1 muutettua tiedostoa jossa 6 lisäystä ja 5 poistoa
  1. 6 5
      EVCB_OCPP.WSServer/Service/StationConfigService.cs

+ 6 - 5
EVCB_OCPP.WSServer/Service/StationConfigService.cs

@@ -57,7 +57,7 @@ public class StationConfigService
     public async Task CheckAndUpdateEvseConfig(WsClientData session, CancellationToken token = default)
     {
         var chargeBoxId = session.ChargeBoxId;
-        var stationId = await webDbService.GetEvseStation(chargeBoxId);
+        var stationId = await webDbService.GetEvseStation(chargeBoxId, token);
         if (stationId is null)
         {
             return;
@@ -66,7 +66,7 @@ public class StationConfigService
         if (session.StationId != stationId)
         {
             session.StationId = stationId;
-            await UpdateEvseConfig(chargeBoxId, stationId.Value);
+            await UpdateEvseConfig(chargeBoxId, stationId.Value, token);
         }
         return;
     }
@@ -100,8 +100,7 @@ public class StationConfigService
         var connectedEvses = portalServer.GetClientDic().Values;
         foreach (var evse in connectedEvses)
         {
-            if (evse.IsCheckIn &&
-                evse.StationId is not null &&
+            if (evse.StationId is not null &&
                 modifiedStations.Contains(evse.StationId.Value))
             {
                 await UpdateEvseConfig(evse.ChargeBoxId, evse.StationId.Value);
@@ -113,9 +112,11 @@ public class StationConfigService
     {
         List<string> modifiedEvses = new();
         var connectedEvses = portalServer.GetClientDic().Values.ToList();
+        var evseStationPair = await webDbService.GetEvseStationPair(connectedEvses.Select(x => x.ChargeBoxId).ToList());
         foreach (var evse in connectedEvses)
         {
-            var currentStation = await webDbService.GetEvseStation(evse.ChargeBoxId);
+            //var currentStation = await webDbService.GetEvseStation(evse.ChargeBoxId);
+            int? currentStation = evseStationPair.ContainsKey(evse.ChargeBoxId) ? evseStationPair[evse.ChargeBoxId] : null;
             if (currentStation is null)
             {
                 evse.StationId = null;