示例#1
0
 internal void ResetProvider()
 {
     nodes    = null;
     rootWeb  = null;
     siteMap  = null;
     rootNode = null;
     InitiateProvider();
 }
示例#2
0
        public WebSiteNodeCollection GetChildNodes(WebSiteNode node)
        {
            WebSiteNodeCollection collection = new WebSiteNodeCollection();

            if (node != null)
            {
                List <WebSiteNode> Children = nodes[node].Children;

                foreach (WebSiteNode childNode in Children)
                {
                    collection.Add(childNode);
                }
            }

            return(collection);
        }
示例#3
0
        private HierarchicalDataSourceView GetTreeView(string viewPath)
        {
            WebSiteNode node = null;

            if (string.IsNullOrEmpty(viewPath))
            {
                WebSiteNodeCollection nodes = this.GetNodes();
                if (nodes != null)
                {
                    return(nodes.GetHierarchicalDataSourceView());
                }
            }
            else
            {
                node = this.Provider.FindSiteMapNodeFromKey(viewPath);
                if (node != null)
                {
                    return(node.ChildNodes.GetHierarchicalDataSourceView());
                }
            }
            return(WebSiteNodeCollection.Empty.GetHierarchicalDataSourceView());
        }
示例#4
0
        internal WebSiteNodeCollection GetPathNodeCollection(string viewPath)
        {
            WebSiteNodeCollection childNodes = null;

            if (string.IsNullOrEmpty(viewPath))
            {
                childNodes = this.GetNodes();
            }
            else
            {
                WebSiteNode node = this.Provider.FindSiteMapNodeFromKey(viewPath);
                if (node != null)
                {
                    childNodes = node.ChildNodes;
                }
            }
            if (childNodes == null)
            {
                childNodes = WebSiteNodeCollection.Empty;
            }
            return(childNodes);
        }
示例#5
0
        private void InitiateProvider()
        {
            if (nodes == null)
            {
                nodes = new WebSiteNodeCollection();
            }

            if (rootWeb != null)
            {
                string url = rootWeb.Url;
            }
            SPWeb  currentWeb = SPContext.Current.Site.RootWeb;
            string curl       = currentWeb.Url;

            if (rootWeb == null || rootWeb != currentWeb)
            {
                SPSite site = SPContext.Current.Site;
                site.CatchAccessDeniedException = false;
                rootWeb  = site.RootWeb;
                rootNode = null;
                //if (siteMap == null)
                //{

                siteMap = rootWeb.Lists.TryGetList("SiteMap");

                if (rootNode == null && siteMap != null)
                {
                    SPListItemCollection rootNodes = null;

                    try
                    {
                        SPQuery query = new SPQuery();
                        query.Query = "<Where><Eq><FieldRef Name=\"Parent\" /><Value Type=\"Lookup\">Root</Value></Eq></Where><OrderBy><FieldRef Name=\"Position\" Ascending=\"True\" /></OrderBy>";
                        //query.Query = "<Where><IsNull><FieldRef Name=\"Parent\"/></IsNull></Where>";
                        query.ViewFields = "<FieldRef Name=\"Title\" /><FieldRef Name=\"Description\" /><FieldRef Name=\"URL\" /><FieldRef Name=\"Enabled\" /><FieldRef Name=\"Selected\" /><FieldRef Name=\"Breadcrumb\" /><FieldRef Name=\"Separator\" /><FieldRef Name=\"Icon\" /><FieldRef Name=\"LargeImage\" /><FieldRef Name=\"Parent\" /><FieldRef Name=\"Position\" /><FieldRef Name=\"ID\" />";
                        rootNodes        = siteMap.GetItems(query);
                    }
                    catch (Exception ex)
                    {
                        ex.ToString();
                    }

                    /*
                     * try
                     * {
                     *  string url = rootWeb.RootFolder.WelcomePage;
                     * }
                     * catch (Exception)
                     * {
                     *  HttpApplication application = HttpContext.Current.ApplicationInstance;
                     *  application.Server.ClearError();
                     *  application.Response.StatusCode = (int)HttpStatusCode.Forbidden;
                     *  throw (new HttpException((int)HttpStatusCode.Forbidden, ""));
                     * }
                     */

                    if (rootNodes != null)
                    {
                        rootNode = new WebSiteNode();
                        //nodes.Add(rootNode);
                        try
                        {
                            foreach (SPListItem item in rootNodes)
                            {
                                string xmlData = ConvertZRowToRegularXml(item.Xml);

                                using (System.IO.StringReader sr = new System.IO.StringReader(xmlData))
                                {
                                    XmlReader reader = XmlReader.Create(sr);
                                    rootNode.ReadXml(reader);
                                }
                            }

                            if (rootNode.HasChildren())
                            {
                                //bool isSet = false;
                                foreach (WebSiteNode cnode in rootNode.Children)
                                {
                                    try
                                    {
                                        nodes.Add(cnode);
                                        //int i = nodes.Add(cnode);
                                        //if (!isSet)
                                        //{
                                        //    rootNode = (WebSiteNode)nodes[i];
                                        //    isSet = true;
                                        //}
                                        FindChildNodes(cnode);
                                    }
                                    catch (Exception ex)
                                    {
                                        ex.ToString();
                                        //throw;
                                    }
                                }
                            }
                        }
                        catch (Exception ex)
                        {
                            ex.ToString();
                        }
                    }
                    //}
                }
            }
        }
 internal static WebSiteDataSourceView ReadOnly(WebSiteNodeCollection webSiteNodeCollection)
 {
     throw new NotImplementedException();
 }