UpdateTemplateOnWeb() 개인적인 메소드

private UpdateTemplateOnWeb ( Web targetWeb, RefreshSitesJob job ) : void
targetWeb Web
job RefreshSitesJob
리턴 void
        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);
                        }
                    }
                }
            }
        }
예제 #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);
            }
        }