Exemple #1
0
        protected override void ExecuteTask()
        {
            try
            {
                Encoding encoding = new OutputFileEncoding(outputFileEncoding).AsEncoding();
                using (TextWriter outputPrintStream = new StreamWriter(outputfile.FullName, true, encoding))
                {
                    TextWriter undoOutputPrintStream = null;
                    if (undoOutputfile != null)
                    {
                        undoOutputPrintStream = new StreamWriter(undoOutputfile.FullName, true, encoding);
                    }

                    DbmsFactory factory = new DbmsFactory(dbType, dbConnection);
                    DatabaseSchemaVersionManager databaseSchemaVersion = new DatabaseSchemaVersionManager(factory, deltaSet, GetCurrentDbVersion(), changeLogTable, changeOwner);

                    IDbmsSyntax           dbmsSyntax           = factory.CreateDbmsSyntax(changeOwner);
                    ToPrintStreamDeployer toPrintSteamDeployer = new ToPrintStreamDeployer(databaseSchemaVersion, dir, outputPrintStream, dbmsSyntax, useTransaction, undoOutputPrintStream);
                    toPrintSteamDeployer.DoDeploy(lastChangeToApply);

                    if (undoOutputPrintStream != null)
                    {
                        undoOutputPrintStream.Close();
                    }
                }
            }
            catch (DbDeployException ex)
            {
                Console.Error.WriteLine(ex.Message);
                throw new BuildException(ex.Message);
            }
            catch (Exception ex)
            {
                Console.Error.WriteLine("Failed to apply changes: " + ex);
                Console.Error.WriteLine("Stack Trace:");
                Console.Error.Write(ex.StackTrace);
                throw new BuildException(ex.Message);
            }
        }
Exemple #2
0
        public static void Main(string[] args)
        {
            try
            {
                var commandLineArgumentsParser = new CommandLineArgumentsParser();
                ParsedArguments parsedArguments = commandLineArgumentsParser.ParseArgs(args);

                var printScreenFactory = new PrintScreenFactory();

                var config = new CommandLineArgsConfiguration(parsedArguments);
                var factory = new DbmsFactory(config.DbType, config.DbConnectionString);
                var databaseSchemaVersion = new DatabaseSchemaVersionManager(factory, config.DbDeltaSet, config.CurrentDbVersion, config.TableName, config.ChangeOwner);

                var directoryInfo = new DirectoryInfo(parsedArguments.GetScriptFilesFolderOrDefaultFolder());
                TextWriter outputPrintStream = printScreenFactory.GetDoPrintStream(parsedArguments);
                var dbmsSyntax = factory.CreateDbmsSyntax(config.ChangeOwner);
                var useTransaction = config.UseTransaction;
                TextWriter undoOutputPrintStream = printScreenFactory.GetUndoPrintStream(parsedArguments);

                var toPrintStreamDeployer = new ToPrintStreamDeployer(databaseSchemaVersion, directoryInfo, outputPrintStream, dbmsSyntax, useTransaction, undoOutputPrintStream);

                toPrintStreamDeployer.DoDeploy(LastVersionChangeToApply);

                printScreenFactory.ClosePrintStream(outputPrintStream);
                printScreenFactory.ClosePrintStream(undoOutputPrintStream);
            }
            catch (DbDeployException ex)
            {
                Console.Error.WriteLine(ex.Message);
                Environment.Exit(1);
            }

            catch (Exception ex)
            {
                Console.Error.WriteLine("Failed to apply changes: " + ex);
                Console.Error.WriteLine(ex.StackTrace);
                Environment.Exit(2);
            }
        }
