通过代码获取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();
            }
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值