Ejemplo n.º 1
0
        /// <summary>
        /// Executes this instance.
        /// </summary>
        public virtual void Execute()
        {
            // fire the event
            SendMessage(string.Format(@"Starting Executing method:'{0}' on Class:'{1}'", Utility.GetCurrentMethodName(), this.GetType().BaseType.Name));

            if (UpdateEnvironment.Equals(Enums.UpdateEnvironment.Unknow))
            {
                throw new Exception(@"ERROR Can not execute the update in a Unknow Environment.");
            }

            if (IsTimeToRun())         // IsTimeToRun is abstract
            {
                GetConfigValues();     // GetConfigValues is virtual
                GetPreExecutionData(); // GetPreExecutionData is virtual

                if (IsRollBack)
                {
                    ExecuteRollBack(); // ExecuteRollBack is abstract
                }
                else
                {
                    ExecuteBackUp(); // ExecuteBackUp is abstract
                    ExecuteUpdate(); // ExecuteUpdate is abstract
                }
            }

            SendMessage(string.Format(@"Ending Executing method:'{0}' on Class:'{1}'", Utility.GetCurrentMethodName(), this.GetType().BaseType.Name));
        }
Ejemplo n.º 2
0
        private static void UpdateEnvironment(UpdateEnvironmentOptions opts)
        {
            if (string.IsNullOrEmpty(opts.Password) && !string.IsNullOrEmpty(opts.Username))
            {
                opts.Password = GetPassword();
            }

            IToolsModule module = new UpdateEnvironment(opts);
            var          result = module.Run();

            Console.WriteLine(result);
        }
Ejemplo n.º 3
0
        protected override void RefreshUpdateStatus()
        {
            SendMessage(string.Format("Starting Executing method:'{0}' on Class:'{1}'", Utility.GetCurrentMethodName(), this.GetType().Name));

            _UpdateStatus = Enums.UpdateStatus.Unknow;

            try
            {
                /*
                 *  NeverApplied = no backup tables,x
                 *  Applied      = the backup exist,x
                 *  Rollbacked   =  backup table versioned exist,
                 *  Unknow       = none of above.
                 */

                if (!UpdateEnvironment.Equals(Enums.UpdateEnvironment.Unknow))
                {
                    GetPreExecutionData();

                    // Check if is  NeverApplied = no backup tables.
                    if (!Utility.TableExist(SQLcs, BACKUP_DATABASE_NAME, TABLE_SCHEMA, @"%_TFS" + TFS_ID + @"%"))
                    {
                        _UpdateStatus = Enums.UpdateStatus.NeverApplied;
                        return;
                    }

                    // Check if is   Applied      = the backup exist,
                    if (Utility.TableExist(SQLcs, BACKUP_DATABASE_NAME, TABLE_SCHEMA, TABLE_NAME + @"_TFS" + TFS_ID))
                    {
                        _UpdateStatus = Enums.UpdateStatus.Applied;
                        return;
                    }

                    // Check if is   backup table versioned exist,
                    if (Utility.TableExist(SQLcs, BACKUP_DATABASE_NAME, TABLE_SCHEMA, TABLE_NAME + @"_TFS" + TFS_ID + @"%"))
                    {
                        _UpdateStatus = Enums.UpdateStatus.Rollbacked;
                        return;
                    }
                }
            }
            catch (Exception ex)
            {
                SendMessage(string.Format("An ERROR has occoured on method:'{0}' on Class:'{1}':" + Environment.NewLine + "'{2}' ", Utility.GetCurrentMethodName(), this.GetType().Name, ex.Message));
            }
            finally
            {
                SendMessage(string.Format("Ending Executing method:'{0}' on Class:'{1}'", Utility.GetCurrentMethodName(), this.GetType().Name));
            }
        }