Browse Source

Fix issue
update charger's status with offline

Jessica Tseng 2 years ago
parent
commit
befd1a7ea2

+ 10 - 13
EVCB_OCPP.TaskScheduler/Jobs/CheckEVSEOnlineJob.cs

@@ -41,19 +41,15 @@ namespace EVCB_OCPP.TaskScheduler.Jobs
 
                 foreach (var evse in _EVSEs)
                 {
-                    latestHeartbeatTime = evse.HeartbeatUpdatedOn;
+                   
                     if (IsOnlineNow(evse))
                     {
 
                         if (!evse.Online)
-                        { //off - on 
-                            logger.Debug(evse.ChargeBoxId + " Off-On Started");
+                        { //off - on                           
 
                             UpdateEVSECurrentStatus(evse.CustomerId.ToString(), evse.ChargeBoxId, true, DefaultSetting.DefaultNullTime);
-
-                            await UpdateOnlineRecords(evse.ChargeBoxId, true, evse.HeartbeatUpdatedOn, null);
-
-                            logger.Debug(evse.ChargeBoxId + " Off-On Finished");
+                            await UpdateOnlineRecords(evse.ChargeBoxId, true, evse.HeartbeatUpdatedOn, null);                         
                         }
 
                     }
@@ -62,15 +58,16 @@ namespace EVCB_OCPP.TaskScheduler.Jobs
 
                         if (evse.Online)
                         {
-                            //on -off  
-                            logger.Debug(evse.ChargeBoxId + " On-Off Started");
+                            //on -off                        
+
+                            UpdateEVSECurrentStatus(evse.CustomerId.ToString(), evse.ChargeBoxId, false, evse.HeartbeatUpdatedOn);
                             var online_row =  await GetOnlineRecord(evse.ChargeBoxId);
                             if(online_row!=null)
                             {
                                 await UpdateOnlineRecords(evse.ChargeBoxId, false, evse.HeartbeatUpdatedOn, online_row.Id);
-                            }                         
+                            }                        
 
-                            logger.Debug(evse.ChargeBoxId + " On-Off Finished");
+                          
                         }
 
                     }
@@ -116,14 +113,14 @@ namespace EVCB_OCPP.TaskScheduler.Jobs
         {
             try
             {
-                string sqlString = string.Format("UPDATE [dbo].[Machine] SET Online=@Online {0} WHERE chargeBoxId=@chargeBoxId and customerId=@customerId", turnOn ? "" : " ,OfflineOn=@OfflineOn");
+                string sqlString = string.Format("UPDATE [dbo].[Machine] SET Online=@Online {0} WHERE chargeBoxId=@chargeBoxId ", turnOn ? "" : " ,OfflineOn=@OfflineOn");
                 using (var dbConn = new SqlConnection(mainDBConnectString))
                 {
                     dbConn.Open();
                     var parameters = new DynamicParameters();
                     parameters.Add("@Online", turnOn, System.Data.DbType.Boolean);
                     parameters.Add("@chargeBoxId", ChargeBoxId, System.Data.DbType.String);
-                    parameters.Add("@customerId", customerId, System.Data.DbType.String);
+                  
                     if (!turnOn)
                     {
                         parameters.Add("@OfflineOn", offlineTime, System.Data.DbType.DateTime);

+ 1 - 1
EVCB_OCPP.TaskScheduler/Properties/AssemblyInfo.cs

@@ -34,4 +34,4 @@ using System.Runtime.InteropServices;
 // [assembly: AssemblyVersion("0.1.0.0")]
 [assembly: AssemblyVersion("0.1.0.0")]
 [assembly: AssemblyFileVersion("0.1.0.0")]
-[assembly: AssemblyInformationalVersion("88e62c5")]
+[assembly: AssemblyInformationalVersion("7b5c47a")]