예제 #1
0
        private void ApplyViewToDocument_DictionarySettings(ObfuscationConfiguration obfuscationConfiguration)
        {
            if ((object)obfuscationConfiguration == null)
            {
                throw new ArgumentNullException("obfuscationConfiguration");
            }

            foreach (IDictionarySpecListView dictionarySpecView in this.View.ObfuscationPartialView.DictionarySettingsPartialView.DictionarySpecListViews)
            {
                DictionaryConfiguration dictionaryConfiguration;

                //if ((object)dictionarySpecView.DictionaryAdapterSettingsPartialView.CurrentAdapterSpecificSettingsPartialView != null)
                //dictionarySpecView.DictionaryAdapterSettingsPartialView.CurrentAdapterSpecificSettingsPartialView.ApplyViewToDocument(obfuscationConfiguration);

                dictionaryConfiguration = new DictionaryConfiguration()
                {
                    DictionaryId   = dictionarySpecView.DictionaryId,
                    PreloadEnabled = dictionarySpecView.PreloadEnabled,
                    RecordCount    = dictionarySpecView.RecordCount,
                    DictionaryAdapterConfiguration = new AdapterConfiguration()
                };

                obfuscationConfiguration.DictionaryConfigurations.Add(dictionaryConfiguration);
            }
        }
예제 #2
0
        private void ApplyDocumentToView_DictionarySettings(ObfuscationConfiguration obfuscationConfiguration)
        {
            IDictionarySpecListView dictionarySpecListView;

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

            if ((object)obfuscationConfiguration.DictionaryConfigurations != null)
            {
                foreach (DictionaryConfiguration dictionaryConfiguration in obfuscationConfiguration.DictionaryConfigurations)
                {
                    Type type;

                    dictionarySpecListView = this.View.ObfuscationPartialView.DictionarySettingsPartialView.AddDictionarySpecView(dictionaryConfiguration.DictionaryId, dictionaryConfiguration.PreloadEnabled, dictionaryConfiguration.RecordCount, null);

                    this.InitializeDictionaryAdapterView(dictionarySpecListView);

                    if ((object)dictionaryConfiguration.DictionaryAdapterConfiguration != null)
                    {
                        if (!DataTypeFascade.Instance.IsNullOrWhiteSpace(dictionaryConfiguration.DictionaryAdapterConfiguration.AdapterAqtn))
                        {
                            type = dictionaryConfiguration.DictionaryAdapterConfiguration.GetAdapterType();
                            dictionarySpecListView.DictionaryAdapterSettingsPartialView.SelectedAdapterType = type;
                        }

                        //if ((object)dictionarySpecListView.DictionaryAdapterSettingsPartialView.CurrentAdapterSpecificSettingsPartialView != null)
                        //dictionarySpecListView.DictionaryAdapterSettingsPartialView.CurrentAdapterSpecificSettingsPartialView.ApplyDocumentToView(obfuscationConfiguration);
                    }
                }
            }
        }
        protected void ApplyViewToDocument(ObfuscationConfiguration obfuscationConfiguration)
        {
            if ((object)obfuscationConfiguration == null)
            {
                throw new ArgumentNullException("obfuscationConfiguration");
            }

            this.ApplyViewToDocument_ObfuscationSettings(obfuscationConfiguration);
        }
        private void ApplyViewToDocumentDelimitedTextSource(ObfuscationConfiguration obfuscationConfiguration)
        {
            //if ((object)obfuscationConfiguration == null)
            //	throw new ArgumentNullException("obfuscationConfiguration");

            //obfuscationConfiguration.SourceAdapterConfiguration.DelimitedTextAdapterConfiguration = new DelimitedTextAdapterConfiguration() { DelimitedTextSpec = new DelimitedTextSpec() };

            //_ApplyViewToDocumentDelimitedText(this.View.ObfuscationPartialView.SourceAdapterSettings.DelTextAdapterSettingsView, obfuscationConfiguration.SourceAdapterConfiguration.DelimitedTextAdapterConfiguration);
        }
        private void ApplyDocumentToViewDelimitedTextSource(ObfuscationConfiguration obfuscationConfiguration)
        {
            //if ((object)obfuscationConfiguration == null)
            //	throw new ArgumentNullException("obfuscationConfiguration");

            //if ((object)obfuscationConfiguration.SourceAdapterConfiguration != null &&
            //	(object)obfuscationConfiguration.SourceAdapterConfiguration.DelimitedTextAdapterConfiguration != null)
            //	_ApplyDocumentToViewDelimitedText(obfuscationConfiguration.SourceAdapterConfiguration.DelimitedTextAdapterConfiguration, this.View.ObfuscationPartialView.SourceAdapterSettings.DelTextAdapterSettingsView);
        }
