private DataView GetEntriesTable() { DataTable entriesTable = FeedCache.GetRssFeedEntries( ModuleId, module.ModuleGuid, config.EntryCacheTimeout, config.MaxDaysOld, config.MaxEntriesPerFeed, config.EnableSelectivePublishing ); return(entriesTable.DefaultView); }
private void btnUpdate_Click(object sender, EventArgs e) { Page.Validate("feeds"); if (!Page.IsValid) { return; } RssFeed feed = new RssFeed(ModuleId, ItemId); if (feed.ModuleId != ModuleId) { SiteUtils.RedirectToAccessDeniedPage(this); return; } feed.ModuleId = ModuleId; feed.Author = txtAuthor.Text; feed.Url = txtWebSite.Text; feed.RssUrl = txtRssUrl.Text; feed.ImageUrl = txtImageUrl.Text; int sortRank = 500; int.TryParse(txtSortRank.Text, out sortRank); feed.SortRank = sortRank; SiteUser siteUser = SiteUtils.GetCurrentSiteUser(); if (siteUser == null) { return; } Module module = new Module(ModuleId); feed.ModuleGuid = module.ModuleGuid; feed.UserId = siteUser.UserId; feed.UserGuid = siteUser.UserGuid; feed.LastModUserGuid = siteUser.UserGuid; feed.PublishByDefault = chkPublishByDefault.Checked; if (feed.Save()) { CurrentPage.UpdateLastModifiedTime(); FeedCache.RefreshFeed( feed, ModuleId, module.ModuleGuid, config.MaxDaysOld, config.MaxEntriesPerFeed, config.EnableSelectivePublishing); String rssFriendlyUrl = "aggregator" + ModuleId.ToInvariantString() + "rss.aspx"; if (!FriendlyUrl.Exists(siteSettings.SiteId, rssFriendlyUrl)) { FriendlyUrl friendlyUrl = new FriendlyUrl(); friendlyUrl.SiteId = siteSettings.SiteId; friendlyUrl.SiteGuid = siteSettings.SiteGuid; friendlyUrl.Url = rssFriendlyUrl; friendlyUrl.RealUrl = "~/FeedManager/FeedAggregate.aspx?pageid=" + PageId.ToInvariantString() + "&mid=" + ModuleId.ToInvariantString(); friendlyUrl.Save(); } if (hdnReturnUrl.Value.Length > 0) { WebUtils.SetupRedirect(this, hdnReturnUrl.Value); return; } WebUtils.SetupRedirect(this, SiteUtils.GetCurrentPageUrl()); } }
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); } }