Esempio n. 1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="feedSubscription"></param>
        public void ProcessRssSubscription(EventRssSubscription feedSubscription)
        {
            try
            {
                _log.DebugFormat("{0}: Processing feed Id {1} ({2}).", _name, feedSubscription.Id, feedSubscription.RssUrl);
                RssFeeds.ProcessFeed(feedSubscription, _db);
                feedSubscription.ErrorCount = 0;
                _db.ORManager.SaveOrUpdate(feedSubscription);
            }
            catch (Exception ex)
            {
                if (feedSubscription != null)
                {
                    _db.ORManager.Refresh(feedSubscription);

                    feedSubscription.ErrorCount += 1;
                    _db.ORManager.SaveOrUpdate(feedSubscription);

                    _log.Error(string.Format("{0}: Error processing feed {1} ({2})", _name, feedSubscription.Id, feedSubscription.RssUrl), ex);

                    if (feedSubscription.ErrorCount >= ERROR_THRESHOLD)
                    {
                        TextMessagesInterface.SendMessage(_db, feedSubscription.Url.UserId, string.Format("RankTrend has tried unsuccessfully {1} or more times to read the RSS feed that you specified in your RSS Subscription \"{0}\".  This could be for a number of reasons such as the URL you specified does not point to an RSS feed or the RSS feed is not available.  Please verify the URL that you specified for this feed.  If you feel this is in error, please let us know.", feedSubscription.Name, ERROR_THRESHOLD));
                    }
                }
                else
                {
                    _log.Error(ex);
                }
            }
        }
Esempio n. 2
0
        protected override void RunCycle()
        {
            try
            {
                int?rssSubscriptionId = _db.GetNextRssSubscriptionId();

                while (rssSubscriptionId != null)
                {
                    EventRssSubscription feedSubscription = _db.ORManager.Get <EventRssSubscription>(rssSubscriptionId);
                    ProcessRssSubscription(feedSubscription);
                    rssSubscriptionId = _db.GetNextRssSubscriptionId();
                }

                _log.DebugFormat("{0}: No more event RSS subscriptions to process.", _name);
            }
            catch (SqlException ex)
            {
                if (Regex.IsMatch(ex.Message, "An error has occurred while establishing a connection to the server.*"))
                {
                    _log.WarnFormat("{0}:  Could not establish connection to database during cycle.", _name);
                }
                else
                {
                    throw;
                }
            }
        }
Esempio n. 3
0
    private void cmdAdd_Click(object sender, EventArgs e)
    {
        EventRssSubscription subscription;

        subscription            = new EventRssSubscription();
        subscription.Name       = "Untitled RSS Feed";
        subscription.Url        = siteList.GetSelectedSite();
        subscription.RssUrl     = "http://";
        subscription.ErrorCount = 0;

        _db.ORManager.SaveOrUpdate(subscription);

        //Add the new item to the list
        lstSubscriptions.Items.Add(new ListItem(subscription.Name, subscription.Id.ToString()));
        lstSubscriptions.SelectedIndex = lstSubscriptions.Items.Count - 1;

        displaySubscription(subscription);
    }
Esempio n. 4
0
    private void displaySubscription(EventRssSubscription ers)
    {
        Win32TimeZone timeZone;

        timeZone = TimeZones.GetTimeZone(Profile.TimeZoneIndex);

        if (ers == null)
        {
            txtName.Enabled          = false;
            txtName.Text             = "";
            cmdReadFeedTitle.Enabled = false;
            txtDescription.Enabled   = false;
            txtDescription.Text      = "";
            txtRssUrl.Enabled        = false;
            txtRssUrl.Text           = "";
            categoryList.Enabled     = false;
            categoryList.SelectAnyItem();
            lblLastCheck.Text = "";
        }
        else
        {
            txtName.Enabled          = true;
            txtName.Text             = ers.Name;
            cmdReadFeedTitle.Enabled = true;
            txtDescription.Enabled   = true;
            txtDescription.Text      = ers.Description;
            txtRssUrl.Enabled        = true;
            txtRssUrl.Text           = ers.RssUrl;
            categoryList.Enabled     = true;
            categoryList.SetSelectedCategory(ers.EventCategory);
            if (ers.LastCheck == null)
            {
                lblLastCheck.Text = "Never";
            }
            else
            {
                lblLastCheck.Text = timeZone.ToLocalTime((DateTime)ers.LastCheck).ToString();
            }
        }
    }
Esempio n. 5
0
 /// <summary>
 ///		Reads the RSS feed specified in the <see cref="EventRssSubscription"/> and
 ///		inserts the new RSS items into the database.
 /// </summary>
 /// <param name="eventRssSubscription">
 ///		The <see cref="EventRssSubscription"/> whose RSS feed should be read and
 ///		processed.
 /// </param>
 /// <param name="db">
 ///		The connection to the database where the new RSS itmes
 ///		should be recorded.
 /// </param>
 public static void ProcessFeed(EventRssSubscription eventRssSubscription, Database db)
 {
     ProcessFeed(eventRssSubscription.RssUrl, db, eventRssSubscription.EventCategory);
 }