コード例 #1
0
 public RoundhouseMigrationRunner(
     string repository_path,
     EnvironmentSet environment_set,
     KnownFolders known_folders,
     FileSystemAccess file_system,
     DatabaseMigrator database_migrator,
     VersionResolver version_resolver,
     bool silent,
     bool dropping_the_database,
     bool dont_create_the_database,
     bool run_in_a_transaction,
     bool use_simple_recovery,
     ConfigurationPropertyHolder configuration)
 {
     this.known_folders = known_folders;
     this.repository_path = repository_path;
     this.environment_set = environment_set;
     this.file_system = file_system;
     this.database_migrator = database_migrator;
     this.version_resolver = version_resolver;
     this.silent = silent;
     this.dropping_the_database = dropping_the_database;
     this.dont_create_the_database = dont_create_the_database;
     this.run_in_a_transaction = run_in_a_transaction;
     this.use_simple_recovery = use_simple_recovery;
     this.configuration = configuration;
 }
コード例 #2
0
    public void SetEnvironment()
    {
        set = setsList[Random.Range(0, setsList.Count)];                             //Set the first environment
        GameObject spawn = Instantiate(set.specialPrefabs[0]);                       //Instantiate the Spawn

        prefabsInstantiated.Add(spawn.GetComponent <EnvironmentPrefabController>()); //Add the spawn to the list of instantiated prefabs
    }
コード例 #3
0
 public RoundhouseMigrationRunner(
     string repository_path,
     EnvironmentSet environment_set,
     KnownFolders known_folders,
     FileSystemAccess file_system,
     DatabaseMigrator database_migrator,
     VersionResolver version_resolver,
     bool silent,
     bool dropping_the_database,
     bool dont_create_the_database,
     bool run_in_a_transaction,
     ConfigurationPropertyHolder configuration)
 {
     this.known_folders            = known_folders;
     this.repository_path          = repository_path;
     this.environment_set          = environment_set;
     this.file_system              = file_system;
     this.database_migrator        = database_migrator;
     this.version_resolver         = version_resolver;
     this.silent                   = silent;
     this.dropping_the_database    = dropping_the_database;
     this.dont_create_the_database = dont_create_the_database;
     this.run_in_a_transaction     = run_in_a_transaction;
     this.configuration            = configuration;
 }
コード例 #4
0
        public void ChangeVar(String refID, String name, String value)
        {
            if (!this.Project.DataTypeReferences.Contains(refID))
            {
                throw new BuildException(String.Format("The refid {0} is not defined.", refID));
            }

            EnvironmentSet RefEnvironmentSet = (EnvironmentSet)this.Project.DataTypeReferences[refID];

            RefEnvironmentSet.EnvironmentVariables[name].Value = value;
        }
コード例 #5
0
        private void btnNew_Click(object sender, EventArgs e)
        {
            AddEnvironment ae = new AddEnvironment();

            if (ae.ShowDialog() == DialogResult.OK)
            {
                EnvironmentSet es = new EnvironmentSet();
                es.Name      = ae.Environment;
                es.Variables = new System.Collections.Hashtable();
                cbVariableSet.Items.Insert(0, es);
                cbVariableSet.SelectedIndex = 0;
                updated = true;
            }
        }
コード例 #6
0
        private void RefreshLbVariables()
        {
            lbVariables.Items.Clear();
            EnvironmentSet es = (EnvironmentSet)cbVariableSet.SelectedItem;

            foreach (var v in es.Variables.Keys)
            {
                lbVariables.Items.Add(v);
            }
            if (lbVariables.Items.Count > 0)
            {
                lbVariables.SelectedIndex = 0;
            }
            ResetButtons();
        }
コード例 #7
0
 public RoundhouseUpdateCheckRunner(
     EnvironmentSet environment_set,
     KnownFolders known_folders,
     FileSystemAccess file_system,
     DatabaseMigrator database_migrator,
     ConfigurationPropertyHolder configuration,
     RoundhouseMigrationRunner migration_runner)
 {
     this.environment_set   = environment_set;
     this.known_folders     = known_folders;
     this.file_system       = file_system;
     this.database_migrator = database_migrator;
     this.configuration     = configuration;
     this.migration_runner  = migration_runner;
 }
