我想在一项应该是“在公园里散步”的任务上得到一些帮助,但最后给我带来了一些麻烦。情况示意图:
客户有一个专门的网站集,用于他的 Web 创作是"/sites/customersite"。在这个站点下创建了一个子站点来放置所有不同的可用模板"/sites/customersite/templates"。一个人可以创建一个基于固定模板“ /sites/customersite/templates/templateweb1 ”的网站。Web 将在 web 下创建,格式为“sites/customersite/{yyyy}/{MM}/HHmmss”
考虑从控制台应用程序运行以下代码:
// 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",到目前为止一切都很好。然后文件夹名称是"/sites/customersite/_catalogs/theme/15"。但是当获取实际文件夹时,“ ServerRelativeUrl ”包含以下值“/sites/customersite/2015/10/161446/sites/customersite/_catalogs/theme/15” 当然给出休错误。
因此,如果有人能启发我了解我所缺少的东西,我将非常感激。