Social Tags from code behind
-
30 decembrie 2010 12:06
Hi,
what If I want to get count of total number of "Likes" of some page irrespective of user profiles?
I know we can get the Tags / Comments for perticular user profile by using SocialTagManager class
but this is something different I want
any idea?
Warm Regards, Bhushan http://www.passionatetechie.blogspot.com
Toate mesajele
-
31 decembrie 2010 17:29
I don't think with the current SP 2010 object model you can get the list of Tags (Favorites) at the individual document level. You can need to get the list of tag counts at the individual user-level, then aggregate that information to arrive at the count for list of favorites at document-level
//Get all the social tags in which the terms have been used.
List<SocialTag> socialTagsList = new List<SocialTag>();
foreach (UserProfile userProf in myUserProfileManager)
{
try
{
SocialTag[] userTags = mySocialTagManager.GetTags(userProf, 0);
foreach (SocialTag aTag in userTags)
{
socialTagsList.Add(aTag);
}
}
catch (UserNotFoundException unfE )
{
//If the user is not found, handle exception.
}
}//For each SocialTag, get the owner and get the number of times that owner has tagged a URL.
foreach (SocialTag aTag in socialTagsList)
{
if (aTag != null)
{
if (!SocialTagStats.ContainsKey(aTag.Owner.DisplayName))
{
int tagCount = mySocialTagManager.GetCount(aTag.Owner);
SocialTagStats.Add(aTag.Owner.DisplayName, tagCount);
}
}
}
Sundar Narasiman- Marcat ca răspuns de Aaron Han - MSFT 7 ianuarie 2011 03:06