「公園を散歩する」はずだったタスクを手伝ってもらいたいのですが、結局、かなりのトラブルが発生します。状況スケッチ:
顧客は、Web 作成専用のサイト コレクション"/sites/customersite"を持っています。このサイトの下に、利用可能なさまざまなテンプレート"/sites/customersite/templates"をすべて配置するサブサイトが作成されます。固定テンプレート " /sites/customersite/templates/templateweb1 "に基づいて、当面は Web を作成できます。Web は、 「sites/customersite/{yyyy}/{MM}/HHmmss」の形式で Web の下に作成されます。
コンソール アプリから実行された次のコードを検討してください。
// Build template from template web
var templateWeb = _context.Site.OpenWeb("/sites/customersite/templates/templateweb1");
_context.Load(templateWeb);
_context.ExecuteQuery();
// Put file connection to files that can not be fetched ex. siteIcon and spcolor file
// Will resolve to path where console is run from taking the CreationResources \bin\Debug\CreationResources
string fileConnection = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "CreationResources");
var ptci = new ProvisioningTemplateCreationInformation(templateWeb)
{
PersistComposedLookFiles = true,
FileConnector = new FileSystemConnector(fileConnection, string.Empty)
};
// Get template from live web
var provisioningTemplate = templateWeb.GetProvisioningTemplate(ptci);
provisioningTemplate.Connector = new FileSystemConnector(fileConnection, string.Empty);
targetWeb.ApplyProvisioningTemplate(provisioningTemplate);
これはクリーンなチーム サイトであり、サイト アイコンと spcolor ファイルのみが適用されているため、問題はないと思います。しかし、「ObjectFiles」では素晴らしい例外が発生します。ファイルを調べる foreach では、ファイル フォルダーの値は「{themecatalog}/15」であり、これまでのところ問題ありません。次に、folderName は"/sites/customersite/_catalogs/theme/15"です。しかし、実際のフォルダーがフェッチされると、「ServerRelativeUrl」には次の値「/sites/customersite/2015/10/161446/sites/customersite/_catalogs/theme/15」が含まれ ます。もちろん、大きなエラーが発生します。
だから誰かが私が欠けているものについて私を啓発することができれば、私はそれを非常に感謝しています.