• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# PnPMonitoredScope类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: ExtractObjects

        public override ProvisioningTemplate ExtractObjects(Web web, ProvisioningTemplate template, ProvisioningTemplateCreationInformation creationInfo)
        {
            using (var scope = new PnPMonitoredScope(this.Name))
            {
                var site = (web.Context as ClientContext).Site;
                try
                {
                    var siteSearchSettings = site.GetSearchConfiguration();

                    if (!String.IsNullOrEmpty(siteSearchSettings))
                    {
                        template.SiteSearchSettings = siteSearchSettings;
                    }

                    var webSearchSettings = web.GetSearchConfiguration();

                    if (!String.IsNullOrEmpty(webSearchSettings))
                    {
                        template.WebSearchSettings = webSearchSettings;
                    }
                }
                catch (ServerException)
                {
                    // The search service is not necessarily configured
                    // Swallow the exception
                }
            }
            return template;
        }
开发者ID:stijnbrouwers,项目名称:PnP-Sites-Core,代码行数:29,代码来源:ObjectSearchSettings.cs


示例2: ProvisionObjects

        public override TokenParser ProvisionObjects(Web web, ProvisioningTemplate template, TokenParser parser, ProvisioningTemplateApplyingInformation applyingInformation)
        {
            using (var scope = new PnPMonitoredScope(this.Name))
            {
                // Check if this is not a noscript site as we're not allowed to write to the web property bag is that one
                bool isNoScriptSite = web.IsNoScriptSite();
                if (isNoScriptSite)
                {

                    return parser;
                }

                web.SetPropertyBagValue("_PnP_ProvisioningTemplateId", template.Id != null ? template.Id : "");
                web.AddIndexedPropertyBagKey("_PnP_ProvisioningTemplateId");

                ProvisioningTemplateInfo info = new ProvisioningTemplateInfo();
                info.TemplateId = template.Id != null ? template.Id : "";
                info.TemplateVersion = template.Version;
                info.TemplateSitePolicy = template.SitePolicy;
                info.Result = true;
                info.ProvisioningTime = DateTime.Now;

                string jsonInfo = JsonConvert.SerializeObject(info);

                web.SetPropertyBagValue("_PnP_ProvisioningTemplateInfo", jsonInfo);
            }
            return parser;
        }
开发者ID:s-KaiNet,项目名称:PnP-Sites-Core,代码行数:28,代码来源:ObjectPersistTemplateInfo.cs


示例3: LocalizeParts

 private static void LocalizeParts(Web web, TokenParser parser, string url, WebPartCollection webParts, PnPMonitoredScope scope)
 {
     if (CanUseAcceptLanguageHeaderForLocalization(web))
     {
         var context = web.Context;
         var allParts = web.GetWebParts(parser.ParseString(url)).ToList();
         foreach (var webPart in webParts)
         {
     #if !SP2016
             var partOnPage = allParts.FirstOrDefault(w => w.ZoneId == webPart.Zone && w.WebPart.ZoneIndex == webPart.Order);
     #else
             var partOnPage = allParts.FirstOrDefault(w => w.WebPart.ZoneIndex == webPart.Order);
     #endif
             if (webPart.Title.ContainsResourceToken() && partOnPage != null)
             {
                 var resourceValues = parser.GetResourceTokenResourceValues(webPart.Title);
                 foreach (var resourceValue in resourceValues)
                 {
                     // Save property with correct locale on the request to make it stick
                     // http://sadomovalex.blogspot.no/2015/09/localize-web-part-titles-via-client.html
                     context.PendingRequest.RequestExecutor.WebRequest.Headers["Accept-Language"] = resourceValue.Item1;
                     partOnPage.WebPart.Properties["Title"] = resourceValue.Item2;
                     partOnPage.SaveWebPartChanges();
                     context.ExecuteQueryRetry();
                 }
             }
         }
         context.PendingRequest.RequestExecutor.WebRequest.Headers.Remove("Accept-Language");
     }
     else
     {
         // warning
         scope.LogWarning(CoreResources.Provisioning_Extensions_WebPartLocalization_Skip);
     }
 }
