Пример #1
0
        public async Task LoadData()
        {
            IsLoading = true;
            SyndicationClient client = new SyndicationClient();
            var result = await client.RetrieveFeedAsync(new Uri("http://channel9.msdn.com/Feeds/RSS/mp4"));

            foreach (var r in result.Items.Take(12))
            {
                try
                {
                    NewsList.Add(new Channel9Item
                    {
                        Title       = r.Title.Text,
                        Description = HtmlUtilities.ConvertToText(r.Summary.Text),
                        ImageUrl    = r.ElementExtensions.Last(e => e.NodeName == "thumbnail").AttributeExtensions[0].Value,
                    });
                }
                catch (Exception)
                {
                    continue;
                }
            }

            IsLoading = false;
        }
Пример #2
0
        /// <summary>
        /// The load syndicated content.
        /// </summary>
        /// <returns>
        /// The <see cref="Task"/> to run asynchronously.
        /// </returns>
        public static async Task LoadSyndicatedContent()
        {
            var client = new SyndicationClient();
            var feed   = await client.RetrieveFeedAsync(CSharperImageUri);

            var group = new DataFeed(
                feed.Id, feed.Title.Text, AuthorSignature, feed.ImageUri.ToString(), feed.Subtitle.Text);

            SingleDataSource.allGroups.Add(group);

            var idx  = 0;
            var urls = new[] { "DarkGray.png", "LightGray.png", "MediumGray.png" };

            foreach (var dataItem in
                     from item in feed.Items
                     let content = Windows.Data.Html.HtmlUtilities.ConvertToText(item.Content.Text)
                                   let summary = string.Format("{0} ...", content.Length > 255 ? content.Substring(0, 255) : content)
                                                 select
                                                 new DataItem(
                         item.Id,
                         item.Title.Text,
                         AuthorSignature,
                         string.Format("ms-appx:///Assets/{0}", urls[idx++ % urls.Length]),
                         summary,
                         content,
                         @group))
            {
                @group.Items.Add(dataItem);
            }
        }
        private async Task GetFeedAsync(string feedUriString)
        {
            Windows.Web.Syndication.SyndicationClient client = new SyndicationClient();

            try
            {
                Uri feedUri = new Uri(feedUriString);

                SyndicationFeed feed = await client.RetrieveFeedAsync(feedUri);

                // This code is executed after RetrieveFeedAsync returns the SyndicationFeed.
                // Process the feed and copy the data we want into our FeedData and FeedItem classes.
                FeedData feedData = new FeedData();

                feedData.Title = feed.Title.Text;
                if (feed.Subtitle != null && feed.Subtitle.Text != null)
                {
                    feedData.Description = feed.Subtitle.Text;
                }
                // Use the date of the latest post as the last updated date.
                feedData.PubDate = feed.Items[0].PublishedDate.DateTime;

                foreach (SyndicationItem item in feed.Items)
                {
                    FeedItem feedItem = new FeedItem();
                    feedItem.Title   = item.Title.Text.Trim();
                    feedItem.PubDate = item.PublishedDate.DateTime;
                    string _authorName = item.Authors[0].Name;
                    if (string.IsNullOrEmpty(item.Authors[0].Name))
                    {
                        _authorName = item.Authors[0].NodeValue;
                    }

                    feedItem.Author = _authorName;
                    // Handle the differences between RSS and Atom feeds.
                    if (feed.SourceFormat == SyndicationFormat.Atom10)
                    {
                        feedItem.Content = item.Content.Text;
                    }
                    else if (feed.SourceFormat == SyndicationFormat.Rss20)
                    {
                        feedItem.Content = item.Summary.Text.Trim();
                    }
                    feedItem.Link = item.Links[0].Uri;
                    this.Feeds.Add(feedItem);
                    //feedData.Items.Add(feedItem);
                }
            }
            catch (Exception ex)
            {
                if (!ApplicationStateParams.isInternetAvailable)
                {
                    _errorMessage = "Error retrieving blog feeds, check your internet connection";
                }
                else
                {
                    _errorMessage = "Error retrieving blog feeds";
                }
            }
        }
