예제 #1
0
        private void SaveSettings(HtmlOptimiserSettings settings)
        {
            var storeScope = this.GetActiveStoreScopeConfiguration(_storeService, _workContext);

            _settingService.SaveSetting(settings, x => x.RemoveHeaders, storeScope, false);
            _settingService.SaveSetting(settings, x => x.AddHeaders, storeScope, false);

            _settingService.ClearCache();

            WebConfigUpdater.UpdateWebConfig(settings.RemoveHeaders);

            RestartPlugin();
        }
        /// <summary>
        /// Uninstalls the plugin.
        /// </summary>
        public override void Uninstall()
        {
            // settings
            _settingService.DeleteSetting <HtmlOptimiserSettings>();

            // locales
            this.DeletePluginLocaleResource(Constants.ResourceFieldsMinificationEnabled);
            this.DeletePluginLocaleResource(Constants.ResourceFieldsMinificationEnabledHint);
            this.DeletePluginLocaleResource(Constants.ResourceFieldsRemoveWhitespace);
            this.DeletePluginLocaleResource(Constants.ResourceFieldsRemoveWhitespaceHint);
            this.DeletePluginLocaleResource(Constants.ResourceFieldsRemoveHtmlComments);
            this.DeletePluginLocaleResource(Constants.ResourceFieldsRemoveHtmlCommentsHint);
            this.DeletePluginLocaleResource(Constants.ResourceFieldsRemoveScriptComments);
            this.DeletePluginLocaleResource(Constants.ResourceFieldsRemoveScriptCommentsHint);
            this.DeletePluginLocaleResource(Constants.ResourceFieldsRemoveCDATASections);
            this.DeletePluginLocaleResource(Constants.ResourceFieldsRemoveCDATASectionsHint);
            this.DeletePluginLocaleResource(Constants.ResourceFieldsUseShortDocType);
            this.DeletePluginLocaleResource(Constants.ResourceFieldsUseShortDocTypeHint);
            this.DeletePluginLocaleResource(Constants.ResourceFieldsRemoveQuotes);
            this.DeletePluginLocaleResource(Constants.ResourceFieldsRemoveQuotesHint);
            this.DeletePluginLocaleResource(Constants.ResourceFieldsRemoveRedundantAttributes);
            this.DeletePluginLocaleResource(Constants.ResourceFieldsRemoveRedundantAttributesHint);
            this.DeletePluginLocaleResource(Constants.ResourceFieldsRemoveOptionalEndTags);
            this.DeletePluginLocaleResource(Constants.ResourceFieldsRemoveOptionalEndTagsHint);
            this.DeletePluginLocaleResource(Constants.ResourceFieldsMinifyInlineScripts);
            this.DeletePluginLocaleResource(Constants.ResourceFieldsMinifyInlineScriptsHint);
            this.DeletePluginLocaleResource(Constants.ResourceFieldsMinifyInlineStyles);
            this.DeletePluginLocaleResource(Constants.ResourceFieldsMinifyInlineStylesHint);
            this.DeletePluginLocaleResource(Constants.ResourceFieldsRemoveHeaders);
            this.DeletePluginLocaleResource(Constants.ResourceFieldsRemoveHeadersHint);
            this.DeletePluginLocaleResource(Constants.ResourceFieldsAddHeaders);
            this.DeletePluginLocaleResource(Constants.ResourceFieldsAddHeadersHint);
            this.DeletePluginLocaleResource(Constants.ResourceIntroPart1);
            this.DeletePluginLocaleResource(Constants.ResourceIntroPart2);
            this.DeletePluginLocaleResource(Constants.ResourceIntroPart3);
            this.DeletePluginLocaleResource(Constants.ResourceIntroPart4);
            this.DeletePluginLocaleResource(Constants.ResourceIntroPart5);
            this.DeletePluginLocaleResource(Constants.ResourceIntroPart6);

            // update web.config
            WebConfigUpdater.UpdateWebConfig(Enumerable.Empty <string>());

            base.Uninstall();
        }