예제 #6
0
        public void Host(ObfuscationConfiguration obfuscationConfiguration, Action <long, bool, double> statusCallback)
        {
            IEnumerable <IDictionary <string, object> > sourceDataEnumerable;
            IEnumerable <Message> messages;

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

            messages = obfuscationConfiguration.Validate();

            if (messages.Any())
            {
                throw new ApplicationException(string.Format("Obfuscation configuration validation failed:\r\n{0}", string.Join("\r\n", messages.Select(m => m.Description).ToArray())));
            }

            using (IOxymoronEngine oxymoronEngine = new OxymoronEngine(this, obfuscationConfiguration))
            {
                using (DisposableList <IDictionaryAdapter> dictionaryAdapters = new DisposableList <IDictionaryAdapter>())
                {
                    foreach (DictionaryConfiguration dictionaryConfiguration in obfuscationConfiguration.DictionaryConfigurations)
                    {
                        IDictionaryAdapter dictionaryAdapter;

                        dictionaryAdapter = dictionaryConfiguration.DictionaryAdapterConfiguration.GetAdapterInstance <IDictionaryAdapter>();
                        dictionaryAdapters.Add(dictionaryAdapter);
                        dictionaryAdapter.Initialize(dictionaryConfiguration.DictionaryAdapterConfiguration);

                        dictionaryAdapter.InitializePreloadCache(dictionaryConfiguration, oxymoronEngine.SubstitutionCacheRoot);

                        this.DictionaryConfigurationToAdapterMappings.Add(dictionaryConfiguration, dictionaryAdapter);
                    }

                    using (ISourceAdapter sourceAdapter = obfuscationConfiguration.SourceAdapterConfiguration.GetAdapterInstance <ISourceAdapter>())
                    {
                        sourceAdapter.Initialize(obfuscationConfiguration.SourceAdapterConfiguration);

                        using (IDestinationAdapter destinationAdapter = obfuscationConfiguration.DestinationAdapterConfiguration.GetAdapterInstance <IDestinationAdapter>())
                        {
                            destinationAdapter.Initialize(obfuscationConfiguration.DestinationAdapterConfiguration);
                            destinationAdapter.UpstreamMetadata = sourceAdapter.UpstreamMetadata;

                            sourceDataEnumerable = sourceAdapter.PullData(obfuscationConfiguration.TableConfiguration);
                            sourceDataEnumerable = oxymoronEngine.GetObfuscatedValues(sourceDataEnumerable);

                            if ((object)statusCallback != null)
                            {
                                sourceDataEnumerable = WrapRecordCounter(sourceDataEnumerable, statusCallback);
                            }

                            destinationAdapter.PushData(obfuscationConfiguration.TableConfiguration, sourceDataEnumerable);
                        }
                    }
                }
            }
        }
        public ObfuscationConfiguration GetObfuscationConfiguration()
        {
            ObfuscationConfiguration obfuscationConfiguration;

            if (DataTypeFascade.Instance.IsNullOrWhiteSpace(this.ObfuscationConfigurationJsonText))
            {
                obfuscationConfiguration = new ObfuscationConfiguration()
                {
                    ConfigurationVersion = ObfuscationConfiguration.CurrentConfigurationVersion,
                    EngineVersion        = ObfuscationConfiguration.CurrentEngineVersion
                }
            }
            ;
            else
            {
                obfuscationConfiguration = new JsonSerializationStrategy().GetObjectFromString <ObfuscationConfiguration>(this.ObfuscationConfigurationJsonText);
            }

            if ((object)obfuscationConfiguration != null)
            {
                if ((object)obfuscationConfiguration.SourceAdapterConfiguration != null)
                {
                    obfuscationConfiguration.SourceAdapterConfiguration.ResetAdapterSpecificConfiguration();
                    obfuscationConfiguration.SourceAdapterConfiguration.AdapterAqtn = typeof(DtsSourceAdapter).AssemblyQualifiedName;
                }

                if ((object)obfuscationConfiguration.DestinationAdapterConfiguration != null)
                {
                    obfuscationConfiguration.DestinationAdapterConfiguration.ResetAdapterSpecificConfiguration();
                    obfuscationConfiguration.DestinationAdapterConfiguration.AdapterAqtn = typeof(DtsDestinationAdapter).AssemblyQualifiedName;
                }

                if ((object)obfuscationConfiguration.DictionaryConfigurations != null)
                {
                    foreach (DictionaryConfiguration dictionaryConfiguration in obfuscationConfiguration.DictionaryConfigurations)
                    {
                        if ((object)dictionaryConfiguration.DictionaryAdapterConfiguration != null)
                        {
                            var items = dictionaryConfiguration.DictionaryAdapterConfiguration.AdapterSpecificConfiguration.Select(kvp => new { KEY = kvp.Key, VAL = kvp.Value }).ToArray();

                            dictionaryConfiguration.DictionaryAdapterConfiguration.ResetAdapterSpecificConfiguration();
                            dictionaryConfiguration.DictionaryAdapterConfiguration.AdapterAqtn = typeof(DtsDictionaryAdapter).AssemblyQualifiedName;

                            foreach (var item in items)
                            {
                                dictionaryConfiguration.DictionaryAdapterConfiguration.AdapterSpecificConfiguration.Add(item.KEY, item.VAL);
                            }

                            dictionaryConfiguration.DictionaryAdapterConfiguration.AdapterSpecificConfiguration.Add("DictionaryUnitOfWorkCallback", this.DictionaryUnitOfWorkCallback);
                        }
                    }
                }
            }

            return(obfuscationConfiguration);
        }
