0
這裏是我的當前設置:SharePoint 2007對象模型:如何創建新的網站集,將原始主網站移動爲新網站集的子網站?
- 一個站點集合在SharePoint 2007(MOSS企業)箱(32 GB的總規模)
- 一個主站點有許多子網站(主要是從團隊網站模板創建的,如果該事項),這是一個網站集合的一部分包裝盒上的
我試圖做*:
**如果有更好的順序,或方法下面,我可以改變它*
- 創建一個新的網站集,與主默認站點,在同一個SP實例(這樣做,容易SP對象模型做)
- 移動rootweb(一)在新的子網站位置,主網站下
當前結構:
rootweb (a)
\
many sub sites (sub a)
看起來應該像什麼新的結構:
newrootweb(b)
\
oldrootweb (a)
\
old many sub sites (sub a)
這裏是我的步驟#代碼2:
注: * SPImport在SharePoint.Administration下的對象模型中,這裏正在使用 *此代碼目前與「未將對象引用實例出現了錯誤對象」,當它觸發錯誤事件處理程序
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);
}
謝謝您的回答。我知道這個工具,我可能不得不試一試,如果以編程方式執行它將無法工作。 謝謝! – program247365 2010-05-04 14:06:48
似乎出口與我的網站在開發達到一定的點,然後永遠不會繼續,並且永遠不會出錯。我讓它運行了大約3個小時,並且在日誌中沒有其他時間戳/條目。它只運行了大約15分鐘並停止了記錄/工作。啊。 – program247365 2010-05-04 19:19:53