Эх сурвалжийг харах

add CarNum to InstantStopTxReport

Robert 1 жил өмнө
parent
commit
db2bcba5d3

+ 16 - 3
EVCB_OCPP.WSServer/Message/CoreProfileHandler.cs

@@ -1111,7 +1111,7 @@ public partial class ProfileHandler
 
                                         if (customerInfo != null && customerInfo.InstantStopTxReport)
                                         {
-
+                                            string CarNum = await GetCustomerFromIdTag(tx.StartIdTag);
                                             var request = new
                                             {
                                                 ChargeBoxId = tx.ChargeBoxId,
@@ -1125,8 +1125,8 @@ public partial class ProfileHandler
                                                 StopReason = tx.StopReasonId < 1 ? "Unknown" : (tx.StopReasonId > 12 ? "Unknown" : ((Reason)tx.StopReasonId).ToString()),
                                                 Receipt = tx.Receipt,
                                                 TotalCost = tx.Cost,
-                                                Fee = tx.Fee
-
+                                                Fee = tx.Fee,
+                                                CarNum = CarNum
                                             };
 
                                             logger.LogDebug("completed_session " + JsonConvert.SerializeObject(request));
@@ -1668,4 +1668,17 @@ public partial class ProfileHandler
 
         return money;
     }
+
+    internal async Task<string> GetCustomerFromIdTag(string startIdTag)
+    {
+        string toReturn;
+        string sqlstatement = "SELECT [CarNum] FROM VehicleCustomer where IdTag = '" + startIdTag + "'";
+        using (var dbConn = await webDbConnectionFactory.CreateAsync())
+        {
+            dbConn.Open();
+            toReturn = await dbConn.ExecuteScalarAsync<string>(sqlstatement);
+        }
+
+        return toReturn;
+    }
 }