Esempio n. 1
0
 private static void UpdateWeather(object state)
 {
     Unified.Rss.RssFeed f = Unified.Rss.RssFeed.Read(RSSUrl);
     lock (WeatherConditions) {
         Weather.WeatherConditions = f.Channels[0].Items[0].Description;
     }
 }
        /// <summary>
        /// check codeplex's rss feed to see if we have a new release available.
        /// </summary>
        private static void CheckForCodeplexRelease()
        {
            bool   checkForUpdate = true;
            string releaseFile    = "LastUpdateCheck.txt";

            if (System.IO.File.Exists(releaseFile))
            {
                string text = System.IO.File.ReadAllText(releaseFile).Trim();
                if (text != string.Empty)
                {
                    DateTime lastUpdate = DateTime.MinValue;
                    if (DateTime.TryParse(text, out lastUpdate))
                    {
                        if (lastUpdate.Date >= DateTime.Now.Date) //dont run the update if the file is today or later..if we have checked today or not
                        {
                            checkForUpdate = false;
                        }
                    }
                }
            }
            if (checkForUpdate)
            {
                Unified.Rss.RssFeed feed = Unified.Rss.RssFeed.Read("http://www.codeplex.com/Terminals/Project/ProjectRss.aspx?ProjectRSSFeed=codeplex%3a%2f%2frelease%2fTerminals");
                if (feed != null)
                {
                    bool needsUpdate = false;
                    foreach (Unified.Rss.RssChannel chan in feed.Channels)
                    {
                        foreach (Unified.Rss.RssItem item in chan.Items)
                        {
                            if (item.PubDate > Program.BuildDate)  //check the date the item was published.  is it after the currently executing application BuildDate? if so, then its probably a new build!
                            {
                                MainForm.ReleaseAvailable   = true;
                                MainForm.ReleaseDescription = item;
                                needsUpdate = true;
                                break;
                            }
                        }
                        if (needsUpdate)
                        {
                            break;
                        }
                    }
                }
                System.IO.File.WriteAllText(releaseFile, DateTime.Now.ToString());
            }
        }