/// <summary> /// Creates a worker to clean missing foreign key valus. /// </summary> /// <param name="targetTableName">Target name of the table to validate against.</param> /// <param name="foreignKeyFields">Name on fields in the foreign key to validate.</param> /// <param name="metadataRepository">Metadata repository.</param> /// <param name="informationLogger">Information logger.</param> public ForeignKeyCleaner(string targetTableName, IEnumerable <string> foreignKeyFields, IMetadataRepository metadataRepository, IInformationLogger informationLogger) : base(targetTableName, metadataRepository) { if (foreignKeyFields == null) { throw new ArgumentNullException("foreignKeyFields"); } if (informationLogger == null) { throw new ArgumentNullException("informationLogger"); } _foreignKeyFields = foreignKeyFields.ToList(); _informationLogger = informationLogger; }
/// <summary> /// Creates a worker to add missing primary keys. /// </summary> /// <param name="targetTableName">Target name of the table to validate against.</param> /// <param name="foreignKeyFields">Name on fields in the foreign key to validate.</param> /// <param name="setFieldValues">Field values to be set on missing primary keys.</param> /// <param name="metadataRepository">Metadata repository.</param> /// <param name="informationLogger">Information logger.</param> public PrimaryKeyAdder(string targetTableName, IEnumerable <string> foreignKeyFields, IDictionary <string, object> setFieldValues, IMetadataRepository metadataRepository, IInformationLogger informationLogger) : base(targetTableName, metadataRepository) { if (foreignKeyFields == null) { throw new ArgumentNullException("foreignKeyFields"); } if (setFieldValues == null) { throw new ArgumentNullException("setFieldValues"); } if (informationLogger == null) { throw new ArgumentNullException("informationLogger"); } _foreignKeyFields = foreignKeyFields.ToList(); _setFieldValues = setFieldValues; _informationLogger = informationLogger; }
private IDeliveryEngine CreateSut(bool useDataValidators, IExceptionHandler exceptionHandler) { if (exceptionHandler == null) { throw new ArgumentNullException(nameof(exceptionHandler)); } IContainer containerMock = MockRepository.GenerateMock <IContainer>(); IInformationLogger informationLoggerMock = MockRepository.GenerateMock <IInformationLogger>(); informationLoggerMock.Expect(m => m.LogInformation(Arg <string> .Is.NotNull)) .WhenCalled(e => Debug.WriteLine(e.Arguments.ElementAt(0))) .Repeat.Any(); informationLoggerMock.Expect(m => m.LogWarning(Arg <string> .Is.NotNull)) .WhenCalled(e => Debug.WriteLine(e.Arguments.ElementAt(0))) .Repeat.Any(); IConfigurationRepository configurationRepositoryMock = MockRepository.GenerateMock <IConfigurationRepository>(); IMetadataRepository metadataRepository = new OldToNewMetadataRepository(RepositoryTestHelper.GetSourcePathForOracleTest(), new ConfigurationValues()); containerMock.Expect(m => m.Resolve <IMetadataRepository>()) .Return(metadataRepository) .Repeat.Any(); ICollection <IDataManipulator> dataManipulatorCollection; using (var windsorContainer = new WindsorContainer()) { windsorContainer.Register(Component.For <IContainer>().Instance(containerMock).LifeStyle.Transient); windsorContainer.Register(Component.For <IInformationLogger>().Instance(informationLoggerMock).LifeStyle.Transient); windsorContainer.Register(Component.For <IMetadataRepository>().Instance(metadataRepository).LifeStyle.Transient); IConfigurationProvider dataManipulatorsConfigurationProvider = new DataManipulatorsConfigurationProvider(); dataManipulatorsConfigurationProvider.AddConfiguration(windsorContainer); dataManipulatorCollection = windsorContainer.ResolveAll <IDataManipulator>(); windsorContainer.Dispose(); } containerMock.Expect(m => m.ResolveAll <IDataManipulator>()) .Return(dataManipulatorCollection.ToArray()) .Repeat.Any(); IDataRepository dataRepository = new OracleDataRepository(new OracleClientFactory(), new DataManipulators(containerMock)); containerMock.Expect(m => m.Resolve <IDataRepository>()) .Return(dataRepository) .Repeat.Any(); IDocumentRepository documentRepositoryMock = MockRepository.GenerateMock <IDocumentRepository>(); IArchiveVersionRepository archiveRepository = new ArchiveVersionRepository(new DirectoryInfo(ConfigurationManager.AppSettings["ArchivePath"])); ICollection <IDataValidator> dataValidatorCollection = useDataValidators ? new Collection <IDataValidator> { new PrimaryKeyDataValidator(dataRepository), new ForeignKeysDataValidator(dataRepository), new MappingDataValidator() } : new Collection <IDataValidator>(); containerMock.Expect(m => m.ResolveAll <IDataValidator>()) .Return(dataValidatorCollection.ToArray()) .Repeat.Any(); IDataValidators dataValidators = new DataValidators(containerMock); return(new DeliveryEngine.BusinessLogic.DeliveryEngine(configurationRepositoryMock, metadataRepository, dataRepository, documentRepositoryMock, dataValidators, archiveRepository, exceptionHandler)); }
/// <summary> /// Entry point. /// </summary> /// <param name="args">Arguments</param> static void Main(string[] args) { Console.WriteLine(Resource.GetText(Text.ArchiveMaker)); Console.WriteLine(); ValidationOnly = false; AcceptWarnings = 1024; string archiveInformationPackageId = null; int tablesHandledSimultaneity = 5; bool removeMissingRelationshipsOnForeignKeys = false; int numberOfForeignTablesToCache = 10; bool? includeEmptyTables = null; try { if (args != null && args.Length > 0) { archiveInformationPackageId = args.Single(m => string.IsNullOrEmpty(m) == false && m.Length > 29 && m.Substring(0, 29).Equals("/ArchiveInformationPackageID:")).Substring(29); string optionalArg = args.SingleOrDefault(m => string.IsNullOrEmpty(m) == false && m.Length > 16 && m.Substring(0, 16).Equals("/ValidationOnly:")); if (optionalArg != null) { ValidationOnly = bool.Parse(optionalArg.Substring(16)); } optionalArg = args.SingleOrDefault(m => string.IsNullOrEmpty(m) == false && m.Length > 28 && m.Substring(0, 30).Equals("/TablesHandledSimultaneity:")); if (optionalArg != null) { tablesHandledSimultaneity = int.Parse(optionalArg.Substring(28)); } optionalArg = args.SingleOrDefault(m => string.IsNullOrEmpty(m) == false && m.Length > 16 && m.Substring(0, 16).Equals("/AcceptWarnings:")); if (optionalArg != null) { AcceptWarnings = int.Parse(optionalArg.Substring(16)); } optionalArg = args.SingleOrDefault(m => string.IsNullOrEmpty(m) == false && m.Length > 41 && m.Substring(0, 41).Equals("/RemoveMissingRelationshipsOnForeignKeys:")); if (optionalArg != null) { removeMissingRelationshipsOnForeignKeys = bool.Parse(optionalArg.Substring(41)); } optionalArg = args.SingleOrDefault(m => string.IsNullOrEmpty(m) == false && m.Length > 30 && m.Substring(0, 30).Equals("/NumberOfForeignTablesToCache:")); if (optionalArg != null) { numberOfForeignTablesToCache = int.Parse(optionalArg.Substring(30)); } optionalArg = args.SingleOrDefault(m => string.IsNullOrEmpty(m) == false && m.Length > 20 && m.Substring(0, 20).Equals("/IncludeEmptyTables:")); if (optionalArg != null) { includeEmptyTables = Convert.ToBoolean(optionalArg.Substring(20)); } } if (string.IsNullOrEmpty(archiveInformationPackageId)) { Console.WriteLine(Resource.GetText(Text.UsageArchiveMaker, new FileInfo(Process.GetCurrentProcess().MainModule.FileName).Name)); Console.WriteLine(); return; } } catch { Console.WriteLine(Resource.GetText(Text.UsageArchiveMaker, new FileInfo(Process.GetCurrentProcess().MainModule.FileName).Name)); Console.WriteLine(); return; } try { IContainer container = ContainerFactory.Create(); InformationLogger = container.Resolve <IInformationLogger>(); IExceptionHandler exceptionHandler = container.Resolve <IExceptionHandler>(); exceptionHandler.OnException += ExceptionEventHandler; IDeliveryEngine deliveryEngine = container.Resolve <IDeliveryEngine>(); deliveryEngine.BeforeGetDataSource += BeforeGetDataSourceEventHandler; deliveryEngine.BeforeArchiveMetadata += BeforeArchiveMetadataEventHandler; deliveryEngine.BeforeGetDataForTargetTable += BeforeGetDataForTargetTableEventHandler; deliveryEngine.BeforeValidateDataInTargetTable += BeforeValidatingDataInTargetTableEventHandler; deliveryEngine.BeforeArchiveDataForTargetTable += BeforeArchiveDataForTargetTableEventHandler; IConfigurationRepository configurationRepository = container.Resolve <IConfigurationRepository>(); IDeliveryEngineExecuteCommand command = new DeliveryEngineExecuteCommand { OverrideArchiveInformationPackageId = archiveInformationPackageId, ValidationOnly = ValidationOnly, TablesHandledSimultaneity = tablesHandledSimultaneity, RemoveMissingRelationshipsOnForeignKeys = removeMissingRelationshipsOnForeignKeys, NumberOfForeignTablesToCache = numberOfForeignTablesToCache, IncludeEmptyTables = includeEmptyTables ?? configurationRepository.IncludeEmptyTables }; deliveryEngine.Execute(command); } catch (Exception ex) { while (ex.InnerException != null) { ex = ex.InnerException; } Console.WriteLine(Resource.GetText(Text.ErrorMessage, ex.Message)); Console.WriteLine(); } }
public CallContext(IInformationLogger informationLogger) { InformationLogger = informationLogger; }