public PagedDataList<PersonalSettingViewModel> PersonalSettingSearch(PersonalSettingSearchViewModel model) { EMVehicleService service = new EMVehicleService(); PositionService positionServ = new PositionService(); try { //int rowCount = 0; //IList<EMVehicle> list = service.Select(model.userCode,model.vehilceLikeStr,true,model.ltGpsTypeID, model.rowIndex,model.pageSize, out rowCount); //IList<Guid> ltVehicleCode_Paging = list.Select(p => p.VehicleCode).ToList(); //IList<EGPSCurrentInfo> ltCurrentInfo = positionServ.GetCurrentInfoList(ltVehicleCode_Paging); //IDictionary<Guid, DateTime> CurrentInfoDic = ltCurrentInfo.ToDictionary(p => p.VehicleCode, p => p.ReportTime); //IList<EMOpenGPSInfo> listEntity = null; /////获取开启GPSCode的返回数据 //if (model.OpenGPSCodeList != null && model.OpenGPSCodeList.Count > 0) //{ // EMOpenGPSInfoService openGPSservice = new EMOpenGPSInfoService(); // listEntity = openGPSservice.GetList(list.Select(p => p.GPSCode).ToList(), 1); //} //if (list != null && list.Count > 0 && rowCount > 0) //{ // List<PersonalSettingViewModel> newList = new List<PersonalSettingViewModel>(); // PagedDataList<PersonalSettingViewModel> pdl = new PagedDataList<PersonalSettingViewModel>(); // foreach (EMVehicle emVehicle in list) // { // PersonalSettingViewModel psvModel = new PersonalSettingViewModel(); // psvModel.GpsCode = emVehicle.GPSCode; // psvModel.GpsTypeID = emVehicle.GPSTypeID; // psvModel.VehicleInfo = emVehicle.LicenceNumber; // psvModel.VehicleCode = emVehicle.VehicleCode; // if (CurrentInfoDic.ContainsKey(emVehicle.VehicleCode)) // { // TimeSpan timeSpan = DateTime.Now.Subtract(CurrentInfoDic[emVehicle.VehicleCode]); // psvModel.IsEnable = !(timeSpan.TotalMinutes > Param_OffLineTime); // } // else // psvModel.IsEnable = false; // if (listEntity != null && listEntity.Count > 0) // { // foreach (EMOpenGPSInfo gpsInfo in listEntity) // { // if (psvModel.GpsCode == gpsInfo.GPSCode) // { // psvModel.OpenResultContent = gpsInfo.Results; // psvModel.LastSetTime = gpsInfo.LastSetTime; // } // } // } // newList.Add(psvModel); // } // pdl.Datas = newList; // pdl.RowCount = rowCount; // return pdl; //代码优化 int rowCount = 0; VehicleDAL vDal = new VehicleDAL(); List<EmPersonalSetting> pelist = service.NewSelect(model.userCode, model.vehilceLikeStr, true, model.ltGpsTypeID, model.rowIndex, model.pageSize, out rowCount, 1); if (pelist != null && pelist.Count > 0 && rowCount > 0) { PagedDataList<PersonalSettingViewModel> pdl = new PagedDataList<PersonalSettingViewModel>(); pdl.Datas = GetPerSettingViewModel(pelist); pdl.RowCount = rowCount; return pdl; } return null; } catch (Exception ex) { Logger.Error(ex.Message); return null; } }