Example #1
0
        /// <summary>
        /// Populates the list of sources
        /// </summary>
        private void PopulateNewsSourcesList()
        {
            _ignore = true;
            dgvNews.SuspendLayout();
            NewsSourceType type = cbbSourceType.GetSelectedValue <Tuple <string, NewsSourceType> >().Item2;

            colURL.Visible = type == NewsSourceType.RSS;
            if (_dbContext != null)
            {
                _dbContext.SaveChanges();
                _dbContext.Dispose();
            }
            _dbContext = new CoinTNetContext();
            _dbContext.NewsSources.Where(ns => ns.Type == (int)type).Load();
            var newsList = _dbContext.NewsSources.Local.ToBindingList();

            _bindingSource        = new BindingSource(newsList, null);
            _bindingSource.Filter = "Type == 0";
            dgvNews.DataSource    = _bindingSource;
            dgvNews.ResumeLayout();
            _ignore = false;
        }
Example #2
0
        /// <summary>
        /// Gets the list of news items
        /// </summary>
        /// <returns></returns>
        private List <NewsItem> FetchNewsItems()
        {
            using (var dbContext = new CoinTNetContext())
            {
                var newsSources = (from ns in dbContext.NewsSources
                                   select ns).ToList();

                List <NewsItem> items = new List <NewsItem>();

                foreach (var ns in newsSources.Where(n => n.Type == (int)NewsSourceType.RSS))
                {
                    items = items.Union(_newsService.GetItemsFromRSS(ns.Name, ns.Url, DateTime.Now.AddHours(-ns.ExpiryInHours))).ToList();
                }

                foreach (var ns in newsSources.Where(n => n.Type == (int)NewsSourceType.Twitter))
                {
                    items = items.Union(_newsService.GetItemsFromTwitter(ns.Name, ns.NbItems, DateTime.Now.AddHours(-ns.ExpiryInHours)))
                            .ToList();
                }

                return(items.OrderByDescending(i => i.DateTime).ToList());
            }
        }
Example #3
0
        /// <summary>
        /// Gets the list of news items
        /// </summary>
        /// <returns></returns>
        private List<NewsItem> FetchNewsItems()
        {

            using (var dbContext = new CoinTNetContext())
            {
                var newsSources = (from ns in dbContext.NewsSources
                                   select ns).ToList();

                List<NewsItem> items = new List<NewsItem>();

                foreach (var ns in newsSources.Where(n => n.Type == (int)NewsSourceType.RSS))
                {
                    items = items.Union(_newsService.GetItemsFromRSS(ns.Name, ns.Url, DateTime.Now.AddHours(-ns.ExpiryInHours))).ToList();
                }

                foreach (var ns in newsSources.Where(n => n.Type == (int)NewsSourceType.Twitter))
                {
                    items = items.Union(_newsService.GetItemsFromTwitter(ns.Name, ns.NbItems, DateTime.Now.AddHours(-ns.ExpiryInHours)))
                        .ToList();
                }

                return items.OrderByDescending(i => i.DateTime).ToList();
            }
        }
Example #4
0
 /// <summary>
 /// Initialises a new instance of the class
 /// </summary>
 public NewsService()
 {
     _dbContext = new CoinTNetContext();
 }
Example #5
0
 /// <summary>
 /// Initialises a new instance of the class
 /// </summary>
 public NewsService()
 {
     _dbContext = new CoinTNetContext();
 }
Example #6
0
 /// <summary>
 /// Populates the list of sources
 /// </summary>
 private void PopulateNewsSourcesList()
 {
     _ignore = true;
     dgvNews.SuspendLayout();
     NewsSourceType type = cbbSourceType.GetSelectedValue<Tuple<string, NewsSourceType>>().Item2;
     colURL.Visible = type == NewsSourceType.RSS;
     if (_dbContext != null)
     {
         _dbContext.SaveChanges();
         _dbContext.Dispose();
     }
     _dbContext = new CoinTNetContext();
     _dbContext.NewsSources.Where(ns => ns.Type == (int)type).Load();
     var newsList = _dbContext.NewsSources.Local.ToBindingList();
     _bindingSource = new BindingSource(newsList, null);
     _bindingSource.Filter = "Type == 0";
     dgvNews.DataSource = _bindingSource;
     dgvNews.ResumeLayout();
     _ignore = false;
 }