protected override void Invoke(object parameter)
        {
            if (this.AssociatedObject == null)
            {
                return;
            }

            var _actionNode = this.ControllerActionNode;

            if (_actionNode == null && !string.IsNullOrEmpty(this.ControllerActionNodeKey))
            {
                if (!SiteMapService.IsSiteMapLoaded)
                {
                    SiteMapService.LoadSiteMap((s) => this.Invoke(null));
                    return;
                }
                _actionNode = SiteMapService.ResolveSiteMapNode(ControllerActionNodeKey) as ControllerActionNode;
            }

            if (_actionNode == null)
            {
                throw new ControllerActionException(NODE_NOT_FOUND, ResponseStatus.HandlerNotFound);
            }

            var _request = new ControllerActionRequest(_actionNode.Url, _actionNode.UrlParameters, _actionNode.SiteArea, base.ResolveHandler(), this.AssociatedObject);

            ControllerService.Execute(_request, (s) =>
            {
                if (s != ResponseStatus.Success && s != ResponseStatus.Cancelled)
                {
                    throw new ControllerActionException(string.Format(ACTION_COULDNOT_EXECUTE, _actionNode.Url), s, _request);
                }
            });
        }
Esempio n. 2
0
        protected override void Invoke(object parameter)
        {
            if (this.AssociatedObject == null) return;

            // resolve the handler
            var _handler = base.ResolveHandler();
            if (_handler == null) throw new NavigationException(HANDLER_NOT_RESOLVE, ResponseStatus.HandlerNotFound);

            // resolve the navigation node
            var _navigationNode = this.NavigationNode;
            if (_navigationNode == null && !string.IsNullOrEmpty(this.NavigationNodeKey))
            {
                if (!SiteMapService.IsSiteMapLoaded)
                {
                    SiteMapService.LoadSiteMap((s) => this.Invoke(null));
                    return;
                }
                _navigationNode = SiteMapService.ResolveSiteMapNode(NavigationNodeKey) as NavigationNode;
            }

            if (_navigationNode == null) throw new NavigationException(NODE_NOT_FOUND, ResponseStatus.UrlNotFound);

            // and navigate
            NavigationService.Navigate(new NavigationRequest(_navigationNode.Url, _navigationNode.UrlParameters,
                _navigationNode.SiteArea, NavigateMode.New), _handler);
        }
        protected override void Invoke(object parameter)
        {
            if (SiteMapNode != null)
            {
                SiteMapNode.Execute();
            }
            else if (!string.IsNullOrEmpty(SiteMapNodeKey))
            {
                if (!SiteMapService.IsSiteMapLoaded)
                {
                    SiteMapService.LoadSiteMap((s) =>
                    {
                        this.Invoke(null);
                    });
                    return;
                }

                var _siteMapNode = SiteMapService.ResolveSiteMapNode(SiteMapNodeKey);
                if (_siteMapNode == null)
                {
                    throw new InvalidOperationException(string.Format(SITEMAPNODE_NOTFOUND, SiteMapNodeKey));
                }
                _siteMapNode.Execute();
            }
        }