Пример #4
0
    private async void Load(ItemsControl list, Uri uri)
    {
        _client = new SyndicationClient();
        _feed   = await _client.RetrieveFeedAsync(uri);

        list.ItemsSource = _feed.Items;
    }
Пример #5
0
        public async static Task <List <QuoteRss> > addItem()
        {
            List <QuoteRss> quoteList = new List <QuoteRss>();

            try
            {
                SyndicationClient Client = new SyndicationClient();
                Uri RSSUri = new Uri("http://happyquotes.tumblr.com/rss");
                var feeds  = await Client.RetrieveFeedAsync(RSSUri);

                foreach (var feed in feeds.Items)
                {
                    if (feed.Title.Text.StartsWith("\"") & !feed.Title.Text.Contains("..."))
                    {
                        quoteList.Add(new QuoteRss {
                            quoteText = feed.Title.Text.Substring(0, feed.Title.Text.Length - 2) + "\""
                        });
                    }
                }
            }
            catch (Exception exception)
            {
                Debug.WriteLine("Error while getting quotes: " + exception);
            }
            return(quoteList);
        }
Пример #6
0
        // <SnippetDownloadRSS>
        // Put the keyword async on the declaration of the event handler.
        private async void Button_Click_1(object sender, RoutedEventArgs e)
        {
            Windows.Web.Syndication.SyndicationClient client = new SyndicationClient();

            Uri feedUri
                = new Uri("http://windowsteamblog.com/windows/b/windowsexperience/atom.aspx");

            try
            {
                SyndicationFeed feed = await client.RetrieveFeedAsync(feedUri);

                // The rest of this method executes after await RetrieveFeedAsync completes.
                rssOutput.Text = feed.Title.Text + Environment.NewLine;

                foreach (SyndicationItem item in feed.Items)
                {
                    rssOutput.Text += item.Title.Text + ", " +
                                      item.PublishedDate.ToString() + Environment.NewLine;
                }
            }
            catch (Exception ex)
            {
                // Log Error.
                rssOutput.Text =
                    "I'm sorry, but I couldn't load the page," +
                    " possibly due to network problems." +
                    "Here's the error message I received: "
                    + ex.ToString();
            }
        }
        public async static Task <string> GetFeedTitleAsync()
        {
            string            response = String.Empty;
            SyndicationFeed   feed     = new SyndicationFeed();
            SyndicationClient client   = new SyndicationClient();

            try
            {
                feed = await client.RetrieveFeedAsync(
                    new Uri("http://www.apress.com/index.php/dailydeals/index/rss"));

                response = feed.GetXmlDocument(SyndicationFormat.Rss20).GetXml();
            }
            catch (Exception ex)
            {
                SyndicationErrorStatus status = SyndicationError.GetStatus(ex.HResult);
                if (status == SyndicationErrorStatus.InvalidXml)
                {
                    response += "Invalid XML!";
                }

                if (status == SyndicationErrorStatus.Unknown)
                {
                    response = ex.Message;
                }
            }

            return(response);
        }
Пример #8
0
        public async Task <string> Process(bool showMotorways, bool showARoads)
        {
            Events = new List <Event>();

            SyndicationClient client = new SyndicationClient();

            Uri feedUri = new Uri(TrafficURL);

            var feed = await client.RetrieveFeedAsync(feedUri);

            foreach (SyndicationItem item in feed.Items)
            {
                try
                {
                    Event newEvent = new Event(item.Title.Text, item.Summary.Text);
                    newEvent.Process();
                    Events.Add(newEvent);

                    if (!ProblemRoads.Contains(newEvent.Road))
                    {
                        ProblemRoads.Add(newEvent.Road);
                    }
                }
                catch (Exception ex)
                {
                }
            }

            return(Filter(showMotorways, showARoads));
        }
