コード例 #1
0
        void Database.ExportToFile(string filePath)
        {
            Directory.CreateDirectory(dataPumpFolderPath);
            try {
                executeMethodWithDbExceptionHandling(
                    delegate {
                    try {
                        // We pass an enter keystroke as input in an attempt to kill the program if it gets stuck on a username prompt because of a bad logon string.
                        EwlStatics.RunProgram(
                            "expdp",
                            getLogonString() + " DIRECTORY=" + dataPumpOracleDirectoryName + " DUMPFILE=\"\"\"" + getDumpFileName() + "\"\"\" NOLOGFILE=y VERSION=12.1",
                            Environment.NewLine,
                            true);
                    }
                    catch (Exception e) {
                        throwUserCorrectableExceptionIfNecessary(e);
                        throw DataAccessMethods.CreateDbConnectionException(info, "exporting (to file)", e);
                    }
                });

                IoMethods.ExecuteWithTempFolder(
                    folderPath => {
                    IoMethods.CopyFile(getDumpFilePath(), EwlStatics.CombinePaths(folderPath, databaseFileDumpFileName));
                    File.WriteAllText(EwlStatics.CombinePaths(folderPath, databaseFileSchemaNameFileName), info.UserAndSchema);
                    ZipOps.ZipFolderAsFile(folderPath, filePath);
                });
            }
            finally {
                IoMethods.DeleteFile(getDumpFilePath());
            }
        }
コード例 #2
0
        internal static byte[] CreateEwlNuGetPackage(DevelopmentInstallation installation, bool useDebugAssembly, string outputFolderPath, bool?prerelease)
        {
            var localExportDateAndTime = prerelease.HasValue ? null as DateTime? : DateTime.Now;

            IoMethods.ExecuteWithTempFolder(folderPath => {
                var ewlOutputFolderPath = StandardLibraryMethods.CombinePaths(installation.GeneralLogic.Path,
                                                                              "Standard Library",
                                                                              StandardLibraryMethods.GetProjectOutputFolderPath(useDebugAssembly));
                var libFolderPath = StandardLibraryMethods.CombinePaths(folderPath, @"lib\net451-full");
                foreach (var fileName in new[] { "dll", "pdb", "xml" }.Select(i => "EnterpriseWebLibrary." + i))
                {
                    IoMethods.CopyFile(StandardLibraryMethods.CombinePaths(ewlOutputFolderPath, fileName), StandardLibraryMethods.CombinePaths(libFolderPath, fileName));
                }

                IoMethods.CopyFile(StandardLibraryMethods.CombinePaths(installation.GeneralLogic.Path, @"Development Utility\Package Manager Console Commands.ps1"),
                                   StandardLibraryMethods.CombinePaths(folderPath, @"tools\init.ps1"));

                var webSitePath = StandardLibraryMethods.CombinePaths(installation.GeneralLogic.Path, "Web Site");
                var webProjectFilesFolderPath = StandardLibraryMethods.CombinePaths(folderPath, AppStatics.WebProjectFilesFolderName);
                IoMethods.CopyFolder(StandardLibraryMethods.CombinePaths(webSitePath, AppStatics.EwfFolderName),
                                     StandardLibraryMethods.CombinePaths(webProjectFilesFolderPath, AppStatics.EwfFolderName),
                                     false);
                IoMethods.CopyFile(StandardLibraryMethods.CombinePaths(webSitePath, AppStatics.StandardLibraryFilesFileName),
                                   StandardLibraryMethods.CombinePaths(webProjectFilesFolderPath, AppStatics.StandardLibraryFilesFileName));

                const string duProjectAndFolderName = "Development Utility";
                IoMethods.CopyFolder(
                    StandardLibraryMethods.CombinePaths(installation.GeneralLogic.Path,
                                                        duProjectAndFolderName,
                                                        StandardLibraryMethods.GetProjectOutputFolderPath(useDebugAssembly)),
                    StandardLibraryMethods.CombinePaths(folderPath, duProjectAndFolderName),
                    false);
                packageGeneralFiles(installation, folderPath, false);
                IoMethods.CopyFolder(
                    StandardLibraryMethods.CombinePaths(installation.ExistingInstallationLogic.RuntimeConfiguration.ConfigurationFolderPath,
                                                        InstallationConfiguration.InstallationConfigurationFolderName,
                                                        InstallationConfiguration.InstallationsFolderName,
                                                        (!prerelease.HasValue || prerelease.Value ? "Testing" : "Live")),
                    StandardLibraryMethods.CombinePaths(folderPath,
                                                        InstallationConfiguration.ConfigurationFolderName,
                                                        InstallationConfiguration.InstallationConfigurationFolderName),
                    false);

                var manifestPath = StandardLibraryMethods.CombinePaths(folderPath, "Package.nuspec");
                using (var writer = IoMethods.GetTextWriterForWrite(manifestPath))
                    writeNuGetPackageManifest(installation, prerelease, localExportDateAndTime, writer);

                StatusStatics.SetStatus(StandardLibraryMethods.RunProgram(StandardLibraryMethods.CombinePaths(installation.GeneralLogic.Path, @"Solution Files\nuget"),
                                                                          "pack \"" + manifestPath + "\" -OutputDirectory \"" + outputFolderPath + "\"",
                                                                          "",
                                                                          true));
            });

            return
                (File.ReadAllBytes(StandardLibraryMethods.CombinePaths(outputFolderPath,
                                                                       EwlNuGetPackageSpecificationStatics.GetNuGetPackageFileName(installation.ExistingInstallationLogic.RuntimeConfiguration.SystemShortName,
                                                                                                                                   installation.CurrentMajorVersion,
                                                                                                                                   !prerelease.HasValue || prerelease.Value ? installation.NextBuildNumber as int? : null,
                                                                                                                                   localExportDateAndTime: localExportDateAndTime))));
        }
