protected virtual void ImportHandHistoriesUsing(IHandHistoryRetriever handHistoryRetriever) { PrepareToImportHandHistoriesUsing(handHistoryRetriever); _backgroundWorker.DoWork += (s, e) => { if (_numberOfHandsToImport > 0) { while (!handHistoryRetriever.IsDone) { ImportNextBatchOfHandHistoriesUsing(handHistoryRetriever); } } }; _backgroundWorker.RunWorkerCompleted += (s, e) => FinishedImportingHandHistories(); _backgroundWorker.RunWorkerAsync(); }
protected void ImportNextBatchOfHandHistoriesUsing(IHandHistoryRetriever handHistoryRetriever) { var nextBatchOfHandHistories = handHistoryRetriever .GetNext(BatchSize) .Aggregate(string.Empty, (collectedSoFar, currentHandHistory) => collectedSoFar + "\n\n" + currentHandHistory); _numberOfHandsAttemptedToImport += BatchSize; var convertedHands = _repository .RetrieveHandsFromString(nextBatchOfHandHistories); _repository.InsertHands(convertedHands); _numberOfHandsSuccessfullyImported += convertedHands.Count(); ReportProgress(_numberOfHandsAttemptedToImport * 100 / _numberOfHandsToImport); }
protected void PrepareToImportHandHistoriesUsing(IHandHistoryRetriever handHistoryRetriever) { _numberOfHandsToImport = handHistoryRetriever.HandHistoriesCount; ReportProgress(0); IsBusy = true; }
protected override void ImportHandHistoriesUsing(IHandHistoryRetriever handHistoryRetriever) { // Don't call base here since it will end up in a while loop which will never end since our HandHistory retriever mock will never be done. RetrieverWithWhichHandHistoriesWereImported = handHistoryRetriever; }
public void Invoke_ImportNextBatchOfHandHistoriesUsing(IHandHistoryRetriever handHistoryRetriever) { ImportNextBatchOfHandHistoriesUsing(handHistoryRetriever); }
public void Invoke_PrepareToImportHandHistoriesUsing(IHandHistoryRetriever handHistoryRetriever) { PrepareToImportHandHistoriesUsing(handHistoryRetriever); }