using EVCB_OCPP.WSServer.Service.DbService; using Quartz; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace EVCB_OCPP.WSServer.Jobs { [DisallowConcurrentExecution] internal class StationConfigPollingJob : IJob { public StationConfigPollingJob( ProtalServer protalServer, WebDbService webDbService) { this.protalServer = protalServer; this.webDbService = webDbService; } private readonly ProtalServer protalServer; private readonly WebDbService webDbService; public async Task Execute(IJobExecutionContext context) { var connectedEvses = protalServer.GetClientDic(); connectedEvses = connectedEvses.Where(x => x.Value.IsCheckIn = true).ToDictionary(x=>x.Key, x=>x.Value); Dictionary> stationEvseConfigs = await webDbService.GetStationEvseConfigs(); Dictionary evseStationPair = await webDbService.GetEvseStationPair(connectedEvses.Keys.ToList()); foreach ( var chargboxId in connectedEvses.Keys ) { if (!evseStationPair.ContainsKey(chargboxId)) { continue; } var stationId = evseStationPair[chargboxId]; var configs = stationEvseConfigs[stationId]; await protalServer.ComparenUpdateConfig(chargboxId, configs); } } } }