Пример #9
0
        static void Main(string[] args)
        {
            SyndicationClient client    = new SyndicationClient();
            JsonArray         jsonArray = new JsonArray();

            foreach (string key in keys)
            {
                string uriString            = "http://social.msdn.microsoft.com/Forums/en-US/" + key + "/threads?outputAs=rss";
                Uri    uri                  = new Uri(uriString);
                Task <SyndicationFeed> task = client.RetrieveFeedAsync(uri).AsTask();
                task.Wait();
                SyndicationFeed feed = task.Result;
                Console.WriteLine(key);
                Console.WriteLine(feed.Title.Text);
                Console.WriteLine(feed.Subtitle.Text);
                Console.WriteLine();

                JsonObject jsonObject = new JsonObject();
                jsonObject.AddStringValue("favicon_url", "http://social.microsoft.com/Forums/GlobalResources/images/Msdn/favicon.ico");
                jsonObject.AddStringValue("icon_url", "http://kiewic.com/questions/icon/" + key);
                jsonObject.AddStringValue("audience", feed.Subtitle.Text);
                jsonObject.AddStringValue("site_url", uriString);
                jsonObject.AddStringValue("api_site_parameter", key);
                jsonObject.AddStringValue("name", feed.Title.Text);

                jsonArray.Add(jsonObject);
            }

            File.WriteAllText("msdn.json", jsonArray.Stringify());
            Console.WriteLine(jsonArray.Stringify());
        }
        public static async Task <ArticleList> GetArticleListFromFeedAsync(string feedUrl)
        {
            var syncClient = new SyndicationClient();
            var lista      = new ArticleList();

            var feed = await syncClient.RetrieveFeedAsync(new Uri(feedUrl));

            foreach (var art in feed.Items)
            {
                var content = CreateContent(art.NodeValue);

                {
                    var newArticle = new Article()
                    {
                        Title   = art.Title.Text,
                        Content = content,
                        Summary = CreateSummary(art.Summary, content),
                        ImgUri  = Find1stImageFromHtml(content)
                    };
                    lista.Add(newArticle);
                }
            }

            return(lista);
        }
        public async Task GetFeed()
        {
            try
            {
                SyndicationClient client = new SyndicationClient();
                SyndicationFeed   feed;

                // Although most HTTP servers do not require User-Agent header,
                // others will reject the request or return a different response if this header is missing.
                // Use the setRequestHeader() method to add custom headers.
                client.SetRequestHeader("User-Agent", "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; WOW64; Trident/6.0)");
                feed = await client.RetrieveFeedAsync(this.uri);

                // Retrieve the title of the feed and store it in a string.
                string title = feed.Title.Text;
                // Iterate through each feed item.
                feedItems = new List <T>();
                foreach (SyndicationItem item in feed.Items)
                {
                    try
                    {
                        feedItems.Add(ObjectFactory(item));
                    }
                    catch { }
                }
                RSSItemsChanged?.Invoke(this, new EventArgs());
                lastUpdated = DateTime.Now;
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.Message);
                Debug.WriteLine(ex.StackTrace);
            }
        }
Пример #12
0
        public async void LoadNews(TextBlock theNewsText, Uri uri)
        {
            try
            {
                SyndicationClient client = new SyndicationClient();
                SyndicationFeed   feed   = await client.RetrieveFeedAsync(uri);

                if (feed != null)
                {
                    foreach (SyndicationItem item in feed.Items)
                    {
                        if (item.Title.Text.Length > 20) // limit over 20 so we wont get short meaningless titles
                        {
                            theNewsText.Text = item.Title.Text;
                            await Task.Delay(7000);
                        }

                        else
                        {
                            continue;
                        }
                    }
                }
            }
            catch
            {
            }

            LoadNews(theNewsText, uri); //function to repeat
        }
