/// <summary> /// Main method to execute the step /// </summary> public override void Execute() { Percentage = 0; Status = StepStatus.Running; var counter = 0; const int totalSteps = 6; const int percentForEachStep = 100 / totalSteps; var percentForMiniStep = 0; var installConfig = InstallController.Instance.GetInstallConfig(); var providerPath = DataProvider.Instance().GetProviderPath(); //Step 1 - Install Base Database. Only when it's not already installed. Globals.DataBaseVersion is null when SPs are not present if (Globals.DataBaseVersion == null) { var defaultProvider = Config.GetDefaultProvider("data").Name; percentForMiniStep = percentForEachStep / (installConfig.Scripts.Count + 1); foreach (var script in installConfig.Scripts) { var scriptFile = providerPath + script + "." + defaultProvider; var description = Localization.Localization.GetString("InstallingDataBaseScriptStep", LocalInstallResourceFile); Details = description + Upgrade.GetFileNameWithoutExtension(scriptFile); var exception = Upgrade.ExecuteScript(scriptFile, false); if (!string.IsNullOrEmpty(exception)) { Errors.Add(exception); Status = StepStatus.Retry; return; } Percentage += percentForMiniStep; } // update the version Globals.UpdateDataBaseVersion(new Version(installConfig.Version)); Details = Localization.Localization.GetString("InstallingMembershipDatabaseScriptStep", LocalInstallResourceFile); //Optionally Install the memberRoleProvider var exceptions = Upgrade.InstallMemberRoleProvider(providerPath, false); if (!string.IsNullOrEmpty(exceptions)) { Errors.Add(exceptions); Status = StepStatus.Retry; return; } } Percentage = percentForEachStep * counter++; //Step 2 - Process the Upgrade Script files var versions = new List <Version>(); var scripts = Upgrade.GetUpgradeScripts(providerPath, DataProvider.Instance().GetVersion()); if (scripts.Count > 0) { percentForMiniStep = percentForEachStep / (scripts.Count); foreach (string scriptFile in scripts) { var fileName = Upgrade.GetFileNameWithoutExtension(scriptFile); versions.Add(new Version(fileName)); string description = Localization.Localization.GetString("ProcessingUpgradeScript", LocalInstallResourceFile); Details = description + fileName; var exceptions = Upgrade.UpgradeVersion(scriptFile, false); if (!string.IsNullOrEmpty(exceptions)) { Errors.Add(exceptions); Status = StepStatus.Retry; return; } Percentage += percentForMiniStep; } } Percentage = percentForEachStep * counter++; //Step 3 - Perform version specific application upgrades foreach (Version ver in versions) { string description = Localization.Localization.GetString("UpgradingVersionApplication", LocalInstallResourceFile); Details = description + ver; var exceptions = Upgrade.UpgradeApplication(providerPath, ver, false); if (!string.IsNullOrEmpty(exceptions)) { Errors.Add(exceptions); Status = StepStatus.Retry; return; } Percentage += percentForMiniStep; } Percentage = percentForEachStep * counter++; //Step 4 - Execute config file updates foreach (Version ver in versions) { string description = Localization.Localization.GetString("UpdatingConfigFile", LocalInstallResourceFile); Details = description + ver; var exceptions = Upgrade.UpdateConfig(providerPath, ver, false); if (!string.IsNullOrEmpty(exceptions)) { Errors.Add(exceptions); Status = StepStatus.Retry; return; } Percentage += percentForMiniStep; } Percentage = percentForEachStep * counter++; //Step 5 - Delete files which are no longer used foreach (Version ver in versions) { string description = Localization.Localization.GetString("DeletingOldFiles", LocalInstallResourceFile); Details = description + ver; var exceptions = Upgrade.DeleteFiles(providerPath, ver, false); if (!string.IsNullOrEmpty(exceptions)) { Errors.Add(exceptions); Status = StepStatus.Retry; return; } Percentage += percentForMiniStep; } Percentage = percentForEachStep * counter++; //Step 6 - Perform general application upgrades Details = Localization.Localization.GetString("UpgradingNormalApplication", LocalInstallResourceFile); Upgrade.UpgradeApplication(); DataCache.ClearHostCache(true); Percentage = percentForEachStep * counter++; Status = Errors.Count > 0 ? StepStatus.Retry : StepStatus.Done; }