zoukankan      html  css  js  c++  java
  • SharePoint 常用操作杂谈

    前言

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

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

    阅读目录

    正文

     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 = 100; 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">123</Value>
      </Eq>
    </Where>
    
    <Where>
      <Eq>
        <FieldRef Name="Author" LookupId="True" />
        <Value Type="Lookup">123</Value>
      </Eq>
    </Where>
    
    <Where>
      <Eq>
        <FieldRef Name="Author" />
        <Value Type="Integer">
          <UserID />
        </Value>
      </Eq>
    </Where>
  • 相关阅读:
    spring 声明式事务的坑 @Transactional 注解
    这样学Linux基本命令,事半功倍
    NIO buffer 缓冲区 API
    Java技术——你真的了解String类的intern()方法吗
    Spring中配置数据源的4种形式
    Java集合框架List,Map,Set等全面介绍
    阿里面试题:关于类中静态,非静态,构造方法的执行顺序
    web.xml加载顺序
    MyBatis 延迟加载,一级缓存,二级缓存设置
    mybatis 调用存储过程
  • 原文地址:https://www.cnblogs.com/renzh/p/3423468.html
Copyright © 2011-2022 走看看