Пример #13
0
        private async Task GetFeed()
        {
            lock (_lock)
            {
                if (lastUpdated > DateTime.Now.Subtract(new TimeSpan(6, 0, 0)))
                {
                    return;
                }
                lastUpdated = DateTime.Now;
            }
            SyndicationClient client = new SyndicationClient();
            SyndicationFeed   feed;

            string uriString = @"https://www.fantasyflightgames.com/en/rss/?tags=x-wing&";
            Uri    uri       = new Uri(uriString);

            try
            {
                // Although most HTTP servers do not require User-Agent header,
                // others will reject the request or return a different response if this header is missing.
                // Use the setRequestHeader() method to add custom headers.
                client.SetRequestHeader("User-Agent", "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; WOW64; Trident/6.0)");
                feed = await client.RetrieveFeedAsync(uri);

                // Retrieve the title of the feed and store it in a string.
                string title = feed.Title.Text;
                // Iterate through each feed item.
                FeedItems = feed.Items.ToList();
            }
            catch (Exception ex)
            {
                lastUpdated = DateTime.MinValue;
            }
        }
Пример #14
0
        // ***Provide a parameter for the CancellationToken.
        //<snippet2>
        async Task DownloadBlogsAsync(CancellationToken ct)
        {
            Windows.Web.Syndication.SyndicationClient client = new SyndicationClient();

            var uriList = CreateUriList();

            // Force the SyndicationClient to download the information.
            client.BypassCacheOnRetrieve = true;

            // The following code avoids the use of implicit typing (var) so that you
            // can identify the types clearly.

            foreach (var uri in uriList)
            {
                // ***These three lines are combined in the single statement that follows them.
                //IAsyncOperationWithProgress<SyndicationFeed, RetrievalProgress> feedOp =
                //    client.RetrieveFeedAsync(uri);
                //Task<SyndicationFeed> feedTask = feedOp.AsTask(ct);
                //SyndicationFeed feed = await feedTask;

                // ***You can combine the previous three steps in one expression.
                //<snippet7>
                SyndicationFeed feed = await client.RetrieveFeedAsync(uri).AsTask(ct);

                //</snippet7>

                DisplayResults(feed);
            }
        }
Пример #15
0
        public async Task <List <KurirNews> > ReadRssVesti(string url, NewsType tipVesti)
        {
            //string kurirUrl = "http://www.kurir.rs/rss/vesti/";
            SyndicationClient client = new SyndicationClient();
            SyndicationFeed   feed   = await client.RetrieveFeedAsync(new Uri(url));

            List <KurirNews> kurirNews = new List <KurirNews>();

            if (feed != null)
            {
                foreach (SyndicationItem item in feed.Items)
                {
                    string[] slikaText = item.Summary.Text.Split(new[] { "<img src=\"", "\"><br>" }, StringSplitOptions.RemoveEmptyEntries);
                    kurirNews.Add(new KurirNews()
                    {
                        Id                = IdCounter++,
                        ImagePath         = slikaText.Length > 0 ? slikaText[0] : "",
                        Summary           = slikaText.Length > 1 ? slikaText[1] : "",
                        PublishedDateTime = item.PublishedDate.DateTime,
                        Title             = item.Title.Text,
                        Url               = item.Links[0].NodeValue ?? item.Id,
                        NewsType          = tipVesti.ToString()
                    });
                }
            }
            return(kurirNews);
        }
Пример #16
0
        /// <summary>
        /// Creates the syndicationClient Object that loads the given News Feed.
        /// </summary>
        /// <returns>List of Syndication Items</returns>
        public async Task <IList <SyndicationItem> > LoadNewsAsync(Uri uri)
        {
            SyndicationClient syndicationClient = new SyndicationClient();
            var feeds = await syndicationClient.RetrieveFeedAsync(uri);

            return(feeds.Items);
        }