コード例 #8
0
 void SetNewEnvironment()
 {
     if (setsList.Count == 1)
     {
         set = setsList[0];
     }
     else
     {
         EnvironmentSet temp = setsList[Random.Range(0, setsList.Count)]; //Set the first environment
                                                                          //Debug.Log(set.name + "  " + temp.name);
         while (set == temp)                                              //Redo the random until we get an environment different to the actual
         {
             temp = setsList[Random.Range(0, setsList.Count)];
             //Debug.Log("IN "+set.name + "  " + temp.name);
         }
         set = temp;//Set the environment        }
     }
 }
コード例 #9
0
        protected override void ExecuteTask()
        {
            EnvironmentSet RefEnvironmentSet = null;

            if (!this.Project.DataTypeReferences.Contains(RefId))
            {
                RefEnvironmentSet                  = new EnvironmentSet();
                RefEnvironmentSet.ID               = this.RefId;
                RefEnvironmentSet.Project          = this.Project;
                RefEnvironmentSet.Parent           = this.Project;
                RefEnvironmentSet.NamespaceManager = this.NamespaceManager;
                this.Project.DataTypeReferences.Add(RefEnvironmentSet.ID, RefEnvironmentSet);
            }

            RefEnvironmentSet = (EnvironmentSet)this.Project.DataTypeReferences[RefId];
            foreach (EnvironmentVariable EnvVar in EnvironmentVariables)
            {
                RefEnvironmentSet.EnvironmentVariables.Add(EnvVar);
            }
        }
コード例 #10
0
        //todo:down story

        public void traverse_files_and_run_sql(string directory, long version_id, MigrationsFolder migration_folder, EnvironmentSet migrating_environment_set,
                                               string repository_version, ConnectionType connection_type)
        {
            if (!file_system.directory_exists(directory)) return;

            var fileNames = configuration.SearchAllSubdirectoriesInsteadOfTraverse
                                ? file_system.get_all_file_name_strings_recurevly_in(directory, SQL_EXTENSION)
                                : file_system.get_all_file_name_strings_in(directory, SQL_EXTENSION);
            foreach (string sql_file in fileNames)
            {
                string sql_file_text = replace_tokens(get_file_text(sql_file));
                Log.bound_to(this).log_a_debug_event_containing(" Found and running {0}.", sql_file);
                bool the_sql_ran = database_migrator.run_sql(sql_file_text, file_system.get_file_name_from(sql_file),
                                                             migration_folder.should_run_items_in_folder_once,
                                                             migration_folder.should_run_items_in_folder_every_time,
                                                             version_id, migrating_environment_set, repository_version, repository_path, connection_type);
                if (the_sql_ran)
                {
                    try
                    {
                        copy_to_change_drop_folder(sql_file, migration_folder);
                    }
                    catch (Exception ex)
                    {
                        Log.bound_to(this).log_a_warning_event_containing("Unable to copy {0} to {1}. {2}{3}", sql_file, migration_folder.folder_full_path,
                                                                          System.Environment.NewLine, ex.to_string());
                    }
                }
            }

            if (configuration.SearchAllSubdirectoriesInsteadOfTraverse) return;
            foreach (string child_directory in file_system.get_all_directory_name_strings_in(directory))
            {
                traverse_files_and_run_sql(child_directory, version_id, migration_folder, migrating_environment_set, repository_version, connection_type);
            }
        }
コード例 #11
0
        public bool this_is_an_environment_file_and_its_in_the_right_environment(string script_name, EnvironmentSet environment_set)
        {
            string environment_set_names = string.Join(", ", environment_set.set_items.Select(x => x.name));

            Log.bound_to(this).log_a_debug_event_containing("Checking to see if {0} is an environment file. We have an environment set containing: .", script_name, environment_set_names);

            if (!script_name.to_lower().Contains(".env."))
            {
                // return true because this is NOT an environment file for the next check
                return(true);
            }

            bool environment_file_is_in_the_right_environment = environment_set.item_is_for_this_environment_set(script_name);

            Log.bound_to(this).log_an_info_event_containing(" {0} is an environment file. We have an environment set containing: {1}. This will{2} run based on this check.",
                                                            script_name, environment_set_names, environment_file_is_in_the_right_environment ? string.Empty : " NOT");

            return(environment_file_is_in_the_right_environment);
        }
