private SyndicationFeed CreateRecentItemFeed(RSSFeedInclude feedData) { List <SyndicationItem> syndicationItems = GetRecentPagesOrPosts(feedData); return(new SyndicationFeed(syndicationItems) { Title = new TextSyndicationContent(this.SiteName), Description = new TextSyndicationContent(this.SiteTagline) }); }
private List <SyndicationItem> GetRecentPagesOrPosts(RSSFeedInclude feedData) { List <SyndicationItem> syndRSS = new List <SyndicationItem>(); List <SiteNav> lst = new List <SiteNav>(); ContentPageType PageType = new ContentPageType(); using (ISiteNavHelper navHelper = SiteNavFactory.GetSiteNavHelper()) { if (feedData == RSSFeedInclude.PageOnly || feedData == RSSFeedInclude.BlogAndPages) { List <SiteNav> lst1 = navHelper.GetLatest(this.SiteID, 8, true); lst = lst.Union(lst1).ToList(); List <SiteNav> lst2 = navHelper.GetLatestUpdates(this.SiteID, 10, true); lst = lst.Union(lst2).ToList(); } if (feedData == RSSFeedInclude.BlogOnly || feedData == RSSFeedInclude.BlogAndPages) { List <SiteNav> lst1 = navHelper.GetLatestPosts(this.SiteID, 8, true); lst = lst.Union(lst1).ToList(); List <SiteNav> lst2 = navHelper.GetLatestPostUpdates(this.SiteID, 10, true); lst = lst.Union(lst2).ToList(); } } lst.RemoveAll(x => x.ShowInSiteMap == false && x.ContentType == ContentPageType.PageType.ContentEntry); lst.RemoveAll(x => x.BlockIndex == true); foreach (SiteNav sn in lst) { SyndicationItem si = new SyndicationItem(); string sPageURI = RemoveDupeSlashesURL(this.ConstructedCanonicalURL(sn)); Uri PageURI = new Uri(sPageURI); si.Content = new TextSyndicationContent(sn.PageTextPlainSummaryMedium.ToString()); si.Title = new TextSyndicationContent(sn.NavMenuText); si.Links.Add(SyndicationLink.CreateSelfLink(PageURI)); si.AddPermalink(PageURI); si.LastUpdatedTime = sn.EditDate; si.PublishDate = sn.CreateDate; syndRSS.Add(si); } return(syndRSS.OrderByDescending(p => p.PublishDate).ToList()); }
public string GetRSSFeed(RSSFeedInclude feedData) { SyndicationFeed feed = CreateRecentItemFeed(feedData); StringBuilder sb = new StringBuilder(); XmlWriterSettings settings = new XmlWriterSettings(); settings.Indent = true; settings.Encoding = Encoding.UTF8; settings.CheckCharacters = true; using (XmlWriter xw = XmlWriter.Create(sb, settings)) { Rss20FeedFormatter rssFormatter = new Rss20FeedFormatter(feed); rssFormatter.WriteTo(xw); } string xml = sb.ToString(); xml = xml.Replace("<?xml version=\"1.0\" encoding=\"utf-16\"", "<?xml version=\"1.0\" encoding=\"utf-8\""); return(xml); }
private List<SyndicationItem> GetRecentPagesOrPosts(RSSFeedInclude feedData) { List<SyndicationItem> syndRSS = new List<SyndicationItem>(); List<SiteNav> lst = new List<SiteNav>(); ContentPageType PageType = new ContentPageType(); using (SiteNavHelper navHelper = new SiteNavHelper()) { if (feedData == RSSFeedInclude.PageOnly || feedData == RSSFeedInclude.BlogAndPages) { List<SiteNav> lst1 = navHelper.GetLatest(this.SiteID, 8, true); lst = lst.Union(lst1).ToList(); List<SiteNav> lst2 = navHelper.GetLatestUpdates(this.SiteID, 10, true); lst = lst.Union(lst2).ToList(); } if (feedData == RSSFeedInclude.BlogOnly || feedData == RSSFeedInclude.BlogAndPages) { List<SiteNav> lst1 = navHelper.GetLatestPosts(this.SiteID, 8, true); lst = lst.Union(lst1).ToList(); List<SiteNav> lst2 = navHelper.GetLatestPostUpdates(this.SiteID, 10, true); lst = lst.Union(lst2).ToList(); } } lst.RemoveAll(x => x.ShowInSiteMap == false && x.ContentType == ContentPageType.PageType.ContentEntry); lst.RemoveAll(x => x.BlockIndex == true); foreach (SiteNav sn in lst) { SyndicationItem si = new SyndicationItem(); string sPageURI = RemoveDupeSlashesURL(this.ConstructedCanonicalURL(sn)); Uri PageURI = new Uri(sPageURI); si.Content = new TextSyndicationContent(sn.PageTextPlainSummaryMedium); si.Title = new TextSyndicationContent(sn.NavMenuText); si.Links.Add(SyndicationLink.CreateSelfLink(PageURI)); si.AddPermalink(PageURI); si.LastUpdatedTime = sn.EditDate; si.PublishDate = sn.CreateDate; syndRSS.Add(si); } return syndRSS.OrderByDescending(p => p.PublishDate).ToList(); }
private SyndicationFeed CreateRecentItemFeed(RSSFeedInclude feedData) { List<SyndicationItem> syndicationItems = GetRecentPagesOrPosts(feedData); return new SyndicationFeed(syndicationItems) { Title = new TextSyndicationContent(this.SiteName), Description = new TextSyndicationContent(this.SiteTagline) }; }
public string GetRSSFeed(RSSFeedInclude feedData) { SyndicationFeed feed = CreateRecentItemFeed(feedData); StringBuilder sb = new StringBuilder(); XmlWriterSettings settings = new XmlWriterSettings(); settings.Indent = true; settings.Encoding = Encoding.UTF8; settings.CheckCharacters = true; using (XmlWriter xw = XmlWriter.Create(sb, settings)) { Rss20FeedFormatter rssFormatter = new Rss20FeedFormatter(feed); rssFormatter.WriteTo(xw); } string xml = sb.ToString(); xml = xml.Replace("<?xml version=\"1.0\" encoding=\"utf-16\"", "<?xml version=\"1.0\" encoding=\"utf-8\""); return xml; }