Ejemplo n.º 1
0
        public static Version GetVersionFromDatabase(DiscoveredDatabase database)
        {
            var tbl = database.ExpectTable(MasterDatabaseScriptExecutor.RoundhouseVersionTable,
                                           MasterDatabaseScriptExecutor.GetRoundhouseSchemaName(database));

            //versions in the database (should only be 1)
            var versions = tbl.GetDataTable().Rows.Cast <DataRow>().Select(r =>
                                                                           r["version"] == DBNull.Value ? new Version(0, 0, 0, 0) : new Version(r["version"].ToString()))
                           .ToArray();

            if (versions.Length == 0)
            {
                return(new Version(0, 0, 0, 0));
            }

            return(versions.Max());
        }
Ejemplo n.º 2
0
        public static PatchingState IsPatchingRequired(DiscoveredDatabase database, IPatcher patcher, out Version databaseVersion, out Patch[] patchesInDatabase, out SortedDictionary <string, Patch> allPatchesInAssembly)
        {
            databaseVersion = DatabaseVersionProvider.GetVersionFromDatabase(database);

            MasterDatabaseScriptExecutor scriptExecutor = new MasterDatabaseScriptExecutor(database);

            patchesInDatabase = scriptExecutor.GetPatchesRun();

            allPatchesInAssembly = patcher.GetAllPatchesInAssembly(database);

            AssemblyName databaseAssemblyName = patcher.GetDbAssembly().GetName();

            if (databaseAssemblyName.Version < databaseVersion)
            {
                return(PatchingState.SoftwareBehindDatabase);
            }

            //if there are patches that have not been applied
            return
                (allPatchesInAssembly.Values
                 .Except(patchesInDatabase)
                 .Any() ? PatchingState.Required:PatchingState.NotRequired);
        }
Ejemplo n.º 3
0
Archivo: Patch.cs Proyecto: lulzzz/RDMP
        public static PatchingState IsPatchingRequired(SqlConnectionStringBuilder builder, IPatcher patcher, out Version databaseVersion, out Patch[] patchesInDatabase, out SortedDictionary <string, Patch> allPatchesInAssembly)
        {
            databaseVersion = DatabaseVersionProvider.GetVersionFromDatabase(builder);

            MasterDatabaseScriptExecutor scriptExecutor = new MasterDatabaseScriptExecutor(builder.DataSource, builder.InitialCatalog, builder.UserID, builder.Password);

            patchesInDatabase = scriptExecutor.GetPatchesRun();

            allPatchesInAssembly = GetAllPatchesInAssembly(patcher);

            AssemblyName databaseAssemblyName = patcher.GetDbAssembly().GetName();

            if (databaseAssemblyName.Version < databaseVersion)
            {
                return(PatchingState.SoftwareBehindDatabase);
            }

            //if there are patches that have not been applied
            return
                (allPatchesInAssembly.Values
                 .Except(patchesInDatabase)
                 .Any() ? PatchingState.Required:PatchingState.NotRequired);
        }