public void RefreshMetaColumnSpecs(IMetadataSettingsPartialView sourceView, object actionContext)
        {
            ObfuscationConfiguration obfuscationConfiguration;
            IEnumerable <Message>    messages;
            bool?result;
            bool succeeded;
            IEnumerable <IMetaColumn> metaColumns;

            if ((object)sourceView == null)
            {
                throw new ArgumentNullException("sourceView");
            }

            if ((object)sourceView != (object)this.View.ObfuscationPartialView.MetadataSettingsPartialView)
            {
                throw new ArgumentOutOfRangeException("sourceView");
            }

            obfuscationConfiguration = new ObfuscationConfiguration()
            {
                ConfigurationVersion = ObfuscationConfiguration.CurrentConfigurationVersion,
                EngineVersion        = ObfuscationConfiguration.CurrentEngineVersion
            };
            this.ApplyViewToDocument(obfuscationConfiguration);

            messages = obfuscationConfiguration.Validate();

            if ((object)messages != null && messages.Any())
            {
                result = this.View.ShowMessages(messages, "Configuration validation on refresh delimited text field spec", true);

                if (!(result ?? false))
                {
                    return;
                }
            }

            using (IToolHost toolHost = new ToolHost())
                succeeded = toolHost.TryGetUpstreamMetadata(obfuscationConfiguration, out metaColumns);

            if (succeeded && (object)metaColumns != null)
            {
                this.View.ObfuscationPartialView.MetadataSettingsPartialView.ClearMetaColumnSpecViews();

                foreach (IMetaColumn metaColumn in metaColumns)
                {
                    var headerSpec = (HeaderSpec)metaColumn.TagContext;
                    this.View.ObfuscationPartialView.MetadataSettingsPartialView.AddMetaColumnSpecView(metaColumn.ColumnName, string.Empty);
                }
            }
        }
Exemplo n.º 2
0
        protected override int OnStartup(string[] args, IDictionary <string, IList <object> > arguments)
        {
            string sourceFilePath;

            if ((object)args == null)
            {
                throw new ArgumentNullException("args");
            }

            if ((object)arguments == null)
            {
                throw new ArgumentNullException("arguments");
            }

            // minimal viable configuration via code example

            /*using (IToolHost toolHost = new ToolHost())
             * {
             *      toolHost.Host(new ObfuscationConfiguration()
             *                              {
             *                                      SourceAdapterConfiguration = new AdapterConfiguration()
             *                                                                                              {
             *                                                                                                      AdapterAqtn = typeof(NullSourceAdapter).AssemblyQualifiedName
             *                                                                                              },
             *                                      DestinationAdapterConfiguration = new AdapterConfiguration()
             *                                                                                                      {
             *                                                                                                              AdapterAqtn = typeof(NullDestinationAdapter).AssemblyQualifiedName
             *                                                                                                      },
             *                                      TableConfiguration = new TableConfiguration(),
             *                                      HashConfiguration = new HashConfiguration()
             *                                                                              {
             *                                                                                      Multiplier = 0,
             *                                                                                      Seed = 0
             *                                                                              }
             *                              });
             * }*/

            sourceFilePath = (string)arguments[CMDLN_TOKEN_SOURCEFILE].Single();

            using (IToolHost toolHost = new ToolHost())
                toolHost.Host(sourceFilePath);

            return(0);
        }
        public void RefreshDelimitedTextFieldSpecs()
        {
            ObfuscationConfiguration obfuscationConfiguration;
            IEnumerable <Message>    messages;
            bool?result;

            bool succeeded;
            IEnumerable <IMetaColumn> metaColumns;

            obfuscationConfiguration = this.ApplyViewToDocument();

            messages = obfuscationConfiguration.Validate();

            if ((object)messages != null && messages.Any())
            {
                result = this.View.FullView.ShowMessages(messages, "Configuration validation on refresh delimited text field spec", true);

                if (!(result ?? false))
                {
                    //this.View.CloseView(null);
                    return;
                }
            }

            using (IToolHost toolHost = new ToolHost())
                succeeded = toolHost.TryGetUpstreamMetadata(obfuscationConfiguration, out metaColumns);

            if (succeeded && (object)metaColumns != null)
            {
                this.View.ClearHeaderSpecViews();

                foreach (IMetaColumn metaColumn in metaColumns)
                {
                    var headerSpec = (HeaderSpec)metaColumn.TagContext;
                    this.View.AddHeaderSpecView(headerSpec.HeaderName, headerSpec.FieldType);
                }
            }
        }
Exemplo n.º 4
0
        public void ExecuteObfuscation(IPartialView sourceView, object actionContext)
        {
            ObfuscationConfiguration obfuscationConfiguration;
            IEnumerable <Message>    messages;

            this.View.ExecutionPartialView.RecordCount     = null;
            this.View.ExecutionPartialView.IsComplete      = null;
            this.View.ExecutionPartialView.DurationSeconds = null;

            obfuscationConfiguration = new ObfuscationConfiguration()
            {
                ConfigurationVersion = ObfuscationConfiguration.CurrentConfigurationVersion,
                EngineVersion        = ObfuscationConfiguration.CurrentEngineVersion
            };
            this.ApplyViewToDocument(obfuscationConfiguration);

            messages = obfuscationConfiguration.Validate();

            if ((object)messages != null && messages.Any())
            {
                this.View.ExecutionPartialView.IsComplete = true;
                this.View.ShowMessages(messages, "Configuration validation on execution", false);

                return;
            }

            using (IToolHost toolHost = new ToolHost())
            {
                toolHost.Host(obfuscationConfiguration, (count, complete, duration) =>
                {
                    this.View.ExecutionPartialView.RecordCount     = count;
                    this.View.ExecutionPartialView.IsComplete      = complete;
                    this.View.ExecutionPartialView.DurationSeconds = duration;
                });
            }

            this.View.ShowAlert("Done.");
        }
Exemplo n.º 5
0
 internal static Task <int> Main(string[] args) => ToolHost.CreateDefaultBuilder(args).RunToolAsync();