zoukankan      html  css  js  c++  java
  • 通过代码获取sharepoint2010的“我喜欢(I like it)”、“标签(Tags and Notes)”、“记事本”以及“文档等级”活动内容

    最近有个项目要实现:sharepoint2010的“我喜欢(I like it)”、“标签(Tags and Nots)”、“记事本”以及“文档等级”活动内容如何通过代码获取?

    通过MSDN资料我们知道是通过User Profiles获取的。

    http://msdn.microsoft.com/en-us/library/microsoft.office.server.socialdata

    看看UserProfile的结构图:

    标签:我喜欢

    打开一个文档库或列表,点击【我喜欢】,如下图:

    image

    点击后会产生一个标签活动,去个人站点下查看会看到如下图内容:

    image

    自定义标签

    image

    点击后会产生一个标签活动,去个人站点下查看会看到如下图内容:

    image

    记事本内容

    image

    去个人站点下查看会看到如下图内容:

    image

    文档等级活动

    创建一个文档库,启用等级设置。如下图:

    image

    接着上传一个文档,打等级标记

    image

    代码部分:

    得到标签的活动内容
     
     //*****************************************************得到标签的活动内容
                string currentSite = "http://win-moss:8010/"; ;
                using (SPSite aSite = new SPSite(currentSite))
                {
                    SPServiceContext currentContext = SPServiceContext.GetContext(aSite);
                    //Get the UserProfileManager from SPServiceContext.
                    UserProfileManager userProfMan = new UserProfileManager(currentContext);
                    //Get the current user.
                    string userName = Environment.UserDomainName + "\\" + Environment.UserName;
                    UserProfile currentUser = userProfMan.GetUserProfile(userName);
     
                    SocialTagManager mySocialTagManager = new SocialTagManager(currentContext);
                    //string[] colleagueAccountNames = new string[currentUser.Colleagues.GetItems().GetLength(0)];
                    SocialTag[] mySocialTags = mySocialTagManager.GetTags(currentUser);
     
                    string temp = string.Empty;
                    foreach (SocialTag item in mySocialTags)
                    {
                        temp += "||活动:" + item.Title + "||" + item.LastModifiedTime;
     
                    }
                    Console.WriteLine(temp);
                    temp = "";
                    SocialTerm[] myTerms = mySocialTagManager.GetTerms(currentUser);
                    foreach (SocialTerm item in myTerms)
                    {
                        temp += ">>标签:" + item.Term.Name;
     
                    }
     
                    Console.WriteLine(temp);
                    Console.Read();
     
                }

    得到记事本的活动内容

    //*********************************************************得到记事本的活动内容
                string currentSite = "http://win-moss:8010/"; ;
                using (SPSite aSite = new SPSite(currentSite))
                {
                    SPServiceContext currentContext = SPServiceContext.GetContext(aSite);
                    //Get the UserProfileManager from SPServiceContext.
                    UserProfileManager userProfMan = new UserProfileManager(currentContext);
                    //Get the current user.
                    string userName = Environment.UserDomainName + "\\" + Environment.UserName;
                    UserProfile currentUser = userProfMan.GetUserProfile(userName);
                    SocialCommentManager socialCommentManager = new SocialCommentManager(currentContext);
                    SocialComment[] allComments = socialCommentManager.GetComments(currentUser);
                    string temp = string.Empty;
                    foreach (SocialComment item in allComments)
                    {
                        temp += "||" + item.Title + item.Comment;
     
                    }
                    Console.WriteLine(temp);
                    Console.Read();
                }

    得到文档评星级的活动内容

     ////*********************************************************得到文档评星级的活动内容
                string currentSite = "http://win-moss:8010/"; ;
                using (SPSite aSite = new SPSite(currentSite))
                {
                    SPServiceContext currentContext = SPServiceContext.GetContext(aSite);
                    //Get the UserProfileManager from SPServiceContext.
                    UserProfileManager userProfMan = new UserProfileManager(currentContext);
                    //Get the current user.
                    string userName = Environment.UserDomainName + "\\" + Environment.UserName;
                    UserProfile currentUser = userProfMan.GetUserProfile(userName);
                    SocialRatingManager socialRatingManager = new SocialRatingManager(currentContext);
                    SocialRating[] allRatings = socialRatingManager.GetRatings(currentUser);
                    string temp = string.Empty;
                    foreach (SocialRating item in allRatings)
                    {
                        temp += "||" + item.Title +">>" + item.Rating;
     
                    }
                    Console.WriteLine(temp);
                    Console.Read();
                }
  • 相关阅读:
    *****Exercise 4.1 Generate a multiplication table
    Exercise 3.4 A calculator that allows multiple calculations
    Exercise 3.3 Calculate a discounted price
    Exercise 3.2 Display a date
    理解Java异常处理机制
    eclipse远程Debug配置
    [转]java代码性能优化总结
    [转]A星寻路算法
    JVM参数配置
    Gradle笔记(1) 安装
  • 原文地址:https://www.cnblogs.com/love007/p/2619708.html
Copyright © 2011-2022 走看看