protected List <KeyValuePair <long, HttpResponce> > SortAndFilterHttpResponcesList() { if (_httpResponces == null) { return(null); } const string preambul = "Value"; //Filter items List <KeyValuePair <long, HttpResponce> > filteredList; if (LastFilterParams != null && LastFilterParams.Conditions.Root != null) { var filterExpression = FilterConditionConverter.GetLinqFilteringConditions(LastFilterParams.Conditions.Root, _httpResponceType, _httpResponcesKnownTypes, preambul); //Dynamic LINQ has constraints at filter by property only into inheritance objects //If use filter via SQL you have more capabilities filteredList = _httpResponces.AsQueryable().Where(filterExpression).ToList(); } else { filteredList = _httpResponces; } //Sort items //Default sort by time var sortString = "DetectTime"; var isAsc = false; if (LastSortParams != null) { bool isFindProperty; var sortProperty = ReflectionHelper.GetPropertyPathFromClass(LastSortParams.PropertyDescr.FieldName, _httpResponceType, _httpResponcesKnownTypes, preambul, out isFindProperty); isAsc = LastSortParams.IsAsc; if (isFindProperty) { sortString = sortProperty; } } List <KeyValuePair <long, HttpResponce> > sortedList; if (isAsc) { sortedList = filteredList.AsQueryable().OrderBy(x => ReflectionHelper.GetPropertyValue(x, sortString)).ToList(); } else { sortedList = filteredList.AsQueryable().OrderByDescending(x => ReflectionHelper.GetPropertyValue(x, sortString)).ToList(); } return(sortedList); }
/// <summary> /// Get available values for expression field /// </summary> /// <param name="field">Expression field</param> /// <returns>Available values</returns> public List <object> GetExpressionAvailableValues(FieldDescription field) { var fieldValues = FilterConditionConverter.GetFieldValuesLinq(field, _httpResponceType, _httpResponces.AsQueryable()).ToList(); return(fieldValues); }
protected void FetchRangeCommand(int startIndex, int pageCount, bool isPriority) { Task.Run(() => { if (_httpResponces == null) { return; } //Filter items List <HttpResponce> filteredList; if (LastFilterParams != null && LastFilterParams.Conditions.Root != null) { var filterExpression = FilterConditionConverter.GetLinqFilteringConditions(LastFilterParams.Conditions.Root, _httpResponceType, _httpResponcesKnownTypes); //Dynamic LINQ has constraints at filter by property only into inheritance objects //If use filter via SQL you have more capabilities filteredList = _httpResponces.AsQueryable().Where(filterExpression).ToList(); } else { filteredList = _httpResponces; } //Sort items //Default sort by time var sortString = "DetectTime"; var isAsc = false; if (LastSortParams != null) { bool isFindProperty; var sortProperty = ReflectionHelper.GetPropertyPathFromClass(LastSortParams.PropertyDescr.FieldName, _httpResponceType, _httpResponcesKnownTypes, String.Empty, out isFindProperty); isAsc = LastSortParams.IsAsc; if (isFindProperty) { sortString = sortProperty; } } List <HttpResponce> sortedList; if (isAsc) { sortedList = filteredList.AsQueryable().OrderBy(x => ReflectionHelper.GetPropertyValue(x, sortString)).ToList(); } else { sortedList = filteredList.AsQueryable().OrderByDescending(x => ReflectionHelper.GetPropertyValue(x, sortString)).ToList(); } int realPageCount; if (sortedList.Count > 0 && sortedList.Count > startIndex + pageCount) { realPageCount = pageCount; } else { realPageCount = sortedList.Count - startIndex; } var array = new HttpResponce[realPageCount]; sortedList.CopyTo(startIndex, array, 0, realPageCount); var requestedList = new List <HttpResponce>(array); var result = new RequestedData <HttpResponce>(startIndex, realPageCount, requestedList, sortedList.Count, isPriority); if (ListUpdates != null) { ListUpdates(new List <ServerListChanging <HttpResponce> > { result }); } }); }