public void LoadCitationsModel(RankingType_T rankingType, Dictionary <string, string> dbStr, DateTimeOffset to_time) { KeyValuePair <DateTimeOffset, List <string> > cit; DateTimeOffset modelTimeLimit = to_time.AddHours(-1 * Ranker.RankingHoursConsidered); string matchingUrl; foreach (KeyValuePair <string, string> rec in dbStr) { _PrlOpt.CancellationToken.ThrowIfCancellationRequested(); cit = RankingDataProcessor.GetCitationsFromDbString(rankingType, rec.Value); // Add the title Article's URL to the Index matchingUrl = RankingDataProcessor.GetMatchingUrl(cit.Value[0]); ArtcileIndexInfo idxval = new ArtcileIndexInfo(); idxval.ArticleId = rec.Key; idxval.ArtcileDatetime = cit.Key; try { if (!string.IsNullOrEmpty(matchingUrl)) { ArticleUrlIdIndex[matchingUrl] = idxval; } } catch (Exception) // This Article is already in Index { Log.Warn("Ranker init(): Error adding Article for matching URL [{0}] to Index for Article: {1}", matchingUrl, rec.Key.ToString()); } // Build the citation model. if (idxval.ArtcileDatetime >= modelTimeLimit) { try { AddCitationsInArticle(cit.Key, cit.Value); } catch (Exception) { Log.Warn("Adding Citations in Article with ID [{0}] failed, URL: {1}", rec.Key.ToString(), rec.Value[0]); //throw; } } } }
/// <summary> /// Add all the citations in the Article to the Citations Model. /// </summary> /// <param name="timestamp">timestamp of the parent Article</param> /// <param name="citations">the list of citations in the Article</param> private void AddCitationsInArticle(DateTimeOffset timestamp, List <string> citations) { // leave out for i=0; this is the parent Article's URL for (int i = 1; i < citations.Count; ++i) { _PrlOpt.CancellationToken.ThrowIfCancellationRequested(); string matchingUrl = RankingDataProcessor.GetMatchingUrl(citations[i]); if (!string.IsNullOrEmpty(matchingUrl)) { try { AddCitation(matchingUrl, timestamp); } catch (Exception ex) { Log.Warn("AddCitation() failed at timestamp[{0}] for URL [{1}]", timestamp.ToString("yyyy/MM/dd HH:mm:ss"), citations[i]); } } } }