开发者ID:OfficeDev,项目名称:PnP-Sites-Core,代码行数:35,代码来源:LocalizationExtensions.cs


示例4: PersistFile

        internal void PersistFile(Web web, ProvisioningTemplateCreationInformation creationInfo, PnPMonitoredScope scope, string folderPath, string fileName, Boolean decodeFileName = false)
        {
            if (creationInfo.FileConnector != null)
            {
                SharePointConnector connector = new SharePointConnector(web.Context, web.Url, "dummy");

                Uri u = new Uri(web.Url);
                if (folderPath.IndexOf(u.PathAndQuery, StringComparison.InvariantCultureIgnoreCase) > -1)
                {
                    folderPath = folderPath.Replace(u.PathAndQuery, "");
                }

                using (Stream s = connector.GetFileStream(fileName, folderPath))
                {
                    if (s != null)
                    {
                        creationInfo.FileConnector.SaveFileStream(decodeFileName ? HttpUtility.UrlDecode(fileName) : fileName, s);
                    }
                }
            }
            else
            {
                WriteWarning("No connector present to persist homepage.", ProvisioningMessageType.Error);
                scope.LogError("No connector present to persist homepage");
            }
        }
开发者ID:rgueldenpfennig,项目名称:PnP-Sites-Core,代码行数:26,代码来源:ObjectContentHandlerBase.cs


示例5: ExtractObjects

        public override ProvisioningTemplate ExtractObjects(Web web, ProvisioningTemplate template, TokenParser parser, 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.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;

                // 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:skybow,项目名称:PnP-Sites-Core,代码行数:35,代码来源:ObjectRegionalSettings.cs


示例6: 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


示例7: 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


示例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;
         foreach (var handler in template.ExtensibilityHandlers
             .Union(template.Providers)
             .Union(applyingInformation.ExtensibilityHandlers))
         {
             if (handler.Enabled)
             {
                 try
                 {
                     if (!string.IsNullOrEmpty(handler.Configuration))
                     {
                         //replace tokens in configuration data
                         handler.Configuration = parser.ParseString(handler.Configuration);
                     }
                     scope.LogDebug(CoreResources.Provisioning_ObjectHandlers_ExtensibilityProviders_Calling_extensibility_callout__0_, handler.Assembly);
                     _extManager.ExecuteExtensibilityProvisionCallOut(context, handler, template, applyingInformation, parser, scope);
                 }
                 catch (Exception ex)
                 {
                     scope.LogError(CoreResources.Provisioning_ObjectHandlers_ExtensibilityProviders_callout_failed___0_____1_, ex.Message, ex.StackTrace);
                     throw;
                 }
             }
         }
     }
     return parser;
 }
开发者ID:stijnbrouwers,项目名称:PnP-Sites-Core,代码行数:31,代码来源:ObjectExtensibilityHandlers.cs


示例9: 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


