/// <summary> /// Retrieves list of pages filtered by tags. /// </summary> /// <param name="tenantId">Identifies website whose pages are listed.</param> /// <param name="parameters">Search and paging parameters.</param> /// <param name="tags">Tags used to filter pages.</param> /// <param name="pageId">Identifies the parent page whose child pages are returned (set NULL to include root folder of website).</param> /// <param name="sortBy">The sort order of pages returned.</param> /// <param name="sortAsc">True to sort ascending, false to sort descending.</param> /// <param name="recursive">Set true to get all child pages, false if only direct descendants are required.</param> /// <param name="pageType">The type of page listed (document or folder).</param> /// <param name="loadTags">Indicates whether tags should be loaded for retrieved pages.</param> /// <param name="unitOfWork">Unit of work.</param> /// <returns>Search result.</returns> public ISearchResult <Page> ListTagged(long tenantId, ISearchParameters parameters, IList <Tag> tags, long?pageId, PageSortBy sortBy, bool sortAsc, bool recursive, PageType pageType, bool loadTags, IUnitOfWork unitOfWork = null) { return(_pageRepository.ListTagged(tenantId, parameters, tags, pageId, sortBy, sortAsc, recursive, pageType, loadTags, unitOfWork)); }
/// <summary> /// Retrieves list of pages filtered by tags. /// </summary> /// <param name="tenantId">Identifies website whose pages are listed.</param> /// <param name="parameters">Search and paging parameters.</param> /// <param name="tags">Tags used to filter pages.</param> /// <param name="pageId">Identifies the parent page whose child pages are returned (set NULL to include root folder of website).</param> /// <param name="sortBy">The sort order of pages returned.</param> /// <param name="sortAsc">True to sort ascending, false to sort descending.</param> /// <param name="recursive">Set true to get all child pages, false if only direct descendants are required.</param> /// <param name="pageType">The type of page listed (document or folder).</param> /// <param name="loadTags">Indicates whether tags should be loaded for retrieved pages.</param> /// <param name="unitOfWork">Unit of work.</param> /// <returns>Search result.</returns> public ISearchResult <Page> ListTagged(long tenantId, ISearchParameters parameters, IList <Tag> tags, long?pageId, PageSortBy sortBy, bool sortAsc, bool recursive, PageType pageType, bool loadTags, IUnitOfWork unitOfWork = null) { TagCollection tagCollection = new TagCollection(); foreach (Tag tag in tags) { tagCollection.Add(tag); } IDatabaseManager dbm = _databaseManagerFactory.GetDatabaseManager(unitOfWork); try { List <Page> pages = new List <Page>(); dbm.SetStoredProcedure(recursive ? "cms.ListTaggedPagesRecursive" : "cms.ListTaggedPages"); dbm.AddParameter("@TenantId", FieldType.BigInt, tenantId); dbm.AddParameter("@PageId", FieldType.BigInt, pageId ?? (object)DBNull.Value); dbm.AddParameter("@SortBy", FieldType.Int, (int)sortBy); dbm.AddParameter("@SortAsc", FieldType.Bit, sortAsc); dbm.AddParameter("@PageType", FieldType.Int, (int)pageType); dbm.AddParameter("@PageIndex", FieldType.Int, parameters.PageIndex); dbm.AddParameter("@PageSize", FieldType.Int, parameters.PageSize); dbm.AddParameter("@Tags", FieldType.Structured, tagCollection.Count == 0 ? null : tagCollection); dbm.ExecuteReader(); while (dbm.Read()) { pages.Add(GetPage(dbm, false, false)); } dbm.Read(); int total = (int)dbm.DataReaderValue("Total"); if (loadTags) { LoadTagsForPages(dbm, tenantId, pages); } return(new SearchResult <Page> { Items = pages, Total = total }); } finally { if (unitOfWork == null) { dbm.Dispose(); } } }