当前位置: 首页>>代码示例>>C#>>正文


C# Model.ProvisioningTemplate类代码示例

本文整理汇总了C#中OfficeDevPnP.Core.Framework.Provisioning.Model.ProvisioningTemplate的典型用法代码示例。如果您正苦于以下问题:C# ProvisioningTemplate类的具体用法?C# ProvisioningTemplate怎么用?C# ProvisioningTemplate使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ProvisioningTemplate类属于OfficeDevPnP.Core.Framework.Provisioning.Model命名空间,在下文中一共展示了ProvisioningTemplate类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ProvisionObjects

        public override void ProvisionObjects(Web web, ProvisioningTemplate template, ProvisioningTemplateApplyingInformation applyingInformation)
        {
            Log.Info(Constants.LOGGING_SOURCE_FRAMEWORK_PROVISIONING, CoreResources.Provisioning_ObjectHandlers_Fields);

            // if this is a sub site then we're not provisioning fields. Technically this can be done but it's not a recommended practice
            if (web.IsSubSite())
            {
                return;
            }


            var existingFields = web.Fields;

            web.Context.Load(existingFields, fs => fs.Include(f => f.Id));
            web.Context.ExecuteQueryRetry();
            var existingFieldIds = existingFields.AsEnumerable<SPField>().Select(l => l.Id).ToList();
            var fields = template.SiteFields;

            foreach (var field in fields)
            {
                XElement templateFieldElement = XElement.Parse(field.SchemaXml.ToParsedString("~sitecollection", "~site"));
                var fieldId = templateFieldElement.Attribute("ID").Value;

                if (!existingFieldIds.Contains(Guid.Parse(fieldId)))
                {
                    CreateField(web, templateFieldElement);
                }
                else
                {
                    UpdateField(web, fieldId, templateFieldElement);
                }
            }
        }
开发者ID:nats31,项目名称:PnP,代码行数:33,代码来源:ObjectField.cs

示例2: HandleCustomActions

 /// <summary>
 /// Member to handle the Url of custom actions
 /// </summary>
 /// <param name="provisioningTemplate"></param>
 /// <param name="siteRequest"></param>
 private void HandleCustomActions(ProvisioningTemplate provisioningTemplate, SiteRequestInformation siteRequest)
 {
     if (provisioningTemplate.CustomActions != null)
     {
         //handle site custom actions
         foreach (var _siteCustomActions in provisioningTemplate.CustomActions.SiteCustomActions)
         {
             //IF ITS A SCRIPT SRC WE DO NOT WANT TO MODIFY
             if (!string.IsNullOrEmpty(_siteCustomActions.Url))
             {
                 var _escapedURI = Uri.EscapeUriString(siteRequest.Url);
                 _siteCustomActions.Url = string.Format(_siteCustomActions.Url, _escapedURI);
             }
         }
         //handle web custom actions
         foreach( var _webActions in provisioningTemplate.CustomActions.WebCustomActions)
         {
             //IF ITS A SCRIPT SRC WE DO NOT WANT TO MODIFY
             if (!string.IsNullOrEmpty(_webActions.Url))
             {
                  var _escapedURI = Uri.EscapeUriString(siteRequest.Url);
                 _webActions.Url = string.Format(_webActions.Url, _escapedURI);
             }
         }
     }
 }
开发者ID:ipbhattarai,项目名称:PnP,代码行数:31,代码来源:TemplateConversion.cs

示例3: CanProvisionRegionalSettings

        public void CanProvisionRegionalSettings()
        {
            using (var scope = new Core.Diagnostics.PnPMonitoredScope("CanProvisionRegionalSettings"))
            {
                using (var ctx = TestCommon.CreateClientContext())
                {
                    // Load the base template which will be used for the comparison work
                    var template = new ProvisioningTemplate();

                    template.RegionalSettings = new Core.Framework.Provisioning.Model.RegionalSettings();
                    template.RegionalSettings.FirstDayOfWeek = System.DayOfWeek.Monday;
                    template.RegionalSettings.WorkDayEndHour = WorkHour.PM0700;
                    template.RegionalSettings.TimeZone = 5;
                    template.RegionalSettings.Time24 = true;

                    var parser = new TokenParser(ctx.Web, template);
                    new ObjectRegionalSettings().ProvisionObjects(ctx.Web, template, parser, new ProvisioningTemplateApplyingInformation());

                    ctx.Load(ctx.Web.RegionalSettings);
                    ctx.Load(ctx.Web.RegionalSettings.TimeZone, tz => tz.Id);
                    ctx.ExecuteQueryRetry();

                    Assert.IsTrue(ctx.Web.RegionalSettings.Time24);
                    Assert.IsTrue(ctx.Web.RegionalSettings.WorkDayEndHour == (short)WorkHour.PM0700);
                    Assert.IsTrue(ctx.Web.RegionalSettings.FirstDayOfWeek == (uint)System.DayOfWeek.Monday);
                    Assert.IsTrue(ctx.Web.RegionalSettings.TimeZone.Id == 5);
                }
            }
        }
