惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

S
Schneier on Security
有赞技术团队
有赞技术团队
T
The Blog of Author Tim Ferriss
F
Fortinet All Blogs
D
DataBreaches.Net
F
Full Disclosure
腾讯CDC
博客园 - 【当耐特】
MyScale Blog
MyScale Blog
Stack Overflow Blog
Stack Overflow Blog
小众软件
小众软件
Hugging Face - Blog
Hugging Face - Blog
Last Week in AI
Last Week in AI
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
爱范儿
爱范儿
The GitHub Blog
The GitHub Blog
Engineering at Meta
Engineering at Meta
大猫的无限游戏
大猫的无限游戏
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
S
SegmentFault 最新的问题
The Register - Security
The Register - Security
WordPress大学
WordPress大学
博客园 - 聂微东
雷峰网
雷峰网
J
Java Code Geeks
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
P
Privacy International News Feed
酷 壳 – CoolShell
酷 壳 – CoolShell
A
Arctic Wolf
Scott Helme
Scott Helme
C
Cyber Attacks, Cyber Crime and Cyber Security
T
Tor Project blog
博客园 - 三生石上(FineUI控件)
Know Your Adversary
Know Your Adversary
AWS News Blog
AWS News Blog
G
Google Developers Blog
www.infosecurity-magazine.com
www.infosecurity-magazine.com
C
CERT Recently Published Vulnerability Notes
O
OpenAI News
Project Zero
Project Zero
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
Application and Cybersecurity Blog
Application and Cybersecurity Blog
云风的 BLOG
云风的 BLOG
N
News and Events Feed by Topic
MongoDB | Blog
MongoDB | Blog
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
Microsoft Security Blog
Microsoft Security Blog
Cisco Talos Blog
Cisco Talos Blog
P
Palo Alto Networks Blog
Schneier on Security
Schneier on Security

博客园 - wengnet

UE4 C++ 输出日志 UE4 获取SurfaceType UE4 C++ 日志输出 基于vue-cli快速构建 CentOS7 使用YUM 安装JDK node-sass 安装报错解决办法 禁止Steam VR随着虚幻4自动启动 SharePoint 2013 对话框 目标主体名称不正确,无法生成 SSPI 上下文。 开发SharePoint 自定义WebService 的小工具 提高SharePoint2013服务器性能 SharePoint 2013 和 SharePoint 2010 功能对比 SharePoint 的PowerShell命令之获取所有网站模版 SharePoint Survey – Custom Action 制作X509证书 SharePoint2010 文档集操作-创建 自定义SharePoint2010文档库的上传页面 Windows Server 无法启用 .Net Framework3.5的问题 JQuery 删除SharePoint菜单
DocumentSet 操作代码(二)
wengnet · 2013-03-29 · via 博客园 - wengnet
public static DocumentSet GetDocumentSetById(this SPList list, int ID)
{
     return DocumentSet.GetDocumentSet(list.GetItemById(ID).Folder);
}
public static bool IsDocumentSet(this SPListItem item)
{
  bool documentSetItem = false;
  DocumentSet documentSet = null;
 
  if (null != item && item.IsFolder())
 {
  documentSet = DocumentSet.GetDocumentSet(item.Folder);
 
  if (null != documentSet)
    documentSetItem = true;
 }
 return documentSetItem;
}

public static bool IsDocumentSetItem(this SPListItem item)
{
 bool documentSetItem = false;
 DocumentSet documentSet = null;
 
 if (null != item && null != item.File)
 {
   documentSet = DocumentSet.GetDocumentSet(item.File.ParentFolder);
 
   if (null != documentSet)
    documentSetItem = true;
 }
 return documentSetItem;
}
public static SPFile MoveFile(SPWeb web, string sourceUrl, DocumentSet docSet)
{
 SPFile file = web.GetFile(sourceUrl);
 string destinationFolderUrl = docSet.Folder.Url;
 
 destinationFolderUrl = (!destinationFolderUrl.EndsWith("/")) ? destinationFolderUrl + "/" : destinationFolderUrl;
 file.MoveTo(destinationFolderUrl + file.Name, true);
 web.Update();
 
 return web.GetFile(web.Url + "/" + destinationFolderUrl + file.Name);
}
public static SPFile CopyFile(SPWeb web, string sourceUrl, DocumentSet docSet)
{
 SPFile file = web.GetFile(sourceUrl);
 string destinationFolderUrl = docSet.Folder.Url;
 
 destinationFolderUrl = (!destinationFolderUrl.EndsWith("/")) ? destinationFolderUrl + "/" : destinationFolderUrl;
 file.CopyTo(destinationFolderUrl + file.Name, true);
 web.Update();
 
 return web.GetFile(web.Url + "/" + destinationFolderUrl + file.Name);
}

