public LocationAlarmInformation GetLocationAlarmByArgs(AlarmSearchArg arg) { if (allLocationAlarmHistory == null) { RefreshAlarmBuffer(); } LocationAlarmInformation locationAlarm = new LocationAlarmInformation(); List <T_LocationAlarm> alarmsTemp = TryGetAllLocationAlarms(arg); if (alarmsTemp == null || alarmsTemp.Count == 0) { return(new LocationAlarmInformation()); } alarmsTemp.Sort(); LocationAlarmInformation devAlarmInfo = GetLocationAlarmPage(arg, alarmsTemp); return(locationAlarm); }
/// <summary> /// 定位告警历史,获取对应切页 /// </summary> /// <param name="arg"></param> /// <param name="list"></param> /// <returns></returns> public LocationAlarmInformation GetLocationAlarmPage(AlarmSearchArg arg, List <Location.TModel.Location.Alarm.LocationAlarm> list) { LocationAlarmInformation locationAlarmInfo = new LocationAlarmInformation(); if (list == null || list.Count == 0) { return(locationAlarmInfo); } locationAlarmInfo.locationAlarmList = new List <Location.TModel.Location.Alarm.LocationAlarm>(); var LocationAlarmlist = locationAlarmInfo.locationAlarmList; if (list.Count == 0) { locationAlarmInfo.Total = 1; } else { if (arg.Page != null) { int maxPage = (int)Math.Ceiling((double)list.Count / (double)arg.Page.Size); locationAlarmInfo.Total = maxPage; if (arg.Page.Number > maxPage) { arg.Page.Number = maxPage - 1; } var queryData = list.Skip(arg.Page.Size * arg.Page.Number).Take(arg.Page.Size); var resultList = queryData.ToList(); LocationAlarmlist.AddRange(resultList); } else { LocationAlarmlist.AddRange(list); } } locationAlarmInfo.SetEmpty(); return(locationAlarmInfo); }