开发者ID:LiyeXu,项目名称:PnP-Sites-Core,代码行数:29,代码来源:ObjectRegionalSettingsTests.cs

示例4: AddExtendedTokens

 public TokenParser AddExtendedTokens(Web web, ProvisioningTemplate template, TokenParser parser, ProvisioningTemplateApplyingInformation applyingInformation)
 {
     using (var scope = new PnPMonitoredScope(this.Name))
     {
         var context = web.Context as ClientContext;
         foreach (var provider in template.Providers)
         {
             if (provider.Enabled)
             {
                 try
                 {
                     if (!string.IsNullOrEmpty(provider.Configuration))
                     {
                         provider.Configuration = parser.ParseString(provider.Configuration);
                     }
                     scope.LogDebug(CoreResources.Provisioning_ObjectHandlers_ExtensibilityProviders_Calling_tokenprovider_extensibility_callout__0_, provider.Assembly);
                     var _providedTokens = _extManager.ExecuteTokenProviderCallOut(context, provider, template);
                     if (_providedTokens != null)
                     {
                         foreach (var token in _providedTokens)
                         {
                             parser.AddToken(token);
                         }
                     }
                 }
                 catch (Exception ex)
                 {
                     scope.LogError(CoreResources.Provisioning_ObjectHandlers_ExtensibilityProviders_tokenprovider_callout_failed___0_____1_, ex.Message, ex.StackTrace);
                     throw;
                 }
             }
         }
         return parser;
     }
 }
开发者ID:skybow,项目名称:PnP-Sites-Core,代码行数:35,代码来源:ObjectExtensibilityProviders.cs

示例5: CanProvisionObjects

        public void CanProvisionObjects()
        {
            var template = new ProvisioningTemplate();

            FileSystemConnector connector = new FileSystemConnector(resourceFolder,"");

            template.Connector = connector;

            template.Files.Add(new Core.Framework.Provisioning.Model.File() { Overwrite = true, Src = fileName, Folder = folder });

            using (var ctx = TestCommon.CreateClientContext())
            {
                var parser = new TokenParser(ctx.Web, template);
                new ObjectFiles().ProvisionObjects(ctx.Web, template, parser, new ProvisioningTemplateApplyingInformation());

                if (!ctx.Web.IsPropertyAvailable("ServerRelativeUrl"))
                {
                    ctx.Load(ctx.Web, w => w.ServerRelativeUrl);
                    ctx.ExecuteQueryRetry();
                }

                var file = ctx.Web.GetFileByServerRelativeUrl(
                    UrlUtility.Combine(ctx.Web.ServerRelativeUrl,
                        UrlUtility.Combine(folder, fileName)));
                ctx.Load(file, f => f.Exists);
                ctx.ExecuteQueryRetry();
                Assert.IsTrue(file.Exists);
            }
        }
开发者ID:rrocham,项目名称:PnP-Sites-Core,代码行数:29,代码来源:ObjectFilesTests.cs