Exemple #3
0
        public static void Main(string[] args)
        {
            try
            {
                var             commandLineArgumentsParser = new CommandLineArgumentsParser();
                ParsedArguments parsedArguments            = commandLineArgumentsParser.ParseArgs(args);

                var printScreenFactory = new PrintScreenFactory();

                var config  = new CommandLineArgsConfiguration(parsedArguments);
                var factory = new DbmsFactory(config.DbType, config.DbConnectionString);
                var databaseSchemaVersion = new DatabaseSchemaVersionManager(factory, config.DbDeltaSet, config.CurrentDbVersion, config.TableName, config.ChangeOwner);

                var        directoryInfo         = new DirectoryInfo(parsedArguments.GetScriptFilesFolderOrDefaultFolder());
                TextWriter outputPrintStream     = printScreenFactory.GetDoPrintStream(parsedArguments);
                var        dbmsSyntax            = factory.CreateDbmsSyntax(config.ChangeOwner);
                var        useTransaction        = config.UseTransaction;
                TextWriter undoOutputPrintStream = printScreenFactory.GetUndoPrintStream(parsedArguments);

                var toPrintStreamDeployer = new ToPrintStreamDeployer(databaseSchemaVersion, directoryInfo, outputPrintStream, dbmsSyntax, useTransaction, undoOutputPrintStream);

                toPrintStreamDeployer.DoDeploy(LastVersionChangeToApply);

                printScreenFactory.ClosePrintStream(outputPrintStream);
                printScreenFactory.ClosePrintStream(undoOutputPrintStream);
            }
            catch (DbDeployException ex)
            {
                Console.Error.WriteLine(ex.Message);
                Environment.Exit(1);
            }

            catch (Exception ex)
            {
                Console.Error.WriteLine("Failed to apply changes: " + ex);
                Console.Error.WriteLine(ex.StackTrace);
                Environment.Exit(2);
            }
        }
Exemple #4
0
		public override bool Execute()
		{
			bool result = false;
			try
			{
				LogTaskProperties();

			    using (TextWriter outputPrintStream = new StreamWriter(outputfile.FullName))
				{
					TextWriter undoOutputPrintStream = null;
					if (undoOutputfile != null)
					{
						undoOutputPrintStream = new StreamWriter(undoOutputfile.FullName);
					}
					DbmsFactory factory = new DbmsFactory(dbType, dbConnection);
					IDbmsSyntax dbmsSyntax = factory.CreateDbmsSyntax();
					DatabaseSchemaVersionManager databaseSchemaVersion = new DatabaseSchemaVersionManager(factory, deltaSet, null);

					ToPrintStreamDeployer toPrintSteamDeployer = new ToPrintStreamDeployer(databaseSchemaVersion, dir, outputPrintStream, dbmsSyntax, useTransaction, undoOutputPrintStream);
					toPrintSteamDeployer.DoDeploy(lastChangeToApply);

					if (undoOutputPrintStream != null)
					{
						undoOutputPrintStream.Close();
					}
				}
				result = true;
			}
			catch (DbDeployException ex)
			{
				Log.LogErrorFromException(ex, true);
				Console.Error.WriteLine(ex.Message);
			}
			catch (Exception ex)
			{
				Log.LogErrorFromException(ex, true);
				Console.Error.WriteLine("Failed to apply changes: " + ex.Message);
				Console.Error.WriteLine("Stack Trace:");
				Console.Error.Write(ex.StackTrace);
			}
			return result;
		}
Exemple #5
0
        protected override void ExecuteTask()
        {
            try
            {
                using (TextWriter outputPrintStream = this.GetOutputStream(outputfile.FullName))
                {
                    TextWriter undoOutputPrintStream = null;
                    if (undoOutputfile != null)
                        undoOutputPrintStream = this.GetOutputStream(undoOutputfile.FullName);

                    DbmsFactory factory = new DbmsFactory(dbType, dbConnection);
                    IDbmsSyntax dbmsSyntax = factory.CreateDbmsSyntax();
                    DatabaseSchemaVersionManager databaseSchemaVersion = new DatabaseSchemaVersionManager(factory, deltaSet, GetCurrentDbVersion(), changeLogTable);

                    ToPrintStreamDeployer toPrintSteamDeployer = new ToPrintStreamDeployer(databaseSchemaVersion, dir, outputPrintStream, dbmsSyntax, useTransaction, undoOutputPrintStream);
                    toPrintSteamDeployer.DoDeploy(lastChangeToApply);

                    if (undoOutputPrintStream != null)
                        undoOutputPrintStream.Close();
                }
            }
            catch (DbDeployException ex)
            {
                Console.Error.WriteLine(ex.Message);
                throw new BuildException(ex.Message);
            }
            catch (Exception ex)
            {
                Console.Error.WriteLine("Failed to apply changes: " + ex);
                Console.Error.WriteLine("Stack Trace:");
                Console.Error.Write(ex.StackTrace);
                throw new BuildException(ex.Message);
            }
        }