Пример #1
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);
        }
Пример #2
0
        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);
        }