} // RunBackgroundTask public bool FetchAndSaveRemoteRSSGlossaryData() { string dataCacheKey = GlossaryPlaceholderData.getRssDataPersistentVariableName(); string lastRunCacheKey = dataCacheKey + "_LastRun"; string rssUrl = GlossaryPlaceholderData.getRssDataSourceUrl(); Rss.RssFeed glossaryRss = Rss.RssFeed.Read(rssUrl); if (glossaryRss.Channels.Count == 0) { // html.Append("<em>Error: could not retrieve Glossary from "+rssUrl+"</em>"); } else { GlossaryData[] items = GlossaryData.FromRSSItems(glossaryRss.Channels[0].Items); CmsPersistentVariable persistedData = CmsPersistentVariable.Fetch(dataCacheKey); persistedData.Name = dataCacheKey; persistedData.PersistedValue = new List <GlossaryData>(items); bool b = persistedData.SaveToDatabase(); if (b) { CmsPersistentVariable persistedLastRun = CmsPersistentVariable.Fetch(lastRunCacheKey); persistedLastRun.PersistedValue = DateTime.Now; persistedLastRun.Name = lastRunCacheKey; return(persistedLastRun.SaveToDatabase()); } } return(false); } // FetchAndSaveRemoteRSSGlossaryData
public RSSEvents(string channelDescription, string channelTittle, string webmaster) { rss = new Rss.RssFeed(); if (rss.Channels.Count == 0) { Rss.RssFeed rs = new Rss.RssFeed(); Rss.RssChannel ch = new Rss.RssChannel(); string cat = ""; //if (rssfile.Contains(@"\Components\")) { cat = "Componente forte"; } //if (rssfile.Contains(@"\Environments\")) { cat = "Entorno forte"; } ch.Description = channelDescription; ch.Title = channelTittle; ch.WebMaster = webmaster; Rss.RssItem rt = new Rss.RssItem(); rt.Author = webmaster; rt.Description = channelDescription; rt.PubDate = DateTime.Now; rt.Title = channelTittle; ch.Items.Add(rt); ch.LastBuildDate = DateTime.Now; ch.PubDate = DateTime.Now; //ch.Link = new Uri(httplink); rss.Channels.Add(ch); } }
/// <summary> /// Draws the title of the feed with the given index. /// </summary> /// <param name="g">The Graphics object to draw onto</param> /// <param name="index">The index of the item in the list</param> private void DrawFeedTitle(Graphics g, int row, Rss.RssFeed rssFeed) { // Set formatting and layout StringFormat stringFormat = new StringFormat(StringFormatFlags.LineLimit); stringFormat.Trimming = StringTrimming.EllipsisCharacter; Rectangle feedTitleRect = new Rectangle(Location.X + padding, Location.Y + (int)(row * RowHeight) + padding, Size.Width - (2 * padding), (int)(percentOfFontHeightForSelectionBox * feedFontHeight)); // Select color and draw border if current index is selected Color textBrushColor = ForeColor; if (rssFeed == feeds.CurrentFeed) { textBrushColor = SelectedForeColor; using (Brush backBrush = new SolidBrush(SelectedBackColor)) { g.FillRectangle(backBrush, feedTitleRect); } } // Draw the title of the feed string textToDraw = rssFeed.Title + " (" + rssFeed.LastWriteTime + ")"; using (Brush textBrush = new SolidBrush(textBrushColor)) { g.DrawString(textToDraw, ItemFont, textBrush, feedTitleRect, stringFormat); } }
public RSSEvents(string filepath) { rssfile = filepath; rss = new Rss.RssFeed(); if (!System.IO.File.Exists(rssfile)) { throw new Exception("El archivo indicado para sindicacion no existe o no es correcto."); } rss = Rss.RssFeed.Read(rssfile); }
private void CatchUpAll() { Cursor.Current = Cursors.WaitCursor; try { progressBar1.Maximum = Settings.Default.Feeds.Count; progressBar1.Minimum = 0; for (int y = 0; y < Settings.Default.Feeds.Count; y++) { FeedItem feedItem = Settings.Default.Feeds[y]; if (feedItem.IsChecked) { progressBar1.Value = y; Rss.RssFeed rssFeed = Utils.GetFeed(Settings.Default.Feeds[y]); if (rssFeed != null) { int Start = Convert.ToInt32(numericValue.Value); for (int q = Start; q < rssFeed.Channels[0].Items.Count; q++) { Rss.RssItem rssItem = rssFeed.Channels[0].Items[q]; if (Settings.Default.History[rssItem.GetHashCode().ToString()] == null) { HistoryItem historyItem = new HistoryItem(); historyItem.FeedGUID = feedItem.GUID; historyItem.Hashcode = rssItem.GetHashCode(); historyItem.Title = rssItem.Title; historyItem.ItemDate = rssItem.PubDate.ToString(); historyItem.FeedUrl = feedItem.Url; Settings.Default.History.Add(historyItem); } } } } } Cursor.Current = Cursors.Default; } catch (Exception ex) { log.Error("Error during catch-up", ex); Cursor.Current = Cursors.Default; MessageBox.Show(ex.Message, languages.FormStrings.ErrorDuringCatchUp, MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1); } }
private RssTorrent[] RetriveFeed() { Rss.RssFeed feed = Rss.RssFeed.Read(this.Url); // Note: // I don't know if more than 1 channel is allowed for torrents feeds // But I will stick to the first one only. // Idea: Probably multiple channels are for multiple languages. // In this case, we select the prefered one. Rss.RssChannel channel = feed.Channels[0]; List <RssTorrent> torrents = new List <RssTorrent>(channel.Items.Count); foreach (Rss.RssItem item in channel.Items) { torrents.Add(item.ToTorrent()); } this.feed_title = channel.Title; return(torrents.ToArray()); }
public RSSEvents(string filepath, string channeldescription, string webmaster, string channeltitle, string httplink) { //rssfile = filerelpath; string tmprssfile = rssfile; rssfile = filepath; rss = new Rss.RssFeed(); if (!System.IO.File.Exists(rssfile)) { //System.IO.StreamWriter str = new System.IO.StreamWriter(rssfile, false); //str.Close(); if (rss.Channels.Count == 0) { Rss.RssFeed rs = new Rss.RssFeed(); Rss.RssChannel ch = new Rss.RssChannel(); string cat = ""; //if (rssfile.Contains(@"\Components\")) { cat = "Componente forte"; } //if (rssfile.Contains(@"\Environments\")) { cat = "Entorno forte"; } ch.Description = channeldescription; ch.Title = channeltitle; ch.WebMaster = webmaster; Rss.RssItem rt = new Rss.RssItem(); rt.Author = webmaster; rt.Description = "Seccion de eventos, canal " + channeltitle + "." + cat; rt.PubDate = DateTime.Now; rt.Title = "Eventos para el canal " + channeltitle; ch.Items.Add(rt); ch.LastBuildDate = DateTime.Now; ch.PubDate = DateTime.Now; ch.Link = new Uri(httplink); rss.Channels.Add(ch); rss.Write(rssfile); } } rss = Rss.RssFeed.Read(rssfile); }
public RSSEvents(Uri url) { rss = Rss.RssFeed.Read(url.ToString()); }
private void RenderRss(RssGroup rssGroup) { Response.ContentType = "application/xml"; Response.ContentEncoding = System.Text.Encoding.UTF8; Hashtable moduleSettings = ModuleSettings.GetModuleSettings(rssGroup.ModuleId); rssGroup.MaximumDays = WebUtils.ParseInt32FromHashtable( moduleSettings, "RSSFeedMaxDaysOldSetting", 90); int entriesLimit = WebUtils.ParseInt32FromHashtable( moduleSettings, "RSSFeedMaxPostsSetting", 90); int entryCount = 0; Rss.RssChannel channel = new Rss.RssChannel(); string baseUrl = Request.Url.ToString().Replace("RSS.aspx", "Topic.aspx"); using (IDataReader posts = rssGroup.GetPostsForRss()) { while ((posts.Read()) && (entryCount <= entriesLimit)) { Rss.RssItem item = new Rss.RssItem(); item.Title = posts["Subject"].ToString(); item.Description = SiteUtils.ChangeRelativeUrlsToFullyQuailifiedUrls(navigationSiteRoot, imageSiteRoot, posts["Post"].ToString()); item.PubDate = Convert.ToDateTime(posts["PostDate"]); string target = baseUrl; if (target.IndexOf("&topic=") < 0 && target.IndexOf("?topic=") < 0) { if (target.IndexOf("?") < 0) { target += "?topic=" + posts["TopicID"].ToString() + "#post" + posts["PostID"].ToString(); } else { target += "&topic=" + posts["TopicID"].ToString() + "#post" + posts["PostID"].ToString(); } } item.Link = new System.Uri(target); item.Author = posts["StartedBy"].ToString(); channel.Items.Add(item); entryCount += 1; } } object value = GetModule(); Module m; channel.LastBuildDate = channel.Items.LatestPubDate(); channel.Link = new System.Uri(groupUrl); if (value != null) { m = (Module)value; channel.Title = m.ModuleTitle; channel.Description = m.ModuleTitle; } else { channel.Title = siteSettings.SiteName; channel.Description = siteSettings.SiteName; } if (channel.Items.Count == 0) { Rss.RssItem item = new Rss.RssItem(); item.Title = "No Items Found"; item.Description = "No items found"; item.PubDate = DateTime.UtcNow; item.Link = new System.Uri(navigationSiteRoot); item.Author = "system"; channel.Items.Add(item); } Rss.RssFeed rss = new Rss.RssFeed(); rss.BaseUrl = cssBaseUrl; rss.Encoding = System.Text.Encoding.UTF8; rss.Channels.Add(channel); rss.Write(Response.OutputStream); //Response.End(); }
private void FinishButton_Click(object sender, EventArgs e) { Settings.Default.ShowAdvancedFeedDialog = ShowAdvancedCheckBox.Checked; _feedItem.Url = UrlTextBox.Text; _showAdvancedDialog = ShowAdvancedCheckBox.Checked; _feedItem.Authenticate = LoginCheckBox.Checked; if (LoginCheckBox.Checked) { _feedItem.Username = UsernameTextBox.Text; _feedItem.Password = PasswordTextBox.Text; } try { Cursor.Current = Cursors.WaitCursor; Rss.RssFeed feed = Utils.GetFeed(_feedItem); if (feed.Exceptions.Count == 0) { char[] trimChars = new char[4]; trimChars[0] = ' '; trimChars[1] = '\n'; trimChars[2] = '\r'; trimChars[3] = '\t'; string strTitle = feed.Channels[0].Title.Trim(trimChars); int intCounter = 1; while (IsTitleUnique(strTitle, _feedItem.GUID) == false) { strTitle = feed.Channels[0].Title.Trim(trimChars) + " (" + intCounter.ToString() + ")"; intCounter++; } _feedItem.Title = feed.Channels[0].Title.Trim(trimChars); _feedItem.FeedHashCode = feed.GetHashCode().ToString("X"); if (feed.Channels[0].Description != null) { _feedItem.Description = feed.Channels[0].Description; } Settings.Default.Feeds.Add(_feedItem); } else { MessageBox.Show(FormStrings.NotAValidFeedCheckTheLogForMoreInformation, FormStrings.ErrorAddingFeed, MessageBoxButtons.OK, MessageBoxIcon.Error); _feedItem = null; if (Settings.Default.LogLevel > 0) { log.Error("Add feed", feed.Exceptions.LastException); } } Cursor.Current = Cursors.Default; } catch (Exception ex) { MessageBox.Show(FormStrings.NotAValidFeedCheckTheLogForMoreInformation, FormStrings.ErrorAddingFeed, MessageBoxButtons.OK, MessageBoxIcon.Error); if (Settings.Default.LogLevel > 0) { log.Error("Add feed", ex); } _feedItem = null; Cursor.Current = Cursors.Default; } }