Ejemplo n.º 1
0
        // Returns the navigation node that corresponds to this content. If
        // we give it a navigation node already, it'll return that node, so
        // no harm done.
        public string GetNavigationNode()
        {
            // Load the contentItem. If we get a Toc entry, then we know it is
            // a navigation node rather than a content node. The reason is that
            // getNavigationPaths only returns the root node if the target node is
            // a navigation node already. We could check to see if we get one path
            // consisting of one node, but the user could give a target node that is
            // the same as the root node. Perf isn't an issue because this should
            // only be called once with the rootNode.

            Load(false); // Don't load images in case we are a content node.

            if (Toc != null)
            {
                return(ContentId);
            }

            var root = new navigationKey {
                contentId = RootContentItem.ContentId, locale = _locale, version = RootContentItem.Version
            };

            var target = new navigationKey {
                contentId = ContentId, locale = _locale, version = _collection + "." + _version
            };
            //            target.contentId = "AssetId:" + assetId;

            var client  = new ContentServicePortTypeClient("ContentService");
            var request = new GetNavigationPathsRequest1
            {
                getNavigationPathsRequest = { target = target, root = root }
            };

            var response = client.GetNavigationPaths(request);

            // We need to deal with the case where the content appears in many
            // places in the TOC. For now, just use the first path.
            if (response.getNavigationPathsResponse.navigationPaths.Length == 0)
            {
                return(null);
            }

            // This is the last node in the first path.
            return(response.getNavigationPathsResponse.navigationPaths[0].navigationPathNodes[response.getNavigationPathsResponse.navigationPaths[0].navigationPathNodes.Length - 1].navigationNodeKey.contentId);
        }
Ejemplo n.º 2
0
        // Returns the navigation node that corresponds to this content. If
        // we give it a navigation node already, it'll return that node, so
        // no harm done.
        public string GetNavigationNode()
        {
            // Load the contentItem. If we get a Toc entry, then we know it is
            // a navigation node rather than a content node. The reason is that
            // getNavigationPaths only returns the root node if the target node is
            // a navigation node already. We could check to see if we get one path
            // consisting of one node, but the user could give a target node that is
            // the same as the root node. Perf isn't an issue because this should
            // only be called once with the rootNode.

            Load(false); // Don't load images in case we are a content node.

            if (Toc != null)
                return ContentId;

            var root = new navigationKey { contentId = RootContentItem.ContentId, locale = _locale, version = RootContentItem.Version };

            var target = new navigationKey { contentId = ContentId, locale = _locale, version = _collection + "." + _version };
            //            target.contentId = "AssetId:" + assetId;

            var client = new ContentServicePortTypeClient("ContentService");
            var request = new GetNavigationPathsRequest1
                              {
                                  getNavigationPathsRequest = {target = target, root = root}
                              };

            var response = client.GetNavigationPaths(request);

            // We need to deal with the case where the content appears in many
            // places in the TOC. For now, just use the first path.
            if (response.getNavigationPathsResponse.navigationPaths.Length == 0)
                return null;

            // This is the last node in the first path.
            return response.getNavigationPathsResponse.navigationPaths[0].navigationPathNodes[response.getNavigationPathsResponse.navigationPaths[0].navigationPathNodes.Length - 1].navigationNodeKey.contentId;
        }