private IEnumerable <Message> get(LogChronicleFilter filter) { filter.NonNull(nameof(filter)); if (!Running) { yield break; } var cLog = m_LogDb[COLLECTION_LOG]; var query = LogFilterQueryBuilder.BuildLogFilterQuery(filter); var totalCount = Math.Min(filter.PagingCount <= 0 ? FETCH_BY_LOG : filter.PagingCount, MAX_FETCH_DOC_COUNT); using (var cursor = cLog.Find(query, filter.PagingStartIndex, FETCH_BY_LOG)) { int i = 0; foreach (var bdoc in cursor) { var msg = BsonConvert.FromBson(bdoc); yield return(msg); if (++i > totalCount || !Running) { break; } } } }
public async Task <IEnumerable <Message> > GetAsync(LogChronicleFilter filter) => await m_Log.NonNull().GetAsync(filter.NonNull(nameof(filter)));