示例10: ProvisionObjects

        public override TokenParser ProvisionObjects(Web web, ProvisioningTemplate template, TokenParser parser, ProvisioningTemplateApplyingInformation applyingInformation)
        {
            using (var scope = new PnPMonitoredScope(this.Name))
            {
                // 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())
                {
                    scope.LogDebug(CoreResources.Provisioning_ObjectHandlers_ContentTypes_Context_web_is_subweb__Skipping_content_types_);
                    return parser;
                }

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

                web.Context.Load(web.ContentTypes, ct => ct.IncludeWithDefaultProperties(c => c.StringId, c => c.FieldLinks,
                                                                                         c => c.FieldLinks.Include(fl => fl.Id, fl => fl.Required, fl => fl.Hidden)));
                web.Context.Load(web.Fields, fld => fld.IncludeWithDefaultProperties(f => f.Id));

                web.Context.ExecuteQueryRetry();

                var existingCTs = web.ContentTypes.ToList();
                var existingFields = web.Fields.ToList();

                foreach (var ct in template.ContentTypes.OrderBy(ct => ct.Id)) // ordering to handle references to parent content types that can be in the same template
                {
                    var existingCT = existingCTs.FirstOrDefault(c => c.StringId.Equals(ct.Id, StringComparison.OrdinalIgnoreCase));
                    if (existingCT == null)
                    {
                        scope.LogDebug(CoreResources.Provisioning_ObjectHandlers_ContentTypes_Creating_new_Content_Type___0_____1_, ct.Id, ct.Name);
                        var newCT = CreateContentType(web, ct, parser, template.Connector ?? null, scope, existingCTs, existingFields, isNoScriptSite);
                        if (newCT != null)
                        {
                            existingCTs.Add(newCT);
                        }
                    }
                    else
                    {
                        if (ct.Overwrite)
                        {
                            scope.LogDebug(CoreResources.Provisioning_ObjectHandlers_ContentTypes_Recreating_existing_Content_Type___0_____1_, ct.Id, ct.Name);

                            existingCT.DeleteObject();
                            web.Context.ExecuteQueryRetry();
                            var newCT = CreateContentType(web, ct, parser, template.Connector ?? null, scope, existingCTs, existingFields, isNoScriptSite);
                            if (newCT != null)
                            {
                                existingCTs.Add(newCT);
                            }
                        }
                        else
                        {
                            scope.LogDebug(CoreResources.Provisioning_ObjectHandlers_ContentTypes_Updating_existing_Content_Type___0_____1_, ct.Id, ct.Name);
                            UpdateContentType(web, existingCT, ct, parser, scope, isNoScriptSite);
                        }
                    }
                }
            }
            return parser;
        }
开发者ID:OfficeDev,项目名称:PnP-Sites-Core,代码行数:59,代码来源:ObjectContentType.cs


示例11: ProvisionObjects

        public override TokenParser ProvisionObjects(Web web, ProvisioningTemplate template, TokenParser parser, ProvisioningTemplateApplyingInformation applyingInformation)
        {
            using (var scope = new PnPMonitoredScope(this.Name))
            {
                if (template.ComposedLook != null &&
                    !template.ComposedLook.Equals(ComposedLook.Empty))
                {
                    bool executeQueryNeeded = false;
                    if (executeQueryNeeded)
                    {
                        web.Context.ExecuteQueryRetry();
                    }

                    if (String.IsNullOrEmpty(template.ComposedLook.ColorFile) &&
                        String.IsNullOrEmpty(template.ComposedLook.FontFile) &&
                        String.IsNullOrEmpty(template.ComposedLook.BackgroundFile))
                    {
                        // Apply OOB theme
                        web.SetComposedLookByUrl(template.ComposedLook.Name);
                    }
                    else
                    {
                        // Apply custom theme
                        string colorFile = null;
                        if (!string.IsNullOrEmpty(template.ComposedLook.ColorFile))
                        {
                            colorFile = parser.ParseString(template.ComposedLook.ColorFile);
                        }
                        string backgroundFile = null;
                        if (!string.IsNullOrEmpty(template.ComposedLook.BackgroundFile))
                        {
                            backgroundFile = parser.ParseString(template.ComposedLook.BackgroundFile);
                        }
                        string fontFile = null;
                        if (!string.IsNullOrEmpty(template.ComposedLook.FontFile))
                        {
                            fontFile = parser.ParseString(template.ComposedLook.FontFile);
                        }

                        string masterUrl = null;
                        if (template.WebSettings != null && !string.IsNullOrEmpty(template.WebSettings.MasterPageUrl))
                        {
                            masterUrl = parser.ParseString(template.WebSettings.MasterPageUrl);
                        }
                        web.CreateComposedLookByUrl(template.ComposedLook.Name, colorFile, fontFile, backgroundFile, masterUrl);
                        web.SetComposedLookByUrl(template.ComposedLook.Name, colorFile, fontFile, backgroundFile, masterUrl);

                        var composedLookJson = JsonConvert.SerializeObject(template.ComposedLook);

                        web.SetPropertyBagValue("_PnP_ProvisioningTemplateComposedLookInfo", composedLookJson);
                    }

                    // Persist composed look info in property bag

                }
            }
            return parser;
        }