예제 #8
0
        private void ApplyViewToDocument_AvalancheSettings(ObfuscationConfiguration obfuscationConfiguration)
        {
            if ((object)obfuscationConfiguration == null)
            {
                throw new ArgumentNullException("obfuscationConfiguration");
            }

            obfuscationConfiguration.HashConfiguration            = obfuscationConfiguration.HashConfiguration ?? new HashConfiguration();
            obfuscationConfiguration.HashConfiguration.Multiplier = this.View.ObfuscationPartialView.AvalancheSettingsPartialView.HashMultiplier;
            obfuscationConfiguration.HashConfiguration.Seed       = this.View.ObfuscationPartialView.AvalancheSettingsPartialView.HashSeed;
        }
예제 #9
0
        private void ApplyDocumentToView_AvalancheSettings(ObfuscationConfiguration obfuscationConfiguration)
        {
            if ((object)obfuscationConfiguration == null)
            {
                throw new ArgumentNullException("obfuscationConfiguration");
            }

            if ((object)obfuscationConfiguration.HashConfiguration != null)
            {
                this.View.ObfuscationPartialView.AvalancheSettingsPartialView.HashMultiplier = obfuscationConfiguration.HashConfiguration.Multiplier;
                this.View.ObfuscationPartialView.AvalancheSettingsPartialView.HashSeed       = obfuscationConfiguration.HashConfiguration.Seed;
            }
        }
        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);
                }
            }
        }
