12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- 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<int, Dictionary<string, string>> stationEvseConfigs = await webDbService.GetStationEvseConfigs();
- Dictionary<string, int> 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.CheckandUpdateConfig(chargboxId, configs);
- }
- }
- }
- }
|