示例6: ExtractObjects

        public override ProvisioningTemplate ExtractObjects(Web web, ProvisioningTemplate template, ProvisioningTemplateCreationInformation creationInfo)
        {
            using (var scope = new PnPMonitoredScope(this.Name))
            {

                web.Context.Load(web.RegionalSettings);
                web.Context.Load(web.RegionalSettings.TimeZone, tz => tz.Id);
                web.Context.ExecuteQueryRetry();

                Model.RegionalSettings settings = new Model.RegionalSettings();

                settings.AdjustHijriDays = web.RegionalSettings.AdjustHijriDays;
                settings.AlternateCalendarType = (CalendarType)web.RegionalSettings.AlternateCalendarType;
                settings.CalendarType = (CalendarType)web.RegionalSettings.CalendarType;
                settings.Collation = web.RegionalSettings.Collation;
                settings.FirstDayOfWeek = (DayOfWeek)web.RegionalSettings.FirstDayOfWeek;
                settings.FirstWeekOfYear = web.RegionalSettings.FirstWeekOfYear;
                settings.LocaleId = (int)web.RegionalSettings.LocaleId;
                settings.ShowWeeks = web.RegionalSettings.ShowWeeks;
                settings.Time24 = web.RegionalSettings.Time24;
                settings.TimeZone = web.RegionalSettings.TimeZone.Id;
                settings.WorkDayEndHour = (WorkHour)web.RegionalSettings.WorkDayEndHour;
                settings.WorkDays = web.RegionalSettings.WorkDays;
                settings.WorkDayStartHour = (WorkHour)web.RegionalSettings.WorkDayStartHour;

                template.RegionalSettings = settings;

                // We're not comparing regional settings with the value stored in the base template as base templates are always for the US locale (1033)
            }
            return template;
        }
开发者ID:stijnbrouwers,项目名称:PnP-Sites-Core,代码行数:31,代码来源:ObjectRegionalSettings.cs

示例7: Validate

        public bool Validate(ContentTypeCollection sourceCollection, ContentTypeCollection targetCollection, TokenParser tokenParser)
        {
            // Convert object collections to XML 
            List<SerializedContentType> sourceContentTypes = new List<SerializedContentType>();
            List<SerializedContentType> targetContentTypes = new List<SerializedContentType>();

            foreach (ContentType ct in sourceCollection)
            {
                ProvisioningTemplate pt = new ProvisioningTemplate();
                pt.ContentTypes.Add(ct);

                sourceContentTypes.Add(new SerializedContentType() { SchemaXml = ExtractElementXml(pt) });                
            }

            foreach (ContentType ct in targetCollection)
            {
                ProvisioningTemplate pt = new ProvisioningTemplate();
                pt.ContentTypes.Add(ct);

                targetContentTypes.Add(new SerializedContentType() { SchemaXml = ExtractElementXml(pt) });
            }

            // Use XML validation logic to compare source and target
            Dictionary<string, string[]> parserSettings = new Dictionary<string, string[]>();
            parserSettings.Add("SchemaXml", null);
            bool isContentTypeMatch = ValidateObjectsXML(sourceContentTypes, targetContentTypes, "SchemaXml", new List<string> { "ID" }, tokenParser, parserSettings);
            Console.WriteLine("-- Content type validation " + isContentTypeMatch);
            return isContentTypeMatch;
        }
开发者ID:stijnbrouwers,项目名称:PnP-Sites-Core,代码行数:29,代码来源:ContentTypeValidator.cs

示例8: ProvisionObjects

        public override TokenParser ProvisionObjects(Web web, ProvisioningTemplate template, TokenParser parser, ProvisioningTemplateApplyingInformation applyingInformation)
        {
            using (var scope = new PnPMonitoredScope(this.Name))
            {
                var context = web.Context as ClientContext;
                var site = context.Site;

                // Check if this is not a noscript site as we're not allowed to update some properties
                bool isNoScriptSite = web.IsNoScriptSite();

                // if this is a sub site then we're not enabling the site collection scoped custom actions
                if (!web.IsSubSite())
                {
                    var siteCustomActions = template.CustomActions.SiteCustomActions;
                    ProvisionCustomActionImplementation(site, siteCustomActions, parser, scope, isNoScriptSite);
                }

                var webCustomActions = template.CustomActions.WebCustomActions;
                ProvisionCustomActionImplementation(web, webCustomActions, parser, scope, isNoScriptSite);

                // Switch parser context back to it's original context
                parser.Rebase(web);
            }
            return parser;
        }
开发者ID:s-KaiNet,项目名称:PnP-Sites-Core,代码行数:25,代码来源:ObjectCustomActions.cs

