我正在使用SSIS脚本任务来尝试创建SharePoint子网站。错误不告诉我任何事情。我知道问题在于ClientContext行。带有SSIS的SQL Server服务器是与SharePoint服务器不同的服务器。有什么想法吗?
using System;
using System.Data;
using Microsoft.SqlServer.Dts.Runtime;
using System.Windows.Forms;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Client;
using System.Collections.Generic;
using Microsoft.SharePoint.Client.Utilities;
namespace ST_a1ecfb3e46dc4211ac17435ad3bb67ec
{
[Microsoft.SqlServer.Dts.Tasks.ScriptTask.SSISScriptTaskEntryPointAttribute]
public partial class ScriptMain : Microsoft.SqlServer.Dts.Tasks.ScriptTask.VSTARTScriptObjectModelBase
{
public void Main()
{
try
{
string SiteDescription = "This is my first site creation using Client Object Model.";
int SiteLanguage = 1033;
string SiteTitle = "Test Site";
string SiteUrl = "Test";
bool SitePermissions = true;
string mywebTemplate = "STS#0";
ClientContext clientContext = new ClientContext("http://extranet.domain.local/");
//Retreive the web from the Client Context. This web is the root web by default.
/*Web oWebsite = clientContext.Web;
//Create a new webCreateInformation object to specify the properties of the new site being created.
WebCreationInformation webCreateInfo = new WebCreationInformation();
webCreateInfo.Description = SiteDescription;
webCreateInfo.Language = SiteLanguage;
webCreateInfo.Title = SiteTitle;
webCreateInfo.Url = SiteUrl;
webCreateInfo.UseSamePermissionsAsParentSite = SitePermissions;
webCreateInfo.WebTemplate = mywebTemplate;
//Adding a new site under the root web
Web oNewWebsite = oWebsite.Webs.Add(webCreateInfo);*/
Dts.TaskResult = (int)ScriptResults.Success;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message.ToString(), "Error", MessageBoxButtons.OK);
}
}
enum ScriptResults
{
Success = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Success,
Failure = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Failure
};
}
}