您的位置:首页 > 编程语言

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

2012-08-02 11:52 399 查看
最近有个项目要实现:sharepoint2010的“我喜欢(Ilikeit)”、“标签(TagsandNots)”、“记事本”以及“文档等级”活动内容如何通过代码获取?

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

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

看看UserProfile的结构图:



标签:我喜欢

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





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





自定义标签





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





记事本内容





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





文档等级活动

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





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





代码部分:

得到标签的活动内容


//*****************************************************得到标签的活动内容



stringcurrentSite="http://win-moss:8010/";;



using(SPSiteaSite=newSPSite(currentSite))



{



SPServiceContextcurrentContext=SPServiceContext.GetContext(aSite);



//GettheUserProfileManagerfromSPServiceContext.



UserProfileManageruserProfMan=newUserProfileManager(currentContext);



//Getthecurrentuser.



stringuserName=Environment.UserDomainName+"\\"+Environment.UserName;



UserProfilecurrentUser=userProfMan.GetUserProfile(userName);






SocialTagManagermySocialTagManager=newSocialTagManager(currentContext);



//string[]colleagueAccountNames=newstring[currentUser.Colleagues.GetItems().GetLength(0)];



SocialTag[]mySocialTags=mySocialTagManager.GetTags(currentUser);






stringtemp=string.Empty;



foreach(SocialTagiteminmySocialTags)



{



temp+="||活动:"+item.Title+"||"+item.LastModifiedTime;






}



Console.WriteLine(temp);



temp="";



SocialTerm[]myTerms=mySocialTagManager.GetTerms(currentUser);



foreach(SocialTermiteminmyTerms)



{



temp+=">>标签:"+item.Term.Name;






}






Console.WriteLine(temp);



Console.Read();






}



得到记事本的活动内容

//*********************************************************得到记事本的活动内容

[code]stringcurrentSite="http://win-moss:8010/";;
using(SPSiteaSite=newSPSite(currentSite))

{

SPServiceContextcurrentContext=SPServiceContext.GetContext(aSite);

//GettheUserProfileManagerfromSPServiceContext.

UserProfileManageruserProfMan=newUserProfileManager(currentContext);

//Getthecurrentuser.

stringuserName=Environment.UserDomainName+"\\"+Environment.UserName;

UserProfilecurrentUser=userProfMan.GetUserProfile(userName);

SocialCommentManagersocialCommentManager=newSocialCommentManager(currentContext);

SocialComment[]allComments=socialCommentManager.GetComments(currentUser);

stringtemp=string.Empty;

foreach(SocialCommentiteminallComments)

{

temp+="||"+item.Title+item.Comment;


}

Console.WriteLine(temp);

Console.Read();

}

[/code]

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


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

[code]stringcurrentSite="http://win-moss:8010/";;
using(SPSiteaSite=newSPSite(currentSite))

{

SPServiceContextcurrentContext=SPServiceContext.GetContext(aSite);

//GettheUserProfileManagerfromSPServiceContext.

UserProfileManageruserProfMan=newUserProfileManager(currentContext);

//Getthecurrentuser.

stringuserName=Environment.UserDomainName+"\\"+Environment.UserName;

UserProfilecurrentUser=userProfMan.GetUserProfile(userName);

SocialRatingManagersocialRatingManager=newSocialRatingManager(currentContext);

SocialRating[]allRatings=socialRatingManager.GetRatings(currentUser);

stringtemp=string.Empty;

foreach(SocialRatingiteminallRatings)

{

temp+="||"+item.Title+">>"+item.Rating;


}

Console.WriteLine(temp);

Console.Read();

}

[/code]
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