public override void ExecuteCommand(MySession session, StringRequestInfo requestInfo) { // Console.WriteLine("Run:" + requestInfo.Body.Length); //foreach (var x in requestInfo.Body) //{ // Console.WriteLine((int)Convert.ToChar(x)); //} //session.Send(requestInfo.Body); RunRealTime real = Analysis.analysisRun(requestInfo); // 33字节请求数据 real.sampleTime = string.Format("{0:yyyyMMddHHmmssfff}", DateTime.Now); if (RealTimeThread.dic.ContainsKey(real.TerminalId)) { CarInfo info = RealTimeThread.dic[real.TerminalId] as CarInfo; if (info != null) { info.Power = real.batteryInfo; info.Voltage = real.voltage; info.Speed = real.speed; info.Mile = real.mile; info.Longitude = real.longitude; info.Latitude = real.latitude; RealTimeThread.dic[real.TerminalId] = info; } } else { CarInfo c = new CarInfo(); c.Power = real.batteryInfo; c.Voltage = real.voltage; c.Speed = real.speed; c.Mile = real.mile; c.Longitude = real.longitude; c.Latitude = real.latitude; RealTimeThread.dic.Add(real.TerminalId, c); } if (requestInfo != null) { db_realtime.uploadRunRealTime(real); } //服务器响应 // session.Send(requestInfo.Body); }
public void Run() { LogerHelper.DefaultInfo(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + " RUN"); Stream inputStream = Request.GetBufferedInputStream(); RunRealTime real = RealTimeAnalysis.analysisRun(inputStream); real.sampleTime = string.Format("{0:yyyyMMddHHmmssfff}", DateTime.Now); if (RealTimeThread.dic.ContainsKey(real.TerminalId)) { CarInfo info = RealTimeThread.dic[real.TerminalId] as CarInfo; if (info != null) { info.Power = real.batteryInfo; info.Voltage = real.voltage; info.Speed = real.speed; info.Mile = real.mile; info.Longitude = real.longitude; info.Latitude = real.latitude; RealTimeThread.dic[real.TerminalId] = info; } } else { CarInfo c = new CarInfo(); c.Power = real.batteryInfo; c.Voltage = real.voltage; c.Speed = real.speed; c.Mile = real.mile; c.Longitude = real.longitude; c.Latitude = real.latitude; RealTimeThread.dic.Add(real.TerminalId, c); } if (real != null) { orderbll.uploadRunRealTime(real); } }