/// <summary>
    /// Enables tasks after separation is over.
    /// </summary>
    private void EnableTasks()
    {
        if (ValidationHelper.GetBoolean(PersistentStorageHelper.GetValue("CMSSchedulerTasksEnabled"), false))
        {
            SettingsKeyInfoProvider.SetGlobalValue("CMSSchedulerTasksEnabled", true);

            // Restart win service
            WinServiceItem def = WinServiceHelper.GetServiceDefinition(WinServiceHelper.HM_SERVICE_BASENAME);
            if (def != null)
            {
                WinServiceHelper.RestartService(def.GetServiceName());
            }
        }
        PersistentStorageHelper.RemoveValue("CMSSchedulerTasksEnabled");
    }
Exemple #2
0
    /// <summary>
    /// Stop tasks.
    /// </summary>
    void btnStopTasks_Click(object sender, EventArgs e)
    {
        // Stop tasks
        PersistentStorageHelper.SetValue("CMSSchedulerTasksEnabled", SettingsKeyInfoProvider.GetBoolValue("CMSSchedulerTasksEnabled"));
        if (SchedulingHelper.EnableScheduler)
        {
            SettingsKeyInfoProvider.SetGlobalValue("CMSSchedulerTasksEnabled", false);
        }

        // Restart win service
        WinServiceItem def = WinServiceHelper.GetServiceDefinition(WinServiceHelper.HM_SERVICE_BASENAME);

        if (def != null)
        {
            WinServiceHelper.RestartService(def.GetServiceName());
        }

        // Display stopping progress
        iconHelp.Visible = btnStopTasks.Visible = false;
        DisplayStoppingTasks();
        TasksManuallyStopped = true;
    }
Exemple #3
0
    /// <summary>
    /// Clears the cache to apply the settings to the web site.
    /// </summary>
    private void ClearCache(string keyName, object keyValue)
    {
        var clearCache        = false;
        var clearOutputCache  = false;
        var clearCSSCache     = false;
        var clearPartialCache = false;

        string serviceBaseName = null;
        var    serviceEnabled  = false;

        // Clear the cached items
        switch (keyName.ToLowerCSafe())
        {
        case "cmsemailsenabled":
            if ((mSiteId <= 0) && (keyValue.ToString().EqualsCSafe("false", true)))
            {
                // Stop current sending of e-mails and newsletters if e-mails are disabled in global settings
                EmailHelper.Queue.CancelSending();
                ModuleCommands.CancelNewsletterSending();
            }
            break;

        case "cmslogsize":
            // Log size changed
            EventLogProvider.Clear();
            break;

        case "cmscacheminutes":
        case "cmscachepageinfo":
        case "cmscacheimages":
        case "cmsmaxcachefilesize":
        case "cmsdefaultaliaspath":
        case "cmsdefaultculturecode":
        case "cmscombinewithdefaultculture":
            // Clear cache upon change
            clearCache = true;
            break;

        case "cmspagekeywordsprefix":
        case "cmspagedescriptionprefix":
        case "cmspagetitleformat":
        case "cmspagetitleprefix":
        case "cmscontrolelement":
        case "cmsenableoutputcache":
        case "cmsfilesystemoutputcacheminutes":
            // Clear output cache upon change
            clearOutputCache = true;
            break;

        case "cmsenablepartialcache":
            // Clear output cache upon change
            clearPartialCache = true;
            break;

        case "cmsresourcecompressionenabled":
        case "cmsstylesheetminificationenabled":
        case "cmsresolvemacrosincss":
            // Clear the CSS styles
            clearCSSCache = true;
            break;

        case "cmsuseexternalservice":
        case "cmsservicehealthmonitoringinterval":
        case "cmsenablehealthmonitoring":
            // Restart Health Monitoring service
        {
            serviceBaseName = WinServiceHelper.HM_SERVICE_BASENAME;
            serviceEnabled  = HealthMonitoringHelper.UseExternalService;

            // Clear status of health monitoring
            HealthMonitoringHelper.Clear();
        }
        break;

        case "cmsprogressivecaching":
            CacheHelper.ProgressiveCaching = ValidationHelper.GetBoolean(keyValue, false);
            break;

        case "cmsscheduleruseexternalservice":
        case "cmsschedulerserviceinterval":
        case "cmsschedulertasksenabled":
            // Restart Scheduler service
            serviceBaseName = WinServiceHelper.SCHEDULER_SERVICE_BASENAME;
            serviceEnabled  = SchedulingHelper.UseExternalService;
            break;

        case "cmsresizeimagestodevice":
            CacheHelper.TouchKey(DeviceProfileInfoProvider.DEVICE_IMAGE_CACHE_KEY);
            break;

        case "cmstranslationscomurl":
        case "cmstranslationscomusername":
        case "cmstranslationscompassword":
        case "cmstranslationscomprojectcode":
            AbstractHumanTranslationService.ClearHashtables();
            break;

        case "cmsuseeventloglistener":
            if (ValidationHelper.GetBoolean(keyValue, false))
            {
                EventLogSourceHelper.RegisterDefaultEventLogListener();
            }
            else
            {
                EventLogSourceHelper.UnregisterDefaultEventLogListener();
            }

            break;
        }

        // Clear the cache to apply the settings to the web site
        if (clearCache)
        {
            CacheHelper.ClearCache(null);
        }
        // Restart windows service
        else if (serviceBaseName != null)
        {
            try
            {
                WinServiceItem def = WinServiceHelper.GetServiceDefinition(serviceBaseName);
                if (def != null)
                {
                    if (serviceEnabled)
                    {
                        WinServiceHelper.RestartService(def.GetServiceName());
                    }
                    else
                    {
                        WinServiceHelper.DeleteServiceFile(def.GetServiceName());
                    }
                }
            }
            catch (Exception ex)
            {
                EventLogProvider.LogException("Settings", "RestartService", ex);
            }
        }
        else
        {
            // Clear only cache portions
            if (clearOutputCache)
            {
                CacheHelper.ClearFullPageCache();
            }
            if (clearCSSCache)
            {
                CacheHelper.ClearCSSCache();
            }
            if (clearPartialCache)
            {
                CacheHelper.ClearPartialCache();
            }
        }
    }