Пример #1
0
        public void LoadData(string feedName)
        {
            KeyValuePair<string, string> feedValue;

            bool feedKey = Settings.RssFeeds.TryGetValue(feedName.ToLower(), out feedValue);

            if (!feedKey)
            {
                NewsFeed = new NewsFeedModel();
            }

            NewsPageTitle = !string.IsNullOrWhiteSpace(feedValue.Key) ? feedValue.Key : "Recent Items";

            NewsFeed = Service.GetNews(feedName, "8");
            NewsItems = NewsFeed.Items;
        }
Пример #2
0
        private void BuildNewsFeedModel(NewsFeedModel data)
        {
            _news.Title = data.Title;
            _news.Description = data.Description;
            _news.Copyright = data.Copyright;
            _news.Link = data.Link;
            _news.Language = data.Language;
            _news.ImageUrl = data.ImageUrl;

            foreach (NewsItemModel item in data.Items)
            {
                var newsItem = new NewsItemModel
                                   {
                                       Title = item.Title,
                                       ArticleLink = item.ArticleLink,
                                       Date = item.Date,
                                       Description = item.Description,
                                       ImageUrl = Coalesce(item.ImageUrl, Settings.DefaulImage).ToString()
                                   };
                _news.Items.Add(newsItem);
            }
        }
Пример #3
0
        public NewsFeedModel GetNews(string newsFeed, string storyCount)
        {
            _news = new NewsFeedModel();
            var loadedEventArgs = new LoadEventArgs();
            string queryString = string.Format("{0}?feed={1}&pageSize={2}", Settings.NewsUrl, newsFeed ?? "",
                                               storyCount ?? "");
            var webClient = new SharpGIS.GZipWebClient();

            Observable.FromEvent<DownloadStringCompletedEventArgs>(webClient, "DownloadStringCompleted")
                .ObserveOn(Scheduler.ThreadPool)
                .Select(x => ProcessNews(x.EventArgs.Result))
                .ObserveOn(Scheduler.Dispatcher)
                .Subscribe(s =>
                               {
                                   BuildNewsFeedModel(s);
                                   loadedEventArgs.IsLoaded = true;
                                   loadedEventArgs.Message = "";
                                   OnNewsLoaded(loadedEventArgs);
                               }, e =>
                                      {
                                          loadedEventArgs.IsLoaded = false;
                                          loadedEventArgs.Message = e.Message.ToString(CultureInfo.InvariantCulture);
                                          OnNewsLoaded(loadedEventArgs);
                                      });
            webClient.DownloadStringAsync(new Uri(queryString));
            return _news;
        }