Esempio n. 1
0
        /// <summary>
        /// Фабрика для запроса на отображение дерева в QP
        /// </summary>
        internal static ITreeProcessor Create(ChildListQuery query)
        {
            using (new QPConnectionScope())
            {
                if (query.EntityTypeCode == EntityTypeCode.Article || query.EntityTypeCode == EntityTypeCode.VirtualArticle)
                {
                    var contentId                 = query.ParentEntityId;
                    var searchQueryParams         = query.SearchQueryParams;
                    var articleContextQueryParams = query.ContextQueryParams;

                    query.Filter = ArticleRepository.FillFullTextSearchParams(contentId, query.Filter, searchQueryParams, query.Parser, out var ftsOptions, out var extensionContentIds, out var _);

                    var filterSqlParams       = new List <DbParameter>();
                    var sourceQuery           = new ArticleFilterSearchQueryParser().GetFilter(searchQueryParams, filterSqlParams);
                    var linkedFilters         = (ArticleRepository.GetLinkSearchParameter(searchQueryParams) ?? new ArticleLinkSearchParameter[0]).ToList();
                    var hasFtsSearchParams    = !string.IsNullOrEmpty(ftsOptions.QueryString) && !(ftsOptions.HasError.HasValue && ftsOptions.HasError.Value);
                    var hasFilterSearchParams = !string.IsNullOrEmpty(sourceQuery) || linkedFilters.Any();
                    var combinedFilter        = string.IsNullOrWhiteSpace(sourceQuery)
                        ? query.HostFilter
                        : string.IsNullOrWhiteSpace(query.HostFilter)
                            ? sourceQuery
                            : $"({query.HostFilter} AND {sourceQuery})";

                    var filterForSmpl = string.IsNullOrWhiteSpace(combinedFilter) ? query.Filter : combinedFilter;

                    return(hasFtsSearchParams || hasFilterSearchParams
                        ? new ArticleFtsProcessor(contentId, query.Filter, combinedFilter, linkedFilters, articleContextQueryParams, filterSqlParams, extensionContentIds, ftsOptions)
                        : new ArticleSimpleProcessor(contentId, query.EntityId, filterForSmpl, query.EntityTypeCode, query.SelectItemIDs) as ITreeProcessor);
                }

                if (query.EntityTypeCode == EntityTypeCode.SiteFolder || query.EntityTypeCode == EntityTypeCode.ContentFolder)
                {
                    return(new SiteFolderProcessor(query.ParentEntityId, query.EntityTypeCode, query.ReturnSelf, query.EntityId));
                }

                if (query.EntityTypeCode == EntityTypeCode.UserGroup)
                {
                    return(new UserGroupProcessor(query.EntityTypeCode, query.EntityId));
                }
            }

            throw new NotImplementedException(query.EntityTypeCode);
        }
Esempio n. 2
0
        /// <summary>
        /// Фабрика для запроса на отображение дерева в QP
        /// </summary>
        internal static ITreeProcessor Create(string entityTypeCode, int?parentEntityId, int?entityId, bool returnSelf, string commonFilter, string hostFilter, string selectItemIDs, IList <ArticleSearchQueryParam> searchQuery, IList <ArticleContextQueryParam> contextQuery, ArticleFullTextSearchQueryParser ftsParser)
        {
            using (new QPConnectionScope())
            {
                if (entityTypeCode == EntityTypeCode.Article || entityTypeCode == EntityTypeCode.VirtualArticle)
                {
                    var contentId = parentEntityId.GetValueOrDefault();
                    commonFilter = ArticleRepository.FillFullTextSearchParams(contentId, commonFilter, searchQuery, ftsParser, out var ftsOptions, out var extensionContentIds, out var _);

                    var filterSqlParams       = new List <SqlParameter>();
                    var sourceQuery           = new ArticleFilterSearchQueryParser().GetFilter(searchQuery, filterSqlParams);
                    var linkedFilters         = (ArticleRepository.GetLinkSearchParameter(searchQuery) ?? new ArticleLinkSearchParameter[0]).ToList();
                    var hasFtsSearchParams    = !string.IsNullOrEmpty(ftsOptions.QueryString) && !(ftsOptions.HasError.HasValue && ftsOptions.HasError.Value);
                    var hasFilterSearchParams = !string.IsNullOrEmpty(sourceQuery) || linkedFilters.Any();
                    var combinedFilter        = string.IsNullOrWhiteSpace(sourceQuery)
                        ? hostFilter
                        : string.IsNullOrWhiteSpace(hostFilter)
                            ? sourceQuery
                            : $"({hostFilter} AND {sourceQuery})";

                    var filterForSmpl = string.IsNullOrWhiteSpace(combinedFilter) ? commonFilter : combinedFilter;
                    return(hasFtsSearchParams || hasFilterSearchParams
                        ? new ArticleFtsProcessor(contentId, commonFilter, combinedFilter, linkedFilters, contextQuery, filterSqlParams, extensionContentIds, ftsOptions)
                        : new ArticleSimpleProcessor(contentId, entityId, filterForSmpl, entityTypeCode, selectItemIDs) as ITreeProcessor);
                }

                if (entityTypeCode == EntityTypeCode.SiteFolder || entityTypeCode == EntityTypeCode.ContentFolder)
                {
                    return(new SiteFolderProcessor(parentEntityId, entityTypeCode, returnSelf, entityId));
                }

                if (entityTypeCode == EntityTypeCode.UserGroup)
                {
                    return(new UserGroupProcessor(entityTypeCode, entityId));
                }
            }

            throw new NotImplementedException(entityTypeCode);
        }