예제 #11
0
        public void Host(ObfuscationConfiguration obfuscationConfiguration, Action<long, bool, double> statusCallback)
        {
            IEnumerable<IDictionary<string, object>> sourceDataEnumerable;
            IEnumerable<Message> messages;

            if ((object)obfuscationConfiguration == null)
                throw new ArgumentNullException("obfuscationConfiguration");

            messages = obfuscationConfiguration.Validate();

            if (messages.Any())
                throw new ApplicationException(string.Format("Obfuscation configuration validation failed:\r\n{0}", string.Join("\r\n", messages.Select(m => m.Description).ToArray())));

            using (IOxymoronEngine oxymoronEngine = new OxymoronEngine(this, obfuscationConfiguration))
            {
                using (DisposableList<IDictionaryAdapter> dictionaryAdapters = new DisposableList<IDictionaryAdapter>())
                {
                    foreach (DictionaryConfiguration dictionaryConfiguration in obfuscationConfiguration.DictionaryConfigurations)
                    {
                        IDictionaryAdapter dictionaryAdapter;

                        dictionaryAdapter = dictionaryConfiguration.DictionaryAdapterConfiguration.GetAdapterInstance<IDictionaryAdapter>();
                        dictionaryAdapters.Add(dictionaryAdapter);
                        dictionaryAdapter.Initialize(dictionaryConfiguration.DictionaryAdapterConfiguration);

                        dictionaryAdapter.InitializePreloadCache(dictionaryConfiguration, oxymoronEngine.SubstitutionCacheRoot);

                        this.DictionaryConfigurationToAdapterMappings.Add(dictionaryConfiguration, dictionaryAdapter);
                    }

                    using (ISourceAdapter sourceAdapter = obfuscationConfiguration.SourceAdapterConfiguration.GetAdapterInstance<ISourceAdapter>())
                    {
                        sourceAdapter.Initialize(obfuscationConfiguration.SourceAdapterConfiguration);

                        using (IDestinationAdapter destinationAdapter = obfuscationConfiguration.DestinationAdapterConfiguration.GetAdapterInstance<IDestinationAdapter>())
                        {
                            destinationAdapter.Initialize(obfuscationConfiguration.DestinationAdapterConfiguration);
                            destinationAdapter.UpstreamMetadata = sourceAdapter.UpstreamMetadata;

                            sourceDataEnumerable = sourceAdapter.PullData(obfuscationConfiguration.TableConfiguration);
                            sourceDataEnumerable = oxymoronEngine.GetObfuscatedValues(sourceDataEnumerable);

                            if ((object)statusCallback != null)
                                sourceDataEnumerable = WrapRecordCounter(sourceDataEnumerable, statusCallback);

                            destinationAdapter.PushData(obfuscationConfiguration.TableConfiguration, sourceDataEnumerable);
                        }
                    }
                }
            }
        }
예제 #12
0
        private void ApplyDocumentToView_MetadataSettings(ObfuscationConfiguration obfuscationConfiguration)
        {
            if ((object)obfuscationConfiguration == null)
            {
                throw new ArgumentNullException("obfuscationConfiguration");
            }

            if ((object)obfuscationConfiguration.TableConfiguration != null &&
                (object)obfuscationConfiguration.TableConfiguration.ColumnConfigurations != null)
            {
                foreach (ColumnConfiguration columnConfiguration in obfuscationConfiguration.TableConfiguration.ColumnConfigurations)
                {
                    this.View.ObfuscationPartialView.MetadataSettingsPartialView.AddMetaColumnSpecView(columnConfiguration.ColumnName, columnConfiguration.ObfuscationStrategyAqtn);
                }
            }
        }
예제 #13
0
        private void ApplyViewToDocument_ObfuscationSettings(ObfuscationConfiguration obfuscationConfiguration)
        {
            if ((object)obfuscationConfiguration == null)
            {
                throw new ArgumentNullException("obfuscationConfiguration");
            }

            obfuscationConfiguration.ConfigurationVersion = obfuscationConfiguration.ConfigurationVersion ?? new Version(this.View.ObfuscationPartialView.ConfigurationVersion);
            //obfuscationConfiguration.EngineVersion = obfuscationConfiguration.EngineVersion ?? new Version(this.View.ObfuscationPartialView.EngineVersion);

            this.ApplyViewToDocument_AvalancheSettings(obfuscationConfiguration);
            this.ApplyViewToDocument_MetadataSettings(obfuscationConfiguration);
            this.ApplyViewToDocument_DictionarySettings(obfuscationConfiguration);
            this.ApplyViewToDocument_SourceAdapterSettings(obfuscationConfiguration);
            this.ApplyViewToDocument_DestinationAdapterSettings(obfuscationConfiguration);
        }
예제 #14
0
        private void ApplyViewToDocument_SourceAdapterSettings(ObfuscationConfiguration obfuscationConfiguration)
        {
            if ((object)obfuscationConfiguration == null)
            {
                throw new ArgumentNullException("obfuscationConfiguration");
            }

            obfuscationConfiguration.SourceAdapterConfiguration = obfuscationConfiguration.SourceAdapterConfiguration ?? new AdapterConfiguration();

            if ((object)this.View.ObfuscationPartialView.SourceAdapterSettingsPartialView.SelectedAdapterType != null)
            {
                obfuscationConfiguration.SourceAdapterConfiguration.AdapterAqtn = this.View.ObfuscationPartialView.SourceAdapterSettingsPartialView.SelectedAdapterType.AssemblyQualifiedName;

                //if ((object)this.View.SourceAdapterSettingsPartialView.CurrentAdapterSpecificSettingsPartialView != null)
                //this.View.SourceAdapterSettingsPartialView.CurrentAdapterSpecificSettingsPartialView.ApplyViewToDocument(obfuscationConfiguration);
            }
        }
