public void Execute(IDataLoadJob job, IEnumerable <MigrationColumnSet> toMigrate, IDataLoadInfo dataLoadInfo, GracefulCancellationToken cancellationToken) { _dataLoadInfo = dataLoadInfo; // Column set for each table we are migrating foreach (var columnsToMigrate in toMigrate) { var inserts = 0; var updates = 0; var tableLoadInfo = dataLoadInfo.CreateTableLoadInfo("", columnsToMigrate.DestinationTable.GetFullyQualifiedName(), new[] { new DataSource(columnsToMigrate.SourceTable.GetFullyQualifiedName(), DateTime.Now) }, 0); try { MigrateTable(job, columnsToMigrate, dataLoadInfo.ID, cancellationToken, ref inserts, ref updates); OnTableMigrationCompleteHandler(columnsToMigrate.DestinationTable.GetFullyQualifiedName(), inserts, updates); tableLoadInfo.Inserts = inserts; tableLoadInfo.Updates = updates; tableLoadInfo.Notes = "Part of Transaction"; } finally { tableLoadInfo.CloseAndArchive(); } cancellationToken.ThrowIfCancellationRequested(); } }
/// <summary> /// Add a bunch of data load runs for the tests in this fixture /// </summary> protected override void SetUp() { try { base.SetUp(); var lds = new DiscoveredServer(UnitTestLoggingConnectionString); var manager = new LogManager(lds); _dataLoadTaskName = "LogTest"; _dataLoadTaskHelper = new DataLoadTaskHelper(lds); _dataLoadTaskHelper.SetUp(); manager.CreateNewLoggingTaskIfNotExists(_dataLoadTaskName); // Insert some data load runs that are used by all the tests _logManager = new LogManager(lds); _failedLoad = _logManager.CreateDataLoadInfo(_dataLoadTaskName, _dataLoadTaskName, _dataLoadTaskName, "", true); _failedLoad.LogFatalError("", ""); _failedLoad.CloseAndMarkComplete(); _successfulLoad = _logManager.CreateDataLoadInfo(_dataLoadTaskName, _dataLoadTaskName, _dataLoadTaskName, "", true); _successfulLoad.LogProgress(DataLoadInfo.ProgressEventType.OnProgress, "", ""); _successfulLoad.CloseAndMarkComplete(); var tableLoadInfo = _successfulLoad.CreateTableLoadInfo("ignoreme", "Nowhereland", new DataSource[] { new DataSource("Firehouse", DateTime.Now.AddDays(-1)), new DataSource("WaterHaus") }, 100); tableLoadInfo.Inserts = 500; tableLoadInfo.Updates = 100; tableLoadInfo.CloseAndArchive(); Task.Delay(1000).Wait(); _anotherSuccessfulLoad = _logManager.CreateDataLoadInfo(_dataLoadTaskName, _dataLoadTaskName, _dataLoadTaskName, "", true); _anotherSuccessfulLoad.LogProgress(DataLoadInfo.ProgressEventType.OnProgress, "", ""); _anotherSuccessfulLoad.CloseAndMarkComplete(); } catch (Exception e) { _setupException = e; } }