예제 #3
0
        public void Execute()
        {
            if (Installed)
            {
                // register type converter
                TypeDescriptor.AddAttributes(typeof(List <AddHeader>), new TypeConverterAttribute(typeof(AddHeaderTypeConverter)));

                // check if web.config needs updating (i.e. after an upgrade)
                WebConfigUpdater.UpdateWebConfig(RemoveHeaders);

                // remove old filter before adding new one
                var currentFilter = GlobalFilters.Filters.FirstOrDefault(f => f.Instance.GetType() == typeof(HtmlFilterAttribute));

                if (currentFilter != null)
                {
                    GlobalFilters.Filters.Remove(currentFilter.Instance);
                }

                GlobalFilters.Filters.Add(new HtmlFilterAttribute()
                {
                    Order = 100
                });
            }
        }
예제 #4
0
        private void ConfigureReadyToUpgradeControls()
        {
            #region Database

            bool dbUpgradeOk = false;
            bool dbUpgradeNotNeeded = false;
            DatabaseUpgrader db = new DatabaseUpgrader(GspConfigSourcePath);

            lblReadyToUpgradeDbHeader.Text = String.Concat(db.DataProvider, " Database");

            if (db.IsUpgradeRequired)
            {
                if (db.IsAutoUpgradeSupported)
                {
                    string msg = Utils.HtmlEncode(String.Format(CultureInfo.InvariantCulture, Resources.GalleryServerPro.Installer_Upgrade_Db_Status_Upgrade_Reqd_Msg, db.GetDatabaseVersionString() ?? "<unknown>"));

                    if (db.DataProvider == ProviderDataStore.SQLite)
                    {
                        msg = msg.TrimEnd(new[] { '.' });
                        msg += " and migrated to the new SQL CE database format.";
                    }

                    lblReadyToUpgradeDbStatus.Text = msg;
                    lblReadyToUpgradeDbStatus.CssClass = "gsp_msgfriendly";
                    imgReadyToUpgradeDbStatus.ImageUrl = Utils.GetUrl("/images/go_14x14.png");

                    dbUpgradeOk = true;
                }
                else
                {
                    lblReadyToUpgradeDbStatus.Text = Utils.HtmlEncode(db.AutoUpgradeNotSupportedReason);
                    lblReadyToUpgradeDbStatus.CssClass = "gsp_msgwarning";
                    imgReadyToUpgradeDbStatus.ImageUrl = Utils.GetUrl("/images/error_16x16.png");
                    imgReadyToUpgradeDbStatus.Width = Unit.Pixel(16);
                    imgReadyToUpgradeDbStatus.Height = Unit.Pixel(16);
                }
            }
            else
            {
                // web.config has same settings as the source web.config. No update needed.
                lblReadyToUpgradeDbStatus.Text = Resources.GalleryServerPro.Installer_Upgrade_Db_Status_No_Upgrade_Reqd_Msg;
                lblReadyToUpgradeDbStatus.CssClass = String.Empty;
                imgReadyToUpgradeDbStatus.ImageUrl = Utils.GetUrl("/images/ok_16x16.png");
                imgReadyToUpgradeDbStatus.Width = Unit.Pixel(16);
                imgReadyToUpgradeDbStatus.Height = Unit.Pixel(16);
                dbUpgradeNotNeeded = true;
                dbUpgradeOk = true;
            }

            #endregion

            #region web.config

            bool webConfigUpdateOk = false;
            bool webConfigUpdateNotNeeded = false;
            // Check permissions on web.config
            WebConfigUpdater webCfg = null;
            try
            {
                webCfg = new WebConfigUpdater();
            }
            catch (FileNotFoundException ex)
            {
                lblReadyToUpgradeWebConfigStatus.Text = ex.Message;
                lblReadyToUpgradeWebConfigStatus.CssClass = "gsp_msgwarning";
                imgReadyToUpgradeWebConfigStatus.ImageUrl = Utils.GetUrl("/images/error_16x16.png");
            }

            if (webCfg != null)
            {
                if (webCfg.UpgradeRequired)
                {
                    if (webCfg.IsWritable)
                    {
                        // An update is needed and we have the necessary write permission to update the file, so we are good to go!
                        string msg = Utils.HtmlEncode(Resources.GalleryServerPro.Installer_Upgrade_Config_Status_Upgrade_Msg);

                        if (DbUpgrader.DataProvider == ProviderDataStore.SQLite)
                        {
                            msg = "Update required: The data provider sections will be updated to use the new SQL CE providers and the cachingConfiguration section will be deleted.";
                        }

                        lblReadyToUpgradeWebConfigStatus.Text = msg;
                        lblReadyToUpgradeWebConfigStatus.CssClass = "gsp_msgfriendly";
                        imgReadyToUpgradeWebConfigStatus.ImageUrl = Utils.GetUrl("/images/go_14x14.png");
                        webConfigUpdateOk = true;
                    }
                    else
                    {
                        // Web.config file needs updating, but installer doesn't have the required write permission.
                        lblReadyToUpgradeWebConfigStatus.Text = String.Format(CultureInfo.InvariantCulture, Resources.GalleryServerPro.Installer_Upgrade_ReadyToUpgrade_Config_Status_No_Perm_Msg, WebConfigPath);
                        lblReadyToUpgradeWebConfigStatus.CssClass = "gsp_msgwarning";
                        imgReadyToUpgradeWebConfigStatus.ImageUrl = Utils.GetUrl("/images/error_16x16.png");
                        imgReadyToUpgradeWebConfigStatus.Width = Unit.Pixel(16);
                        imgReadyToUpgradeWebConfigStatus.Height = Unit.Pixel(16);
                    }
                }
                else
                {
                    // web.config has same settings as the source web.config. The only update to do is delete the cachingConfiguration section.
                    lblReadyToUpgradeWebConfigStatus.Text = Resources.GalleryServerPro.Installer_Upgrade_WebConfig_Imported_Items1;
                    lblReadyToUpgradeWebConfigStatus.CssClass = "gsp_msgfriendly";
                    imgReadyToUpgradeWebConfigStatus.ImageUrl = Utils.GetUrl("/images/go_14x14.png");
                    webConfigUpdateNotNeeded = true;
                    webConfigUpdateOk = true;
                }
            }

            #endregion

            #region galleryserverpro.config

            bool gspConfigOk = false;
            bool gspConfigUpgradeNotNeeded = false;
            if (db.GetDatabaseVersion() <= GalleryDataSchemaVersion.V2_3_3421)
            {
                // Check permissions on galleryserverpro.config
                GspConfigImporter gspCfg = null;
                try
                {
                    gspCfg = new GspConfigImporter(GspConfigSourcePath, DbUpgrader);
                }
                catch (FileNotFoundException)
                {
                    lblReadyToUpgradeGspConfigStatus.Text = String.Format(CultureInfo.InvariantCulture, Resources.GalleryServerPro.Installer_Upgrade_ReadyToUpgrade_GspConfigNotFound, GspConfigSourcePath);
                    lblReadyToUpgradeGspConfigStatus.CssClass = "gsp_msgwarning";
                    imgReadyToUpgradeGspConfigStatus.ImageUrl = Utils.GetUrl("/images/error_16x16.png");
                    imgReadyToUpgradeGspConfigStatus.Width = Unit.Pixel(16);
                    imgReadyToUpgradeGspConfigStatus.Height = Unit.Pixel(16);
                }

                if (gspCfg != null)
                {
                    lblReadyToUpgradeGspConfigStatus.Text = String.Format(CultureInfo.InvariantCulture, Resources.GalleryServerPro.Installer_Upgrade_ReadyToUpgrade_Config_Status_OK_Msg, GspConfigSourcePath);
                    lblReadyToUpgradeGspConfigStatus.CssClass = "gsp_msgfriendly";
                    imgReadyToUpgradeGspConfigStatus.ImageUrl = Utils.GetUrl("/images/go_14x14.png");
                    gspConfigOk = true;
                }
            }
            else
            {
                lblReadyToUpgradeGspConfigStatus.Text = "Not needed: Version 2.4 and higher does not use galleryserverpro.config.";
                lblReadyToUpgradeGspConfigStatus.CssClass = "";
                imgReadyToUpgradeGspConfigStatus.ImageUrl = Utils.GetUrl("/images/ok_16x16.png");
                imgReadyToUpgradeGspConfigStatus.Width = Unit.Pixel(16);
                imgReadyToUpgradeGspConfigStatus.Height = Unit.Pixel(16);
                gspConfigUpgradeNotNeeded = true;
                gspConfigOk = true;
            }

            #endregion

            if (dbUpgradeNotNeeded && webConfigUpdateNotNeeded && gspConfigUpgradeNotNeeded)
            {
                // No updates are needed.
                lblReadyToUpgradeHdrMsg.Text = "No Update Needed";
                lblReadyToUpgradeDetail1Msg.Text = String.Format(CultureInfo.InvariantCulture, "The gallery is already up to date. <a href='{0}'>Go to your gallery</a>", Utils.GetCurrentPageUrl());
                btnNext.Enabled = false;
                imgReadyToUpgradeStatus.ImageUrl = Utils.GetUrl("/images/ok_26x26.png");
                imgReadyToUpgradeStatus.Width = Unit.Pixel(26);
                imgReadyToUpgradeStatus.Height = Unit.Pixel(26);

                DeleteInstallAndUpgradeFileTriggers();
            }
            else if (dbUpgradeOk && webConfigUpdateOk && gspConfigOk)
            {
                // Show the summary text that we are ready for the upgrade.
                lblReadyToUpgradeHdrMsg.Text = Resources.GalleryServerPro.Installer_Upgrade_ReadyToUpgrade_Hdr;
                lblReadyToUpgradeDetail1Msg.Text = Resources.GalleryServerPro.Installer_Upgrade_ReadyToUpgrade_OK_Dtl1;
                imgReadyToUpgradeStatus.ImageUrl = Utils.GetUrl("/images/ok_26x26.png");
                imgReadyToUpgradeStatus.Width = Unit.Pixel(26);
                imgReadyToUpgradeStatus.Height = Unit.Pixel(26);
            }
            else
            {
                // Show the summary text that something is wrong and we can't proceed.
                lblReadyToUpgradeHdrMsg.Text = Resources.GalleryServerPro.Installer_Upgrade_ReadyToUpgrade_Cannot_Upgrade_Hdr;
                lblReadyToUpgradeDetail1Msg.Text = Resources.GalleryServerPro.Installer_Upgrade_ReadyToUpgrade_CannotUpgrade_Dtl1;

                if ((webCfg != null) && (!webCfg.IsWritable))
                {
                    lblReadyToUpgradeDetail2Msg.Text = Resources.GalleryServerPro.Installer_Upgrade_ReadyToUpgrade_No_Perm_Dtl1;
                }

                lbTryAgain.Visible = true;
                btnNext.Enabled = false;
                imgReadyToUpgradeStatus.ImageUrl = Utils.GetUrl("/images/warning_32x32.png");
                imgReadyToUpgradeStatus.Width = Unit.Pixel(32);
                imgReadyToUpgradeStatus.Height = Unit.Pixel(32);
            }
        }
예제 #5
0
 private void UpdateWebConfig(bool addSqlCeConfiguration)
 {
     try
     {
         WebConfigUpdater configImporter = new WebConfigUpdater();
         this.WebConfigUpdateRequired = configImporter.UpgradeRequired;
         configImporter.Upgrade(addSqlCeConfiguration);
         WebConfigSuccessfullyUpdated = true;
     }
     catch (Exception ex)
     {
         WebConfigUpdateErrorMsg = GetExceptionDetails(ex);
     }
 }
예제 #6
0
 private void DeleteSqliteReferencesFromWebConfig()
 {
     WebConfigUpdater webConfig = new WebConfigUpdater();
     webConfig.DeleteSqliteReferences();
 }