これが私の現在の設定です:
- SharePoint 2007 (MOSS Enterprise) ボックス上の 1 つのサイト コレクション (合計サイズ 32 GB)
- ボックス上の 1 つのサイト コレクションの一部である、多数のサブサイト (重要な場合はほとんどがチーム サイト テンプレートから作成されたもの) を含む 1 つのメイン サイト
私がやろうとしていること*:
**より良い順序や方法があれば、変更しても構いません*
- 同じ SP インスタンス上に、メインの既定のサイトを持つ新しいサイト コレクションを作成します (これは、SP オブジェクト モデルで簡単に実行できます)。
- rootweb (a) をメイン サイトの下の新しい場所のサブサイトに移動します。
現在の構造:
rootweb (a)
\
many sub sites (sub a)
新しい構造は次のようになります。
newrootweb(b)
\
oldrootweb (a)
\
old many sub sites (sub a)
ステップ#2のコードは次のとおりです。
注: * 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);
}