Example #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);
            }
        }
Example #2
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);
            }
        }