public override void Run() { var configService = _container.GetInstance <IConfigurationService>(); var options = configService.Get <MigrateFromAvmsConfiguration>(); var sourceDatabase = new GetOpenConnectionFromConnectionString(options.SourceConnectionString); var targetDatabase = new GetOpenConnectionFromConnectionString(options.TargetConnectionString); var genericSyncRepository = new GenericSyncRespository(_logService, sourceDatabase, targetDatabase); var avmsSyncRepository = new AvmsSyncRespository(_logService, sourceDatabase, targetDatabase); var tables = new AvmsToAvmsPlusTables(_logService, options, avmsSyncRepository, true).All; var controller = new Controller( options, _logService, genericSyncRepository, tableSpec => new MutateTarget(_logService, genericSyncRepository, (int)Math.Max(5000 * tableSpec.BatchSizeMultiplier, 1), tableSpec), tables ); try { controller.DoAll(_cancelSource); } catch (Exception ex) { _logService.Error("Unhandled exception from controller.DoAll method", ex); throw; } }
public MigrationProcessor(IConfigurationService configurationService, ILogService logService) { _logService = logService; var configuration = configurationService.Get <MigrateFromFaaToAvmsPlusConfiguration>(); //Ensure date precision is honoured Dapper.SqlMapper.AddTypeMap(typeof(DateTime), System.Data.DbType.DateTime2); var sourceDatabase = new GetOpenConnectionFromConnectionString(configuration.SourceConnectionString); var targetDatabase = new GetOpenConnectionFromConnectionString(configuration.TargetConnectionString); var genericSyncRespository = new GenericSyncRespository(_logService, sourceDatabase, targetDatabase); _syncRepository = new SyncRepository(targetDatabase); var applicationMappers = new ApplicationMappers(_logService); _candidateMigrationProcessor = new CandidateMigrationProcessor(new CandidateMappers(_logService), _syncRepository, genericSyncRespository, targetDatabase, configurationService, _logService); _traineeshipApplicationsMigrationProcessor = new VacancyApplicationsMigrationProcessor(new TraineeshipApplicationsUpdater(_syncRepository), applicationMappers, genericSyncRespository, sourceDatabase, targetDatabase, configurationService, _logService); _apprenticeshipApplicationsMigrationProcessor = new VacancyApplicationsMigrationProcessor(new ApprenticeshipApplicationsUpdater(_syncRepository), applicationMappers, genericSyncRespository, sourceDatabase, targetDatabase, configurationService, _logService); _auditMigrationProcessor = new AuditMigrationProcessor(_syncRepository, targetDatabase, configurationService, _logService); _logService.Info("Initialisation"); }
static void Main(string[] args) { var log = new ConsoleLogService(); log.Info("Initialisation"); var options = new Options(); if (!CommandLine.Parser.Default.ParseArguments(args, options)) { return; } if (options.SourceConnectionString == null || options.TargetConnectionString == null || options.RecordBatchSize == 0) { var configService = new AzureBlobConfigurationService(new MyConfigurationManager(), log); var persistentConfig = configService.Get <MigrateFromAvmsConfiguration>(); if (options.SourceConnectionString == null) { options.SourceConnectionString = persistentConfig.SourceConnectionString; } if (options.TargetConnectionString == null) { options.TargetConnectionString = persistentConfig.TargetConnectionString; } if (options.RecordBatchSize == 0) { options.RecordBatchSize = persistentConfig.RecordBatchSize; } if (options.MaxNumberOfChangesToDetailPerTable == null) { options.MaxNumberOfChangesToDetailPerTable = persistentConfig.MaxNumberOfChangesToDetailPerTable; } if (options.AnonymiseData == false) { options.AnonymiseData = persistentConfig.AnonymiseData; } } if (options.Verbose) { Console.WriteLine($@" SourceConnectionString = {options.SourceConnectionString} TargetConnectionString = {options.TargetConnectionString} RecordBatchSize = {options.RecordBatchSize} MaxNumberOfChangesToDetailPerTable = {options.MaxNumberOfChangesToDetailPerTable} AnonymiseData = {options.AnonymiseData} SingleFullUpdate = {options.SingleFullUpdate} "); } var sourceDatabase = new GetOpenConnectionFromConnectionString(options.SourceConnectionString); var targetDatabase = new GetOpenConnectionFromConnectionString(options.TargetConnectionString); var genericSyncRepository = new GenericSyncRespository(log, sourceDatabase, targetDatabase); var avmsSyncRepository = new AvmsSyncRespository(log, sourceDatabase, targetDatabase); Func <ITableSpec, IMutateTarget> createMutateTarget; if (options.DummyRun) { createMutateTarget = tableSpec => new DummyMutateTarget(log, tableSpec); } else { createMutateTarget = tableSpec => new MutateTarget(log, genericSyncRepository, (int)Math.Max(5000 * tableSpec.BatchSizeMultiplier, 1), tableSpec); } var tables = new AvmsToAvmsPlusTables(log, options, avmsSyncRepository, !options.ExcludeVacancy).All; if (options.SingleTable != null) { tables = tables.Where(t => t.Name == options.SingleTable); } var controller = new Controller(options, log, genericSyncRepository, createMutateTarget, tables); if (options.Reset) { controller.Reset(); } var cancellationTokenSource = new System.Threading.CancellationTokenSource(); bool threaded = true; if (options.SingleFullUpdate) { controller.DoFullScanForAll(threaded); } else { controller.DoAll(new System.Threading.CancellationTokenSource(), threaded); } }