/// <summary> /// Gets the state sets that match the specified search filter. /// </summary> /// <param name="identity">The identity of the caller.</param> /// <param name="filter">The state set search filter.</param> /// <param name="cancellationToken">The cancellation token for the request.</param> /// <returns> /// The state sets defined by the historian, indexed by set name. /// </returns> protected override Task <IEnumerable <StateSet> > GetStateSets(ClaimsPrincipal identity, StateSetFilter filter, CancellationToken cancellationToken) { if (filter == null) { throw new ArgumentNullException(nameof(filter)); } IEnumerable <StateSet> result = _stateSets.Values; if (!String.IsNullOrWhiteSpace(filter.Filter)) { result = result.Where(x => x.Name.Contains(filter.Filter)); } result = result.OrderBy(x => x.Name, StringComparer.OrdinalIgnoreCase) .Skip((filter.Page - 1) * filter.PageSize) .Take(filter.PageSize) .ToArray(); return(Task.FromResult(result)); }
/// <summary> /// Gets the state sets that match the specified search filter. /// </summary> /// <param name="identity">The identity of the caller.</param> /// <param name="filter">The state set search filter.</param> /// <param name="cancellationToken">The cancellation token for the request.</param> /// <returns> /// The state sets defined by the historian, indexed by set name. /// </returns> protected abstract Task <IEnumerable <StateSet> > GetStateSets(ClaimsPrincipal identity, StateSetFilter filter, CancellationToken cancellationToken);
protected override Task <IEnumerable <StateSet> > GetStateSets(ClaimsPrincipal identity, StateSetFilter filter, CancellationToken cancellationToken) { IEnumerable <StateSet> stateSets; if (String.IsNullOrWhiteSpace(filter.Filter)) { stateSets = _stateSets.Values; } else { var f = filter.Filter.ToUpperInvariant(); stateSets = _stateSets.Values.Where(x => x.Name.ToUpperInvariant().Contains(f)); } var result = stateSets.OrderBy(x => x.Name).Skip((filter.Page - 1) * filter.PageSize).Take(filter.PageSize).ToArray(); return(Task.FromResult <IEnumerable <StateSet> >(result)); }
/// <summary> /// Gets the state sets that match the specified search filter. /// </summary> /// <param name="identity">The identity of the caller.</param> /// <param name="filter">The state set search filter.</param> /// <param name="cancellationToken">The cancellation token for the request.</param> /// <returns> /// The state sets defined by the historian, indexed by set name. /// </returns> async Task <IEnumerable <StateSet> > IHistorian.GetStateSets(ClaimsPrincipal identity, StateSetFilter filter, CancellationToken cancellationToken) { ThrowIfDisposed(); return(await GetStateSets(identity, filter, cancellationToken).ConfigureAwait(false)); }