コード例 #1
0
        public void Parse(JObject rootObject, TrendsList trendsList)
        {
            LogService.Debug(this.GetType(), "Entering Parse for WhatTheThrendTrendsParser");
            try
            {
                JArray trendsJArray = rootObject.Value<JArray>("trends");
                if (trendsJArray != null)
                {
                    foreach (JObject trendJObject in trendsJArray)
                    {
                        string name = trendJObject.Value<string>("name");
                        if (name != null && !name.Contains("#") && !name.Contains("WTT test") && !name.Contains("ttrtpt"))
                        {
                            JToken t;
                            trendJObject.TryGetValue("description", out t);
                            if (t.HasValues)
                            {
                                JObject descriptionJSONObject = trendJObject.Value<JObject>("description");
                                if (descriptionJSONObject != null)
                                {
                                    string text = descriptionJSONObject.Value<string>("text");
                                    if (text != null)
                                    {
                                        TrendItem trendItem = new TrendItem(name, name, ProviderEnum.WhatTheTrend);
                                        trendItem.Weight = 5;
                                        trendsList.Add(trendItem);

                                        ExplanationItem explanationLItem = new ExplanationItem(trendItem.Title, trendItem.Title, text);
                                        ExplanationCacheHelper.CacheExplanationItem(trendItem.Title, explanationLItem);
                                    }
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception exception)
            {
                ErrorService.Log("WhatTheTrendTrendsService", "Parse", null, exception);
            }
            LogService.Debug(this.GetType(), "Exiting Parse for WhatTheThrendTrendsParser");
        }
コード例 #2
0
 public static void CacheExplanationItem(string query, ExplanationItem explanationItem)
 {
     string cacheName = "explanation-" + query;
     int cacheExpiration = ConfigService.GetConfig(ConfigKeys.THEINTERNETBUZZ_EXPLANATION_EXPIRATION, 600);
     CacheService.Put(cacheName, cacheExpiration, explanationItem);
 }