Esempio n. 1
0
        private IEnumerable <BestBet> GetBestBetsForLanguage(string language, string index)
        {
            foreach (BestBet bestBet in _bestBetsRepository.GetBestBets(language, index))
            {
                var contentLink = new ContentReference(Convert.ToInt32(ContentReference.Parse(bestBet.Id).ID), bestBet.Provider);
                if (_contentLoader.TryGet(contentLink, out IContent content))
                {
                    bestBet.Name = content.Name;
                }

                yield return(bestBet);
            }
        }
 private void RestoreBestBets(IEnumerable <LanguageBranch> languages)
 {
     foreach (var language in languages.Select(l => l.LanguageID))
     {
         try
         {
             var indexName = GetIndexName(language);
             _logger.Debug("Index: " + indexName);
             OnStatusChanged("Restoring best bets for index " + indexName);
             var bestBets = _bestBetsRepository.GetBestBets(language, indexName);
             foreach (var bestBet in bestBets)
             {
                 _coreIndexer.UpdateBestBets(indexName, typeof(IndexItem), bestBet.Id, bestBet.GetTerms());
             }
         }
         catch (Exception ex)
         {
             _logger.Warning("Failed to update mappings", ex);
         }
     }
 }