コード例 #3
0
 private void createAndZipSystem(Stream stream)
 {
     IoMethods.ExecuteWithTempFolder(
         folderPath => {
         createSystemFilesInFolder(EwlStatics.CombinePaths(ConfigurationStatics.FilesFolderPath, "System Template"), folderPath, "");
         ZipOps.ZipFolderAsStream(folderPath, stream);
     });
 }
コード例 #4
0
        void Database.DeleteAndReCreateFromFile(string filePath)
        {
            executeDbMethodWithSpecifiedDatabaseInfo(
                new OracleInfo(
                    (info as DatabaseInfo).SecondaryDatabaseName,
                    info.DataSource,
                    "sys",
                    ConfigurationLogic.OracleSysPassword,
                    info.SupportsConnectionPooling,
                    info.SupportsLinguisticIndexes),
                cn => {
                executeLongRunningCommand(cn, "CREATE OR REPLACE DIRECTORY " + dataPumpOracleDirectoryName + " AS '" + dataPumpFolderPath + "'");
                deleteAndReCreateUser(cn);
            });

            try {
                IoMethods.ExecuteWithTempFolder(
                    tempFolderPath => {
                    var folderPath = EwlStatics.CombinePaths(tempFolderPath, "Database File");
                    ZipOps.UnZipFileAsFolder(filePath, folderPath);
                    try {
                        IoMethods.CopyFile(EwlStatics.CombinePaths(folderPath, databaseFileDumpFileName), getDumpFilePath());

                        executeMethodWithDbExceptionHandling(
                            delegate {
                            try {
                                EwlStatics.RunProgram(
                                    "impdp",
                                    getLogonString() + " DIRECTORY=" + dataPumpOracleDirectoryName + " DUMPFILE=\"\"\"" + getDumpFileName() + "\"\"\" NOLOGFILE=y REMAP_SCHEMA=" +
                                    File.ReadAllText(EwlStatics.CombinePaths(folderPath, databaseFileSchemaNameFileName)) + ":" + info.UserAndSchema,
                                    "",
                                    true);
                            }
                            catch (Exception e) {
                                throwUserCorrectableExceptionIfNecessary(e);
                                if (e is FileNotFoundException)
                                {
                                    throw new UserCorrectableException("The schema name file was not found, probably because of a corrupt database file in the data package.", e);
                                }

                                // Secondary databases such as RLE cause procedure compilation errors when imported, and since we have no way of
                                // distinguishing these from legitimate import problems, we have no choice but to ignore all exceptions.
                                if ((info as DatabaseInfo).SecondaryDatabaseName.Length == 0)
                                {
                                    throw DataAccessMethods.CreateDbConnectionException(info, "re-creating (from file)", e);
                                }
                            }
                        });
                    }
                    finally {
                        IoMethods.DeleteFile(getDumpFilePath());
                    }
                });
            }
            catch {
                // We don't want to leave a partial user/schema on the machine since it may confuse future ISU operations.
                executeDbMethodWithSpecifiedDatabaseInfo(
                    new OracleInfo(
                        (info as DatabaseInfo).SecondaryDatabaseName,
                        info.DataSource,
                        "sys",
                        ConfigurationLogic.OracleSysPassword,
                        info.SupportsConnectionPooling,
                        info.SupportsLinguisticIndexes),
                    deleteUser);

                throw;
            }
        }
