private SiteMapNode GetParentNodeFromNode(DXInfo.Models.aspnet_Sitemaps item)
 {
     if (!_nodes.ContainsKey(item.ParentCode))
     {
         throw new ProviderException(string.Format("无效父节点Code={0},Title={1}", item.Code, item.Title));
         //DXInfo.Models.aspnet_Sitemaps item1 = siteMpaQuery.Find(f => f.Code == item.ParentCode);
         //SiteMapNode node = CreateSiteMapFromRow(item1);
         //AddNode(node, GetParentNodeFromNode(item1));
     }
     return(_nodes[item.ParentCode]);
 }
        private SiteMapNode CreateSiteMapFromRow(DXInfo.Models.aspnet_Sitemaps item)
        {
            if (_nodes.ContainsKey(item.Code))
            {
                throw new ProviderException(string.Format("重复节点Code={0},Title={1}", item.Code, item.Title));
            }
            SiteMapNode node = new SiteMapNode(this, item.Code);

            node["IsAuthorize"] = item.IsAuthorize.ToString();
            if (!string.IsNullOrEmpty(item.Url))
            {
                node.Title       = string.IsNullOrEmpty(item.Title) ? null : item.Title;
                node.Description = string.IsNullOrEmpty(item.Description) ? null : item.Description;
                node.Url         = string.IsNullOrEmpty(item.Url) ? null : item.Url;
            }
            else
            {
                node.Title       = string.IsNullOrEmpty(item.Title) ? null : item.Title;
                node.Description = string.IsNullOrEmpty(item.Description) ? null : item.Description;

                //IDictionary<string, object> routeValues = new Dictionary<string, object>();

                //if (string.IsNullOrEmpty(item.Controller))
                //    routeValues.Add("controller", "Home");
                //else
                //    routeValues.Add("controller", item.Controller);

                //if (string.IsNullOrEmpty(item.Action))
                //    routeValues.Add("action", "Index");
                //else
                //    routeValues.Add("action", item.Action);

                //if (!string.IsNullOrEmpty(item.ParaId))
                //    routeValues.Add("id", item.ParaId);



                HttpContextWrapper httpContext = new HttpContextWrapper(HttpContext.Current);
                RouteData          routeData   = RouteTable.Routes.GetRouteData(httpContext);

                if (routeData != null)
                {
                    //VirtualPathData virtualPath = routeData.Route.GetVirtualPath(new RequestContext(httpContext, routeData), new RouteValueDictionary(routeValues));
                    //string str = System.Web.Mvc.UrlHelper.GenerateUrl("", "", "", new RouteValueDictionary(routeValues), new RouteCollection(), httpContext, true);
                    System.Web.Routing.RequestContext rc  = new RequestContext(httpContext, routeData);
                    System.Web.Mvc.UrlHelper          url = new System.Web.Mvc.UrlHelper(rc);
                    RouteValueDictionary routeValues      = new RouteValueDictionary();

                    if (!string.IsNullOrEmpty(item.ParaId))
                    {
                        string[] paras = item.ParaId.Split('&');
                        foreach (string para in paras)
                        {
                            if (!string.IsNullOrEmpty(para))
                            {
                                string[] para1 = para.Split('=');
                                if (para1.Length == 2)
                                {
                                    routeValues.Add(para1[0], para1[1]);
                                }
                            }
                        }
                    }
                    node.Url = url.Action(item.Action, item.Controller, routeValues);

                    //if (virtualPath != null)
                    //{
                    //    node.Url = "~/" + virtualPath.VirtualPath;
                    //}
                }
            }

            _nodes.Add(item.Code, node);

            return(node);
        }