public void ExecuteSteps()
        {
            Enabled = false;
            var attribute = cmbAttributes.SelectedItem as ObjectCollectionItem <AttributeMetadata>;

            if (attribute == null)
            {
                MessageBox.Show(@"No Attribute Selected!", @"Unable To Execute", MessageBoxButtons.OK, MessageBoxIcon.Information);
                Enabled = true;
                return;
            }

            var newName = txtNewAttributeName.Text;

            if (string.IsNullOrWhiteSpace(newName) || !newName.Contains('_'))
            {
                MessageBox.Show(@"Invalid new Schema Name!  Schema name must contain an '_'.", @"Unable To Execute", MessageBoxButtons.OK, MessageBoxIcon.Information);
                Enabled = true;
                return;
            }

            var steps = clbSteps.CheckedItems.Cast <string>().Aggregate <string, Logic.Steps>(0, (current, item) => current | StepMapper[item]);

            if (steps == 0)
            {
                MessageBox.Show(@"No Steps Selected!", @"Unable To Execute", MessageBoxButtons.OK, MessageBoxIcon.Information);
                Enabled = true;
                return;
            }

            if (clbSteps.Items.Count == 6)
            {
                // Create of Temporary is required.  Add it to the steps
                steps |= Logic.Steps.MigrationToTempRequired;
            }


            // Update Display Name
            var langCode = attribute.Value.DisplayName.UserLocalizedLabel.LanguageCode;

            attribute.Value.DisplayName.LocalizedLabels.First(l => l.LanguageCode == langCode).Label = txtDisplayName.Text;
            tabControl.SelectedTab = tabLog;

            WorkAsync(new WorkAsyncInfo("Performing Steps...", (w, e) =>
            {
                var info = (ExecuteStepsInfo)e.Argument;
                Logic.LogHandler onLog = m => w.ReportProgress(0, m);
                info.Migrator.OnLog   += onLog;
                var result             = new ExecuteStepsResult
                {
                    Steps      = info.Steps,
                    Successful = false
                };
                e.Result = result;
                try
                {
                    info.Migrator.Run(info.CurrentAttribute, info.NewAttributeName, info.Steps, info.Action, info.NewAttribute);
                    w.ReportProgress(99, "Steps Completed!");
                    result.Successful = true;
                }
                catch (Exception ex)
                {
                    w.ReportProgress(int.MinValue, ex);
                    result.Successful = false;
                }
                finally
                {
                    info.Migrator.OnLog -= onLog;
                }
            })
            {
                PostWorkCallBack = e =>
                {
                    var result = (ExecuteStepsResult)e.Result;
                    if (result.Steps.HasFlag(Logic.Steps.MigrateToNewAttribute) && result.Successful)
                    {
                        AttributesNeedLoaded = true;
                        ExecuteMethod(LoadAttributes);
                    }
                    Enabled = true;
                },
                ProgressChanged = e =>
                {
                    var text = e.UserState.ToString();

                    if (e.ProgressPercentage != int.MinValue)
                    {
                        var state = e.UserState as Exception;
                        SetWorkingMessage(state?.Message ?? text);
                    }
                    txtLog.AppendText(text + Environment.NewLine);
                },
                AsyncArgument = new ExecuteStepsInfo
                {
                    Action           = GetCurrentAction(),
                    CurrentAttribute = attribute.Value,
                    NewAttribute     = GetNewAttributeType(),
                    NewAttributeName = txtNewAttributeName.Text,
                    Migrator         = new Logic(Service, ConnectionDetail, Metadata, Settings.TempSchemaPostfix, chkMigrate.Checked),
                    Steps            = steps
                }
            });
        }
        public void ExecuteSteps()
        {
            Enabled = false;
            var attribute = cmbAttributes.SelectedItem as ObjectCollectionItem<AttributeMetadata>;
            if (attribute == null)
            {
                MessageBox.Show(@"No Attribute Selected!", @"Unable To Execute", MessageBoxButtons.OK, MessageBoxIcon.Information);
                Enabled = true;
                return;
            }

            var newName = txtNewAttributeName.Text;
            if (string.IsNullOrWhiteSpace(newName) || !newName.Contains('_'))
            {
                MessageBox.Show(@"Invalid new Schema Name!  Schema name must contain an '_'.", @"Unable To Execute", MessageBoxButtons.OK, MessageBoxIcon.Information);
                Enabled = true;
                return;
            }

            var steps = clbSteps.CheckedItems.Cast<string>().Aggregate<string, Logic.Steps>(0, (current, item) => current | StepMapper[item]);

            if (steps == 0)
            {
                MessageBox.Show(@"No Steps Selected!", @"Unable To Execute", MessageBoxButtons.OK, MessageBoxIcon.Information);
                Enabled = true;
                return;
            }

            if (clbSteps.Items.Count == 6)
            {
                // Create of Temporary is required.  Add it to the steps
                steps |= Logic.Steps.MigrationToTempRequired;
            }


            // Update Display Name
            var langCode = attribute.Value.DisplayName.UserLocalizedLabel.LanguageCode;
            attribute.Value.DisplayName.LocalizedLabels.First(l => l.LanguageCode == langCode).Label = txtDisplayName.Text;
            tabControl.SelectedTab = tabLog;

            WorkAsync(new WorkAsyncInfo("Performing Steps...", (w, e) =>
            {
                var info = (ExecuteStepsInfo) e.Argument;
                Logic.LogHandler onLog = m => w.ReportProgress(0, m);
                info.Migrator.OnLog += onLog;
                var result = new ExecuteStepsResult
                {
                    Steps = info.Steps,
                    Successful = false
                };
                e.Result = result;
                try
                {
                    info.Migrator.Run(info.CurrentAttribute, info.NewAttributeName, info.Steps, info.Action, info.NewAttribute);
                    w.ReportProgress(99, "Steps Completed!");
                    result.Successful = true;
                }
                catch (Exception ex)
                {
                    w.ReportProgress(int.MinValue, ex);
                    result.Successful = false;
                }
                finally
                {
                    info.Migrator.OnLog -= onLog;
                }
            })
            {
                PostWorkCallBack = e =>
                {
                    var result = (ExecuteStepsResult) e.Result;
                    if (result.Steps.HasFlag(Logic.Steps.MigrateToNewAttribute) && result.Successful)
                    {
                        AttributesNeedLoaded = true;
                        ExecuteMethod(LoadAttributes);
                    }
                    Enabled = true;
                },
                ProgressChanged = e =>
                {
                    var text = e.UserState.ToString();

                    if (e.ProgressPercentage != int.MinValue)
                    {
                        var state = e.UserState as Exception;
                        SetWorkingMessage(state?.Message ?? text);
                    }
                    txtLog.AppendText(text + Environment.NewLine);
                },
                AsyncArgument = new ExecuteStepsInfo
                {
                    Action = GetCurrentAction(),
                    CurrentAttribute = attribute.Value,
                    NewAttribute = GetNewAttributeType(),
                    NewAttributeName = txtNewAttributeName.Text,
                    Migrator = new Logic(Service, ConnectionDetail, Metadata, Settings.TempSchemaPostfix, chkMigrate.Checked),
                    Steps = steps
                }
            });
        }