繁体   English   中英

SharePoint 2007对象模型:如何制作新的网站集,将原始主网站移动为新网站集的子网站?

[英]SharePoint 2007 Object Model: How can I make a new site collection, move the original main site to be a subsite of the new site collection?

这是我当前的设置:

  • SharePoint 2007(MOSS Enterprise)框上的一个网站集(总大小为32 GB)
  • 一个主站点上有许多子站点(如果需要的话,大多数子站点是从团队站点模板创建的),该主站点是盒子上一个站点集合的一部分

我正在尝试做的事情*:

**如果有更好的订单或以下方法,我愿意更改它*

  1. 在同一SP实例上创建一个具有主要默认站点的新网站集(此操作很容易在SP对象模型中完成)
  2. 将rootweb(a)移到主站点下新位置的子站点

当前结构:

rootweb (a)
          \
          many sub sites (sub a)

新的结构应如下所示:

newrootweb(b)
       \
        oldrootweb (a)
            \
             old many sub sites (sub a)

这是第二步的代码:

注意:*在SharePoint.Administration下的对象模型中使用SPImport,此处使用的是*在激发错误事件处理程序时,此代码当前错误为“对象引用不是对象的实例”

using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Deployment;

public static bool FullImport(string baseFilename, bool CommandLineVerbose, bool bfileCompression, string fileLocation, bool HaltOnNonfatalError,
           bool HaltOnWarning, bool IgnoreWebParts, string LogFilePath, string destinationUrl)
        {
            #region my try at import

            string message = string.Empty;
            bool bSuccess = false;
            try
            {
                SPImportSettings settings = new SPImportSettings();
                settings.BaseFileName = baseFilename;
                settings.CommandLineVerbose = CommandLineVerbose;
                settings.FileCompression = bfileCompression;
                settings.FileLocation = fileLocation;
                settings.HaltOnNonfatalError = HaltOnNonfatalError;
                settings.HaltOnWarning = HaltOnWarning;
                settings.IgnoreWebParts = IgnoreWebParts;
                settings.IncludeSecurity = SPIncludeSecurity.All;
                settings.LogFilePath = fileLocation;
                settings.WebUrl = destinationUrl;
                settings.SuppressAfterEvents = true;
                settings.UpdateVersions = SPUpdateVersions.Append;
                settings.UserInfoDateTime = SPImportUserInfoDateTimeOption.ImportAll;

                SPImport import = new SPImport(settings);

                import.Started += delegate(System.Object o, SPDeploymentEventArgs e)
                {
                    //started
                    message = "Current Status: " + e.Status.ToString() + " " + e.ObjectsProcessed.ToString() + " of " + e.ObjectsTotal + " objects processed thus far.";
                    message = e.Status.ToString();
                };
                import.Completed += delegate(System.Object o, SPDeploymentEventArgs e)
                {
                    //done
                    message = "Current Status: " + e.Status.ToString() + " " + e.ObjectsProcessed.ToString() + " of " + e.ObjectsTotal + " objects processed.";
                };
                import.Error += delegate(System.Object o, SPDeploymentErrorEventArgs e)
                {
                    //broken
                    message = "Error Message: " + e.ErrorMessage.ToString() + " Error Type: " + e.ErrorType + " Error Recommendation: " + e.Recommendation
                        + " Deployment Object: " + e.DeploymentObject.ToString();
                    System.Console.WriteLine("Error");
                };
                import.ProgressUpdated += delegate(System.Object o, SPDeploymentEventArgs e)
                {
                    //something happened
                    message = "Current Status: " + e.Status.ToString() + " " + e.ObjectsProcessed.ToString() + " of " + e.ObjectsTotal + " objects processed thus far.";
                };

                import.Run();

                bSuccess = true;
            }
            catch (Exception ex)
            {
                bSuccess = false;
                message = string.Format("Error: The site collection '{0}' could not be imported. The message was '{1}'. And the stacktrace was '{2}'", destinationUrl, ex.Message, ex.StackTrace);
            }

            #endregion

            return bSuccess;
        }

这是调用上述方法的代码:

[TestMethod]
public void MOSS07_ObjectModel_ImportSiteCollection()
{
    bool bSuccess = ObjectModelManager.MOSS07.Deployment.SiteCollection.FullImport("SiteCollBAckup.cmp", true, true, @"C:\SPBACKUP\SPExports", false, false, false, @"C:\SPBACKUP\SPExports", "http://spinstancename/TestImport");
    Assert.IsTrue(bSuccess);
}

您是否尝试过使用Codeplex中的SharePoint Content Deployment Wizard ,而不是尝试对此进行编码?
导出当前层次结构,然后使用此工具将其导入到新位置。

问候,M

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM