处方1-1使用对象模型新建站点集
2008-12-16 20:34
501 查看
SharePoint2007 Development Recipes 读书笔记 处方1-1
使用对象模型新建站点集
关键代码:
private static int AddSiteCollection(string[] args) {
try {
// Get a handle to the root site on server
string[] arrSitePath = args[0].Split('/');
string strServerPath = (arrSitePath[0]
+ ("//" + arrSitePath[2]));
SPSite site = new SPSite(strServerPath);
// Get the list of site collections for the web
// application
SPSiteCollection siteCollection =
site.WebApplication.Sites;
// Step 3: Add the site collection
// args(0) = Site url
// args(1) = Title
// args(2) = Description
// args(3) = Web template
// args(4) = Owner login
// args(5) = Owner name
// args(6) = Owner email
siteCollection.Add(args[0], args[1], args[2], 1033,
args[3], args[4], args[5], args[6]);
// Step 5: Confirm site collection information
Console.WriteLine();
Console.WriteLine(("Site collection \'"
+ (args[0] + "\' successfully created.")));
Console.WriteLine();
DisplayParams(args);
// Release memory used by SPSite object
site.Dispose();
return 0;
}
说明:通过主站点的URL取得SPSite对象然后通过SPSite.WebApplication.Sites属性得到SPSiteCollection对象,最后通过SPSiteCollection.Add()方法即可以在主站点上添加网站集。
限制:由于SPSiteCollection.Add()方法的安全限制,导致程序只能在SharePoint服务器场中的前端Web服务器上执行,且必须要在有相应权限的用户登陆情况下才能正常工作,所以不是真正意义上的Web服务。
使用对象模型新建站点集
关键代码:
private static int AddSiteCollection(string[] args) {
try {
// Get a handle to the root site on server
string[] arrSitePath = args[0].Split('/');
string strServerPath = (arrSitePath[0]
+ ("//" + arrSitePath[2]));
SPSite site = new SPSite(strServerPath);
// Get the list of site collections for the web
// application
SPSiteCollection siteCollection =
site.WebApplication.Sites;
// Step 3: Add the site collection
// args(0) = Site url
// args(1) = Title
// args(2) = Description
// args(3) = Web template
// args(4) = Owner login
// args(5) = Owner name
// args(6) = Owner email
siteCollection.Add(args[0], args[1], args[2], 1033,
args[3], args[4], args[5], args[6]);
// Step 5: Confirm site collection information
Console.WriteLine();
Console.WriteLine(("Site collection \'"
+ (args[0] + "\' successfully created.")));
Console.WriteLine();
DisplayParams(args);
// Release memory used by SPSite object
site.Dispose();
return 0;
}
说明:通过主站点的URL取得SPSite对象然后通过SPSite.WebApplication.Sites属性得到SPSiteCollection对象,最后通过SPSiteCollection.Add()方法即可以在主站点上添加网站集。
限制:由于SPSiteCollection.Add()方法的安全限制,导致程序只能在SharePoint服务器场中的前端Web服务器上执行,且必须要在有相应权限的用户登陆情况下才能正常工作,所以不是真正意义上的Web服务。
相关文章推荐
- 处方1-2使用Web Services新建站点集
- 处理模型——对小而快的对象使用Ray-Traced进行碰撞检测
- SharePoint 2013 Silverlight中使用Net客户端对象模型
- 《Entity Framework 6 Recipes》中文翻译系列 (38) ------ 第七章 使用对象服务之动态创建连接字符串和从数据库读取模型
- Spring 如何将无法使用new操作符新建的对象作为spring的bean (使用FactoryBean接口)
- Sharepoint2010应用开发四:使用客户对象模型(Client Object Model)向SharePoint列表写数据
- Android -使用DOM(文档对象模型)解析XML文件
- 使用服务器端对象模型,编写程序管理SharePoint列表
- 使用客户端对象模型回写SharePoint列表
- 使用对象的 RDS 编程模型
- 使用对象模型来创建内容类型
- 新建ftp站点,使用代码从ftp服务器下载文件(mfc)
- Django入门-5:模型的基本使用3-模型成员&创建对象
- alv使用标准按钮调用excel查看数据时,需要开通对vba工程对象模型的访问
- XML文档对象模型----使用XmlNodeReader
- SP2010开发和VS2010专家"食谱"--第七章节--使用客户端对象模型
- SharePoint对象模型设置字段是否在新建编辑显示页面中显示
- 使用对象模型操作文档库(DocumentLibrary)
- 使用页面对象模型(pageFactory)