Пример #1
0
        public override SiteMapNodeCollection GetChildNodes(SiteMapNode node)
        {
            TraceInfo("GetChildNodes({0})", node.Key);

            var children = new SiteMapNodeCollection();

            var entityNode = node as CrmSiteMapNode;

            if (entityNode == null || !entityNode.HasCrmEntityName("adx_webpage"))
            {
                return(children);
            }

            var portal  = PortalContext;
            var context = portal.ServiceContext;
            var website = portal.Website;

            var entity = context.MergeClone(entityNode.Entity);

            var blogs = FindBlogs(context, website, entity);

            foreach (var blog in blogs)
            {
                var blogNode = GetBlogNode(context, blog);

                if (ChildNodeValidator.Validate(context, blogNode))
                {
                    children.Add(blogNode);
                }
            }

            return(children);
        }
Пример #2
0
        public override SiteMapNodeCollection GetChildNodes(SiteMapNode node)
        {
            TraceInfo("GetChildNodes({0})", node.Key);

            var children = new List <SiteMapNode>();

            var portal  = PortalContext;
            var context = portal.ServiceContext;
            var website = portal.Website;

            var page = UrlMapping.LookupPageByUrlPath(context, website, node.Url);

            // If the node URL is that of a web page...
            if (page != null)
            {
                var childEntities = context.GetChildPages(page).Union(context.GetChildFiles(page));

                // Add the (valid) child pages and files of that page to the children we will return.
                foreach (var entity in childEntities)
                {
                    var childNode = GetNode(context, entity);

                    if (ChildNodeValidator.Validate(context, childNode))
                    {
                        children.Add(childNode);
                    }
                }
            }

            // Append values from other site map providers.
            foreach (SiteMapProvider subProvider in SiteMap.Providers)
            {
                // Skip this provider if it is the same as this one.
                if (subProvider.Name == Name)
                {
                    continue;
                }

                var subProviderChildNodes = subProvider.GetChildNodes(node);

                if (subProviderChildNodes == null)
                {
                    continue;
                }

                foreach (SiteMapNode childNode in subProviderChildNodes)
                {
                    children.Add(childNode);
                }
            }

            children.Sort(new SiteMapNodeDisplayOrderComparer());

            return(new SiteMapNodeCollection(children.ToArray()));
        }
