private static void EnsureStepProcessed(SmugglerProgressBase.Counts counts) { if (counts.Processed) { return; } counts.Processed = true; counts.Skipped = true; }
private void SkipType(DatabaseItemType type, SmugglerResult result, bool ensureStepProcessed = true) { result.AddInfo($"Skipping '{type}' processing."); _onProgress.Invoke(result.Progress); SmugglerProgressBase.Counts counts; switch (type) { case DatabaseItemType.DatabaseRecord: counts = result.DatabaseRecord; break; case DatabaseItemType.Documents: counts = result.Documents; break; case DatabaseItemType.RevisionDocuments: counts = result.RevisionDocuments; break; case DatabaseItemType.Tombstones: counts = result.Tombstones; break; case DatabaseItemType.Conflicts: counts = result.Conflicts; break; case DatabaseItemType.Indexes: counts = result.Indexes; break; case DatabaseItemType.Identities: counts = result.Identities; break; case DatabaseItemType.CompareExchange: counts = result.CompareExchange; break; case DatabaseItemType.Counters: counts = result.Counters; break; case DatabaseItemType.LegacyDocumentDeletions: counts = new SmugglerProgressBase.Counts(); break; default: throw new ArgumentOutOfRangeException(nameof(type), type, null); } void OnSkipped(long skipped) { if (type == DatabaseItemType.Documents) { result.Documents.SkippedCount = skipped; } if (skipped % 10000 != 0) { return; } result.AddInfo($"Skipped {skipped:#,#;;0} {type.ToString().ToLowerInvariant()}"); _onProgress.Invoke(result.Progress); } var numberOfItemsSkipped = _source.SkipType(type, onSkipped: OnSkipped); if (ensureStepProcessed == false) { return; } counts.Skipped = true; counts.Processed = true; if (numberOfItemsSkipped > 0) { counts.ReadCount = numberOfItemsSkipped; result.AddInfo($"Skipped '{type}' processing. Skipped {numberOfItemsSkipped:#,#;;0} items."); } else { result.AddInfo($"Skipped '{type}' processing."); } _onProgress.Invoke(result.Progress); }