|
@@ -89,7 +89,7 @@ namespace EVCB_OCPP.WSServer.Message
|
|
|
{
|
|
|
using (var db = new MainDBContext())
|
|
|
{
|
|
|
- var item = db.MachineOperateRecord.Where(x => x.ChargeBoxId == session.ChargeBoxId && x.RequestType == 0)
|
|
|
+ var item = db.MachineOperateRecord.Where(x => x.ChargeBoxId == session.ChargeBoxId && x.Action== "UpdateFirmware" && x.RequestType == 0)
|
|
|
.OrderByDescending(x => x.CreatedOn).FirstOrDefault();
|
|
|
if (item != null)
|
|
|
{
|
|
@@ -111,23 +111,22 @@ namespace EVCB_OCPP.WSServer.Message
|
|
|
{
|
|
|
DiagnosticsStatusNotificationRequest _request = request as DiagnosticsStatusNotificationRequest;
|
|
|
|
|
|
- using (var db = new MainDBContext())
|
|
|
+
|
|
|
+ if (_request.status != Packet.Messages.SubTypes.DiagnosticsStatus.Idle)
|
|
|
{
|
|
|
- db.MachineOperateRecord.Add(new MachineOperateRecord()
|
|
|
+ using (var db = new MainDBContext())
|
|
|
{
|
|
|
- CreatedOn = DateTime.UtcNow,
|
|
|
- ChargeBoxId = session.ChargeBoxId,
|
|
|
- SerialNo = Guid.NewGuid().ToString(),
|
|
|
- RequestContent = JsonConvert.SerializeObject(_request, new JsonSerializerSettings() { NullValueHandling = NullValueHandling.Ignore, Formatting = Formatting.None }),
|
|
|
- EVSE_Status = 0,
|
|
|
- EVSE_Value = _request.status.ToString(),
|
|
|
- Status = 0,
|
|
|
- RequestType = 0,
|
|
|
- Action = _request.Action.ToString()
|
|
|
-
|
|
|
- });
|
|
|
-
|
|
|
- await db.SaveChangesAsync();
|
|
|
+ var item = db.MachineOperateRecord.Where(x => x.ChargeBoxId == session.ChargeBoxId && x.Action == "GetDiagnostics" && x.RequestType == 1)
|
|
|
+ .OrderByDescending(x => x.CreatedOn).FirstOrDefault();
|
|
|
+ if (item != null)
|
|
|
+ {
|
|
|
+ item.EVSE_Status = (int)_request.status;
|
|
|
+ item.FinishedOn = DateTime.UtcNow;
|
|
|
+ }
|
|
|
+
|
|
|
+ await db.SaveChangesAsync();
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
|
|
|
|
|
@@ -180,8 +179,7 @@ namespace EVCB_OCPP.WSServer.Message
|
|
|
if (operation != null)
|
|
|
{
|
|
|
operation.FinishedOn = DateTime.UtcNow;
|
|
|
- operation.Status = 1;//電樁有回覆
|
|
|
- operation.EVSE_Status = (int)1;//OK
|
|
|
+ operation.Status = 1;//電樁有回覆
|
|
|
operation.EVSE_Value = string.IsNullOrEmpty(evse_rep) ? operation.EVSE_Value : evse_rep;
|
|
|
db.SaveChanges();
|
|
|
}
|