예제 #15
0
        public OxymoronEngine(IOxymoronHost oxymoronHost, ObfuscationConfiguration obfuscationConfiguration)
        {
            if ((object)oxymoronHost == null)
            {
                throw new ArgumentNullException("oxymoronHost");
            }

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

            this.oxymoronHost             = oxymoronHost;
            this.obfuscationConfiguration = obfuscationConfiguration;

            EnsureValidConfigurationOnce(this.ObfuscationConfiguration);
        }
예제 #16
0
        private void ApplyDocumentToView_ObfuscationSettings(ObfuscationConfiguration obfuscationConfiguration)
        {
            if ((object)obfuscationConfiguration == null)
            {
                throw new ArgumentNullException("obfuscationConfiguration");
            }

            if ((object)obfuscationConfiguration.ConfigurationVersion != null)
            {
                this.View.ObfuscationPartialView.ConfigurationVersion = obfuscationConfiguration.ConfigurationVersion.SafeToString();
                //this.View.ObfuscationPartialView.EngineVersion = obfuscationConfiguration.EngineVersion.SafeToString();
            }

            this.ApplyDocumentToView_AvalancheSettings(obfuscationConfiguration);
            this.ApplyDocumentToView_MetadataSettings(obfuscationConfiguration);
            this.ApplyDocumentToView_DictionarySettings(obfuscationConfiguration);
            this.ApplyDocumentToView_SourceAdapterSettings(obfuscationConfiguration);
            this.ApplyDocumentToView_DestinationAdapterSettings(obfuscationConfiguration);
        }
예제 #17
0
        private void ApplyDocumentToView_DestinationAdapterSettings(ObfuscationConfiguration obfuscationConfiguration)
        {
            Type type;

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

            if ((object)obfuscationConfiguration.DestinationAdapterConfiguration != null)
            {
                if (!DataTypeFascade.Instance.IsNullOrWhiteSpace(obfuscationConfiguration.DestinationAdapterConfiguration.AdapterAqtn))
                {
                    type = obfuscationConfiguration.DestinationAdapterConfiguration.GetAdapterType();
                    this.View.ObfuscationPartialView.SourceAdapterSettingsPartialView.SelectedAdapterType = type;
                }

                //if ((object)this.View.DestinationAdapterSettingsPartialView.CurrentAdapterSpecificSettingsPartialView != null)
                //this.View.DestinationAdapterSettingsPartialView.CurrentAdapterSpecificSettingsPartialView.ApplyDocumentToView(obfuscationConfiguration);
            }
        }
예제 #18
0
        public bool TryGetUpstreamMetadata(ObfuscationConfiguration obfuscationConfiguration, out IEnumerable <IMetaColumn> metaColumns)
        {
            if ((object)obfuscationConfiguration == null)
            {
                throw new ArgumentNullException("obfuscationConfiguration");
            }

            metaColumns = null;

            if ((object)obfuscationConfiguration.SourceAdapterConfiguration != null &&
                (object)obfuscationConfiguration.SourceAdapterConfiguration.GetAdapterType() != null)
            {
                using (ISourceAdapter sourceAdapter = obfuscationConfiguration.SourceAdapterConfiguration.GetAdapterInstance <ISourceAdapter>())
                {
                    sourceAdapter.Initialize(obfuscationConfiguration.SourceAdapterConfiguration);
                    metaColumns = sourceAdapter.UpstreamMetadata;
                }
            }

            return(true);
        }
예제 #19
0
        private void ApplyViewToDocument_MetadataSettings(ObfuscationConfiguration obfuscationConfiguration)
        {
            if ((object)obfuscationConfiguration == null)
            {
                throw new ArgumentNullException("obfuscationConfiguration");
            }

            obfuscationConfiguration.TableConfiguration = obfuscationConfiguration.TableConfiguration ?? new TableConfiguration();

            foreach (IMetaColumnSpecListView metaColumnSpecView in this.View.ObfuscationPartialView.MetadataSettingsPartialView.MetaColumnSpecListViews)
            {
                ColumnConfiguration columnConfiguration;

                columnConfiguration = new ColumnConfiguration()
                {
                    ColumnName = metaColumnSpecView.ColumnName ?? string.Empty,
                    ObfuscationStrategyAqtn = metaColumnSpecView.ObfuscationStrategyAqtn
                };

                obfuscationConfiguration.TableConfiguration.ColumnConfigurations.Add(columnConfiguration);
            }
        }