开发者ID:LiyeXu,项目名称:PnP-Sites-Core,代码行数:58,代码来源:ObjectComposedLook.cs


示例12: 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;
        }
开发者ID:skybow,项目名称:PnP-Sites-Core,代码行数:57,代码来源:ObjectPages.cs


示例13: ExtractObjects

        public override ProvisioningTemplate ExtractObjects(Web web, ProvisioningTemplate template, ProvisioningTemplateCreationInformation creationInfo)
        {
            using (var scope = new PnPMonitoredScope(this.Name))
            {
                // Set default values for Template ID and Version
                template.Id = String.Format("TEMPLATE-{0:N}", Guid.NewGuid()).ToUpper();
                template.Version = 1;

                template.BaseSiteTemplate = web.GetBaseTemplateId();

                // Retrieve original Template ID and remove it from Property Bag Entries
                int provisioningTemplateIdIndex = template.PropertyBagEntries.FindIndex(f => f.Key.Equals("_PnP_ProvisioningTemplateId"));
                if (provisioningTemplateIdIndex > -1)
                {
                    var templateId = template.PropertyBagEntries[provisioningTemplateIdIndex].Value;
                    if (!String.IsNullOrEmpty(templateId))
                    {
                        template.Id = templateId;
                    }
                    template.PropertyBagEntries.RemoveAt(provisioningTemplateIdIndex);
                }

                // Retrieve original Template Info and remove it from Property Bag Entries
                int provisioningTemplateInfoIndex = template.PropertyBagEntries.FindIndex(f => f.Key.Equals("_PnP_ProvisioningTemplateInfo"));
                if (provisioningTemplateInfoIndex > -1)
                {
                    var jsonInfo = template.PropertyBagEntries[provisioningTemplateInfoIndex].Value;

                    if (jsonInfo != null)
                    {
                        ProvisioningTemplateInfo info = JsonConvert.DeserializeObject<ProvisioningTemplateInfo>(jsonInfo);

                        // Override any previously defined Template ID, Version, and SitePolicy
                        // with the one stored in the Template Info, if any
                        if (info != null)
                        {
                            if (!String.IsNullOrEmpty(info.TemplateId))
                            {
                                template.Id = info.TemplateId;
                            }
                            if (!String.IsNullOrEmpty(info.TemplateSitePolicy))
                            {
                                template.SitePolicy = info.TemplateSitePolicy;
                            }
                            if (info.TemplateVersion > 0)
                            {
                                template.Version = info.TemplateVersion;
                            }
                        }
                    }
                    template.PropertyBagEntries.RemoveAt(provisioningTemplateInfoIndex);
                }
            }
            return template;
        }
开发者ID:stijnbrouwers,项目名称:PnP-Sites-Core,代码行数:55,代码来源:ObjectRetrieveTemplateInfo.cs


示例14: Provision

        public void Provision(ClientContext ctx, ProvisioningTemplate template, ProvisioningTemplateApplyingInformation applyingInformation, TokenParser tokenParser, PnPMonitoredScope scope, string configurationData)
        {
            bool _urlCheck = ctx.Url.Equals(ExtensibilityTestConstants.MOCK_URL, StringComparison.OrdinalIgnoreCase);
            if (!_urlCheck) throw new Exception("CTXURLNOTTHESAME");

            bool _templateCheck = template.Id.Equals(ExtensibilityTestConstants.PROVISIONINGTEMPLATE_ID, StringComparison.OrdinalIgnoreCase);
            if (!_templateCheck) throw new Exception("TEMPLATEIDNOTTHESAME");

            bool _configDataCheck = configurationData.Equals(ExtensibilityTestConstants.PROVIDER_MOCK_DATA, StringComparison.OrdinalIgnoreCase);
            if (!_configDataCheck) throw new Exception("CONFIGDATANOTTHESAME");
        }
开发者ID:stijnbrouwers,项目名称:PnP-Sites-Core,代码行数:11,代码来源:ExtensibilityMockHandler.cs


