SharePoint 2013 中使用代码取特定用户的social tag
来源:互联网 发布:ae mac中文版下载 编辑:程序博客网 时间:2024/05/16 13:56
本文讲述如何使用SharePoint 2013 中使用代码取特定用户的social tag。
1. 首先确保Social feature 配置正确,可以打tag,笔者打了三个tag
2. 新建一个Console application,将其target platform 改成X64
3. 引用如下Dll
Microsoft.Office.Server.UserProfiles.dll
Microsoft.SharePoint.dll
Microsoft.SharePoint.Taxonomy.dll
Microsoft.Office.Server.dll3. Program.cs代码 :
using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;using Microsoft.SharePoint;using Microsoft.Office.Server.SocialData;using Microsoft.SharePoint.Utilities;using Microsoft.Office.Server.UserProfiles;namespace GetTags{ class Program { static void Main(string[] args) { if (args.Length == 0) { Console.WriteLine("Please use: GetTags SiteUrl"); } else { using (SPSite site = new SPSite(args[0])) { using (SPWeb web = site.OpenWeb()) { // 取 SocialTagManager SPServiceContext serviceContext = SPServiceContext.GetContext(site); SocialTagManager stm = new SocialTagManager(serviceContext); Console.WriteLine("Get profile manager"); UserProfileManager profileManager = new UserProfileManager(serviceContext); // 如果在web part中 userloginName可以传 SPContext.Current.Web.CurrentUser.LoginName // 在Console application中使用用户的alias,不带域名 Console.WriteLine("Get user profile"); UserProfile profile = profileManager.GetUserProfile("userloginName"); Uri uri = new Uri(web.Url); Console.WriteLine("Start request"); // 取对应的用户的social tags var itemTags = stm.GetTags(profile); // 打印 soical tags Console.WriteLine("----------------------------------------------"); Console.WriteLine("Tags count: " + itemTags.Length); foreach (var tag in itemTags) { Console.WriteLine(string.Format("Title: {0} - URL: {1}, Term: {2}", tag.Title, tag.Url, tag.Term.GetDefaultLabel(1033))); } // 可以使用 itemTags[0].Delete(); 删除tag // 可以使用 itemTags[0].Update(); 更新tag } } } Console.WriteLine("Press any key to exit"); Console.ReadKey(); } }}
4. 结果为:
5. 可以在 .../my/_layouts/15/thoughts.aspx 中删除tag
- SharePoint 2013 中使用代码取特定用户的social tag
- sharepoint 2007 在web.config中阻止特定的用户/组访问站点
- 取SharePoint用户Profile
- SharePoint 2013 之社交功能(Social feature)
- Custom Social Newsfeed in SharePoint 2013
- Github 中Tag的使用
- 在asp.net里使用指定的用户运行访问Sharepoint网站的代码
- 使用Sharepoint的user/group管理用户
- SharePoint 2013 使用 PowerShell 更新用户
- linux 操作系统中检查特定用户上次登录的时间lastlog命令的使用
- sharepoint中列表的使用
- 使用VS2012 开发SharePoint 2013 客户化的action (代码)
- JAVA字符串中取特定字符的位置
- Ajax中一些特定代码的解释
- SharePoint 2013 Tagging - Social Tags, Hashtags, and Keywords
- tag 的取值注意
- openvswitch中bridge的TAG使用
- Idea中使用github的标签(tag)
- Java Web项目调试
- sqlite如何创建成内存数据库和临时数据库(即非持久化)
- 【Android】图片切角,切指定的边。
- C++ - 在文件中 查找 指定的词 出现的行号 (shared_ptr)
- hdu 4287 Intelligent IME (字典树)
- SharePoint 2013 中使用代码取特定用户的social tag
- Android Activity 之间切换的各种效果
- 分布式设计与开发(一)------宏观概述
- HDU1788 Chinese remainder theorem again 中国剩余定理
- 阻塞/非阻塞读写总结、tcp网络编程的本质、muduo::Buffer设计简介
- Android手机百度地图
- MySQL CMake参数说明手册
- 对于tableItem的新窗口打开问题
- JS创建类和对象