コード例 #5
0
        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));
                    }
                }
            });
        }
コード例 #6
0
        internal static IReadOnlyCollection <(string id, IReadOnlyList <byte[]> packages)> CreateEwlNuGetPackages(
            DevelopmentInstallation installation, PackagingConfiguration packagingConfiguration, bool useDebugAssembly, string outputFolderPath,
            IEnumerable <bool?> prereleaseValues)
        {
            var now      = DateTime.Now;
            var packages = new List <(string, IReadOnlyList <byte[]>)>();

            var mainId       = packagingConfiguration.SystemShortName;
            var mainPackages = prereleaseValues.Select(
                prerelease => {
                var localExportDateAndTime = prerelease.HasValue ? (DateTime?)null : now;

                IoMethods.ExecuteWithTempFolder(
                    folderPath => {
                    var ewlOutputFolderPath = EwlStatics.CombinePaths(
                        installation.GeneralLogic.Path,
                        EwlStatics.CoreProjectName,
                        EwlStatics.GetProjectOutputFolderPath(useDebugAssembly));
                    var libFolderPath = EwlStatics.CombinePaths(folderPath, @"lib\net472-full");
                    foreach (var fileName in new[] { "dll", "pdb", "xml" }.Select(i => "EnterpriseWebLibrary." + i))
                    {
                        IoMethods.CopyFile(EwlStatics.CombinePaths(ewlOutputFolderPath, fileName), EwlStatics.CombinePaths(libFolderPath, fileName));
                    }

                    IoMethods.CopyFile(
                        EwlStatics.CombinePaths(installation.GeneralLogic.Path, @"Development Utility\Package Manager Console Commands.ps1"),
                        EwlStatics.CombinePaths(folderPath, @"tools\init.ps1"));

                    IoMethods.CopyFolder(
                        EwlStatics.CombinePaths(installation.GeneralLogic.Path, EwlStatics.CoreProjectName, StaticFile.FrameworkStaticFilesSourceFolderPath),
                        EwlStatics.CombinePaths(folderPath, InstallationFileStatics.WebFrameworkStaticFilesFolderName),
                        false);
                    IoMethods.DeleteFolder(
                        EwlStatics.CombinePaths(folderPath, InstallationFileStatics.WebFrameworkStaticFilesFolderName, AppStatics.StaticFileLogicFolderName));

                    const string duProjectAndFolderName = "Development Utility";
                    IoMethods.CopyFolder(
                        EwlStatics.CombinePaths(installation.GeneralLogic.Path, duProjectAndFolderName, EwlStatics.GetProjectOutputFolderPath(useDebugAssembly)),
                        EwlStatics.CombinePaths(folderPath, duProjectAndFolderName),
                        false);
                    packageGeneralFiles(installation, folderPath, false);
                    IoMethods.CopyFolder(
                        EwlStatics.CombinePaths(
                            installation.ExistingInstallationLogic.RuntimeConfiguration.ConfigurationFolderPath,
                            InstallationConfiguration.InstallationConfigurationFolderName,
                            InstallationConfiguration.InstallationsFolderName,
                            !prerelease.HasValue || prerelease.Value ? "Testing" : "Live"),
                        EwlStatics.CombinePaths(
                            folderPath,
                            InstallationConfiguration.ConfigurationFolderName,
                            InstallationConfiguration.InstallationConfigurationFolderName),
                        false);
                    if (File.Exists(installation.ExistingInstallationLogic.RuntimeConfiguration.InstallationSharedConfigurationFilePath))
                    {
                        IoMethods.CopyFile(
                            installation.ExistingInstallationLogic.RuntimeConfiguration.InstallationSharedConfigurationFilePath,
                            EwlStatics.CombinePaths(
                                folderPath,
                                InstallationConfiguration.ConfigurationFolderName,
                                InstallationConfiguration.InstallationConfigurationFolderName,
                                InstallationConfiguration.InstallationSharedConfigurationFileName));
                    }

                    var manifestPath = EwlStatics.CombinePaths(folderPath, "Package.nuspec");
                    using (var writer = IoMethods.GetTextWriterForWrite(manifestPath))
                        writeNuGetPackageManifest(
                            writer,
                            installation,
                            mainId,
                            "",
                            w => {
                            var lines = from line in File.ReadAllLines(
                                EwlStatics.CombinePaths(installation.GeneralLogic.Path, EwlStatics.CoreProjectName, "packages.config"))
                                        let trimmedLine = line.Trim()
                                                          where trimmedLine.StartsWith("<package ")
                                                          select trimmedLine;
                            foreach (var line in lines)
                            {
                                w.WriteLine(Regex.Replace(line.Replace("package", "dependency"), @" targetFramework=""[\w]+""", ""));
                            }
                        },
                            prerelease,
                            localExportDateAndTime);

                    StatusStatics.SetStatus(
                        TewlContrib.ProcessTools.RunProgram(
                            EwlStatics.CombinePaths(installation.GeneralLogic.Path, @"Solution Files\nuget"),
                            "pack \"" + manifestPath + "\" -OutputDirectory \"" + outputFolderPath + "\"",
                            "",
                            true));
                });

                return(File.ReadAllBytes(
                           EwlStatics.CombinePaths(
                               outputFolderPath,
                               EwlNuGetPackageSpecificationStatics.GetNuGetPackageFileName(
                                   mainId,
                                   installation.CurrentMajorVersion,
                                   !prerelease.HasValue || prerelease.Value ? installation.NextBuildNumber as int? : null,
                                   localExportDateAndTime: localExportDateAndTime))));
            })
                               .MaterializeAsList();

            packages.Add((mainId, mainPackages));

            var samlId       = mainId + ".Saml";
            var samlPackages = prereleaseValues.Select(
                prerelease => {
                var localExportDateAndTime = prerelease.HasValue ? (DateTime?)null : now;

                IoMethods.ExecuteWithTempFolder(
                    folderPath => {
                    foreach (var fileName in new[] { "dll", "pdb" }.Select(i => "EnterpriseWebLibrary.Saml." + i))
                    {
                        IoMethods.CopyFile(
                            EwlStatics.CombinePaths(
                                installation.GeneralLogic.Path,
                                EwlStatics.SamlProviderProjectPath,
                                EwlStatics.GetProjectOutputFolderPath(useDebugAssembly),
                                fileName),
                            EwlStatics.CombinePaths(folderPath, @"lib\net472-full", fileName));
                    }

                    var manifestPath = EwlStatics.CombinePaths(folderPath, "Package.nuspec");
                    using (var writer = IoMethods.GetTextWriterForWrite(manifestPath))
                        writeNuGetPackageManifest(
                            writer,
                            installation,
                            samlId,
                            "SAML Provider",
                            w => {
                            w.WriteLine(
                                "<dependency id=\"{0}\" version=\"[{1}]\" />".FormatWith(
                                    mainId,
                                    EwlNuGetPackageSpecificationStatics.GetNuGetPackageVersionString(
                                        installation.CurrentMajorVersion,
                                        !prerelease.HasValue || prerelease.Value ? (int?)installation.NextBuildNumber : null,
                                        localExportDateAndTime: localExportDateAndTime)));
                            w.WriteLine("<dependency id=\"ComponentSpace.Saml2.Net.Licensed\" version=\"5.0.0\" />");
                        },
                            prerelease,
                            localExportDateAndTime);

                    StatusStatics.SetStatus(
                        TewlContrib.ProcessTools.RunProgram(
                            EwlStatics.CombinePaths(installation.GeneralLogic.Path, @"Solution Files\nuget"),
                            "pack \"" + manifestPath + "\" -OutputDirectory \"" + outputFolderPath + "\"",
                            "",
                            true));
                });

                return(File.ReadAllBytes(
                           EwlStatics.CombinePaths(
                               outputFolderPath,
                               EwlNuGetPackageSpecificationStatics.GetNuGetPackageFileName(
                                   samlId,
                                   installation.CurrentMajorVersion,
                                   !prerelease.HasValue || prerelease.Value ? installation.NextBuildNumber as int? : null,
                                   localExportDateAndTime: localExportDateAndTime))));
            })
                               .MaterializeAsList();

            packages.Add((samlId, samlPackages));

            return(packages);
        }