0

我正在使用 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
        };


    }
}
4

0 回答 0