コード例 #12
0
        public bool this_script_is_new_or_updated(string script_name, string sql_to_run, EnvironmentSet environment_set)
        {
            if (!this_is_an_environment_file_and_its_in_the_right_environment(script_name, environment_set))
            {
                return(false);
            }

            if (this_script_has_run_already(script_name) &&
                !this_script_has_changed_since_last_run(script_name, sql_to_run))
            {
                return(false);
            }

            return(true);
        }
コード例 #13
0
        public bool run_sql(string sql_to_run, string script_name, bool run_this_script_once, bool run_this_script_every_time, long version_id, EnvironmentSet environment_set, string repository_version, string repository_path, ConnectionType connection_type)
        {
            bool this_sql_ran = false;
            bool skip_run     = is_baseline;

            if (this_is_a_one_time_script_that_has_changes_but_has_already_been_run(script_name, sql_to_run, run_this_script_once))
            {
                if (error_on_one_time_script_changes)
                {
                    database.rollback();
                    string error_message = string.Format("{0} has changed since the last time it was run. By default this is not allowed - scripts that run once should never change. To change this behavior to a warning, please set warnOnOneTimeScriptChanges to true and run again. Stopping execution.", script_name);
                    record_script_in_scripts_run_errors_table(script_name, sql_to_run, sql_to_run, error_message, repository_version, repository_path);
                    database.close_connection();
                    throw new Exception(error_message);
                }
                if (ignore_one_time_script_changes)
                {
                    skip_run = true;
                }
                Log.bound_to(this).log_a_warning_event_containing("{0} is a one time script that has changed since it was run.", script_name);
            }

            if (this_is_an_environment_file_and_its_in_the_right_environment(script_name, environment_set) &&
                this_script_should_run(script_name, sql_to_run, run_this_script_once, run_this_script_every_time))
            {
                if (!is_dryrun)
                {
                    Log.bound_to(this).log_an_info_event_containing(" {3} {0} on {1} - {2}.", script_name, database.server_name, database.database_name,
                                                                    skip_run ? "BASELINING: Recording" : "Running");
                }
                if (!skip_run)
                {
                    if (!is_dryrun)
                    {
                        foreach (var sql_statement in get_statements_to_run(sql_to_run))
                        {
                            try
                            {
                                database.run_sql(sql_statement, connection_type);
                            }
                            catch (Exception ex)
                            {
                                database.rollback();

                                record_script_in_scripts_run_errors_table(script_name, sql_to_run, sql_statement, ex.Message, repository_version, repository_path);
                                database.close_connection();
                                throw;
                            }
                        }
                    }
                    else
                    {
                        Log.bound_to(this).log_a_warning_event_containing(" DryRun: {0} on {1} - {2}.", script_name, database.server_name, database.database_name);
                    }
                }
                if (!is_dryrun)
                {
                    record_script_in_scripts_run_table(script_name, sql_to_run, run_this_script_once, version_id);
                    this_sql_ran = true;
                }
            }
            else
            {
                Log.bound_to(this).log_an_info_event_containing(" Skipped {0} - {1}.", script_name, run_this_script_once ? "One time script" : "No changes were found to run");
            }

            return(this_sql_ran);
        }
コード例 #14
0
        public bool this_is_an_environment_file_and_its_in_the_right_environment(string script_name, EnvironmentSet environment_set)
        {
            string environment_set_names = string.Join(", ", environment_set.set_items.Select(x => x.name));

            Log.bound_to(this).log_a_debug_event_containing("Checking to see if {0} is an environment file. We have an environment set containing: .", script_name, environment_set_names);

            if (!script_name.to_lower().Contains(".env."))
            {
                // return true because this is NOT an environment file for the next check
                return true;
            }

            bool environment_file_is_in_the_right_environment = environment_set.item_is_for_this_environment_set(script_name);

            Log.bound_to(this).log_an_info_event_containing(" {0} is an environment file. We have an environment set containing: {1}. This will{2} run based on this check.",
                                                            script_name, environment_set_names, environment_file_is_in_the_right_environment ? string.Empty : " NOT");

            return environment_file_is_in_the_right_environment;
        }