示例9: CanProvisionSupportedUILanguages

        public void CanProvisionSupportedUILanguages()
        {
            using (var scope = new Core.Diagnostics.PnPMonitoredScope("CanProvisionSupportedUILanguages"))
            {
                using (var ctx = TestCommon.CreateClientContext())
                {
                    // Load the base template which will be used for the comparison work
                    var template = new ProvisioningTemplate();

                    template.SupportedUILanguages.Add(new SupportedUILanguage() { LCID = 1033 }); // English
                    template.SupportedUILanguages.Add(new SupportedUILanguage() { LCID = 1032 }); // Greek

                    var parser = new TokenParser(ctx.Web, template);
                    new ObjectSupportedUILanguages().ProvisionObjects(ctx.Web, template, parser, new ProvisioningTemplateApplyingInformation());

                    ctx.Load(ctx.Web, w => w.SupportedUILanguageIds);

                    ctx.ExecuteQueryRetry();

                    Assert.IsTrue(ctx.Web.SupportedUILanguageIds.Count() == 2);
                    Assert.IsTrue(ctx.Web.SupportedUILanguageIds.Any(i => i == 1033));
                    Assert.IsTrue(ctx.Web.SupportedUILanguageIds.Any(i => i == 1032));
                }
            }
        }
开发者ID:LiyeXu,项目名称:PnP-Sites-Core,代码行数:25,代码来源:ObjectSupportedUILanguagesTests.cs

示例10: CanProvisionAuditSettings

        public void CanProvisionAuditSettings()
        {
            using (var scope = new Core.Diagnostics.PnPMonitoredScope("CanProvisionAuditSettings"))
            {
                using (var ctx = TestCommon.CreateClientContext())
                {
                    // Load the base template which will be used for the comparison work
                    var template = new ProvisioningTemplate();

                    template.AuditSettings = new AuditSettings();
                    template.AuditSettings.AuditFlags = AuditMaskType.CheckIn;
                    template.AuditSettings.AuditLogTrimmingRetention = 5;
                    template.AuditSettings.TrimAuditLog = true;

                    var parser = new TokenParser(ctx.Web, template);
                    new ObjectAuditSettings().ProvisionObjects(ctx.Web, template, parser, new ProvisioningTemplateApplyingInformation());

                    var site = ctx.Site;

                    var auditSettings = site.Audit;
                    ctx.Load(auditSettings, af => af.AuditFlags);
                    ctx.Load(site, s => s.AuditLogTrimmingRetention, s => s.TrimAuditLog);
                    ctx.ExecuteQueryRetry();

                    Assert.IsTrue(auditSettings.AuditFlags == AuditMaskType.CheckIn);
                    Assert.IsTrue(site.AuditLogTrimmingRetention == 5);
                    Assert.IsTrue(site.TrimAuditLog = true);
                }
            }
        }
开发者ID:LiyeXu,项目名称:PnP-Sites-Core,代码行数:30,代码来源:ObjectAuditSettingsTests.cs

示例11: CanProvisionObjects

        public void CanProvisionObjects()
        {
            var template = new ProvisioningTemplate();
            template.SiteFields.Add(new Core.Framework.Provisioning.Model.Field() { SchemaXml = ElementSchema });

            using (var ctx = TestCommon.CreateClientContext())
            {
                var parser = new TokenParser(ctx.Web, template);
                new ObjectField().ProvisionObjects(ctx.Web, template, parser, new ProvisioningTemplateApplyingInformation());
                new ObjectLookupFields().ProvisionObjects(ctx.Web, template, parser, new ProvisioningTemplateApplyingInformation());

                var f = ctx.Web.GetFieldById<FieldLookup>(fieldId);

                Assert.IsNotNull(f);
                Assert.IsInstanceOfType(f, typeof(FieldLookup));

                var schemaXml = f.SchemaXml;
                // so listId MUST have braces
                Assert.IsTrue(schemaXml.Contains("List=\""+_listIdWithBraces+"\""));
                // web id should NOT have braces
                Assert.IsTrue(schemaXml.Contains("WebId=\"" + ctx.Web.Id.ToString()+ "\""));
                // Source ID MUST have braces
                Assert.IsTrue(schemaXml.Contains("SourceID=\"" + ctx.Web.Id.ToString("B") + "\""));
            }

        }
