Inheritance: OfficeDevPnP.PartnerPack.Infrastructure.Jobs.Handlers.ProvisioningJobHandler
        private void UpdateTemplates(RefreshSitesJob job)
        {
            // For each Site Collection in the tenant
            using (var adminContext = PnPPartnerPackContextProvider.GetAppOnlyTenantLevelClientContext())
            {
                var tenant = new Tenant(adminContext);

                var siteCollections = tenant.GetSiteProperties(0, true);
                adminContext.Load(siteCollections);
                adminContext.ExecuteQueryRetry();

                foreach (var site in siteCollections)
                {
                    // Exclude Microsoft NextGen Portals
                    if (!site.Url.ToLower().Contains("/portals/") 
                        && !site.Url.ToLower().Contains("-public.sharepoint.com") 
                        && !site.Url.ToLower().Contains("-my.sharepoint.com"))
                    {
                        using (var siteContext = PnPPartnerPackContextProvider.GetAppOnlyClientContext(site.Url))
                        {
                            // Get a reference to the target web
                            var targetWeb = siteContext.Site.RootWeb;

                            // Update the root web of the site collection
                            RefreshSitesJobHandler.UpdateTemplateOnWeb(targetWeb, job);
                        }
                    }
                }
            }
        }
Esempio n. 2
0
        private void UpdateTemplates(RefreshSingleSiteJob job)
        {
            using (var siteContext = PnPPartnerPackContextProvider.GetAppOnlyClientContext(job.TargetSiteUrl))
            {
                // Get a reference to the target web
                var targetWeb = siteContext.Site.RootWeb;

                // Update the root web of the site collection
                RefreshSitesJobHandler.UpdateTemplateOnWeb(targetWeb);
            }
        }