public async Task <SnapshotEksInputResult> ExecuteAsync(DateTime snapshotStart) { _Logger.WriteStart(); var stopwatch = new Stopwatch(); stopwatch.Start(); const int pagesize = 10000; var index = 0; using var tx = _DkSourceDbContext.BeginTransaction(); var page = Read(index, pagesize); while (page.Length > 0) { var db = _PublishingDbContextFactory(); await db.BulkInsertAsync2(page, new SubsetBulkArgs()); index += page.Length; page = Read(index, pagesize); } var result = new SnapshotEksInputResult { SnapshotSeconds = stopwatch.Elapsed.TotalSeconds, TekInputCount = index }; _Logger.WriteTeksToPublish(index); return(result); }
public async Task <SnapshotEksInputResult> ExecuteAsync(DateTime snapshotStart) { _logger.WriteStart(); var stopwatch = new Stopwatch(); stopwatch.Start(); const int PageSize = 10000; var index = 0; var filteredTekInputCount = 0; await using var tx = _dkSourceDbContext.BeginTransaction(); var(page, filteredResult) = ReadAndFilter(index, PageSize); while (page.Length > 0) { MarkFilteredEntitiesForCleanup(page, filteredResult); var db = _publishingDbContextFactory(); if (filteredResult.Length > 0) { await db.BulkInsertAsync2(filteredResult, new SubsetBulkArgs()); } index += page.Length; filteredTekInputCount += filteredResult.Length; (page, filteredResult) = ReadAndFilter(index, PageSize); } _dkSourceDbContext.SaveAndCommit(); var snapshotEksInputResult = new SnapshotEksInputResult { SnapshotSeconds = stopwatch.Elapsed.TotalSeconds, TekInputCount = index, FilteredTekInputCount = filteredTekInputCount }; _logger.WriteTeksToPublish(index); return(snapshotEksInputResult); }