博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
SharePoint 站点集和子站点数据互相读取
阅读量:5866 次
发布时间:2019-06-19

本文共 5183 字,大约阅读时间需要 17 分钟。

1.站点集中可以使用SPSite.AllWeb,然后遍历所有站点的isRootWeb,根据siteTemplate取得需要的子站点。

 

///         /// Handles the Load event of the Page control.        ///         protected void Page_Load(object sender, EventArgs e)        {            var web = SPControl.GetContextWeb(Context);            var subSite = new SPSite(web.Site.ID).AllWebs;            var list = new List
(); //Foreach sub site foreach (SPWeb site in subSite) { if (site.IsRootWeb) continue; if (site.WebTemplate != WebTemplate.PM.ToString()) continue; try { var content = site.Lists.TryGetList(ProjectOverviewContent.ProjectListName); if (content == null || content.Items.Count == 0) continue; var link = new ProjectOverviewContent { //get sitrUrl SubSiteUrl = site.Url, //get site created time SiteCreateTime = site.Created, }; //Foreach sub site list => ProjectContent foreach (SPListItem item in content.Items) { link.ProjectName = item[ProjectOverviewContent.ProjectNameMapping].TryToString(); link.StartDate = item[ProjectOverviewContent.StartDateMapping].TryToString().SplitDate(); link.EndDate = item[ProjectOverviewContent.EndDateMapping].TryToString().SplitDate(); link.ServiceLine = item[ProjectOverviewContent.ServiceLineMapping].TryToString(); link.Industry = item[ProjectOverviewContent.IndustryMapping].TryToString(); } content = site.Lists.TryGetList(ProjectOverviewContent.MemberListName); if (content == null) { list.Add(link); continue; } //Foreach sub site list => MemberContent foreach (SPListItem item in content.Items) { link.Position = item[ProjectOverviewContent.PositionMapping].TryToString(); if (link.Position == Position.MIC.ToString()) { link.MIC = item[ProjectOverviewContent.MemberNameMapping].TryToString(); } else if (link.Position == Position.PIC.ToString()) { link.PIC = item[ProjectOverviewContent.MemberNameMapping].TryToString(); } else if (link.Position == Position.PM.ToString()) { link.PM = item[ProjectOverviewContent.MemberNameMapping].TryToString(); } } list.Add(link); } catch (SPException spException) { LogHelper.Error(spException); } catch (Exception ex) { LogHelper.ShowError(lblErrorMessage, ex); } } list.Sort(); tblProjectOverview.DataSource = list.Take(10); tblProjectOverview.DataBind(); }
View Code

 

2.子站点读取站点集数据可以通过New SPSite("url").RootWeb获取。

 

public SPWeb RootSite = new SPSite(ProjectContent.SiteUrlMapping).RootWeb;///         /// Gets the project information from root site.        ///         public List
GetProjectInfo(string projectCode) { var siteContent = RootSite.Lists[ServiceOfferingContent.ListName]; if (siteContent == null || siteContent.Items.Count == 0) return null; var list = new List
(); foreach (SPListItem item in siteContent.Items) { var link = new ServiceOfferingContent() { ProjectCode = item[ServiceOfferingContent.ProjectCodeMapping].TryToString(), ServiceLine = item[ServiceOfferingContent.ServiceLineMapping].TryToString(), Industry = item[ServiceOfferingContent.IndustryMapping].TryToString(), Id = item[ServiceOfferingContent.IdMapping].TryToString(), Title = item[ServiceOfferingContent.TitleMapping].TryToString(), Contents = item[ServiceOfferingContent.ContentsMapping].TryToString(), ThumbnailUrl = item[ServiceOfferingContent.ThumbnailUrlMapping].TryToString(), HeadImageUrl = item[ServiceOfferingContent.HeadImageUrlMapping].TryToString(), ContentsImageUrl = item[ServiceOfferingContent.ContentsImageUrlMapping].TryToString(), Summary = item[ServiceOfferingContent.SummaryMapping].TryToString(), }; if (link.ProjectCode != projectCode) continue; list.Add(link); return list; } return null; }
View Code

 

转载地址:http://rsynx.baihongyu.com/

你可能感兴趣的文章
php 直接调用svn命令
查看>>
建立低权限的ftp帐号
查看>>
htpasswd
查看>>
Android窗口机制(三)Window和WindowManager的创建与Activity
查看>>
Android 编译出错解决
查看>>
iOS--The request was denied by service delegate (SBMainWorkspace) for reason:
查看>>
Android 打开WIFI并快速获取WIFI的信息
查看>>
【IOS开发】GDataXML解析XML
查看>>
Iptables
查看>>
GridView多行多列合并单元格(指定列合并)
查看>>
什么是DDOS攻击?怎么防御?
查看>>
状态模式(State Pattern)
查看>>
log4j日志框架学习
查看>>
function 与 => 的区别
查看>>
TYVJ P1077 有理逼近 Label:坑,tle的好帮手 不懂
查看>>
面试题:缓存Redis与Memcached的比较 有用
查看>>
EXCEL自动撤销合并单元格并填充相应内容(转帖)
查看>>
Python3学习笔记10-条件控制
查看>>
Nginx 1.2.6 稳定版发布
查看>>
黄聪:如何使用CodeSmith批量生成代码(原创系列教程)
查看>>