/// <summary> /// Возвращает постранично группы из AD, имена которых удовлетворяют заданному фильтру /// </summary> /// <param name="groupFilter">Фильтр по имени группы.</param> /// <param name="args"></param> /// <returns></returns> public PagingResult FindGroups( string groupFilter, PagingArgs args ) { try { using (DirectoryEntry entry = new DirectoryEntry( _groupPath, LdapUserName, ConfigurationManager.AppSettings["LdapPassword"] )) using (DirectorySearcher searcher = new DirectorySearcher( entry )) { searcher.SearchScope = SearchScope.Subtree; searcher.Sort.PropertyName = ADGroup.GetADPropertyName( args.SortExpression ); searcher.Sort.Direction = args.SortOrderASC ? SortDirection.Ascending : SortDirection.Descending; searcher.Filter = String.Format( @"(&(objectCategory=group)(name={0}))", groupFilter ); ADGroupCollection groups = new ADGroupCollection(); try { foreach (SearchResult result in searcher.FindAll()) groups.Add( new ADGroup( result ) ); } catch (ArgumentException) { } // неверная строка поиска return groups.GetPage( args ); } } catch (Exception ex) { throw new CoreApplicationException(Resources.ResourceManager.GetString("ErrorSearchingGroupException"), ex); } }
/// <summary> /// Возвращает страницу со списком пользователей, удовлетворяющих фильтру по имени и /// по идентификатору роли. /// </summary> /// <param name="userNamePart">Фильтр по имени</param> /// <param name="args">Параметры страницы</param> /// <param name="roleID">Номер роли (-1 - все роли)</param> /// <returns></returns> public static PagingResult GetUsersPage( string userNamePart, int roleID, PagingArgs args ) { return GetUsers( userNamePart, roleID ).GetPage( args ); }
/// <summary> /// Adds the <see cref="PagingArgs"/> parameters. /// </summary> /// <param name="paging">The <see cref="PagingArgs"/> value.</param> /// <param name="direction">The <see cref="ParameterDirection"/> (defaults to <see cref="ParameterDirection.Input"/>).</param> /// <returns>An <see cref="DbParameter"/> array for those that were added.</returns> /// <remarks>Uses the following parameter names: <see cref="DatabaseColumns.PagingSkipName"/> and <see cref="DatabaseColumns.PagingTakeName"/>.</remarks> public DatabaseCommand PagingParams(PagingArgs paging, ParameterDirection direction = ParameterDirection.Input) { Parameters.AddPagingParameters(paging, direction); return(this); }
/// <summary> /// Ищет пользователей AD по заданной части имени пользователя /// </summary> /// <param name="namePart">Часть имени/логина пользователя</param> /// <param name="groupName"> /// Имя группы, которой следует ограничить поиск (null - искать во всех группах). /// </param> /// <returns>Список найденных пользователей</returns> public PagingResult FindUsers( string namePart, string groupName, PagingArgs args ) { return FindUsers( namePart, groupName ).GetPage( args ); }
/// <summary> /// Initializes a new instance of the <see cref="ODataArgs{T}"/> class. /// </summary> /// <param name="mapper">The <see cref="IODataMapper{TSrce}"/>.</param> /// <param name="paging">The <see cref="PagingArgs"/>.</param> public ODataArgs(IODataMapper <T> mapper, PagingArgs paging) : base(paging) { Mapper = mapper ?? throw new ArgumentNullException(nameof(mapper)); }
/// <summary> /// Creates the <see cref="PagingArgs"/> from the query string. /// </summary> /// <param name="controller">The <see cref="ControllerBase"/> that has the request url.</param> /// <returns>The <see cref="PagingArgs"/>.</returns> /// <remarks>Will return the <see cref="ExecutionContext"/> <see cref="ExecutionContext.PagingArgs"/> where already set; otherwise, will update it once value inferred.</remarks> public static PagingArgs CreatePagingArgs(this ControllerBase controller) { Check.NotNull(controller, nameof(controller)); if (ExecutionContext.HasCurrent && ExecutionContext.Current.PagingArgs != null) { return(ExecutionContext.Current.PagingArgs); } #pragma warning disable CA1062 // Validate arguments of public methods; see earlier Check. var q = controller.HttpContext?.Request?.Query; #pragma warning restore CA1062 PagingArgs pa; if (q == null || q.Count == 0) { pa = new PagingArgs(); } else { long?skip = ParseLongValue(GetNamedQueryString(controller, PagingArgsSkipQueryStringNames)); long?take = ParseLongValue(GetNamedQueryString(controller, PagingArgsTakeQueryStringNames)); long?page = skip.HasValue ? null : ParseLongValue(GetNamedQueryString(controller, PagingArgsPageQueryStringNames)); if (skip == null && page == null) { pa = (take.HasValue) ? PagingArgs.CreateSkipAndTake(0, take) : new PagingArgs(); } else { pa = (skip.HasValue) ? PagingArgs.CreateSkipAndTake(skip.Value, take) : PagingArgs.CreatePageAndSize(page.Value, take); } pa.IsGetCount = ParseBoolValue(GetNamedQueryString(controller, PagingArgsCountQueryStringNames)); } if (ExecutionContext.HasCurrent && ExecutionContext.Current.PagingArgs == null) { ExecutionContext.Current.PagingArgs = pa; } return(pa); }
/// <summary> /// Initializes a new instance of the <see cref="RobotCollectionResult"/> class with a <paramref name="collection"/> of items to add. /// </summary> /// <param name="collection">A collection containing items to add.</param> /// <param name="paging">The <see cref="PagingArgs"/>.</param> public RobotCollectionResult(IEnumerable <Robot> collection, PagingArgs paging = null) : base(paging) { this.Result.AddRange(collection); }
/// <summary> /// Initializes a new instance of the <see cref="ODataArgs"/> class. /// </summary> /// <param name="paging">The <see cref="PagingResult"/>.</param> public ODataArgs(PagingArgs paging) : this(new PagingResult(paging ?? throw new ArgumentNullException(nameof(paging))))
/// <summary> /// Initializes a new instance of the <see cref="RobotCollectionResult"/> class with default <see cref="PagingArgs"/>. /// </summary> /// <param name="paging">The <see cref="PagingArgs"/>.</param> public RobotCollectionResult(PagingArgs paging) : base(paging) { }
/// <summary> /// Initializes a new instance of the <see cref="CosmosDbArgs{T, TModel}"/> class. /// </summary> /// <param name="mapper">The <see cref="IEntityMapper{T, TModel}"/>.</param> /// <param name="containerId">The <see cref="Container"/> identifier.</param> /// <param name="partitionKey">The <see cref="PartitionKey"/>.</param> /// <param name="paging">The <see cref="PagingResult"/>.</param> /// <param name="requestOptions">The optional <see cref="FeedOptions"/>.</param> public CosmosDbArgs(IEntityMapper <T, TModel> mapper, string containerId, PartitionKey?partitionKey, PagingArgs paging, QueryRequestOptions?requestOptions = null) : this(mapper, containerId, partitionKey, new PagingResult(Check.NotNull(paging, (nameof(paging)))), requestOptions) { }
private Task <PersonDetailCollectionResult> GetDetailByArgsOnImplementationAsync(PersonArgs args, PagingArgs paging) { var pdcr = new PersonDetailCollectionResult(new PagingResult(paging)); Database.Default.StoredProcedure("[Demo].[spPersonGetDetailByArgs]") .Params(p => { p.ParamWithWildcard(args?.FirstName, DbMapper.Default[Person.Property_FirstName]) .ParamWithWildcard(args?.LastName, DbMapper.Default[Person.Property_LastName]) .TableValuedParamWith(args?.Genders, "GenderIds", () => TableValuedParameter.Create(args.Genders.ToGuidIdList())); }) .SelectQueryMultiSet(pdcr.Paging, new MultiSetCollArgs <PersonCollection, Person>(PersonData.DbMapper.Default, (r) => r.ForEach((p) => { var pd = new PersonDetail(); pd.CopyFrom(p); pdcr.Result.Add(pd); })), new MultiSetCollArgs <WorkHistoryCollection, WorkHistory>(WorkHistoryData.DbMapper.Default, (r) => { PersonDetail pd = null; foreach (var wh in r) { if (pd == null || wh.PersonId != pd.Id) { pd = pdcr.Result.Where(x => x.Id == wh.PersonId).Single(); pd.History = new WorkHistoryCollection(); } pd.History.Add(wh); } })); return(Task.FromResult(pdcr)); }
/// <summary> /// Initializes a new instance of the <see cref="PersonCollectionResult"/> class with a <paramref name="collection"/> of items to add. /// </summary> /// <param name="collection">A collection containing items to add.</param> /// <param name="paging">The <see cref="PagingArgs"/>.</param> public PersonCollectionResult(IEnumerable <Person> collection, PagingArgs paging = null) : base(paging) { Result.AddRange(collection); }
/// <summary> /// Initializes a new instance of the <see cref="PersonCollectionResult"/> class with default <see cref="PagingArgs"/>. /// </summary> /// <param name="paging">The <see cref="PagingArgs"/>.</param> public PersonCollectionResult(PagingArgs paging) : base(paging) { }