protected override void CreateChildControls() { return; SPQuery query = new SPQuery(); // supports less than 130,000 records // query.Query = "<Where><Eq><FieldRef Name='_x804c__x4f4d_'/><Value Type='Text'>J</Value></Eq></Where>"; query.Query = "<Where><And><Eq><FieldRef Name='_x6027__x522b_'/><Value Type='Text'>男</Value></Eq><Eq><FieldRef Name='_x804c__x4f4d_'/><Value Type='Text'>J</Value></Eq></And></Where>"; SPWeb web = SPContext.Current.Web; PortalSiteMapProvider ps = PortalSiteMapProvider.WebSiteMapProvider; PortalWebSiteMapNode psNode = (PortalWebSiteMapNode)ps.FindSiteMapNode(web.ServerRelativeUrl); if (psNode != null) { Stopwatch timer = new Stopwatch(); timer.Start(); SiteMapNodeCollection items = ps.GetCachedListItemsByQuery(psNode, "人物列表", query, web); StringBuilder sb = new StringBuilder(); foreach (PortalListItemSiteMapNode item in items) { sb.Append(item["性别"]); sb.Append(","); } timer.Stop(); sb.Append("<hr>"); sb.Append(string.Format("{0:N}", timer.Elapsed.Ticks / 10m)); LiteralControl lc = new LiteralControl(); lc.Text = sb.ToString(); this.Controls.Add(lc); } }
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 />"; } }
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; } }
private void InitPortalSiteMapProvider(SiteMapProvider siteMapProvider) { if (siteMapProvider is PortalSiteMapProvider) { _provider = siteMapProvider as PortalSiteMapProvider; _provider.DynamicChildLimit = 0; _provider.EncodeOutput = true; _provider.IncludeAuthoredLinks = _includeAuthoredLinks; _provider.IncludeHeadings = _includeHeadings; _provider.IncludePages = GetIncludeOption(_includePages); _provider.IncludeSubSites = GetIncludeOption(_includeSubSites); } }
private SiteMapNode GetSiteMapRootNodeOfCurrentWeb(string url) { SiteMapNode result; try { url = SPContext.Current.Site.Url + url; using (SPSite site = new SPSite(url)) { using (SPWeb web = site.OpenWeb()) { //获取站点结构 PortalSiteMapProvider CombinedNavSiteMapProvider = PortalSiteMapProvider.CurrentNavSiteMapProviderNoEncode; result = CombinedNavSiteMapProvider.FindSiteMapNode(web.ServerRelativeUrl); } } } catch (Exception ex) { return(null); } return(result); }