protected void WriteRSSFile() { try { string fileName = links.RssFeedLink.Replace(@"~\", ""); ; string filePath = HttpRuntime.AppDomainAppPath + fileName; XmlWriter xml = new XmlTextWriter(new StreamWriter(filePath)); RssWriter rss = new RssWriter(xml); List<Item> itemList = engine.LoadItemDB(ProcessingEngine.Sort.Hot); rss.WriteHeader("getputs.com", "http://www.getputs.com", "All Your News Belong To Us!", null); foreach (Item item in itemList) { rss.WriteItem(item); } rss.Close(); xml.Close(); } catch (Exception ex) { if (log.isLoggingOn && log.isAppLoggingOn) { log.Log("Error in RssPage.aspx"); log.Log(ex); } } }
protected void Page_Load(object sender, EventArgs e) { DateTime now = DateTime.Now; Organization org = Organization.FromIdentity(Int32.Parse(Request.QueryString["OrganizationId"])); ExternalActivities activities = ExternalActivities.ForOrganization(org); activities.Sort(ExternalActivities.SortOrder.DateDescending); Response.ContentType = "text/xml"; XmlWriter xml = new XmlTextWriter(Response.Output); RssWriter rss = new RssWriter(xml); rss.WriteHeader("Aktivism - " + org.Name, "http://www.piratpartiet.se", "Aktivism för Piratpartiet", null); foreach (ExternalActivity activism in activities) { string title = "Aktivism i " + activism.Geography.Name; if (title.Length > 60) { title = title.Substring(0, 57) + "..."; } rss.WriteItem(title, "<img src=\"http://data.piratpartiet.se/Handlers/DisplayActivism.aspx?Id=" + activism.Identity.ToString() + "\" />", new Uri("http://data.piratpartiet.se/Handlers/DisplayActivism.aspx?Id=" + activism.Identity), activism.CreatedDateTime); } rss.Close(); xml.Close(); }
protected void Page_Load(object sender, EventArgs e) { DateTime now = DateTime.Now; MediaEntries entries = (MediaEntries) Cache.Get(cacheKey); if (entries == null) { entries = MediaEntries.FromBlogKeyword("Piratpartiet", now.AddDays(-7)); Cache.Insert(cacheKey, entries, null, DateTime.UtcNow.AddMinutes (5) , System.Web.Caching.Cache.NoSlidingExpiration); // five minute cache is plenty to prevent db F5 attacks } Response.ContentType = "text/xml"; XmlWriter xml = new XmlTextWriter(Response.Output); RssWriter rss = new RssWriter(xml); rss.WriteHeader("Bloggat om Piratpartiet", "http://www.piratpartiet.se", "Bloggposter som nämner Piratpartiet", null); foreach (MediaEntry entry in entries) { string title = entry.Title; if (title.Length > 30) { title = title.Substring(0, 27) + "..."; } rss.WriteItem(title, string.Empty, new Uri (entry.Url), entry.DateTime); } rss.Close(); xml.Close(); }
private static IResponse ToRssResponse(SelectResult result, string rssUrl, string query, string itemUrlWithoutId) { DateTime utcNow = DateTime.UtcNow; const string outputMimeType = "application/rss+xml; encoding=utf-8"; var resp = new StreamWriterResponse(outputMimeType, async(s) => { SerializationContext context = new SerializationContext(s); RssWriter w = new RssWriter(context); ByteBlock queryBB = (ByteBlock)query; w.WriteRssHeader(queryBB, queryBB, rssUrl, utcNow, TimeSpan.FromHours(1)); ByteBlock baseLink = itemUrlWithoutId; var items = result.Values; for (int row = 0; row < items.RowCount; ++row) { ByteBlock id = ConvertToByteBlock(items[row, 0]); w.WriteItem(id, id, id, baseLink, utcNow); } w.WriteRssFooter(); context.Writer.Flush(); await s.FlushAsync(); }); return(resp); }
protected void Page_Load(object sender, EventArgs e) { DateTime now = DateTime.Now; MediaEntries entries = (MediaEntries)Cache.Get(cacheKey); if (entries == null) { entries = MediaEntries.FromBlogKeyword("Piratpartiet", now.AddDays(-7)); Cache.Insert(cacheKey, entries, null, DateTime.UtcNow.AddMinutes(5), System.Web.Caching.Cache.NoSlidingExpiration); // five minute cache is plenty to prevent db F5 attacks } Response.ContentType = "text/xml"; XmlWriter xml = new XmlTextWriter(Response.Output); RssWriter rss = new RssWriter(xml); rss.WriteHeader("Bloggat om Piratpartiet", "http://www.piratpartiet.se", "Bloggposter som nämner Piratpartiet", null); foreach (MediaEntry entry in entries) { string title = entry.Title; if (title.Length > 30) { title = title.Substring(0, 27) + "..."; } rss.WriteItem(title, string.Empty, new Uri(entry.Url), entry.DateTime); } rss.Close(); xml.Close(); }