示例15: ExtractObjects

 public override ProvisioningTemplate ExtractObjects(Web web, ProvisioningTemplate template, ProvisioningTemplateCreationInformation creationInfo)
 {
     using (var scope = new PnPMonitoredScope(this.Name))
     {
         // 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:neoassyrian,项目名称:PnP-Sites-Core,代码行数:12,代码来源:ObjectExtensibilityProviders.cs


示例16: ExecuteExtensibilityExtractionCallOut

        /// <summary>
        /// Method to Invoke Custom Extraction Handlers. 
        /// </summary>
        /// <remarks>
        /// Ensure the ClientContext is not disposed in the custom provider.
        /// </remarks>
        /// <param name="ctx">Authenticated ClientContext that is passed to the custom provider.</param>
        /// <param name="handler">A custom Extensibility Provisioning Provider</param>
        /// <param name="template">ProvisioningTemplate that is passed to the custom provider</param>
        /// <param name="creationInformation">The Provisioning Template creation information object</param>
        /// <param name="scope">The PnPMonitoredScope of the current step in the pipeline</param>
        /// <exception cref="ExtensiblityPipelineException"></exception>
        /// <exception cref="ArgumentException">Provider.Assembly or Provider.Type is NullOrWhiteSpace></exception>
        /// <exception cref="ArgumentNullException">ClientContext is Null></exception>
        public ProvisioningTemplate ExecuteExtensibilityExtractionCallOut(ClientContext ctx, ExtensibilityHandler handler, ProvisioningTemplate template, ProvisioningTemplateCreationInformation creationInformation, PnPMonitoredScope scope)
        {
            var _loggingSource = "OfficeDevPnP.Core.Framework.Provisioning.Extensibility.ExtensibilityManager.ExecuteCallout";

            if (ctx == null)
                throw new ArgumentNullException(CoreResources.Provisioning_Extensibility_Pipeline_ClientCtxNull);

            if (string.IsNullOrWhiteSpace(handler.Assembly))
                throw new ArgumentException(CoreResources.Provisioning_Extensibility_Pipeline_Missing_AssemblyName);

            if (string.IsNullOrWhiteSpace(handler.Type))
                throw new ArgumentException(CoreResources.Provisioning_Extensibility_Pipeline_Missing_TypeName);

            ProvisioningTemplate parsedTemplate = null;

            try
            {

                var _instance = GetProviderInstance(handler);
                if (_instance is IProvisioningExtensibilityHandler)
                {
                    Log.Info(_loggingSource,
                        CoreResources.Provisioning_Extensibility_Pipeline_BeforeInvocation,
                        handler.Assembly,
                        handler.Type);

                    parsedTemplate = (_instance as IProvisioningExtensibilityHandler).Extract(ctx, template, creationInformation, scope, handler.Configuration);

                    Log.Info(_loggingSource,
                        CoreResources.Provisioning_Extensibility_Pipeline_Success,
                        handler.Assembly,
                        handler.Type);
                }
                else
                {
                    parsedTemplate = template;
                }
            }
            catch (Exception ex)
            {
                string _message = string.Format(
                    CoreResources.Provisioning_Extensibility_Pipeline_Exception,
                    handler.Assembly,
                    handler.Type,
                    ex);
                Log.Error(_loggingSource, _message);
                throw new ExtensiblityPipelineException(_message, ex);

            }

            return parsedTemplate;
        }
开发者ID:rroman81,项目名称:PnP-Sites-Core,代码行数:66,代码来源:ExtensibilityManager.cs


示例17: VerifyDocLib

        // This function will be triggered based on the schedule you have set for this WebJob
        public static void VerifyDocLib()
        {
            var url = ConfigurationManager.AppSettings["SpUrl"].ToString();
            var user = ConfigurationManager.AppSettings["SpUserName"].ToString();
            var pw = ConfigurationManager.AppSettings["SpPassword"].ToString();
            using (PnPMonitoredScope p = new PnPMonitoredScope())
            {
                p.LogInfo("Gathering connect info from web.config");
                p.LogInfo("SharePoint url is " + url);
                p.LogInfo("SharePoint user is " + user);
                try
                {
                    ClientContext cc = new ClientContext(url);
                    cc.AuthenticationMode = ClientAuthenticationMode.Default;
                    cc.Credentials = new SharePointOnlineCredentials(user, GetPassword(pw));
                    using (cc)
                    {
                        if (cc != null)
                        {
                            string listName = "Site Pages";
                            p.LogInfo("This is what a Monitored Scope log entry looks like in PNP, more to come as we try to validate a lists existence.");
                            p.LogInfo("Connect to Sharepoint");
                            ListCollection lists = cc.Web.Lists;
                            IEnumerable<List> results = cc.LoadQuery<List>(lists.Where(lst => lst.Title == listName));
                            p.LogInfo("Executing query to find the Site Pages library");
                            cc.ExecuteQuery();
                            p.LogInfo("Query Executed successfully.");
                            List list = results.FirstOrDefault();
                            if (list == null)
                            {
                                p.LogError("Site Pages library not found.");
                            }
                            else
                            {
                                p.LogInfo("Site Pages library found.");

                                ListItemCollection items = list.GetItems(new CamlQuery());
                                cc.Load(items, itms => itms.Include(item => item.DisplayName));
                                cc.ExecuteQueryRetry();
                                string pgs = "These pages were found, " + string.Join(", ", items.Select(x => x.DisplayName));
                                p.LogInfo(pgs);
                            }
                        }
                    }

                }
                catch (System.Exception ex)
                {
                    p.LogInfo("We had a problem: " + ex.Message);
                }
            }
        }
开发者ID:tandis,项目名称:PnP,代码行数:53,代码来源:Functions.cs


示例18: ProvisionObjects

        public override TokenParser ProvisionObjects(Web web, ProvisioningTemplate template, TokenParser parser, ProvisioningTemplateApplyingInformation applyingInformation)
        {
            using (var scope = new PnPMonitoredScope(this.Name))
            {
                var site = (web.Context as ClientContext).Site;
                if (!String.IsNullOrEmpty(template.SearchSettings))
                {
                    site.SetSearchConfiguration(template.SearchSettings);
                }
            }

            return parser;
        }
开发者ID:skybow,项目名称:PnP-Sites-Core,代码行数:13,代码来源:ObjectSearchSettings.cs


示例19: ExtractObjects

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

                if (sitePolicyEntity != null)
                {
                    template.SitePolicy = sitePolicyEntity.Name;
                }
            }
            return template;
        }
