diff --git a/WebStarter/Controllers/CarController.cs b/WebStarter/Controllers/CarController.cs index 4ceacbb..6752523 100644 --- a/WebStarter/Controllers/CarController.cs +++ b/WebStarter/Controllers/CarController.cs @@ -1,4 +1,5 @@ -using HybirdFrameworkDriver.Session; +using HybirdFrameworkCore.Utils; +using HybirdFrameworkDriver.Session; using log4net; using Microsoft.AspNetCore.Mvc; using Newtonsoft.Json; @@ -29,19 +30,25 @@ public class CarController : ControllerBase{ CarInfoResp carInfoResp = new CarInfoResp() { Connected = CarServerMgr.CarServer != null && ioSession != null, + CarNo = carNo }; - ioSession.BusinessMap.TryGetValue("ElecMsg", out var elecMsg); - if (elecMsg != null) + if (ObjUtils.IsNotNull(ioSession)) { - carInfoResp.ElecMsg = (ElecMsg)elecMsg; - } + ioSession.BusinessMap.TryGetValue("ElecMsg", out var elecMsg); + if (elecMsg != null) + { + carInfoResp.ElecMsg = (ElecMsg)elecMsg; + } - ioSession.BusinessMap.TryGetValue("HeartBeatMsg", out var heartBeatMsg); - if (heartBeatMsg != null) - { - carInfoResp.HeartBeatMsg = (HeartBeatMsg)heartBeatMsg; + ioSession.BusinessMap.TryGetValue("HeartBeatMsg", out var heartBeatMsg); + if (heartBeatMsg != null) + { + carInfoResp.HeartBeatMsg = (HeartBeatMsg)heartBeatMsg; + } } + + return carInfoResp; }