Example #1
0
        /*--------------------------------------------------------------------------
         * Functions for the CITATIONS Table.
         * Table Format:
         *     key: ArticleGuid or other unique string ID
         *     value: "ArticleCreateTimestamp|citation1|citation2|..."
         */

        // This is the function the Crawler will call every time it adds a new Article
        // to the database, when the Crawler adds it, sumultaneously populating the
        // CITATONS table for that Article.
        public static void WriteArticleRankingDataToDb(RankingType_T rankingType,
                                                       Grouping verticalId,
                                                       string articleId, // Uniquely identifies the Article within the Vertical
                                                       DateTimeOffset articleCreationTime,
                                                       string articleUrl,
                                                       string articleText)
        {
            string key   = articleId;
            string value = "";

            if (rankingType == RankingType_T.Popularity)
            {
                value = RankingDataProcessor.GetCitationsDbString(articleCreationTime,
                                                                  articleUrl,
                                                                  articleText);
            }
            else
            {
                StringBuilder sb = new StringBuilder(articleCreationTime.ToString());
                sb.Append(RankingDataProcessor.Separator).Append(articleUrl);
                sb.Append(RankingDataProcessor.Separator).Append(articleText);
                value = sb.ToString();
            }

            if (!string.IsNullOrEmpty(value))
            {
                // Write <key, value> to database CITATIONS table for Vertical
            }
        }