Exemplo n.º 1
0
        public virtual void RunSync()
        {
            if (!SpeedyGenerationSettings.ShouldGenerateViaScheduledTask())
            {
                return;
            }

            if (!SpeedyGenerationSettings.IsPublicFacingEnvironment())
            {
                return;
            }

            var criticalCSSRepository = ServiceLocator.ServiceProvider.GetService <ICriticalCSSRepository>();

            using (var context = ContentSearchManager.GetIndex(GlobalSettings.Index.Master).CreateSearchContext())
            {
                foreach (var result in GetSpeedyPagesByTemplate(context.Index))
                {
                    if (result.IsSpeedyEnabledForPage() && result.IsCriticalStylesEnabledAndPossible())
                    {
                        criticalCSSRepository.UpdateCriticalCSS(result, GlobalSettings.Database.Master);
                    }
                }
            }
        }