zoukankan      html  css  js  c++  java
  • SharePoint 2013 开发——其他社交功能

    博客地址:http://blog.csdn.net/FoxDave

    上一篇讲了如何获取用户配置文件的相关属性,它属于SharePoint 2013社交功能的一个小的构成部分。社交功能是SharePoint 2013改进的一大亮点。可以在现有网站上开启社交功能或者新建一个专门用于社交用途的社区网站,社交功能包括关注(人或内容)、艾特@、#等功能、有清晰的用户积分制度等等。由于工作中不会有太多关于这方面的开发需求,并且个人觉得这部分做得挺不错,基本的需求应该是够用了(强大的或许就不在SharePoint上了微笑),所以本篇只会用两个小例子展示一下如何用客户端对象模型与SharePoint社交功能进行交互来说明SharePoint 2013社交功能的开发,当然不仅限于客户端对象模型,JSOM和REST也可以做类似的事情。

    包括之前提到的用户配置文件相关的开发,在用客户端对象模型做社交相关功能的代码交互开发时,需要引入Microsoft.SharePoint.Client、Microsoft.SharePoint.ClientRuntime和Microsoft.SharePoint.Client.UserProfiles这三个程序集,并在代码文件头部增加如下两个引用:

    using Microsoft.SharePoint.Client;
    using Microsoft.SharePoint.Client.Social;

    首先构建上下文对象:

    ClientContext clientContext = new ClientContext("<你的网站URL>");
    

    在Microsoft.SharePoint.Client.Social这个命名空间下,有SocialFeedManager、SocialFeedOptions、SocialPostCreationData和SocialFollowingManager等对象模型可供我们使用,分别跟订阅、回帖、关注等有关。

    获取指定用户的动态:

    SocialFeedManager feedManager = new SocialFeedManager(clientContext);
                SocialFeedOptions feedOptions = new SocialFeedOptions();
                feedOptions.MaxThreadCount = 10;
                ClientResult<SocialFeed> feed = feedManager.GetFeedFor("<指定的用户>", feedOptions);
                clientContext.ExecuteQuery();
                for (int i = 0; i < feed.Value.Threads.Length; i++)
                {
                    SocialThread thread = feed.Value.Threads[i];
                    string postText = thread.RootPost.Text;
                    Console.WriteLine("	" + (i + 1) + ". " + postText);
                }

    获得指定用户关注和被关注的人:

    static void Main(string[] args)
            {
                string serverUrl = "<你的网站URL>";
                string targetUser = "<指定的用户>";
                ClientContext clientContext = new ClientContext(serverUrl);
                SocialFollowingManager followingManager = new SocialFollowingManager(clientContext);
                SocialActorInfo actorInfo = new SocialActorInfo();
                actorInfo.AccountName = targetUser;
                ClientResult<int> followedCount = followingManager.GetFollowedCount(SocialActorTypes.Users);
                ClientResult<SocialActor[]> followedResult = followingManager.GetFollowed(SocialActorTypes.Users);
                ClientResult<SocialActor[]> followersResult = followingManager.GetFollowers();
                clientContext.ExecuteQuery();
                Console.WriteLine("当前用户关注的人数: ({0})", followedCount.Value);
                IterateThroughPeople(followedResult.Value);
                Console.WriteLine("
    谁关注此用户:");
                IterateThroughPeople(followersResult.Value);
                Console.ReadKey();
            }
    
            static void IterateThroughPeople(SocialActor[] actors)
            {
                foreach (SocialActor actor in actors)
                {
                    Console.WriteLine("  - {0}", actor.Name);
                    Console.WriteLine("	链接: {0}", actor.PersonalSiteUri);
                    Console.WriteLine("	头像: {0}", actor.ImageUri);
                }
            }

    更多内容请参考微软MSDN文档,写得还是很详细清晰的,如果我们在工作中遇到了相关内容的任务,能够提供很有力的参考和帮助。

  • 相关阅读:
    django-rest-framework
    史上最全的状态码
    __new__、__init__、__call__三个特殊方法
    量化投资与Python之pandas
    MongoDB 3.0 Release Notes
    TokuMX写操作无法加锁的问题
    TokuMX唯一索引不支持dropDups选项
    接着写吧
    Windows下Python IDLE设置
    20145320周岐浩免考
  • 原文地址:https://www.cnblogs.com/justinliu/p/5961609.html
Copyright © 2011-2022 走看看