前言

本文完全原创,转载请说明出处,希望对大家有用。

本篇博客是个人总结,一方面以便日后查看,另一方面希望能为其他人提供一些便利。

阅读目录

正文

 SharePoint 2010 UserProfile 添加属性

以下方法是为了将自定义属性添加到SharePoint UserProfile中

   SPServiceContext context =SPServiceContext.GetContext(site);
UserProfileConfigManager upcm = new UserProfileConfigManager(context);
ProfilePropertyManager ppm = upcm.ProfilePropertyManager;
CorePropertyManager cpm = ppm.GetCoreProperties();
if (cpm.GetPropertyByName(name) == null)
{
CoreProperty cp = cpm.Create(false);
cp.Name = name;
cp.DisplayName = name;
cp.Type = PropertyDataType.StringSingleValue;
cp.Length = ;
cpm.Add(cp);
ProfileTypePropertyManager ptpm =ppm.GetProfileTypeProperties(ProfileType.User);
ProfileTypeProperty ptp = ptpm.Create(cp);
ptpm.Add(ptp);
ProfileSubtypeManager psm =ProfileSubtypeManager.Get(context);
ProfileSubtype ps = psm.GetProfileSubtype(ProfileSubtypeManager.GetDefaultProfileName(ProfileType.User));
ProfileSubtypePropertyManager pspm = ps.Properties;
ProfileSubtypeProperty psp = pspm.Create(ptp);
psp.IsUserEditable = true;
psp.PrivacyPolicy = PrivacyPolicy.OptIn;
psp.DefaultPrivacy = Privacy.Organization;
pspm.Add(psp);
}

如果需要新增的属性是一个Taxonomy类型的字段,则加入以下代码:

    TaxonomySession taxonomySession = new TaxonomySession(site);
TermStore termStore = taxonomySession.DefaultSiteCollectionTermStore;
Group group = termStore.Groups[your group name];
TermSet termSet = group.TermSets[your Termset name];
cp.TermSet = termSet;
 修改默认母板页

通常我们在发布自定义母板页的同时希望将站点默认模板页修改为自定义母板页

     public void changeCustomMasterPage(SPWeb web, string masterpageurl,bool isCustomMasterPage)
{
SPFile newMasterPageFile = web.GetFile(master);
if (newMasterPageFile.Exists)
{
if (isCustomMasterPage)
web.CustomMasterUrl = newMasterPageFile.ServerRelativeUrl;
else
web.MasterUrl = newMasterPageFile.ServerRelativeUrl;
web.Update();
}
}
 Taxonomy字段绑定TermSet
     public static void BindTermSet(TaxonomyField field, TermSet termSet, bool isPathRendered)
{
try
{
field.SspId = termSet.TermStore.Id;
field.TermSetId = termSet.Id;
field.TargetTemplate = string.Empty;
field.AnchorId = Guid.Empty;
field.IsPathRendered = isPathRendered;
field.Update(true);
}
catch (Exception ex)
{
throw ex;
}
}

Query Author

<Where>
<Eq>
<FieldRef Name="Author" LookupId="True" />
<Value Type="User"></Value>
</Eq>
</Where> <Where>
<Eq>
<FieldRef Name="Author" LookupId="True" />
<Value Type="Lookup"></Value>
</Eq>
</Where> <Where>
<Eq>
<FieldRef Name="Author" />
<Value Type="Integer">
<UserID />
</Value>
</Eq>
</Where>

最新文章

  1. 运用Mono.Cecil 反射读取.NET程序集元数据
  2. 使用shell/python获取hostname/fqdn释疑
  3. iOS项目中常用的第三方开源库
  4. 小白学数据分析-----&gt;移动游戏的使用时长分析
  5. 仿APP系列 - 超级强大的拖动插件(支持块级的拖拉,左右拖拉)
  6. 5月18日:top10面试算法-LRUcache的实现
  7. Spring事务管理 -- 挺好
  8. oracle 树形SQL
  9. Pull解析-解析xml文件
  10. 原生javascript焦点轮播图
  11. Apache Hadoop压缩包与Eclipse结合,导入jar包归整总结(手动)
  12. LA 3998 Prime k-tuple
  13. Android Handler Message总结一下
  14. SGU 200. Cracking RSA(高斯消元+高精度)
  15. NTSC色域(CIE1931)计算公式
  16. ElasticSearch的Marvel更新license
  17. 【译】Java中的字符串字面量
  18. 浅谈移动端适配-rem
  19. JSON的简单书写(初学),使用Java语言反序列化
  20. 机器学习——KMeans聚类,KMeans原理,参数详解

热门文章

  1. max_int和-1
  2. swift 单例模式
  3. CXSprite.cpp文件
  4. Node.js用fs.renameSync报cross-device link not permitted错
  5. sensor dma alloc failed问题
  6. hdoj 1272 小希的迷宫 又一个并查集的简单应用
  7. java学习之局部变量以及全局变量
  8. Cannot proceed with delivery: an existing transporter instance is currently uploading this package
  9. 1.thinkphp 权限分析
  10. MyBatis的优缺点