Ejemplo n.º 1
0
 /// <summary>
 /// Initializes the logger
 /// </summary>
 /// <param name="buildTask">The task object with which to iitialize the looger</param>
 public void Init(object buildTask)
 {
     if (buildTask is Task)
     {
         Task task = (Task)buildTask;
         if (task.BuildEngine == null)
         {
             logger = new TraceLog();
         }
         else
         {
             logger = new BuildLog();
             logger.Init(task.Log);
         }
     }
     else
     {
         logger = new TraceLog();
     }
 }
        /// <summary>
        /// Executes the task
        /// </summary>
        /// <param name="buildLogger">The logger instance to be used for all logging</param>
        /// <returns>False if unsuccessful</returns>
        public bool Execute(SqlDeployment.Interfaces.ILogger buildLogger)
        {
            Assembly     thisDLL = Assembly.GetExecutingAssembly();
            AssemblyName an      = thisDLL.GetName();

            Utilities.Logger = buildLogger;
            Utilities.Logger.LogInformation("Extract Database task version: {0}...", an.Version);

            ServerConnection connection = null;
            Server           sqlServer;
            string           db;

            db = string.Format("SQL_Extract_{0}", this.projectGUID);

            try
            {
                Utilities.Logger.LogInformation(string.Format("Attempting to connect to {0}...", this.sqlInstanceName));
                this.InitializeExistenceChecker();
                connection = new ServerConnection(this.sqlInstanceName);

                if (string.IsNullOrEmpty(this.sqlUsername))
                {
                    connection.LoginSecure = true;
                }
                else
                {
                    connection.LoginSecure = false;
                    connection.Login       = this.sqlUsername;
                    connection.Password    = this.sqlPassword;
                }
                connection.Connect();

                sqlServer = new Server(connection);
                this.CreateDatabase(sqlServer, db);
                this.ExtractClr();
                this.ExtractDatabase();
                this.ExtractReferenceData();
                this.GeneratePermissions();
                this.CopyCustomFiles();

                Utilities.Logger.LogInformation("Extract complete...");

                this.DropDatabase();

                Utilities.Logger.LogInformation("Dropping build database...");
            }
            catch (Exception ex)
            {
                if (Utilities.Logger.LogErrorFromException(ex))
                {
                    throw;
                }

                return(false);
            }
            finally
            {
                connection.Disconnect();
            }

            return(true);
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Initializes a new instance of the BaseLog class
 /// </summary>
 /// <param name="buildLogger">The logger object to use</param>
 public BaseLog(object buildLogger)
 {
     logger = (SqlDeployment.Interfaces.ILogger)buildLogger;
 }