Пример #17
0
        private async void stack_Tapped(object sender, TappedRoutedEventArgs e)
        {
            if (MainBorder.Height == 46)
            {
                // Expand
                ExpandCollapse.Content = "";
                ExpandItems(46, (cat.websites.Count * 66) + 46 + 80);

                if (!loaded)
                {
                    SyndicationClient client = new SyndicationClient();
                    foreach (Website ws in cat.websites)
                    {
                        ListFeed feeditem = await GetItem(client, ws.url);

                        Display.Items.Add(feeditem);
                    }
                    LoadStatus.IsIndeterminate = false;
                    LoadStatus.Opacity         = 0;
                    loaded = true;
                }
            }
            else
            {
                // Collapse
                ExpandCollapse.Content = "";
                ExpandItems((cat.websites.Count * 66) + 46 + 80, 46);
            }
        }
Пример #18
0
        public async void ConnectRSS()
        {
            try
            {
                progress.IsIndeterminate = true;

                SyndicationClient client = new SyndicationClient();
                Uri RSSuri = new Uri("http://www.kocaeli.bel.tr/Rss.aspx");
                var feeds  = await client.RetrieveFeedAsync(RSSuri);

                foreach (var feed in feeds.Items)
                {
                    string str = feed.Title.Text;
                    str = str.Replace("&#34;", "");
                    str = str.Replace("&#39;", "");
                    listTitles.Items.Add(str);
                }

                progress.IsIndeterminate = false;
            }

            catch (Exception)
            {
                progress.IsIndeterminate = false;

                if (NetworkInformation.GetInternetConnectionProfile() == null)
                {
                    control.Message("Herhangi bir ağ bağlantısı bulunamadı. Telefon ayarlarınızı kontrol edin ve yeniden deneyin.", "Bir hata oluştu :(");
                }
            }
        }
Пример #19
0
        public async Task <IList <SyndicationItem> > LoadNewsAsync()
        {
            SyndicationClient syndicationClient = new SyndicationClient();
            var feeds = await syndicationClient.RetrieveFeedAsync(new Uri("http://golem.de.dynamic.feedsportal.com/pf/578068/http://rss.golem.de/rss.php?feed=RSS2.0"));

            return(feeds.Items);
        }
Пример #20
0
        /// <summary>
        /// Get Articles From Feed
        /// </summary>
        /// <param name="feedUrl"></param>
        /// <returns></returns>
        public static async Task <ArticleList> GetArticleListFromFeedAsync(string feedUrl)
        {
            var syncClient = new SyndicationClient();
            var lista      = new ArticleList();

            if (InternetConectivity)
            {
                var feed = await syncClient.RetrieveFeedAsync(new Uri(feedUrl));

                foreach (var art in feed.Items)
                {
                    var content = CreateContent(art.NodeValue);
                    lista.Add(new Article()
                    {
                        Title   = art.Title.Text,
                        Content = content,
                        Summary = CreateSummary(art.Summary, content),
                        ImgUri  = Find1stImageFromHtml(content)
                    });
                }
            }
            else
            {
                throw new Exception(INTERNET_REQUIRED);
            }

            return(lista);
        }
        public static async Task <ObservableCollection <apergiaFeedItem> > getFeedsAsync(string url)
        {
            //The web object that will retrieve our feeds..
            SyndicationClient client = new SyndicationClient();
            //The URL of our feeds..
            Uri feedUri = new Uri(url);
            //Retrieve async the feeds..
            var feed = await client.RetrieveFeedAsync(feedUri);

            //The list of our feeds..
            ObservableCollection <apergiaFeedItem> feedData = new ObservableCollection <apergiaFeedItem>();

            //Fill up the list with each feed content..
            foreach (SyndicationItem item in feed.Items)
            {
                apergiaFeedItem af = new apergiaFeedItem();
                af.PubDate = item.PublishedDate.DateTime;
                af.Title   = item.Title.Text;
                af.Summary = extractSummary(item.Summary.Text);
                try { af.Link = item.Links[0].Uri; }
                catch (Exception) { }

                feedData.Add(af);
            }
            return(feedData);
        }