コード例 #15
0
        public bool run_sql(string sql_to_run, string script_name, bool run_this_script_once, bool run_this_script_every_time, long version_id, EnvironmentSet environment_set, string repository_version, string repository_path, ConnectionType connection_type)
        {
            bool this_sql_ran = false;
            bool skip_run = is_baseline;

            if (this_is_a_one_time_script_that_has_changes_but_has_already_been_run(script_name, sql_to_run, run_this_script_once))
            {
                if (error_on_one_time_script_changes)
                {
                    database.rollback();
                    string error_message = string.Format("{0} has changed since the last time it was run. By default this is not allowed - scripts that run once should never change. To change this behavior to a warning, please set warnOnOneTimeScriptChanges to true and run again. Stopping execution.", script_name);
                    record_script_in_scripts_run_errors_table(script_name, sql_to_run, sql_to_run, error_message, repository_version, repository_path);
                    database.close_connection();
                    throw new Exception(error_message);
                }
                if (ignore_one_time_script_changes)
                {
                    skip_run = true;
                }
                Log.bound_to(this).log_a_warning_event_containing("{0} is a one time script that has changed since it was run.", script_name);
            }

            if (this_is_an_environment_file_and_its_in_the_right_environment(script_name, environment_set)
                && this_script_should_run(script_name, sql_to_run, run_this_script_once, run_this_script_every_time))
            {
                if (!is_dryrun)
                {
                    Log.bound_to(this).log_an_info_event_containing(" {3} {0} on {1} - {2}.", script_name, database.server_name, database.database_name,
                                            skip_run ? "BASELINING: Recording" : "Running");
                }
                if (!skip_run)
                {
                    if (!is_dryrun)
                    {
                        foreach (var sql_statement in get_statements_to_run(sql_to_run))
                        {
                            try
                            {
                                database.run_sql(sql_statement, connection_type);
                            }
                            catch (Exception ex)
                            {
                                database.rollback();

                                record_script_in_scripts_run_errors_table(script_name, sql_to_run, sql_statement, ex.Message, repository_version, repository_path);
                                database.close_connection();
                                throw;
                            }
                        }
                    }
                    else
                    {
                        Log.bound_to(this).log_a_warning_event_containing(" DryRun: {0} on {1} - {2}.", script_name, database.server_name, database.database_name);
                    }
                }
                if (!is_dryrun)
                {
                    record_script_in_scripts_run_table(script_name, sql_to_run, run_this_script_once, version_id);
                    this_sql_ran = true;
                }
            }
            else
            {
                Log.bound_to(this).log_an_info_event_containing(" Skipped {0} - {1}.", script_name, run_this_script_once ? "One time script" : "No changes were found to run");
            }

            return this_sql_ran;
        }
コード例 #16
0
        //todo:down story

        public void traverse_files_and_run_sql(string directory, long version_id, MigrationsFolder migration_folder, EnvironmentSet migrating_environment_set,
                                               string repository_version, ConnectionType connection_type)
        {
            if (!file_system.directory_exists(directory))
            {
                return;
            }

            var fileNames = configuration.SearchAllSubdirectoriesInsteadOfTraverse
                                ? file_system.get_all_file_name_strings_recurevly_in(directory, SQL_EXTENSION)
                                : file_system.get_all_file_name_strings_in(directory, SQL_EXTENSION);

            foreach (string sql_file in fileNames)
            {
                string sql_file_text = replace_tokens(get_file_text(sql_file));
                Log.bound_to(this).log_a_debug_event_containing(" Found and running {0}.", sql_file);
                bool the_sql_ran = database_migrator.run_sql(sql_file_text, file_system.get_file_name_from(sql_file),
                                                             migration_folder.should_run_items_in_folder_once,
                                                             migration_folder.should_run_items_in_folder_every_time,
                                                             version_id, migrating_environment_set, repository_version, repository_path, connection_type);
                if (the_sql_ran)
                {
                    try
                    {
                        copy_to_change_drop_folder(sql_file, migration_folder);
                    }
                    catch (Exception ex)
                    {
                        Log.bound_to(this).log_a_warning_event_containing("Unable to copy {0} to {1}. {2}{3}", sql_file, migration_folder.folder_full_path,
                                                                          System.Environment.NewLine, ex.to_string());
                    }
                }
            }

            if (configuration.SearchAllSubdirectoriesInsteadOfTraverse)
            {
                return;
            }
            foreach (string child_directory in file_system.get_all_directory_name_strings_in(directory))
            {
                traverse_files_and_run_sql(child_directory, version_id, migration_folder, migrating_environment_set, repository_version, connection_type);
            }
        }