Exemplo n.º 1
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);
                        }
                    }
                }
            }
        }
Exemplo n.º 2
0
 public ETLConfig SetDestinationAdapter(IDestinationAdapter DestinationAdapter)
 {
     _destinationAdapter = DestinationAdapter;
     return(this);
 }