开发者ID:LiyeXu,项目名称:PnP-Sites-Core,代码行数:13,代码来源:ObjectSitePolicy.cs


示例20: ProvisionObjects

        public override TokenParser ProvisionObjects(Web web, ProvisioningTemplate template, TokenParser parser, ProvisioningTemplateApplyingInformation applyingInformation)
        {
            using (var scope = new PnPMonitoredScope(this.Name))
            {
                // 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())
                {
                    scope.LogDebug(CoreResources.Provisioning_ObjectHandlers_Fields_Context_web_is_subweb__skipping_site_columns);
                    return parser;
                }

                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(parser.ParseString(field.SchemaXml, "~sitecollection", "~site"));
                    var fieldId = templateFieldElement.Attribute("ID").Value;

                    if (!existingFieldIds.Contains(Guid.Parse(fieldId)))
                    {
                        try
                        {
                            scope.LogDebug(CoreResources.Provisioning_ObjectHandlers_Fields_Adding_field__0__to_site, fieldId);
                            CreateField(web, templateFieldElement, scope, parser, field.SchemaXml);
                        }
                        catch (Exception ex)
                        {
                            scope.LogError(CoreResources.Provisioning_ObjectHandlers_Fields_Adding_field__0__failed___1_____2_, fieldId, ex.Message, ex.StackTrace);
                            throw;
                        }
                    }
                    else
       

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Pocket类代码示例发布时间:2022-05-24
下一篇:
C# PluginResult类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap