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; } }
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); } }