|
@@ -74,8 +74,9 @@ namespace EVCB_OCPP.WSServer.Message
|
|
|
int.TryParse(configVaule, out heartbeat_interval);
|
|
|
}
|
|
|
}
|
|
|
- var confirm = new BootNotificationConfirmation() { currentTime = DateTime.Now, interval = heartbeat_interval, status = Packet.Messages.SubTypes.RegistrationStatus.Accepted };
|
|
|
+ var confirm = new BootNotificationConfirmation() { currentTime = DateTime.Now, interval = session.IsPending ? heartbeat_interval : 5, status = session.IsPending ? Packet.Messages.SubTypes.RegistrationStatus.Accepted : RegistrationStatus.Pending };
|
|
|
|
|
|
+ session.IsPending = !session.IsPending;
|
|
|
result.Message = confirm;
|
|
|
result.Success = true;
|
|
|
}
|
|
@@ -451,6 +452,7 @@ namespace EVCB_OCPP.WSServer.Message
|
|
|
internal MessageResult ExecuteCoreConfirm(Actions action, ClientData session, IConfirmation confirm, string requestId)
|
|
|
{
|
|
|
MessageResult result = new MessageResult() { Success = true };
|
|
|
+
|
|
|
switch (action)
|
|
|
{
|
|
|
case Actions.DataTransfer:
|
|
@@ -640,92 +642,102 @@ namespace EVCB_OCPP.WSServer.Message
|
|
|
break;
|
|
|
case Actions.GetConfiguration:
|
|
|
{
|
|
|
- GetConfigurationConfirmation _confirm = confirm as GetConfigurationConfirmation;
|
|
|
- GetConfigurationRequest _request = _confirm.GetRequest() as GetConfigurationRequest;
|
|
|
|
|
|
- using (var db = new MainDBContext())
|
|
|
+ try
|
|
|
{
|
|
|
- var configure = db.MachineConfiguration.Where(x => x.ChargeBoxId == session.ChargeBoxId).ToList();
|
|
|
+ GetConfigurationConfirmation _confirm = confirm as GetConfigurationConfirmation;
|
|
|
+ // GetConfigurationRequest _request = _confirm.GetRequest() as GetConfigurationRequest;
|
|
|
|
|
|
- if (_confirm.configurationKey != null)
|
|
|
+ using (var db = new MainDBContext())
|
|
|
{
|
|
|
- foreach (var item in _confirm.configurationKey)
|
|
|
- {
|
|
|
- string oldValue = string.Empty;
|
|
|
- var foundConfig = configure.Find(x => x.ConfigureName == item.key);
|
|
|
+ var configure = db.MachineConfiguration.Where(x => x.ChargeBoxId == session.ChargeBoxId).ToList();
|
|
|
|
|
|
- if (foundConfig != null)
|
|
|
+ if (_confirm.configurationKey != null)
|
|
|
+ {
|
|
|
+ foreach (var item in _confirm.configurationKey)
|
|
|
{
|
|
|
- if (foundConfig.ConfigureName == "SecurityProfile")
|
|
|
+ string oldValue = string.Empty;
|
|
|
+ if (item.key == null)
|
|
|
{
|
|
|
- oldValue = foundConfig.ConfigureSetting;
|
|
|
+ Console.WriteLine("*********************");
|
|
|
}
|
|
|
+ var foundConfig = configure.Find(x => x.ConfigureName == item.key);
|
|
|
|
|
|
- foundConfig.ReadOnly = item.IsReadOnly;
|
|
|
- foundConfig.ConfigureSetting = string.IsNullOrEmpty(item.value) ? string.Empty : item.value;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- db.MachineConfiguration.Add(new MachineConfiguration()
|
|
|
+
|
|
|
+ if (foundConfig != null)
|
|
|
{
|
|
|
- ChargeBoxId = session.ChargeBoxId,
|
|
|
- ConfigureName = item.key,
|
|
|
- ReadOnly = item.IsReadOnly,
|
|
|
- ConfigureSetting = string.IsNullOrEmpty(item.value) ? string.Empty : item.value,
|
|
|
- Exists = true
|
|
|
- });
|
|
|
- }
|
|
|
+ if (foundConfig.ConfigureName == null)
|
|
|
+ {
|
|
|
+ Console.WriteLine("*********************");
|
|
|
+ }
|
|
|
|
|
|
- if (foundConfig.ConfigureName == "SecurityProfile")
|
|
|
- {
|
|
|
+ if (foundConfig.ConfigureName == "SecurityProfile")
|
|
|
+ {
|
|
|
+ oldValue = foundConfig.ConfigureSetting;
|
|
|
+ }
|
|
|
|
|
|
- if (foundConfig.ConfigureSetting != oldValue)
|
|
|
+ foundConfig.ReadOnly = item.IsReadOnly;
|
|
|
+ foundConfig.ConfigureSetting = string.IsNullOrEmpty(item.value) ? string.Empty : item.value;
|
|
|
+ }
|
|
|
+ else
|
|
|
{
|
|
|
- session.ResetSecurityProfile = true;
|
|
|
+ db.MachineConfiguration.Add(new MachineConfiguration()
|
|
|
+ {
|
|
|
+ ChargeBoxId = session.ChargeBoxId,
|
|
|
+ ConfigureName = item.key,
|
|
|
+ ReadOnly = item.IsReadOnly,
|
|
|
+ ConfigureSetting = string.IsNullOrEmpty(item.value) ? string.Empty : item.value,
|
|
|
+ Exists = true
|
|
|
+ });
|
|
|
}
|
|
|
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
- if (_confirm.unknownKey != null)
|
|
|
- {
|
|
|
- foreach (var item in _confirm.unknownKey)
|
|
|
+ if (_confirm.unknownKey != null)
|
|
|
{
|
|
|
- var foundConfig = configure.Find(x => x.ConfigureName == item);
|
|
|
- if (foundConfig != null)
|
|
|
- {
|
|
|
- foundConfig.ReadOnly = true;
|
|
|
- foundConfig.ConfigureSetting = string.Empty;
|
|
|
- foundConfig.Exists = false;
|
|
|
- }
|
|
|
- else
|
|
|
+
|
|
|
+ foreach (var item in _confirm.unknownKey)
|
|
|
{
|
|
|
- db.MachineConfiguration.Add(new MachineConfiguration()
|
|
|
+ var foundConfig = configure.Find(x => x.ConfigureName == item);
|
|
|
+ if (foundConfig != null)
|
|
|
+ {
|
|
|
+ foundConfig.ReadOnly = true;
|
|
|
+ foundConfig.ConfigureSetting = string.Empty;
|
|
|
+ foundConfig.Exists = false;
|
|
|
+ }
|
|
|
+ else
|
|
|
{
|
|
|
- ChargeBoxId = session.ChargeBoxId,
|
|
|
- ConfigureName = item
|
|
|
- });
|
|
|
+ db.MachineConfiguration.Add(new MachineConfiguration()
|
|
|
+ {
|
|
|
+ ChargeBoxId = session.ChargeBoxId,
|
|
|
+ ConfigureName = item
|
|
|
+ });
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
|
|
|
|
|
|
|
|
|
+ var operation = db.MachineOperateRecord.Where(x => x.SerialNo == requestId &&
|
|
|
+ x.ChargeBoxId == session.ChargeBoxId && x.Status == 0).FirstOrDefault();
|
|
|
|
|
|
- var operation = db.MachineOperateRecord.Where(x => x.SerialNo == requestId &&
|
|
|
- x.ChargeBoxId == session.ChargeBoxId && x.Status == 0).FirstOrDefault();
|
|
|
-
|
|
|
- if (operation != null)
|
|
|
- {
|
|
|
- operation.FinishedOn = DateTime.Now;
|
|
|
- operation.Status = 1;//電樁有回覆
|
|
|
- operation.EVSE_Status = 1;
|
|
|
- operation.EVSE_Value = JsonConvert.SerializeObject(_confirm.configurationKey, Formatting.None);
|
|
|
+ if (operation != null)
|
|
|
+ {
|
|
|
+ operation.FinishedOn = DateTime.Now;
|
|
|
+ operation.Status = 1;//電樁有回覆
|
|
|
+ operation.EVSE_Status = 1;
|
|
|
+ operation.EVSE_Value = JsonConvert.SerializeObject(_confirm.configurationKey, Formatting.None);
|
|
|
|
|
|
- }
|
|
|
+ }
|
|
|
|
|
|
- db.SaveChanges();
|
|
|
+ db.SaveChanges();
|
|
|
|
|
|
+ }
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+ logger.Error(ex.ToString());
|
|
|
}
|
|
|
|
|
|
}
|
|
@@ -757,6 +769,8 @@ namespace EVCB_OCPP.WSServer.Message
|
|
|
}
|
|
|
break;
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
return result;
|
|
|
}
|
|
|
|