Пример #22
0
        private async Task <FeedData> GetFeedAsync(string uriString)
        {
            Uri feedUri = new Uri(uriString);
            SyndicationClient client   = new SyndicationClient();
            FeedData          feedData = null;

            try
            {
                var feed = await client.RetrieveFeedAsync(feedUri);

                feedData = new FeedData();

                feedData.Title = feed?.Title?.Text;
                feedData.Link  = feed?.Links[0]?.Uri;

                foreach (var item in feed.Items)
                {
                    var feedItem = new FeedDataItem();

                    feedItem.Title       = item?.Title?.Text;
                    feedItem.Description = item?.Summary?.Text;
                    feedItem.Link        = item?.Links[0]?.Uri;
                    feedItem.PubDate     = item.PublishedDate.DateTime;
                    feedItem.ImageLink   = item?.Links[1]?.Uri;

                    feedData.Items.Add(feedItem);
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine("Ldkeofjersngioregiorejgloergirejngnre" + ex.Message);
            }

            return(feedData);
        }
        private async void GetFeed_Click(object sender, RoutedEventArgs e)
        {
            outputField.Text = "";

            // By default 'FeedUri' is disabled and URI validation is not required. When enabling the text box
            // validating the URI is required since it was received from an untrusted source (user input).
            // The URI is validated by calling Uri.TryCreate() that will return 'false' for strings that are not valid URIs.
            // Note that when enabling the text box users may provide URIs to machines on the intrAnet that require
            // the "Home or Work Networking" capability.
            Uri uri;

            if (!Uri.TryCreate(FeedUri.Text.Trim(), UriKind.Absolute, out uri))
            {
                rootPage.NotifyUser("Error: Invalid URI.", NotifyType.ErrorMessage);
                return;
            }

            SyndicationClient client = new SyndicationClient();

            client.BypassCacheOnRetrieve = true;

            // Although most HTTP servers do not require User-Agent header, others will reject the request or return
            // a different response if this header is missing. Use SetRequestHeader() to add custom headers.
            client.SetRequestHeader("User-Agent", "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; WOW64; Trident/6.0)");

            rootPage.NotifyUser("Downloading feed...", NotifyType.StatusMessage);
            outputField.Text = "Downloading feed: " + uri.ToString() + "\r\n";

            try
            {
                currentFeed = await client.RetrieveFeedAsync(uri);

                rootPage.NotifyUser("Feed download complete.", NotifyType.StatusMessage);

                DisplayFeed();
            }
            catch (Exception ex)
            {
                SyndicationErrorStatus status = SyndicationError.GetStatus(ex.HResult);
                if (status == SyndicationErrorStatus.InvalidXml)
                {
                    outputField.Text += "An invalid XML exception was thrown. " +
                                        "Please make sure to use a URI that points to a RSS or Atom feed.";
                }

                if (status == SyndicationErrorStatus.Unknown)
                {
                    WebErrorStatus webError = WebError.GetStatus(ex.HResult);

                    if (webError == WebErrorStatus.Unknown)
                    {
                        // Neither a syndication nor a web error. Rethrow.
                        throw;
                    }
                }

                rootPage.NotifyUser(ex.Message, NotifyType.ErrorMessage);
            }
        }
Пример #24
0
        public RssFeed(string feedUrl)
        {
            this.FeedUrl           = new Uri(feedUrl);
            this.syndicationClient = new SyndicationClient();
            this.feed = null;

            var feedPromise = GetFeed();
        }
        public async Task <IEnumerable <NewsEntry> > GetNewsEntriesAsync()
        {
            var client = new SyndicationClient();
            var feeds  = await client.RetrieveFeedAsync(new Uri(_RssUri));

            return(feeds.Items.Take(Math.Min(_MaxCount, feeds.Items.Count)).Select(
                       item => new NewsEntry(item.Title.Text, item.Summary.Text, item.PublishedDate)));
        }
Пример #26
0
        private async Task GetRssFeed()
        {
            Uri newsFeed = new Uri("http://www.ynet.co.il/Integration/StoryRss550.xml");
            SyndicationClient rssClient = new SyndicationClient();
            var feed = await rssClient.RetrieveFeedAsync(newsFeed);

            RssFeed = feed.Items.FirstOrDefault().ToString();
        }
Пример #27
0
        /// <summary>
        /// 刷新报纸,获取文章列表
        /// </summary>
        public async Task <List <NewsItem> > GetNewsListAsync()
        {
            OnNewsRefreshing?.Invoke();
            List <NewsItem> newNewsitems      = new List <NewsItem>();
            int             originalNewsCount = NewsList.Count;

            foreach (var feedUrl in FeedUrls)
            {
                var syndicationClient = new SyndicationClient();
                try
                {
                    var feed = await new SyndicationClient().RetrieveFeedAsync(feedUrl);
                    feed.Id = feedUrl.AbsoluteUri;
                    FeedModel feedModel = new FeedModel(feed);
                    if (!Feeds.Contains(feedModel))
                    {
                        Feeds.Add(feedModel);
                    }
                    //将新闻添加到newsItems中
                    for (int retrievedNewsIndex = feed.Items.Count - 1; retrievedNewsIndex >= 0; --retrievedNewsIndex)
                    {
                        var newsLink = feed.Items[retrievedNewsIndex].ItemUri ?? feed.Items[retrievedNewsIndex].Links.Select(l => l.Uri).FirstOrDefault();
                        var newsItem = new NewsItem(feed.Items[retrievedNewsIndex], newsLink, PaperTitle, feed);

                        //如果原新闻列表中不包含改新闻,则添加到新闻列表
                        if (!NewsList.Contains(newsItem))
                        {
                            newNewsitems.Add(newsItem);
                            NewsList.Add(newsItem);
                        }
                    }
                    var orderedNewsList = NewsList.OrderBy(news => news.PublishedDate);
                    NewsList = orderedNewsList.ToList();
                }
                catch (Exception exception)
                {
                    System.Diagnostics.Debug.WriteLine(exception.Message);
                    OnUpdateFailed?.Invoke(feedUrl.AbsoluteUri);
                }
            }
            if (NewsList.Count > originalNewsCount)
            {
                OnNewsRefreshed?.Invoke(NewsList);
            }
            else
            {
                NoNewNews?.Invoke();
            }
            if (NewsList.Count != originalNewsCount)
            {
                await SaveToFile(this);

                OnNewsUpdatedToFile?.Invoke();
            }
            return(NewsList);
        }
Пример #28
0
        private async void listTitles_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            SyndicationClient client = new SyndicationClient();
            Uri RSSuri = new Uri("http://www.kocaeli.bel.tr/Rss.aspx");
            var feeds  = await client.RetrieveFeedAsync(RSSuri);

            string uriToLaunch = feeds.Items[listTitles.SelectedIndex].Links[0].Uri.ToString();
            var    uri         = new Uri(uriToLaunch);
            var    success     = await Windows.System.Launcher.LaunchUriAsync(uri);
        }
Пример #29
0
        private static SyndicationClient GetSyndicationClient()
        {
            var client = new SyndicationClient
            {
                BypassCacheOnRetrieve = false
            };

            client.SetRequestHeader("user-agent", USER_AGENT);
            return(client);
        }
        public async Task <IEnumerable <News> > GetNews()
        {
            SyndicationClient client = new SyndicationClient();
            SyndicationFeed   feed   = await client.RetrieveFeedAsync(new Uri("http://feeds.feedburner.com/qmatteoq_eng", UriKind.Absolute));

            IEnumerable <News> news = feed.Items.Select(x => new News {
                Title = x.Title.Text, Summary = x.Summary.Text
            });

            return(news);
        }