public void Execute(SqlConnection connection, IScriptExecuteCallback callback)
        {
            if (connection == null)
            {
                throw new ArgumentNullException("connection");
            }
            if (callback == null)
            {
                throw new ArgumentNullException("callback");
            }

            int        index = 0;
            ScriptStep stepToRun;

            callback.ExecutionStarting(this);

            while (index < Count)
            {
                stepToRun = this[index];
                if (!callback.Progress(stepToRun, index + 1, Count))
                {
                    break;
                }
                stepToRun.Execute(connection, callback);

                index++;
            }
        }
Ejemplo n.º 2
0
        public void Execute(SqlConnection connection, IScriptExecuteCallback callback)
        {
            if (runState != ScriptRunState.None)
            {
                throw new InvalidOperationException("Already Run");
            }

            SqlCommand command = connection.CreateCommand();

            command.CommandText    = commandText;
            command.CommandType    = CommandType.Text;
            command.CommandTimeout = 0;

            runState = ScriptRunState.Running;
            try
            {
                ExecuteCommand(command);
                runState = ScriptRunState.Succeeded;
            }
            catch (SqlException ex)
            {
                exception = ex;
                callback.Error(this, ex);
                runState = ScriptRunState.Failed;
            }
        }
Ejemplo n.º 3
0
 public WorkerThreadArguments(bool scriptOnly, IScriptExecuteCallback callback, string server, string userId, string password, string database, bool dropAllConstraints, string collation, FullTextLanguage language, bool setSingleUser)
 {
     this.scriptOnly         = scriptOnly;
     this.callback           = callback;
     this.server             = server;
     this.userId             = userId;
     this.password           = password;
     this.database           = database;
     this.dropAllConstraints = dropAllConstraints;
     this.collation          = collation;
     this.language           = language;
     this.setSingleUser      = setSingleUser;
 }
        public void Execute(SqlConnection connection, IScriptExecuteCallback callback)
        {
            if (connection == null) throw new ArgumentNullException("connection");
            if (callback== null) throw new ArgumentNullException("callback");

            int index=0;
            ScriptStep stepToRun;
            callback.ExecutionStarting(this);

            while (index < Count)
            {
                stepToRun = this[index];
                if (!callback.Progress(stepToRun, index + 1, Count)) break;
                stepToRun.Execute(connection, callback);

                index++;
            }
        }
Ejemplo n.º 5
0
        public ScriptStepCollection GenerateScript(IScriptExecuteCallback callback, string server, string userId, string password, string database, bool dropAllConstraints, string collation, FullTextLanguage language, bool setSingleUser)
        {
            SqlConnection connection = new SqlConnection();
            connection.ConnectionString = Utils.ConnectionString(server, userId, password, 2, database);

            try
            {
                connection.Open();
                ScriptStepCollection script = LoadScript(new Version(connection.ServerVersion), database, dropAllConstraints, collation, language, setSingleUser);
                //now get the last script entry and replace it with
                //a special component that will return out

                ScriptStepGenerateScript generator = new ScriptStepGenerateScript(script[script.Count - 1]);
                script[script.Count - 1] = generator;
                script.Execute(connection, callback);
                return generator.Script;
            }
            finally
            {
                connection.Dispose();
            }
        }
Ejemplo n.º 6
0
        public void Execute(SqlConnection connection, IScriptExecuteCallback callback)
        {
            if (runState != ScriptRunState.None)
                throw new InvalidOperationException("Already Run");

            SqlCommand command = connection.CreateCommand();
            command.CommandText = commandText;
            command.CommandType = CommandType.Text;
            command.CommandTimeout = 0;

            runState = ScriptRunState.Running;
            try
            {
                ExecuteCommand(command);
                runState = ScriptRunState.Succeeded;
            }
            catch(SqlException ex)
            {
                exception = ex;
                callback.Error(this, ex);
                runState = ScriptRunState.Failed;
            }
        }
Ejemplo n.º 7
0
        public ScriptStepCollection GenerateScript(IScriptExecuteCallback callback, string server, string userId, string password, string database, bool dropAllConstraints, string collation, FullTextLanguage language, bool setSingleUser)
        {
            SqlConnection connection = new SqlConnection();

            connection.ConnectionString = Utils.ConnectionString(server, userId, password);

            try
            {
                connection.Open();
                ScriptStepCollection script = LoadScript(new Version(connection.ServerVersion), database, dropAllConstraints, collation, language, setSingleUser);
                //now get the last script entry and replace it with
                //a special component that will return out

                ScriptStepGenerateScript generator = new ScriptStepGenerateScript(script[script.Count - 1]);
                script[script.Count - 1] = generator;
                script.Execute(connection, callback);
                return(generator.Script);
            }
            finally
            {
                connection.Dispose();
            }
        }
Ejemplo n.º 8
0
            public WorkerThreadArguments(bool scriptOnly, IScriptExecuteCallback callback, string server, string userId, string password, string database, bool dropAllConstraints, string collation, FullTextLanguage language, bool setSingleUser)
            {
                this.scriptOnly = scriptOnly;
                this.callback = callback;
                this.server = server;
                this.userId = userId;
                this.password = password;
                this.database = database;
                this.dropAllConstraints = dropAllConstraints;
                this.collation = collation;
                this.language = language;
				this.setSingleUser =setSingleUser;
            }