|
@@ -1019,9 +1019,12 @@ namespace EVCB_OCPP.WSServer
|
|
|
var displayPriceText = await webDbService.SetDefaultFee(session);
|
|
|
UpdateClientDisplayPrice(session.ChargeBoxId, displayPriceText);
|
|
|
|
|
|
- sendTask = async () => await messageService.SendChangeConfigurationRequest(
|
|
|
- session.ChargeBoxId, key: "DefaultPrice", value: displayPriceText);
|
|
|
- await confirmWaitingMessageSerevice.SendAndWaitUntilResultAsync(sendTask, session.DisconnetCancellationToken);
|
|
|
+ if (!string.IsNullOrEmpty(displayPriceText))
|
|
|
+ {
|
|
|
+ sendTask = async () => await messageService.SendChangeConfigurationRequest(
|
|
|
+ session.ChargeBoxId, key: "DefaultPrice", value: displayPriceText);
|
|
|
+ await confirmWaitingMessageSerevice.SendAndWaitUntilResultAsync(sendTask, session.DisconnetCancellationToken);
|
|
|
+ }
|
|
|
|
|
|
if (session.CustomerId == new Guid("298918C0-6BB5-421A-88CC-4922F918E85E") || session.CustomerId == new Guid("9E6BFDCC-09FB-4DAB-A428-43FE507600A3"))
|
|
|
{
|
|
@@ -1035,12 +1038,7 @@ namespace EVCB_OCPP.WSServer
|
|
|
session.ChargeBoxId, key: "StopTransactionOnInvalidId", value: "True");
|
|
|
}
|
|
|
|
|
|
- sendTask = async () => await messageService.SendGetEVSEConfigureRequest(session.ChargeBoxId);
|
|
|
- response = await confirmWaitingMessageSerevice.SendAndWaitUntilResultAsync(sendTask, session.DisconnetCancellationToken);
|
|
|
- if (response.Success && response.Message is GetConfigurationConfirmation confirmation)
|
|
|
- {
|
|
|
- await CheckandUpdateConfig(session.ChargeBoxId, confirmation.configurationKey.ToDictionary(x => x.key, x => x.value));
|
|
|
- }
|
|
|
+ await GetnChecknUpdateConfig(session.ChargeBoxId, session.DisconnetCancellationToken);
|
|
|
|
|
|
sendTask = async () => await messageService.SendDataTransferRequest(
|
|
|
session.ChargeBoxId,
|
|
@@ -1050,19 +1048,48 @@ namespace EVCB_OCPP.WSServer
|
|
|
await confirmWaitingMessageSerevice.SendAndWaitUntilResultAsync(sendTask, session.DisconnetCancellationToken);
|
|
|
}
|
|
|
|
|
|
- internal async Task CheckandUpdateConfig(string chargeBoxId, Dictionary<string,string> currentConfigs, CancellationToken token = default)
|
|
|
+ internal async Task GetnChecknUpdateConfig(string chargeBoxId, CancellationToken token = default)
|
|
|
{
|
|
|
- List<KeyValuePair<string, string>> configs = await webDbService.GetCustomerStationEvseConfig(chargeBoxId);
|
|
|
+ MessageResult response = await GetEvseCurrentConfig(chargeBoxId, token);
|
|
|
+ if (!response.Success || response.Message is not GetConfigurationConfirmation confirmation)
|
|
|
+ {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ Dictionary<string,string> configs = await GetEvseDBCurrentConfig(chargeBoxId, token);
|
|
|
if (configs == null)
|
|
|
{
|
|
|
logger.LogInformation("{0} get station config failed", chargeBoxId);
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- foreach(var config in configs)
|
|
|
+ await ComparenUpdateConfig(chargeBoxId,
|
|
|
+ evseCurrentConfigs: confirmation.configurationKey.ToDictionary(x => x.key, x => x.value),
|
|
|
+ evseDbConfigs: configs,
|
|
|
+ token);
|
|
|
+ }
|
|
|
+
|
|
|
+ private async Task<MessageResult> GetEvseCurrentConfig(string chargeBoxId, CancellationToken token = default)
|
|
|
+ {
|
|
|
+ var sendTask = async () => await messageService.SendGetEVSEConfigureRequest(chargeBoxId);
|
|
|
+ var response = await confirmWaitingMessageSerevice.SendAndWaitUntilResultAsync(sendTask, token);
|
|
|
+ return response;
|
|
|
+ }
|
|
|
+
|
|
|
+ private Task<Dictionary<string, string>> GetEvseDBCurrentConfig(string chargeBoxId, CancellationToken token = default)
|
|
|
+ {
|
|
|
+ return webDbService.GetCustomerStationEvseConfig(chargeBoxId, token);
|
|
|
+ }
|
|
|
+
|
|
|
+ internal async Task ComparenUpdateConfig(string chargeBoxId,
|
|
|
+ Dictionary<string,string> evseCurrentConfigs,
|
|
|
+ Dictionary<string, string> evseDbConfigs,
|
|
|
+ CancellationToken token = default)
|
|
|
+ {
|
|
|
+ foreach(var config in evseDbConfigs)
|
|
|
{
|
|
|
- if (currentConfigs.Keys.Contains(config.Key) &&
|
|
|
- currentConfigs[config.Key] == config.Value)
|
|
|
+ if (evseCurrentConfigs.Keys.Contains(config.Key) &&
|
|
|
+ evseCurrentConfigs[config.Key] == config.Value)
|
|
|
{
|
|
|
continue;
|
|
|
}
|