Ejemplo n.º 1
0
        private Sresponse getSentiment(DataJob.Doc d)
        {
            this.client = new WebClient();
            this.s = new Sresponse();
            s = JsonConvert.DeserializeObject<Sresponse>(client.DownloadString(sService + sQuery + d.source.enriched.url.url + "&apikey=" + apiKey));

            if (s.status == "OK" && s.results != null)
            {
                Sentiment r = s.results[0].sentiment;

                using (Context db = new Context())
                {
                    r.docid = d.id;
                    r.timestamp = d.timestamp;
                    r.url = d.source.enriched.url.url;
                    r.title = d.source.enriched.url.title;

                    db.Sentiment.Add(r);
                    db.SaveChanges();
                    Console.WriteLine("Added new article: " + r.url);
                }
            }

            return s;
        }