public KnownInstallationLogic(RsisInstallation rsisInstallation)
 {
     this.rsisInstallation = rsisInstallation;
 }
        public static Action DownloadDataPackageAndGetDataUpdateMethod(
            ExistingInstallation installation, bool installationIsStandbyDb, RsisInstallation source, bool forceNewPackageDownload,
            OperationResult operationResult)
        {
            var recognizedInstallation = installation as RecognizedInstallation;
            var packageZipFilePath     = recognizedInstallation != null?source.GetDataPackage(forceNewPackageDownload, operationResult) : "";

            return(() => {
                IoMethods.ExecuteWithTempFolder(
                    tempFolderPath => {
                    var packageFolderPath = EwlStatics.CombinePaths(tempFolderPath, "Package");
                    if (packageZipFilePath.Any())
                    {
                        ZipOps.UnZipFileAsFolder(packageZipFilePath, packageFolderPath);
                    }

                    // Delete and re-create databases.
                    DatabaseOps.DeleteAndReCreateDatabaseFromFile(
                        installation.ExistingInstallationLogic.Database,
                        databaseHasMinimumDataRevision(installation.ExistingInstallationLogic.RuntimeConfiguration.PrimaryDatabaseSystemConfiguration),
                        packageFolderPath);
                    if (recognizedInstallation != null)
                    {
                        foreach (var secondaryDatabase in recognizedInstallation.RecognizedInstallationLogic.SecondaryDatabasesIncludedInDataPackages)
                        {
                            DatabaseOps.DeleteAndReCreateDatabaseFromFile(
                                secondaryDatabase,
                                databaseHasMinimumDataRevision(
                                    installation.ExistingInstallationLogic.RuntimeConfiguration.GetSecondaryDatabaseSystemConfiguration(
                                        secondaryDatabase.SecondaryDatabaseName)),
                                packageFolderPath);
                        }
                    }
                });

                DatabaseOps.WaitForDatabaseRecovery(installation.ExistingInstallationLogic.Database);
                if (recognizedInstallation != null)
                {
                    recompileProceduresInSecondaryOracleDatabases(recognizedInstallation);
                }

                if (!installationIsStandbyDb)
                {
                    // Bring database logic up to date with the rest of the logic in this installation. In other words, reapply changes lost when we deleted the database.
                    StatusStatics.SetStatus("Updating database logic...");
                    DatabaseOps.UpdateDatabaseLogicIfUpdateFileExists(
                        installation.ExistingInstallationLogic.Database,
                        installation.ExistingInstallationLogic.DatabaseUpdateFilePath,
                        installation.ExistingInstallationLogic.RuntimeConfiguration.InstallationType == InstallationType.Development);
                }

                // If we're an intermediate installation and we are getting data from a live installation, sanitize the data and do other conversion commands.
                if (installation is RecognizedInstalledInstallation recognizedInstalledInstallation &&
                    recognizedInstalledInstallation.KnownInstallationLogic.RsisInstallation.InstallationTypeElements is IntermediateInstallationElements &&
                    source.InstallationTypeElements is LiveInstallationElements)
                {
                    StatusStatics.SetStatus("Executing live -> intermediate conversion commands...");
                    doDatabaseLiveToIntermediateConversionIfCommandsExist(
                        installation.ExistingInstallationLogic.Database,
                        installation.ExistingInstallationLogic.RuntimeConfiguration.PrimaryDatabaseSystemConfiguration);
                    foreach (var secondaryDatabase in recognizedInstallation.RecognizedInstallationLogic.SecondaryDatabasesIncludedInDataPackages)
                    {
                        doDatabaseLiveToIntermediateConversionIfCommandsExist(
                            secondaryDatabase,
                            installation.ExistingInstallationLogic.RuntimeConfiguration.GetSecondaryDatabaseSystemConfiguration(secondaryDatabase.SecondaryDatabaseName));
                    }
                }
            });
        }