Beispiel #1
0
 static void GoBizatch()
 {
     while (true)
     {
         try
         {
             lock (FeedManager.feeds)
             {
                 foreach (string feed in FeedManager.feeds)
                 {
                     //load the feed
                     RssChannel channel = RssParses.ProcessRSS(feed);
                     //if we've never read, mark all as read
                     if (!_feeds.ContainsKey(channel.link))
                     {
                         Dictionary <string, DateTime> curDictionary = _feeds[channel.link] = new Dictionary <string, DateTime>();
                         foreach (RssItem item in channel.Items)
                         {
                             //just use timestamp as value.  no purpose, but dictionary is best method
                             curDictionary[item.guid] = DateTime.Now;
                         }
                     }
                     else
                     {
                         Dictionary <string, DateTime> curDictionary = _feeds[channel.link];
                         foreach (RssItem item in channel.Items)
                         {
                             //if item is not seen before, balloon
                             if (!curDictionary.ContainsKey(item.guid))
                             {
                                 _lastUrl = item.link;
                                 string title       = StripHTML(item.title);
                                 string description = StripHTML(item.description);
                                 _icon.ShowBalloonTip(20000, title, description, ToolTipIcon.Info);
                                 curDictionary[item.guid] = DateTime.Now;
                             }
                         }
                     }
                 }
             }
             Thread.Sleep(5000);
         }
         catch (Exception ex)
         {
             _icon.ShowBalloonTip(90000, "AnAppADay.com RSS Alerter Error", ex.Message, ToolTipIcon.Error);
         }
     }
 }
Beispiel #2
0
 private void button1_Click(object sender, EventArgs e)
 {
     try
     {
         RssChannel c = RssParses.ProcessRSS(textBox1.Text);
         if (c.Items.Length > 0)
         {
             if (c.Items[0].guid == null)
             {
                 throw new Exception("Feeds with no GUIDs are not supported.  Contact the webmaster and whine to them.");
             }
         }
         lock (FeedManager.feeds)
         {
             FeedManager.feeds.AddLast(textBox1.Text);
         }
         listBox1.Items.Add(textBox1.Text);
     }
     catch (Exception ex)
     {
         MessageBox.Show("Error adding feed: " + ex.Message);
     }
 }
Beispiel #3
0
        private void GoYouFool()
        {
            bool shouldRead = true;

            while (true)
            {
                try
                {
                    shouldRead = true;
                    if (Properties.Settings.Default.ActiveDuringTimes)
                    {
                        DateTime now        = DateTime.Now;
                        string   timeString = Properties.Settings.Default.TimeFrom;
                        int      hours      = int.Parse(timeString.Substring(0, 2));
                        int      mins       = int.Parse(timeString.Substring(3, 2));
                        DateTime from       = new DateTime(now.Year, now.Month, now.Day, hours, mins, 0);
                        timeString = Properties.Settings.Default.TimeTo;
                        hours      = int.Parse(timeString.Substring(0, 2));
                        mins       = int.Parse(timeString.Substring(3, 2));
                        DateTime to = new DateTime(now.Year, now.Month, now.Day, hours, mins, 0);
                        if (now < from || now > to)
                        {
                            shouldRead = false;
                        }
                    }
                    if (shouldRead)
                    {
                        //here we get the RSS feeds
                        string[] feeds = Properties.Settings.Default.Feeds.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries);
                        foreach (string feed in feeds)
                        {
                            if (feed.Trim() == "")
                            {
                                continue;
                            }
                            //load the feed
                            RssChannel channel = RssParses.ProcessRSS(feed);
                            //if we've never read, mark all as read
                            if (!_feeds.ContainsKey(channel.link))
                            {
                                Dictionary <string, DateTime> curDictionary = _feeds[channel.link] = new Dictionary <string, DateTime>();
                                foreach (RssItem item in channel.Items)
                                {
                                    //just use timestamp as value.  no purpose, but dictionary is best method
                                    curDictionary[item.guid] = DateTime.Now;
                                }
                            }
                            else
                            {
                                Dictionary <string, DateTime> curDictionary = _feeds[channel.link];
                                foreach (RssItem item in channel.Items)
                                {
                                    //if item is not seen before, SPEAK!
                                    if (!curDictionary.ContainsKey(item.guid))
                                    {
                                        string title       = Utility.StripHTML(item.title);
                                        string description = Utility.StripHTML(item.description);
                                        _lastUrl = item.link;
                                        _speech.Speak(channel.title, SpeechVoiceSpeakFlags.SVSFDefault);
                                        Thread.Sleep(1000);
                                        _speech.Speak(title, SpeechVoiceSpeakFlags.SVSFDefault);
                                        Thread.Sleep(1000);
                                        _speech.Speak(description, SpeechVoiceSpeakFlags.SVSFDefault);
                                        curDictionary[item.guid] = DateTime.Now;
                                        //give 5 seconds for a hotkey press....
                                        Thread.Sleep(5000);
                                    }
                                }
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    Program._icon.ShowBalloonTip(5000, "RSS TTS Error", ex.Message, ToolTipIcon.Error);
                }
                Thread.Sleep(((int)Properties.Settings.Default.PollRate) * 60000);
            }
        }