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; } }
public JsonResult PersonalSettingsSearch1(string licenceNumber, string gpsCodeStr, string page, string rows) { rows = "10"; if (string.IsNullOrEmpty(page) || string.IsNullOrEmpty(rows)) { page = "1"; } int pageIndex = Convert.ToInt32(page); int pageSize = Convert.ToInt32(rows); int rowIndex = (pageIndex - 1) * pageSize; PersonalSettingSearchViewModel model = new PersonalSettingSearchViewModel() { ltGpsTypeID = ltGPSTypeId, OpenGPSCodeList = !string.IsNullOrEmpty(gpsCodeStr) ? gpsCodeStr.Split(',').ToList() : null, pageSize = pageSize, rowIndex = rowIndex, userCode = SessionUserInfo.UserCode, vehilceLikeStr = licenceNumber }; PagedDataList<PersonalSettingViewModel> pdl = _ISysSettingWCFService.PersonalSettingSearch(model); if (pdl != null && pdl.RowCount > 0 && pdl.Datas != null) { var query = from u in pdl.Datas select new { cell = new string[]{ u.VehicleCode.ToString(), "", u.GpsCode, u.GpsTypeID.ToString(), u.IsEnable.ToString(), !string.IsNullOrEmpty(u.OpenResultContent)?u.OpenResultContent:"", u.VehicleInfo, u.LastSetTime.HasValue?u.LastSetTime.Value.ToString("yyyy-MM-dd HH:mm:ss"):"" } }; var result = new { total = pdl.RowCount / Convert.ToInt32(pageSize) + 1, page = pageIndex, records = pdl.RowCount, rows = query.Take(pdl.RowCount) }; return Json(result, JsonRequestBehavior.AllowGet); } return null; }