Esempio n. 1
0
        public static void MapRoutes(RouteCollection routes, ContextualPublishedCache umbracoCache)
        {
            //find all Dialogue forum root nodes - Testing adding new line
            var dialogueNodes = umbracoCache.GetByXPath(string.Concat("//", AppConstants.DocTypeForumRoot)).ToArray();


            //NOTE: need to write lock because this might need to be remapped while the app is running if
            // any articulate nodes are updated with new values
            using (routes.GetWriteLock())
            {
                //clear the existing articulate routes (if any)
                RemoveExisting(routes);

                // For each articulate root, we need to create some custom route, BUT routes can overlap
                // based on multi-tenency so we need to deal with that.
                // For example a root articulate node might yield a route like:
                //      /
                // and another articulate root node that has a domain might have this url:
                //      http://mydomain/
                // but when that is processed through RoutePathFromNodeUrl, it becomes:
                //      /
                // which already exists and is already assigned to a specific node ID.
                // So what we need to do in these cases is use a special route handler that takes
                // into account the domain assigned to the route.
                var groups = dialogueNodes.GroupBy(x => RouteCollectionExtensions.RoutePathFromNodeUrl(x.Url));
                foreach (var grouping in groups)
                {
                    var nodesAsArray = grouping.ToArray();

                    MapTopicRoute(routes, grouping.Key, nodesAsArray);
                    MapDialoguePages(routes, grouping.Key, nodesAsArray);
                    MapMemberRoute(routes, grouping.Key, nodesAsArray);
                }
            }
        }
        public static void MapRoutes(RouteCollection routes, ContextualPublishedCache umbracoCache, UrlProvider umbracoUrlProvider)
        {
            //find all dialogue root nodes
            var dialogueNodes = umbracoCache.GetByXPath(string.Concat("//", DialogueConfiguration.Instance.DocTypeForumRoot)).ToArray();

            LogHelper.Info(typeof(DialogueRoutes), () => $"Mapping routes for {dialogueNodes.Length} Dialogue root nodes");

            //NOTE: need to write lock because this might need to be remapped while the app is running if
            // any articulate nodes are updated with new values
            using (routes.GetWriteLock())
            {
                //clear the existing articulate routes (if any)
                RemoveExisting(routes);

                // For each articulate root, we need to create some custom route, BUT routes can overlap
                // based on multi-tenency so we need to deal with that.
                // For example a root articulate node might yield a route like:
                //      /
                // and another articulate root node that has a domain might have this url:
                //      http://mydomain/
                // but when that is processed through RoutePathFromNodeUrl, it becomes:
                //      /
                // which already exists and is already assigned to a specific node ID.
                // So what we need to do in these cases is use a special route handler that takes
                // into account the domain assigned to the route.
                var groups = dialogueNodes
                             .GroupBy(x => RouteCollectionExtensions.RoutePathFromNodeUrl(x.Url))
                             //This is required to ensure that we create routes that are more specific first
                             // before creating routes that are less specific
                             .OrderByDescending(x => x.Key.Split('/').Length);
                foreach (var grouping in groups)
                {
                    var nodesAsArray = grouping.ToArray();

                    MapTopicRoute(routes, umbracoUrlProvider, grouping.Key, nodesAsArray);
                    MapDialoguePages(routes, umbracoUrlProvider, grouping.Key, nodesAsArray);
                    MapMemberRoute(routes, umbracoUrlProvider, grouping.Key, nodesAsArray);
                }
            }
        }