Пример #1
0
        void runQueryButton_Click(object sender, EventArgs e)
        {
            //The PortalSiteMapProvider class provides high-performance queries for
            //data that changes infrequently because it makes use of SharePoint's
            //query caches. If you frequently query for the same dataset that changes rarely,
            //you should consider using this object to run your queries.

            //A PortalSiteMapProvider object is large and takes lots of resources to set
            //up. You should not create a new one for your queries but instead use one of
            //the examples SharePoint provides by default. If you need to create your own
            //PortalSiteMapProvider you should configure the web application with web.config.

            //We'll get the example that SharePoint uses to build the breadcrumb trail
            PortalSiteMapProvider portalProvider = PortalSiteMapProvider.CurrentNavSiteMapProviderNoEncode;

            //Write a introductory results line
            resultsLabel.Text = "Sites: <br />";

            //Run a query. This example gets all the child sites.
            SiteMapNodeCollection children = portalProvider.GetChildNodes(((PortalSiteMapNode)portalProvider.CurrentNode).WebNode,
                                                                          Microsoft.SharePoint.Publishing.NodeTypes.Area, Microsoft.SharePoint.Publishing.NodeTypes.Area);

            //Loop through the results and display the site title.
            foreach (SiteMapNode node in children)
            {
                resultsLabel.Text += node.Title + "<br />";
            }
        }
Пример #2
0
        public void SetIncidentStatusListData()
        {
            PortalSiteMapProvider provider = PortalSiteMapProvider.CombinedNavSiteMapProvider;

            if (provider.CurrentNode != null && provider.CurrentNode.HasChildNodes)
            {
                List <IncidentStatus> incidentStatuses = new List <IncidentStatus>();
                foreach (PortalWebSiteMapNode node in provider.GetChildNodes(provider.CurrentNode))
                {
                    if (node.GetProperty(BusinessEventProperty) != null && node.GetProperty(BusinessEventProperty).ToString().ToLower(CultureInfo.CurrentCulture) == "incident")
                    {
                        IncidentStatus incidentStatus = new IncidentStatus();
                        incidentStatus.Title            = node.Title;
                        incidentStatus.Url              = node.Url;
                        incidentStatus.Status           = (string)node.GetProperty(StatusProperty);
                        incidentStatus.CreatedDate      = node.CreatedDate.ToString();
                        incidentStatus.LastModifiedDate = node.LastModifiedDate.ToString();

                        incidentStatuses.Add(incidentStatus);
                    }
                }

                view.Data = incidentStatuses;
            }
        }
Пример #3
0
        protected override void CreateChildControls()
        {
            base.CreateChildControls();

            try
            {
                if (_provider == null)
                {
                    throw new HttpException("Invalid SiteMapProvder:" + _siteMapProvider);
                }

                currNode = _provider.FindSiteMapNodeFromKey(Microsoft.SharePoint.SPContext.Current.Web.ServerRelativeUrl);

                sNode = GetStartingNode();
                SiteMapNodeCollection nodes = _provider.GetChildNodes(sNode);

                // if we are only displaying the subnodes or if we are at /eng or /fra then only show children
                if ((!displaySubNodesOnly) || (Microsoft.SharePoint.SPContext.Current.Web.ParentWeb.IsRootWeb))
                {
                    // displaying children as sections
                    PlaceHolder placeHolder = new PlaceHolder();

                    foreach (SiteMapNode childrenNode in nodes)
                    {
                        RenderNode(placeHolder, childrenNode, 0);
                    }

                    Controls.Add(placeHolder);
                }
                else
                {
                    // displaying top level as only section and everything else as children
                    PlaceHolder placeHolder = new PlaceHolder();
                    RenderNode(placeHolder, GetStartingNode(), 0);
                    Controls.Add(placeHolder);
                }
            }
            catch (Exception ex)
            {
                Logger.WriteLog(ex.Message + " " + ex.StackTrace);
            }
        }