Exemple #1
0
        private void AddUrlDefinedToDocument(Document document, string entityLogicalName, FetchXmlResult fetchXmlResult)
        {
            var isUrlDefined = false;

            if (entityLogicalName == "adx_blog")
            {
                var blogPartialUrlFetch = fetchXmlResult.FirstOrDefault(x => x.Name == "adx_partialurl");
                var parentPageIdFetch   = fetchXmlResult.FirstOrDefault(x => x.Name == "adx_parentpageid");
                if (blogPartialUrlFetch == null || parentPageIdFetch == null)
                {
                    return;
                }

                var blogPartialUrl = blogPartialUrlFetch.Value;
                isUrlDefined = CmsIndexHelper.IsWebPageUrlDefined(
                    this._contentMapProvider,
                    new Guid(parentPageIdFetch.Value),
                    blogPartialUrl);
            }
            if (entityLogicalName == "adx_blogpost")
            {
                var blogPostPartialUrlFetch = fetchXmlResult.FirstOrDefault(x => x.Name == "adx_partialurl");
                var blogPartialUrlFetch     = fetchXmlResult.FirstOrDefault(x => x.Name == "adx_blog_blogpost.adx_partialurl");
                var parentWebPageIdFetch    = fetchXmlResult.FirstOrDefault(x => x.Name == "adx_blog_blogpost.adx_parentpageid");
                if (blogPartialUrlFetch == null || parentWebPageIdFetch == null)
                {
                    return;
                }
                var blogPostId = fetchXmlResult.FirstOrDefault(x => x.Name == "adx_blogpostid");
                if (blogPostPartialUrlFetch == null && blogPostId == null)
                {
                    return;
                }
                var blogPostPartialUrl = blogPostPartialUrlFetch == null ? blogPostId.Value : blogPostPartialUrlFetch.Value;
                var blogPartialUrl     = blogPartialUrlFetch.Value;

                var blogPostsCombineUrl = string.Format("{0}/{1}", blogPartialUrl, blogPostPartialUrl);

                isUrlDefined = CmsIndexHelper.IsWebPageUrlDefined(
                    this._contentMapProvider,
                    new Guid(parentWebPageIdFetch.Value),
                    blogPostsCombineUrl);
            }

            if (entityLogicalName == "adx_communityforum")
            {
                var forumIdFetch =
                    fetchXmlResult.FirstOrDefault(x => x.Name == "adx_communityforumid");
                if (forumIdFetch == null)
                {
                    return;
                }
                isUrlDefined = CmsIndexHelper.IsForumUrlDefined(
                    this._contentMapProvider,
                    new Guid(forumIdFetch.Value));
            }
            if (entityLogicalName == "adx_communityforumthread")
            {
                var forumIdFetch =
                    fetchXmlResult.FirstOrDefault(x => x.Name == "adx_forumid");
                if (forumIdFetch == null)
                {
                    return;
                }
                isUrlDefined = CmsIndexHelper.IsForumUrlDefined(
                    this._contentMapProvider,
                    new Guid(forumIdFetch.Value));
            }
            if (entityLogicalName == "adx_communityforumpost")
            {
                var forumIdFetch =
                    fetchXmlResult.FirstOrDefault(x => x.Name == "adx_communityforumpost_communityforumthread.adx_forumid");
                if (forumIdFetch == null)
                {
                    return;
                }
                isUrlDefined = CmsIndexHelper.IsForumUrlDefined(
                    this._contentMapProvider,
                    new Guid(forumIdFetch.Value));
            }

            if (entityLogicalName == "adx_idea")
            {
                var ideaPartialUrlFetch      = fetchXmlResult.FirstOrDefault(x => x.Name == "adx_partialurl");
                var ideaForumPartialUrlFetch = fetchXmlResult.FirstOrDefault(x => x.Name == "adx_idea_ideaforum.adx_partialurl");
                if (ideaPartialUrlFetch == null || ideaForumPartialUrlFetch == null)
                {
                    return;
                }
                var ideaPartialUrl      = ideaPartialUrlFetch.Value;
                var ideaForumPartialUrl = ideaForumPartialUrlFetch.Value;

                isUrlDefined = !string.IsNullOrEmpty(ideaPartialUrl) && !string.IsNullOrEmpty(ideaForumPartialUrl);
            }
            if (entityLogicalName == "adx_ideaforum")
            {
                var ideaForumPartialUrlFetch = fetchXmlResult.FirstOrDefault(x => x.Name == "adx_partialurl");
                if (ideaForumPartialUrlFetch == null)
                {
                    return;
                }
                isUrlDefined = !string.IsNullOrEmpty(ideaForumPartialUrlFetch.Value);
            }

            if (entityLogicalName == "incident")
            {
                isUrlDefined = CmsIndexHelper.IsSiteMakerUrlDefined(this._contentMapProvider, "Case");
            }

            if (entityLogicalName == "adx_webfile")
            {
                var webfilePartialUrlFetch = fetchXmlResult.FirstOrDefault(x => x.Name == "adx_partialurl");
                var webPageIdFetch         = fetchXmlResult.FirstOrDefault(x => x.Name == "adx_parentpageid");
                if (webfilePartialUrlFetch == null || webPageIdFetch == null)
                {
                    return;
                }
                isUrlDefined = CmsIndexHelper.IsWebPageUrlDefined(
                    this._contentMapProvider,
                    new Guid(webPageIdFetch.Value),
                    webfilePartialUrlFetch.Value);
            }

            if (entityLogicalName == "adx_webpage")
            {
                var webpageId = fetchXmlResult.FirstOrDefault(x => x.Name == "adx_webpageid");
                if (webpageId == null)
                {
                    return;
                }
                var primaryId = new Guid(webpageId.Value);
                isUrlDefined = CmsIndexHelper.IsWebPageUrlDefined(this._contentMapProvider, primaryId);
            }

            if (!this.oOBUrlDefinedEntities.Contains(entityLogicalName))
            {
                isUrlDefined = true;
            }

            document.Add(
                new Field(this._index.IsUrlDefinedFieldName, isUrlDefined.ToString(), Field.Store.NO, Field.Index.NOT_ANALYZED));
        }