public static SPFile CreateDocumentLink(this SPList list, string documentName, string documentUrl, DocumentSet docSet)
{
 SPFile file = null;
 SPListItem item = null;
 if (list is SPDocumentLibrary)
 {
  SPDocumentLibrary docLib = (SPDocumentLibrary)list;
  if (docLib.ContentTypesEnabled)
  {
   SPContentType myCType = list.ContentTypes["Link to a Document"];
   if (myCType != null)
   {
 
    //replace string template with values
    string redirectAspx = RedirectAspxPage();
    redirectAspx.Replace("{0}", documentUrl);
 
    //should change the name of the .aspx file per item
    file = docSet.Folder.Files.Add(documentName + ".aspx", UTF8Encoding.UTF8.GetBytes(redirectAspx));
 
    //set list item properties
    item = file.Item;
 
 
    item["ContentTypeId"] = myCType.Id;
    item.Update();
 
    if (item["ContentType"].ToString() == "Link to a Document")
    {
     SPFieldUrlValue fieldUrl = new SPFieldUrlValue() { Description = documentName, Url = documentUrl };
 
     item["URL"] = fieldUrl;
     item.Update();
    }
   }
  }
 }
 
 return file;
}
 
public static string RedirectAspxPage()
{
 StringBuilder builder = new StringBuilder();
 builder.Append("<%@ Assembly Name='Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c' %>");
 builder.Append("<%@ Register TagPrefix='SharePoint' Namespace='Microsoft.SharePoint.WebControls' Assembly='Microsoft.SharePoint' %>");
 builder.Append("<%@ Import Namespace='System.IO' %>");
 builder.Append("<%@ Import Namespace='Microsoft.SharePoint' %>");
 builder.Append("<%@ Import Namespace='Microsoft.SharePoint.Utilities' %>");
 builder.Append("<%@ Import Namespace='Microsoft.SharePoint.WebControls' %>");
 builder.Append("<html xmlns:mso=\"urn:schemas-microsoft-com:office:office\" xmlns:msdt=\"uuid:C2F41010-65B3-11d1-A29F-00AA00C14882\">");
 builder.Append("<head>");
 builder.Append("<meta name=\"WebPartPageExpansion\" content=\"full\" /> <meta name='progid' content='SharePoint.Link' /> ");
 builder.Append("<!--[if gte mso 9]><SharePoint:CTFieldRefs runat=server Prefix=\"mso:\" FieldList=\"FileLeafRef,URL\"><xml>");
 builder.Append("<mso:CustomDocumentProperties>");
 builder.Append("<mso:ContentTypeId msdt:dt=\"string\">0x01010A00DC3917D9FAD55147B56FF78B40FF3ABB</mso:ContentTypeId>");
 builder.Append("<mso:IconOverlay msdt:dt=\"string\">|docx|linkoverlay.gif</mso:IconOverlay>");
 builder.Append("<mso:URL msdt:dt=\"string\">{0}, {0}</mso:URL>");
 builder.Append("</mso:CustomDocumentProperties>");
 builder.Append("</xml></SharePoint:CTFieldRefs><![endif]-->");
 builder.Append("</head>");
 builder.Append("<body>");
 builder.Append("<form id='Form1' runat='server'>");
 builder.Append("<SharePoint:UrlRedirector id='Redirector1' runat='server' />");
 builder.Append("</form>");
 builder.Append("</body>");
 builder.Append("</html>");
 return builder.ToString();
}