private IList<VehicleOilControlInfoVM> BuildVM(IList<EMVehicle> ltVehicle,
            IList<EGPSCurrentInfo> ltCurrentInfo, IList<EBreakOilLastRecord> ltLastRecord)
        {
            IList<VehicleOilControlInfoVM> ltVM = new List<VehicleOilControlInfoVM>();
            foreach (EMVehicle item in ltVehicle)
            {
                VehicleOilControlInfoVM vm = new VehicleOilControlInfoVM();
                vm.VehicleCode = item.VehicleCode;
                vm.LicenceNumber = item.LicenceNumber;

                var currentInfo = ltCurrentInfo.FirstOrDefault(s => s.VehicleCode == vm.VehicleCode);
                if (currentInfo != null)
                {
                    vm.GPSCode = currentInfo.GPSCode;
                    vm.Acc = currentInfo.ACCState;
                    vm.Speed = currentInfo.Speed;
                    vm.Latitude = currentInfo.Latitude;
                    vm.Longitude = currentInfo.Longitude;
                    vm.OilState = currentInfo.OilState;
                    vm.ReportTime = currentInfo.ReportTime;
                    TimeSpan timeSpan = DateTime.Now.Subtract(currentInfo.ReportTime);
                    vm.IsEnable = !(timeSpan.TotalMinutes > Param_OffLineTime);
                }

                var lastRecord = ltLastRecord.FirstOrDefault(s => s.VehicleCode == vm.VehicleCode);
                if (lastRecord != null)
                {
                    vm.LastSendCommandTime = lastRecord.BreakOilHistoryRecord.SetTime;
                    vm.CommandState = lastRecord.BreakOilHistoryRecord.CommandState;
                }

                ltVM.Add(vm);
            }
            return ltVM;
        }
 private string GetVehicleInfo(VehicleOilControlInfoVM entity)
 {
     string VehicleInfo = string.Empty;
     if (!string.IsNullOrEmpty(entity.GPSCode))    //有当前信息
     {
         VehicleInfo = string.Format("{0}, {1}, {2}, {3}, {4}公里/小时, <span id='spanVehCode_{5}' Lat='{6}' Lng='{7}'>位置解析中...</span>",
                             entity.LicenceNumber,
                             entity.ReportTimeStr,
                             entity.RunningStateStr,
                             entity.OilStateStr,
                             entity.Speed,
                             entity.VehicleCode, entity.Latitude, entity.Longitude);
         if (entity.ReportTime.HasValue)
         {
             if (entity.ReportTime == DateTime.Parse("1900-01-01 00:00:00"))
                 VehicleInfo = entity.LicenceNumber;
         }
     }
     else
     {
         VehicleInfo = entity.LicenceNumber;
     }
     return VehicleInfo;
 }
 private IList<VehicleOilControlInfoVM> NewBuildVM(List<EMVehicleOilInfo> veOilList)
 { 
      IList<VehicleOilControlInfoVM> ltVMList = new List<VehicleOilControlInfoVM>();
      for (int i = 0; i < veOilList.Count; i++)
      {
             VehicleOilControlInfoVM vm = new VehicleOilControlInfoVM();
             vm.VehicleCode = veOilList[i].VehicleCode;
             vm.LicenceNumber = veOilList[i].LicenceNumber;
             vm.GPSCode = veOilList[i].GPSCode;
             vm.Acc = veOilList[i].Acc;
             vm.Speed = veOilList[i].Speed;
             vm.Latitude = veOilList[i].Latitude;
             vm.Longitude = veOilList[i].Longitude;
             vm.OilState = veOilList[i].OilState;
             vm.ReportTime = veOilList[i].ReportTime;
             vm.IsEnable = veOilList[i].IsEnable;
             vm.LastSendCommandTime = veOilList[i].LastSendCommandTime;
             vm.CommandState = veOilList[i].CommandState;
             ltVMList.Add(vm);
      }
      return ltVMList;
 }
        private string GetRunningState(VehicleOilControlInfoVM entity)
        {
            if (!entity.ReportTime.HasValue)
            {
                return "离线";
            }
            TimeSpan tp = DateTime.Now - entity.ReportTime.Value;

            if (tp.TotalMinutes < OffLineTimeParam)
            {
                if (entity.Acc == 1) return "行驶";
                else return "停车";
            }
            else
            {
                return "离线";
            }
        }