private void ParseCountry(IExplodedReview <Album> explodedReview) { var review = explodedReview as AlbumExplodedReview; if (review == null) { throw new InvalidCastException("explodedReview cannot be cast as AlbumExplodedReview"); } IList <Country> countries = null; if (_countryCodesParser.TryParse(review.ArtistCountry, review.RecordId, ref countries)) { review.ProcessedArtistCountries = countries; } }
private IDictionary <int, CountryDefinition> InternalProcess(BackgroundWorker worker, DoWorkEventArgs e, OperationsManager_Deprecated managerDeprecated) { managerDeprecated.Infos = "extraction des pays d'origine... "; var count = 0; worker.ReportProgress(count); var artistsCountries = new Dictionary <int, CountryDefinition>(); foreach (var review in managerDeprecated.ParsedReviews) { try { CountryDefinition countryDefinition = null; if (_countryCodesParser.TryParse(review.Album.Artist.OriginCountry, review.Id, ref countryDefinition)) { artistsCountries.Add(review.Album.Artist.Id, countryDefinition); if (!_countryCodesDefinitions.Keys.Contains(review.Album.Artist.OriginCountry)) { _countryCodesDefinitions.Add(review.Album.Artist.OriginCountry, countryDefinition); } } if (worker.CancellationPending) { e.Cancel = true; break; } } catch (Exception ex) { Logging.Instance.LogError(string.Format("Une erreur est survenue lors de l'extraction des pays de l'artiste (review {0}) : {1}", review.Id, ex.Message), ErrorLevel.Error); continue; } managerDeprecated.Infos = "extraction des pays d'artistes... "; worker.ReportProgress(++count * 100 / (managerDeprecated.ParsedReviews.Count)); } return(artistsCountries); }