private DataView GetEntriesTable() { DataTable entriesTable = FeedCache.GetRssFeedEntries( ModuleId, module.ModuleGuid, config.EntryCacheTimeout, config.MaxDaysOld, config.MaxEntriesPerFeed, config.EnableSelectivePublishing ); return(entriesTable.DefaultView); }
private void RenderRss() { DataView dv = FeedCache.GetRssFeedEntries( module.ModuleId, module.ModuleGuid, entryCacheTimeout, maxDaysOld, maxEntriesPerFeed, EnableSelectivePublishing).DefaultView; dv.Sort = "PubDate DESC"; if (dv.Table.Rows.Count == 0) { return; } Argotic.Syndication.RssFeed feed = new Argotic.Syndication.RssFeed(); RssChannel channel = new RssChannel(); channel.Generator = "mojoPortal Feed Manager module"; feed.Channel = channel; if (module != null) { channel.Title = module.ModuleTitle; channel.Description = module.ModuleTitle; //channel.LastBuildDate = channel.Items.LatestPubDate(); try { channel.Link = new System.Uri(WebUtils.ResolveServerUrl(SiteUtils.GetCurrentPageUrl())); } catch (UriFormatException) { channel.Link = new System.Uri(SiteUtils.GetNavigationSiteRoot()); } } else { // this prevents an error: Can't close RssWriter without first writing a channel. channel.Title = "Not Found"; channel.Description = "Not Found"; channel.LastBuildDate = DateTime.UtcNow; //channel.Link = new System.Uri(SiteUtils.GetCurrentPageUrl()); } foreach (DataRowView row in dv) { bool confirmed = Convert.ToBoolean(row["Confirmed"]); if (!EnableSelectivePublishing) { confirmed = true; } if (confirmed) { RssItem item = new RssItem(); item.Title = row["Title"].ToString(); item.Description = row["Description"].ToString(); item.PublicationDate = Convert.ToDateTime(row["PubDate"]); item.Link = new System.Uri(row["Link"].ToString()); Trace.Write(item.Link.ToString()); item.Author = row["Author"].ToString(); channel.AddItem(item); } } Response.Cache.SetExpires(DateTime.Now.AddMinutes(5)); Response.Cache.SetCacheability(HttpCacheability.Public); Response.ContentType = "application/xml"; Encoding encoding = new UTF8Encoding(); Response.ContentEncoding = encoding; using (XmlTextWriter xmlTextWriter = new XmlTextWriter(Response.OutputStream, encoding)) { xmlTextWriter.Formatting = Formatting.Indented; ////////////////// // style for RSS Feed viewed in browsers if (ConfigurationManager.AppSettings["RSSCSS"] != null) { string rssCss = ConfigurationManager.AppSettings["RSSCSS"].ToString(); xmlTextWriter.WriteWhitespace(" "); xmlTextWriter.WriteRaw("<?xml-stylesheet type=\"text/css\" href=\"" + cssBaseUrl + rssCss + "\" ?>"); } if (ConfigurationManager.AppSettings["RSSXsl"] != null) { string rssXsl = ConfigurationManager.AppSettings["RSSXsl"].ToString(); xmlTextWriter.WriteWhitespace(" "); xmlTextWriter.WriteRaw("<?xml-stylesheet type=\"text/xsl\" href=\"" + cssBaseUrl + rssXsl + "\" ?>"); } /////////////////////////// feed.Save(xmlTextWriter); } }