LogStep() private method

private LogStep ( string version, string message, bool isImportant = true ) : void
version string
message string
isImportant bool
return void
Esempio n. 1
0
        internal VersionBase(string version, Logger sharedLogger, string logName, Log parentLog = null)
        {
            logger   = sharedLogger;
            _version = version;
            logger.LogStep(_version, "Initialized version-upgrade object for " + this.GetType().Name);

            Log = new Log(logName, parentLog);
        }
Esempio n. 2
0
        internal string UpgradeModule(string version)
        {
            // Check if table "ToSIC_SexyContent_Templates" exists.
            // If it's gone, then PROBABLY skip all upgrade-codes incl. 8.11!
            var sql           = @"SELECT COUNT(*) FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[ToSIC_SexyContent_Templates]') AND TYPE IN(N'U')";
            var sqlConnection = new SqlConnection(ConfigurationManager.ConnectionStrings["SiteSqlServer"].ConnectionString);

            sqlConnection.Open();
            var sqlCommand           = new SqlCommand(sql, sqlConnection);
            var runDbChangesUntil811 = (Int32)sqlCommand.ExecuteScalar() == 1; // if there is one result row, this means the templates table still exists, we need to run changes before 08.11

            sqlConnection.Close();

            // if version is 01.00.00, the upgrade has to run because log files should be cleared
            if (!runDbChangesUntil811 && version != "01.00.00" && (new Version(version) <= new Version(8, 11, 0)))
            {
                _installLogger.LogStep(version, "Upgrade skipped because 00.99.00 install detected (installation of everything until and including 08.11 has been done by 00.99.00.SqlDataProvider)", true);
                _installLogger.LogVersionCompletedToPreventRerunningTheUpgrade(version);
                return(version);
            }

            _installLogger.LogStep(version, "UpgradeModule starting", false);

            // Configure Unity / eav, etc.
            Settings.EnsureSystemIsInitialized();
            // new UnityConfig().Configure();

            // Abort upgrade if it's already done - if version is 01.00.00, the module has probably been uninstalled - continue in this case.
            if (version != "01.00.00" && IsUpgradeComplete(version, "- Check on Start UpgradeModule"))
            {
                _installLogger.LogStep(version, "Apparently trying to update this version, but this versions upgrade is apparently compeleted, will abort");
                throw new Exception("2sxc upgrade for version " + version +
                                    " started, but it looks like the upgrade for this version is already complete. Aborting upgrade.");
            }
            _installLogger.LogStep(version, "version / upgrade-complete test passed");

            if (IsUpgradeRunning)
            {
                _installLogger.LogStep(version, "Apparently upgrade is running, will abort");
                throw new Exception("2sxc upgrade for version " + version +
                                    " started, but the upgrade is already running. Aborting upgrade.");
            }
            _installLogger.LogStep(version, "is-upgrade-running test passed");

            IsUpgradeRunning = true;
            _installLogger.LogStep(version, "----- Upgrade to " + version + " started -----");

            try
            {
                switch (version)
                {
                case "01.00.00":     // Make sure that log folder empty on new installations (could happen if 2sxc was already installed on a system)
                    MaybeResetUpgradeLogsToStartAgainFromV1();
                    break;

                case "07.02.00":
                    new V7(version, _installLogger, Log).Version070200();
                    break;

                case "07.02.02":
                    // Make sure upgrades FROM BETWEEN 07.00.00 and 07.02.02 do not run again (create log files for each of them)
                    _installLogger.LogVersionCompletedToPreventRerunningTheUpgrade("07.00.00", false);
                    _installLogger.LogVersionCompletedToPreventRerunningTheUpgrade("07.00.03", false);
                    _installLogger.LogVersionCompletedToPreventRerunningTheUpgrade("07.02.00", false);
                    break;

                case "07.03.01":
                    new V7(version, _installLogger, Log).EnsurePipelineDesignerAttributeSets();     // Need to ensure this again because of upgrade problems
                    break;

                case "07.03.03":
                    new V7(version, _installLogger, Log).Version070303();
                    break;

                case "08.00.02":
                    new V8(version, _installLogger, Log).Version080002();
                    break;

                case "08.00.04":
                    new V8(version, _installLogger, Log).Version080004();
                    break;

                case "08.00.07":
                    new V8(version, _installLogger, Log).Version080007();
                    break;

                case "08.01.00":
                    new V8(version, _installLogger, Log).Version080100();
                    break;

                case "08.03.00":
                    break;

                case "08.03.02":
                    new V8(version, _installLogger, Log).Version080302();
                    break;

                case "08.03.03":
                    new V8(version, _installLogger, Log).Version080303();
                    break;

                case "08.03.05":
                    Helpers.ImportXmlSchemaOfVersion("08.03.05", false);
                    break;

                case "08.04.00":
                    Helpers.ImportXmlSchemaOfVersion("08.04.00", false);
                    break;

                case "08.04.03":
                    Helpers.ImportXmlSchemaOfVersion("08.04.03", false);
                    break;

                case "08.04.05":
                    Helpers.ImportXmlSchemaOfVersion("08.04.03", false);     // this is correct, RE-RUN 08.04.03 as there was a problem in that version number before
                    break;

                case "08.05.00":
                    Helpers.ImportXmlSchemaOfVersion("08.05.00", false);
                    break;

                case "08.05.01":
                    new V8(version, _installLogger, Log).Version080501();
                    break;

                case "08.05.02":
                    Helpers.ImportXmlSchemaOfVersion("08.05.02", false);
                    break;

                case "08.05.03":
                    Helpers.ImportXmlSchemaOfVersion("08.05.03", false);
                    break;

                case "08.05.05":
                    Helpers.ImportXmlSchemaOfVersion("08.05.05", false);
                    break;

                case "08.11.00":
                    new V8(version, _installLogger, Log).Version081100();
                    break;

                    // warning!!! when you add a new case, make sure you upgrade the version number on Settings.Installation.LastVersionWithServerChanges!!!
                }
                _installLogger.LogStep(version, "version-list check / switch done", false);

                // Increase ClientDependency version upon each upgrade (System and all Portals)
                // prevents browsers caching old JS and CSS files for editing, which could cause several errors
                // only set this on the last upgraded version, to prevent crazy updating the client-resource-cache while upgrading
                if (version == Settings.Installation.UpgradeVersionList.Last())
                {
                    _installLogger.LogStep(version, "ClientResourceManager- seems to be last item in version-list, will clear");
                    ClientResourceManager.UpdateVersion();
                    _installLogger.LogStep(version, "ClientResourceManager- done clearing");

                    UpdateUpgradeCompleteStatus();
                    _installLogger.LogStep(version, "updated upgrade-complete status");
                }

                _installLogger.LogVersionCompletedToPreventRerunningTheUpgrade(version);
                _installLogger.LogStep(version, "----- Upgrade to " + version + " completed -----");
            }
            catch (Exception e)
            {
                _installLogger.LogStep(version, "Upgrade failed - " + e.Message);
                throw;
            }
            finally
            {
                IsUpgradeRunning = false;
            }
            _installLogger.LogStep(version, "UpgradeModule done / returning");
            return(version);
        }
        internal string UpgradeModule(string version)
        {
            _logger.LogStep(version, "UpgradeModule starting", false);

            // Configure Unity / eav, etc.
            Settings.EnsureSystemIsInitialized();
            // new UnityConfig().Configure();

            // Abort upgrade if it's already done - if version is 01.00.00, the module has probably been uninstalled - continue in this case.
            if (version != "01.00.00" && IsUpgradeComplete(version, "- Check on Start UpgradeModule"))
            {
                _logger.LogStep(version, "Apparently trying to update this version, but this versions upgrade is apparently compeleted, will abort");
                throw new Exception("2sxc upgrade for version " + version +
                                    " started, but it looks like the upgrade for this version is already complete. Aborting upgrade.");
            }
            _logger.LogStep(version, "version / upgrade-complete test passed");

            if (IsUpgradeRunning)
            {
                _logger.LogStep(version, "Apparently upgrade is running, will abort");
                throw new Exception("2sxc upgrade for version " + version +
                                    " started, but the upgrade is already running. Aborting upgrade.");
            }
            _logger.LogStep(version, "is-upgrade-running test passed");

            IsUpgradeRunning = true;
            _logger.LogStep(version, "----- Upgrade to " + version + " started -----");

            try
            {
                switch (version)
                {
                case "01.00.00":     // Make sure that log folder empty on new installations (could happen if 2sxc was already installed on a system)
                    MaybeResetUpgradeLogsToStartAgainFromV1();
                    break;

                case "05.05.00":
                    new V5(version, _logger).Version050500();
                    break;

                case "06.06.00":
                case "06.06.04":
                    new V6(version, _logger).EnsurePipelineDesignerAttributeSets();
                    break;

                case "07.00.00":
                    new V7(version, _logger).Version070000();
                    break;

                case "07.00.03":
                    new V7(version, _logger).Version070003();
                    break;

                case "07.02.00":
                    new V7(version, _logger).Version070200();
                    break;

                case "07.02.02":
                    // Make sure upgrades FROM BETWEEN 07.00.00 and 07.02.02 do not run again (create log files for each of them)
                    _logger.LogVersionCompletedToPreventRerunningTheUpgrade("07.00.00", false);
                    _logger.LogVersionCompletedToPreventRerunningTheUpgrade("07.00.03", false);
                    _logger.LogVersionCompletedToPreventRerunningTheUpgrade("07.02.00", false);
                    break;

                case "07.03.01":
                    new V6(version, _logger).EnsurePipelineDesignerAttributeSets();     // Need to ensure this again because of upgrade problems
                    break;

                case "07.03.03":
                    new V7(version, _logger).Version070303();
                    break;

                case "08.00.02":
                    new V8(version, _logger).Version080002();
                    break;

                case "08.00.04":
                    new V8(version, _logger).Version080004();
                    break;

                case "08.00.07":
                    new V8(version, _logger).Version080007();
                    break;

                case "08.01.00":
                    new V8(version, _logger).Version080100();
                    break;

                case "08.03.00":
                    break;

                case "08.03.02":
                    new V8(version, _logger).Version080302();
                    break;

                case "08.03.03":
                    new V8(version, _logger).Version080303();
                    break;

                case "08.03.05":
                    Helpers.ImportXmlSchemaOfVersion("08.03.05", false);
                    break;

                case "08.04.00":
                    Helpers.ImportXmlSchemaOfVersion("08.04.00", false);
                    break;

                case "08.04.03":
                    Helpers.ImportXmlSchemaOfVersion("08.04.03", false);
                    break;

                case "08.04.05":
                    Helpers.ImportXmlSchemaOfVersion("08.04.03", false);     // this is correct, RE-RUN 08.04.03 as there was a problem in that version number before
                    break;

                case "08.05.00":
                    Helpers.ImportXmlSchemaOfVersion("08.05.00", false);
                    break;

                case "08.05.01":
                    new V8(version, _logger).Version080501();
                    break;

                case "08.05.02":
                    Helpers.ImportXmlSchemaOfVersion("08.05.02", false);
                    break;

                case "08.05.03":
                    Helpers.ImportXmlSchemaOfVersion("08.05.03", false);
                    break;

                case "08.05.05":
                    Helpers.ImportXmlSchemaOfVersion("08.05.05", false);
                    break;

                    // warning!!! when you add a new case, make sure you upgrade the version number on Settings.Installation.LastVersionWithServerChanges!!!
                }
                _logger.LogStep(version, "version-list check / switch done", false);

                // Increase ClientDependency version upon each upgrade (System and all Portals)
                // prevents browsers caching old JS and CSS files for editing, which could cause several errors
                // only set this on the last upgraded version, to prevent crazy updating the client-resource-cache while upgrading
                if (version == Settings.Installation.UpgradeVersionList.Last())
                {
                    _logger.LogStep(version, "ClientResourceManager- seems to be last item in version-list, will clear");
                    ClientResourceManager.UpdateVersion();
                    _logger.LogStep(version, "ClientResourceManager- done clearing");

                    UpdateUpgradeCompleteStatus();
                    _logger.LogStep(version, "updated upgrade-complete status");
                }

                _logger.LogVersionCompletedToPreventRerunningTheUpgrade(version);
                _logger.LogStep(version, "----- Upgrade to " + version + " completed -----");
            }
            catch (Exception e)
            {
                _logger.LogStep(version, "Upgrade failed - " + e.Message);
                throw;
            }
            finally
            {
                IsUpgradeRunning = false;
            }
            _logger.LogStep(version, "UpgradeModule done / returning");
            return(version);
        }