private static async Task <ApplicationLogSearchResults> FilterLogsAsync(ILogStore logStore, ApplicationLogFilterModel filter, int offset) { Debug.Assert(filter.dfrom.HasValue); Debug.Assert(filter.dto.HasValue); var levels = new List <LogRecord.ELogLevel>(); for (short lvl = filter.lfrom ?? 0; lvl <= filter.lto; lvl++) { levels.Add((LogRecord.ELogLevel)lvl); } var searchResults = await logStore.FilterLogsAsync(new LogSearchCriteria { ApplicationPath = filter.apppath, Server = filter.server, FromUtc = filter.dfrom.Value.ToUniversalTime(), ToUtc = filter.dto.Value.ToUniversalTime(), Logger = filter.logger, Keywords = KeywordsParser.Parse(filter.keywords), Levels = levels.ToArray(), Limit = MaxLogsCount + 1, Offset = offset }); var foundItems = searchResults.FoundItems.ToArray(); LogRecord[] finalResults; if (foundItems.Length < MaxLogsCount + 1) { finalResults = foundItems; } else { finalResults = new LogRecord[foundItems.Length - 1]; Array.Copy(foundItems, finalResults, finalResults.Length); } return(new ApplicationLogSearchResults { FoundItems = finalResults, Limit = MaxLogsCount, Offset = offset, IsLastPage = foundItems.Length < MaxLogsCount + 1 }); }