예제 #20
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.");
        }
        private ObfuscationConfiguration ThreadSafeLoadCurrentDocument(object parameter)
        {
            string documentFilePath;
            ObfuscationConfiguration obfuscationConfiguration;

            documentFilePath = this.View.FilePath;

            if (!DataTypeFascade.Instance.IsNullOrWhiteSpace(documentFilePath))
            {
                documentFilePath         = Path.GetFullPath(documentFilePath);
                obfuscationConfiguration = OxymoronEngine.FromJsonFile <ObfuscationConfiguration>(documentFilePath);
            }
            else
            {
                // just create new
                obfuscationConfiguration = new ObfuscationConfiguration()
                {
                    ConfigurationVersion = ObfuscationConfiguration.CurrentConfigurationVersion,
                    EngineVersion        = ObfuscationConfiguration.CurrentEngineVersion
                };
            }

            return(obfuscationConfiguration);
        }
        public bool SaveDocument(bool asCopy)
        {
            ObfuscationConfiguration obfuscationConfiguration;
            IEnumerable <Message>    messages;
            string filePath;
            bool?  result;

            this.View.StatusText = "Document validation started...";

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

            messages = obfuscationConfiguration.Validate();

            if (             /*!DataTypeFascade.Instance.IsNullOrWhiteSpace(this.View.ObfuscationPartialView.FilePath) &&*/
                messages.Any())
            {
                result = this.View.ShowMessages(messages, "Obfuscation configuration save validation failed.", true);

                if (!(result ?? false))
                {
                    this.View.StatusText = "Document save canceled.";
                    //this.View.CloseView(null);
                    return(false);
                }
            }

            this.View.StatusText = "Document validation completed successfully.";

            this.View.StatusText = "Document save started...";

            if (asCopy && !DataTypeFascade.Instance.IsNullOrWhiteSpace(this.View.FilePath))
            {
                if (!this.View.ShowConfirm("Do you want to save a copy of the current document?", Severity.Information))
                {
                    this.View.StatusText = "Document save canceled.";
                    return(false);
                }
            }

            if (asCopy)
            {
                // get new file path
                if (!this.View.TryGetSaveFilePath(out filePath))
                {
                    this.View.StatusText = "Document save canceled.";
                    return(false);
                }

                this.View.FilePath = filePath;
            }
            else
            {
                if (DataTypeFascade.Instance.IsNullOrWhiteSpace(this.View.FilePath))
                {
                    if (!this.View.TryGetSaveFilePath(out filePath))
                    {
                        this.View.StatusText = "Document save canceled.";
                        return(false);
                    }

                    this.View.FilePath = filePath;
                }
            }

            result = this.View.ShowAsync <bool>("Saving document...", this.ThreadSafeSaveCurrentDocument, obfuscationConfiguration);

            if (!(bool)result)
            {
                this.View.StatusText = "Document save canceled.";
                return(false);
            }

            this.View.ViewText   = string.Format("{0}", this.View.FilePath.SafeToString(null, "<new>"));
            this.View.StatusText = "Document save completed successfully.";

            return(true);
        }
예제 #23
0
        public bool TryGetUpstreamMetadata(ObfuscationConfiguration obfuscationConfiguration, out IEnumerable<IMetaColumn> metaColumns)
        {
            if ((object)obfuscationConfiguration == null)
                throw new ArgumentNullException("obfuscationConfiguration");

            metaColumns = null;

            if ((object)obfuscationConfiguration.SourceAdapterConfiguration != null &&
                (object)obfuscationConfiguration.SourceAdapterConfiguration.GetAdapterType() != null)
            {
                using (ISourceAdapter sourceAdapter = obfuscationConfiguration.SourceAdapterConfiguration.GetAdapterInstance<ISourceAdapter>())
                {
                    sourceAdapter.Initialize(obfuscationConfiguration.SourceAdapterConfiguration);
                    metaColumns = sourceAdapter.UpstreamMetadata;
                }
            }

            return true;
        }