日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

SharePoint的API

發布時間:2024/3/26 编程问答 24 豆豆
生活随笔 收集整理的這篇文章主要介紹了 SharePoint的API 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

之前培訓寫過一個作業,關于SharePoint的API的,之后做restore和backup也經常用到,在這里給總結下如何創建。

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Administration;
using System.Xml;
using System.IO;

namespace SP1
{
class Program
{
static void Main(string[] args)
{
string url = @"http://win-gao9n2dooq5:7000/mysite/mysubsite/default.aspx";
XmlDocument doc = new XmlDocument();
XmlElement rootNode = doc.CreateElement("Folder");
ToSite(url, rootNode, doc);
doc.LoadXml(rootNode.OuterXml);
doc.Save(@"C:\shi.xml");
}
//獲取WebApp下的Site
public static void ToSite(string url, XmlElement myNode, XmlDocument myDocument)
{
//string url=@"http://win-gao9n2dooq5:7000/mysite/mysubsite/default.aspx";
SPWebApplication webApp = SPWebApplication.Lookup(new Uri(url));
foreach (SPSite site in webApp.Sites)
{
using (site)
{
XmlElement childElement = myDocument.CreateElement("Site");
childElement.SetAttribute("Url", site.Url.ToString());
childElement.SetAttribute("AllWebs", site.AllWebs.ToString());
childElement.SetAttribute("ID", site.ID.ToString());
myNode.AppendChild(childElement);
if (site != null)
{
ToWeb(site, childElement, myDocument);
}
}
}
}
//獲取Site下的Web
private static void ToWeb(SPSite site, XmlElement childElement, XmlDocument myDocument)
{

using (site)
{
SPWeb rootweb = site.RootWeb;
foreach (SPWeb web in rootweb.Webs)
{
using (web)
{
Console.WriteLine(web.Name.ToString());
XmlElement childElement1 = myDocument.CreateElement("Web");
childElement1.SetAttribute("Language", web.Language.ToString());
childElement1.SetAttribute("Title", web.Title.ToString());
//childElement1.SetAttribute("ParentWeb", web.ParentWeb.ToString());
childElement.AppendChild(childElement1);
//web.Update(); //更新Web屬性
if (web.Webs.Count != 0)
{
ToWeb(site, childElement, myDocument);
}
ToList(web, childElement, myDocument);
}
}
}
}
//獲取Web下的List,folder,web等
private static void ToList(SPWeb web, XmlElement childElement, XmlDocument myDocument)
{
//using (site)
//{
foreach (SPList list in web.Lists)
{
if (list.Hidden ==true)
{
Console.WriteLine(list.Title.ToString());
XmlElement childElement2 = myDocument.CreateElement("List");
childElement2.SetAttribute("Title", list.Title.ToString());
childElement.AppendChild(childElement2);
ToFolder(list,childElement2,myDocument);
}
if (list != null)
{
ToList( web, childElement, myDocument);
}
}
//}
}

public static void ToFolder(SPList list ,XmlElement childElement ,XmlDocument myDocument)
{
SPFolder rootFolder = list.RootFolder;
foreach (SPFolder folder in rootFolder.SubFolders)
{
Console.WriteLine(folder.ServerRelativeUrl);
}
}
}
}

轉載于:https://www.cnblogs.com/davidshi/p/3349192.html

總結

以上是生活随笔為你收集整理的SharePoint的API的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。