Пример #3
0
        public override SiteMapNodeCollection GetChildNodes(SiteMapNode node)
        {
            TraceInfo("GetChildNodes({0})", node.Key);

            var children = new SiteMapNodeCollection();

            var crmNode = node as CrmSiteMapNode;

            if (crmNode == null || !crmNode.HasCrmEntityName("adx_webpage"))
            {
                return(children);
            }

            var portal  = PortalContext;
            var context = portal.ServiceContext;
            var website = portal.Website;

            var entity = crmNode.Entity;

            var childSurveys = FindSurveys(context, website, entity);

            if (childSurveys == null)
            {
                return(children);
            }

            foreach (var childSurvey in childSurveys)
            {
                var childNode = GetNode(context, childSurvey);

                if (ChildNodeValidator.Validate(context, childNode))
                {
                    children.Add(childNode);
                }
            }

            return(children);
        }
        public override SiteMapNodeCollection GetChildNodes(SiteMapNode node)
        {
            TraceInfo("GetChildNodes({0})", node.Key);

            var children = new List <SiteMapNode>();

            var portal  = PortalContext;
            var context = portal.ServiceContext;
            var website = portal.Website;

            // Shorcuts do not have children, may have the same Url as a web page.
            if (IsShortcutNode(node))
            {
                return(new SiteMapNodeCollection());
            }

            var pageMappingResult = UrlMapping.LookupPageByUrlPath(context, website, node.Url);

            // If the node URL is that of a web page...
            if (pageMappingResult.Node != null && pageMappingResult.IsUnique)
            {
                var childEntities = context.GetChildPages(pageMappingResult.Node).Union(context.GetChildFiles(pageMappingResult.Node)).Union(context.GetChildShortcuts(pageMappingResult.Node));

                foreach (var entity in childEntities)
                {
                    try
                    {
                        if (entity.LogicalName == "adx_shortcut")
                        {
                            var targetNode        = GetShortcutTargetNode(context, entity);
                            var shortcutChildNode = GetShortcutCrmNode(context, entity, targetNode);

                            if (shortcutChildNode != null && ChildNodeValidator.Validate(context, shortcutChildNode))
                            {
                                children.Add(shortcutChildNode);
                            }
                        }
                        else
                        {
                            var childNode = GetNode(context, entity);

                            if (childNode != null && ChildNodeValidator.Validate(context, childNode))
                            {
                                children.Add(childNode);
                            }
                        }
                    }
                    catch (Exception e)
                    {
                        ADXTrace.Instance.TraceError(TraceCategory.Application, string.Format(@"Exception creating child node for node child entity [{0}:{1}]: {2}", EntityNamePrivacy.GetEntityName(entity.LogicalName), entity.Id, e.ToString()));

                        continue;
                    }
                }
            }

            // Append values from other site map providers.
            foreach (SiteMapProvider subProvider in SiteMap.Providers)
            {
                // Skip this provider if it is the same as this one.
                if (subProvider.Name == Name)
                {
                    continue;
                }

                var subProviderChildNodes = subProvider.GetChildNodes(node);

                if (subProviderChildNodes == null)
                {
                    continue;
                }

                foreach (SiteMapNode childNode in subProviderChildNodes)
                {
                    children.Add(childNode);
                }
            }

            children.Sort(new SiteMapNodeDisplayOrderComparer());

            return(new SiteMapNodeCollection(children.ToArray()));
        }
        private SiteMapNodeCollection GetChildNodes(SiteMapNode node, ContentMap map)
        {
            WebsiteNode site;
            IContentMapEntityUrlProvider urlProvider;

            using (PerformanceProfiler.Instance.StartMarker(PerformanceMarkerName.SiteMapProvider, PerformanceMarkerArea.Cms, PerformanceMarkerTagName.GetChildNodes))
            {
                if (!TryGetWebsite(map, out site, out urlProvider))
                {
                    return(base.GetChildNodes(node));
                }

                var children = new List <SiteMapNode>();

                // Shorcuts do not have children, may have the same Url as a web page.
                if (IsShortcutNode(node))
                {
                    return(new SiteMapNodeCollection());
                }

                // SiteMap is not language-aware, so the node.Url will always be URL of the root WebPage, so look for root.
                var langContext  = HttpContext.Current.GetContextLanguageInfo();
                var filterResult = ContentMapUrlMapping.LookupPageByUrlPath(site, node.Url, ContentMapUrlMapping.WebPageLookupOptions.RootOnly, langContext);

                if (filterResult.Node != null && filterResult.IsUnique)
                {
                    var portal  = PortalContext;
                    var context = portal.ServiceContext;

                    foreach (var child in filterResult.Node.WebPages)
                    {
                        // Only get children pages who match the current active language.
                        var childNode = IsValidLanguageContentPage(child, langContext) ? GetNode(map, child, HttpStatusCode.OK, urlProvider) : null;

                        if (childNode == null)
                        {
                            continue;
                        }

                        if (ChildNodeValidator.Validate(context, childNode))
                        {
                            children.Add(childNode);
                        }
                    }

                    foreach (var file in filterResult.Node.WebFiles)
                    {
                        var childNode = GetNode(map, file, urlProvider);

                        if (ChildNodeValidator.Validate(context, childNode))
                        {
                            children.Add(childNode);
                        }
                    }

                    foreach (var shortcut in filterResult.Node.Shortcuts)
                    {
                        var childNode = GetNode(map, shortcut, urlProvider);

                        if (childNode != null && ChildNodeValidator.Validate(context, childNode))
                        {
                            children.Add(childNode);
                        }
                    }
                }

                // Append values from other site map providers.
                foreach (SiteMapProvider subProvider in SiteMap.Providers)
                {
                    // Skip this provider if it is the same as this one.
                    if (subProvider.Name == Name)
                    {
                        continue;
                    }

                    // Check if the provider has solution dependencies
                    var solutionDependent = subProvider as ISolutionDependent;

                    if (solutionDependent != null)
                    {
                        if (map.Solution.Solutions.Intersect(solutionDependent.RequiredSolutions).Count() != solutionDependent.RequiredSolutions.Count())
                        {
                            continue;
                        }
                    }

                    var subProviderChildNodes = subProvider.GetChildNodes(node);

                    if (subProviderChildNodes == null)
                    {
                        continue;
                    }

                    foreach (SiteMapNode childNode in subProviderChildNodes)
                    {
                        children.Add(childNode);
                    }
                }

                children.Sort(new SiteMapNodeDisplayOrderComparer());

                return(new SiteMapNodeCollection(children.ToArray()));
            }
        }