开发者ID:stijnbrouwers,项目名称:PnP-Sites-Core,代码行数:26,代码来源:ObjectLookupFieldsTests.cs

示例12: CreateEntities

        public override ProvisioningTemplate CreateEntities(Web web, ProvisioningTemplate template, ProvisioningTemplateCreationInformation creationInfo)
        {
            // if this is a sub site then we're not creating content type entities. 
            if (web.IsSubSite())
            {
                return template;
            }

            var cts = web.ContentTypes;
            web.Context.Load(cts);
            web.Context.ExecuteQueryRetry();

            foreach (var ct in cts)
            {
                if (!BuiltInContentTypeId.Contains(ct.StringId))
                {
                    template.ContentTypes.Add(new ContentType() { SchemaXml = ct.SchemaXml });
                }
            }

            // 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;
        }
开发者ID:ivanvagunin,项目名称:PnP,代码行数:28,代码来源:ObjectContentType.cs

示例13: ProvisionObjects

        public override void ProvisionObjects(Web web, ProvisioningTemplate template)
        {
            // if this is a sub site then we're not provisioning content types. Technically this can be done but it's not a recommended practice
            if (web.IsSubSite())
            {
                return;
            }

            var existingCts = web.AvailableContentTypes;
            web.Context.Load(existingCts, cts => cts.Include(ct => ct.StringId));
            web.Context.ExecuteQueryRetry();

            var existingCtsIds = existingCts.Select(cts => cts.StringId.ToLower()).ToList();

            foreach (var ct in template.ContentTypes)
            {
                // find the id of the content type
                XDocument document = XDocument.Parse(ct.SchemaXml);
                var contentTypeId = document.Root.Attribute("ID").Value;
                if (!existingCtsIds.Contains(contentTypeId.ToLower()))
                {
                    web.CreateContentTypeFromXMLString(ct.SchemaXml);
                    existingCtsIds.Add(contentTypeId);
                }
            }
        }
开发者ID:ivanvagunin,项目名称:PnP,代码行数:26,代码来源:ObjectContentType.cs

示例14: ProvisionObjects

        public override void ProvisionObjects(Web web, ProvisioningTemplate template)
        {
            TokenParser parser = new TokenParser(web);
            var context = web.Context as ClientContext;

            if (!web.IsPropertyAvailable("ServerRelativeUrl"))
            {
                context.Load(web, w => w.ServerRelativeUrl);
                context.ExecuteQueryRetry();
            }

            foreach (var file in template.Files)
            {

                var folderName = parser.Parse(file.Folder);

                if (folderName.ToLower().StartsWith((web.ServerRelativeUrl.ToLower())))
                {
                    folderName = folderName.Substring(web.ServerRelativeUrl.Length);
                }
                

                var folder = web.EnsureFolderPath(folderName);

                using (var stream = template.Connector.GetFileStream(file.Src))
                {
                    folder.UploadFile(file.Src, stream, true);
                }

            }

        }
开发者ID:ivanvagunin,项目名称:PnP,代码行数:32,代码来源:ObjectFiles.cs

示例15: CanProvisionObjects

        public void CanProvisionObjects()
        {
            var template = new ProvisioningTemplate();


            foreach (var user in admins)
            {
                template.Security.AdditionalMembers.Add(new User() { Name = user.LoginName});
            }



            using (var ctx = TestCommon.CreateClientContext())
            {
                TokenParser.Initialize(ctx.Web, template);
                new ObjectSiteSecurity().ProvisionObjects(ctx.Web, template);

                var memberGroup = ctx.Web.AssociatedMemberGroup;
                ctx.Load(memberGroup, g => g.Users);
                ctx.ExecuteQueryRetry();
                foreach (var user in admins)
                {
                    var existingUser = memberGroup.Users.GetByLoginName(user.LoginName);
                    ctx.Load(existingUser);
                    ctx.ExecuteQueryRetry();
                    Assert.IsNotNull(existingUser);
                }
            }
        }
开发者ID:ipbhattarai,项目名称:PnP,代码行数:29,代码来源:ObjectSiteSecurityTests.cs


注:本文中的OfficeDevPnP.Core.Framework.Provisioning.Model.ProvisioningTemplate类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。