0

我想让我的 Windows Phone 应用程序中的后台代理在后台检查新提要,我使用 webclient 下载它们并将它们显示在列表框中我使用 webbrowser 控件将选定的提要显示到它来自的页面我从 syndicationitem 获得的 url,现在我想保存让我们说标题或发布日期到隔离存储,并且后台代理每 30 分钟检查一次。对于提要并检查是否有一些新提要可用,比较最后一个提要标题或已保存的最后发布日期和页面上的最新消息,然后如果有较新的提要,它应该发送一个带有提要标题的 toast 通知和打开我的应用程序。

我之前没有做任何事情来保存提要,我不知道该怎么做,我不知道如何使用后台代理和做我上面写的。我使用 Microsoft 的 RSS 阅读器示例作为我的应用程序逻辑的背景。下载,在此处显示与示例类似的所有内容 - http://msdn.microsoft.com/en-us/library/windowsphone/develop/hh487167(v=vs.105).aspx

这是一些代码:

我用它来下载提要

WebClient webClient = new WebClient();
webClient.DownloadStringCompleted += new DownloadStringCompletedEventHandler(webClient_DownloadStringCompleted);
webClient.DownloadStringAsync(new System.Uri("http://wpnovosti.com/feeds/posts/default?alt=rss"));

我用来在我的列表框中显示它们,并且还有一些动态磁贴的逻辑:

public void UpdateFeedList(string feedXML)
    {


        StringReader stringReader = new StringReader(feedXML);
        XmlReader xmlReader = XmlReader.Create(stringReader);
        SyndicationFeed feed = SyndicationFeed.Load(xmlReader);  

        Deployment.Current.Dispatcher.BeginInvoke(() =>
        {
            // Bind the list of SyndicationItems to our ListBox.
            feedListBox.ItemsSource = feed.Items;
            SystemTray.SetProgressIndicator(this, null);

            //Live Tiles
            ShellTile appTile = ShellTile.ActiveTiles.First();
            if (appTile != null)
            {
                FlipTileData TileData = new FlipTileData()
                {
                    Title = "",
                    BackTitle = "WP Novosti",
                    BackContent = feed.Items.First().Title.Text,
                    WideBackContent = feed.Items.First().Title.Text,
                    Count = 0,
                };

                appTile.Update(TileData);
            }
            else
            {
            }


        });

如果在列表框中选择了一个项目,我会使用它:

public void feedListBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
    {
        ListBox listBox = sender as ListBox;


        if (listBox != null && listBox.SelectedItem != null)
        {
            // Get the SyndicationItem that was tapped.
            SyndicationItem sItem = (SyndicationItem)listBox.SelectedItem;


            // Set up the page navigation only if a link actually exists in the feed item.
            if (sItem.Links.Count > 0)
            {                   
               Uri uri = sItem.Links.FirstOrDefault().Uri;

               NavigationService.Navigate(new Uri("/Pregled.xaml?url=" + uri, UriKind.Relative));

               UpdateFeedList(State["feed"] as string);
            }

        }
    }

其余的只是通过 webbrowser 控件在另一个页面上显示这个传递的 url。我怎样才能让它像我想在上面描述的那样现在真正起作用?!

4

0 回答 0