本文整理汇总了C#中OfficeDevPnP.Core.Framework.Provisioning.ObjectHandlers.ProvisioningTemplateCreationInformation.ExecutePostProvisionEvent方法的典型用法代码示例。如果您正苦于以下问题:C# ProvisioningTemplateCreationInformation.ExecutePostProvisionEvent方法的具体用法?C# ProvisioningTemplateCreationInformation.ExecutePostProvisionEvent怎么用?C# ProvisioningTemplateCreationInformation.ExecutePostProvisionEvent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OfficeDevPnP.Core.Framework.Provisioning.ObjectHandlers.ProvisioningTemplateCreationInformation
的用法示例。
在下文中一共展示了ProvisioningTemplateCreationInformation.ExecutePostProvisionEvent方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ExtractObjects
public override ProvisioningTemplate ExtractObjects(Web web, ProvisioningTemplate template, TokenParser parser, ProvisioningTemplateCreationInformation creationInfo)
{
using (var scope = new PnPMonitoredScope(this.Name))
{
var lists = this.GetListsWithPages(template);
template.Pages = new PageCollection(template);
var homePageUrl = web.GetHomePageRelativeUrl();
foreach (var list in lists)
{
try
{
List splist = web.Lists.GetById(list.ID);
web.Context.Load(splist);
web.Context.ExecuteQueryRetry();
if (!creationInfo.ExecutePreProvisionEvent<ListInstance, List>(Handlers.Pages, template, list, null))
{
continue;
}
var listItems = GetListPages(web, splist);
var fileItems = listItems.AsEnumerable().Where(x => x.IsFile());
foreach (ListItem item in fileItems)
{
try
{
IPageModelProvider provider = GetProvider(item, homePageUrl, web, parser);
if (null != provider)
{
provider.AddPage(item, template);
}
}
catch (Exception ex)
{
var message = string.Format("Error in export page for list: {0}", list.ServerRelativeUrl);
scope.LogError(ex, message);
}
}
creationInfo.ExecutePostProvisionEvent<ListInstance, List>(Handlers.Pages, template, list, splist);
}
catch (Exception exception)
{
var message = string.Format("Error in export publishing page for list: {0}", list.ServerRelativeUrl);
scope.LogError(exception, message);
}
}
// Impossible to return all files in the site currently
// If a base template is specified then use that one to "cleanup" the generated template model
if (creationInfo.BaseTemplate != null)
{
template = CleanupEntities(template, creationInfo.BaseTemplate);
}
}
return template;
}
示例2: ExtractObjects
public override ProvisioningTemplate ExtractObjects(Web web, ProvisioningTemplate template, TokenParser parser, ProvisioningTemplateCreationInformation creationInfo)
{
using (var scope = new PnPMonitoredScope(this.Name))
{
foreach (var listInstance in template.Lists)
{
List list = web.Lists.GetById(listInstance.ID);
web.Context.Load(list);
web.Context.ExecuteQueryRetry();
if (creationInfo.ExecutePreProvisionEvent<ListInstance, List>(Handlers.ListContents, template, listInstance, list))
{
ListItemsProvider provider = new ListItemsProvider(list, web, template);
List<DataRow> dataRows = provider.ExtractItems(creationInfo, parser, scope);
listInstance.DataRows.AddRange(dataRows);
creationInfo.ExecutePostProvisionEvent<ListInstance, List>(Handlers.ListContents, template, listInstance, list);
}
}
}
return template;
}
示例3: ExtractObjects
public override ProvisioningTemplate ExtractObjects(Web web, ProvisioningTemplate template, TokenParser parser, ProvisioningTemplateCreationInformation creationInfo)
{
using (var scope = new PnPMonitoredScope(this.Name))
{
// if this is a sub site then we're not creating field entities.
if (web.IsSubSite())
{
scope.LogDebug(CoreResources.Provisioning_ObjectHandlers_Fields_Context_web_is_subweb__skipping_site_columns);
return template;
}
var existingFields = web.Fields;
web.Context.Load(web, w => w.ServerRelativeUrl);
web.Context.Load(existingFields);
web.Context.Load(web.Lists, ls => ls.Include(l => l.Id, l => l.Title));
web.Context.ExecuteQueryRetry();
var taxTextFieldsToMoveUp = new List<Guid>();
foreach (var field in existingFields)
{
if (!BuiltInFieldId.Contains(field.Id))
{
if (creationInfo.ExecutePreProvisionEvent<Field,SPField>(Handlers.Fields, template, null, field))
{
var fieldXml = field.SchemaXml;
XElement element = XElement.Parse(fieldXml);
// Check if the field contains a reference to a list. If by Guid, rewrite the value of the attribute to use web relative paths
var listIdentifier = element.Attribute("List") != null ? element.Attribute("List").Value : null;
if (!string.IsNullOrEmpty(listIdentifier))
{
var listGuid = Guid.Empty;
fieldXml = ParseFieldSchema(fieldXml, web.Lists);
element = XElement.Parse(fieldXml);
//if (Guid.TryParse(listIdentifier, out listGuid))
//{
// fieldXml = ParseListSchema(fieldXml, web.Lists);
//if (newfieldXml == fieldXml)
//{
// var list = web.Lists.GetById(listGuid);
// web.Context.Load(list, l => l.RootFolder.ServerRelativeUrl);
// web.Context.ExecuteQueryRetry();
// var listUrl = list.RootFolder.ServerRelativeUrl.Substring(web.ServerRelativeUrl.Length).TrimStart('/');
// element.Attribute("List").SetValue(listUrl);
// fieldXml = element.ToString();
//}
//}
}
// Check if the field is of type TaxonomyField
if (field.TypeAsString.StartsWith("TaxonomyField"))
{
var taxField = (TaxonomyField)field;
web.Context.Load(taxField, tf => tf.TextField, tf => tf.Id);
web.Context.ExecuteQueryRetry();
taxTextFieldsToMoveUp.Add(taxField.TextField);
}
// Check if we have version attribute. Remove if exists
if (element.Attribute("Version") != null)
{
element.Attributes("Version").Remove();
fieldXml = element.ToString();
}
Field templateField = new Field() { SchemaXml = fieldXml };
template.SiteFields.Add(templateField);
creationInfo.ExecutePostProvisionEvent<Field, SPField>(Handlers.Fields, template, templateField, field);
}
}
}
// move hidden taxonomy text fields to the top of the list
foreach (var textFieldId in taxTextFieldsToMoveUp)
{
var field = template.SiteFields.First(f => Guid.Parse(f.SchemaXml.ElementAttributeValue("ID")).Equals(textFieldId));
template.SiteFields.RemoveAll(f => Guid.Parse(f.SchemaXml.ElementAttributeValue("ID")).Equals(textFieldId));
template.SiteFields.Insert(0, field);
}
// If a base template is specified then use that one to "cleanup" the generated template model
if (creationInfo.BaseTemplate != null)
{
template = CleanupEntities(template, creationInfo.BaseTemplate);
}
}
return template;
}
示例4: ExtractObjects
//.........这里部分代码省略.........
continue;
}
}
}
if (!creationInfo.ExecutePreProvisionEvent<ListInstance, List>(Handlers.Lists, template, null, siteList))
{
continue;
}
string documentTemplateContent = string.Empty;
if (!String.IsNullOrEmpty(siteList.DocumentTemplateUrl)) {
documentTemplateContent = web.GetFileAsString(siteList.DocumentTemplateUrl);
}
var contentTypeFields = new List<FieldRef>();
var list = new ListInstance
{
Description = siteList.Description,
EnableVersioning = siteList.EnableVersioning,
TemplateType = siteList.BaseTemplate,
Title = siteList.Title,
Hidden = siteList.Hidden,
EnableFolderCreation = siteList.EnableFolderCreation,
DocumentTemplate = TokenizeUrl(siteList.DocumentTemplateUrl, parser),
DocumentTemplateContent = documentTemplateContent,
ContentTypesEnabled = siteList.ContentTypesEnabled,
Url = siteList.RootFolder.ServerRelativeUrl.Substring(serverRelativeUrl.Length).TrimStart('/'),
TemplateFeatureID = siteList.TemplateFeatureId,
EnableAttachments = siteList.EnableAttachments,
OnQuickLaunch = siteList.OnQuickLaunch,
MaxVersionLimit =
siteList.IsObjectPropertyInstantiated("MajorVersionLimit") ? siteList.MajorVersionLimit : 0,
EnableMinorVersions = siteList.EnableMinorVersions,
MinorVersionLimit =
siteList.IsObjectPropertyInstantiated("MajorWithMinorVersionsLimit")
? siteList.MajorWithMinorVersionsLimit
: 0,
ParentWebUrl = web.Url,
ID = siteList.Id,
ParentWebId = web.Id,
ServerRelativeUrl = siteList.RootFolder.ServerRelativeUrl
};
try
{
list = ExtractForms(web, siteList, list);
}
catch (Exception ex)
{
scope.LogDebug("Extract forms on list {0} failed. {1}. {2}", list.Title, ex.Message, ex.StackTrace);
}
list = ExtractContentTypes(web, siteList, contentTypeFields, list);
list = ExtractViews(siteList, list);
list = ExtractFields(web, siteList, contentTypeFields, list, lists, siteColumns);
if (siteList.HasUniqueRoleAssignments)
{
list.Security = siteList.GetSecurity(parser);
}
var logCTWarning = false;
if (baseTemplateList != null)
{
if (!baseTemplateList.Equals(list))
{
scope.LogDebug(CoreResources.Provisioning_ObjectHandlers_ListInstances_Adding_list___0_____1_, list.Title, list.Url);
template.Lists.Add(list);
if (list.ContentTypesEnabled && list.ContentTypeBindings.Any() && web.IsSubSite())
{
logCTWarning = true;
}
}
}
else
{
scope.LogDebug(CoreResources.Provisioning_ObjectHandlers_ListInstances_Adding_list___0_____1_, list.Title, list.Url);
template.Lists.Add(list);
if (list.ContentTypesEnabled && list.ContentTypeBindings.Any() && web.IsSubSite())
{
logCTWarning = true;
}
}
creationInfo.ExecutePostProvisionEvent<ListInstance, List>(Handlers.Lists, template, list, siteList);
if (logCTWarning)
{
scope.LogWarning("You are extracting a template from a subweb. List '{0}' refers to content types. Content types are not exported when extracting a template from a subweb", list.Title);
WriteWarning(string.Format("You are extracting a template from a subweb. List '{0}' refers to content types. Content types are not exported when extracting a template from a subweb", list.Title), ProvisioningMessageType.Warning);
}
}
}
return template;
}