/// <summary> /// Generates the channel items. /// </summary> /// <param name="rssChannel">The RSS channel.</param> /// <returns></returns> private string GenerateChannelItems(RssChannel rssChannel) { if (this.Parameters.ClassName.StartsWith("List_")) { return(GenerateListChannelItems(rssChannel)); } return(RssXmlHelper.ToRfc822(DateTime.Now)); }
/// <summary> /// Generates the list channel items. /// </summary> /// <param name="rssChannel">The RSS channel.</param> /// <returns></returns> private string GenerateListChannelItems(RssChannel rssChannel) { DateTime lastBuildDate = DateTime.MinValue; MetaClass listMetaClass = DataContext.Current.GetMetaClass(this.Parameters.ClassName); foreach (EntityObject item in BusinessManager.List(this.Parameters.ClassName, this.CurrentProfile.Filters.ToArray(), this.CurrentProfile.Sorting.ToArray())) { RssItem rssItem = new RssItem(); rssItem.Guid = new RssGuid(); rssItem.Title = string.IsNullOrEmpty(listMetaClass.TitleFieldName) ? ("#" + item.PrimaryKeyId.Value.ToString()) : (string)item[listMetaClass.TitleFieldName]; rssItem.Link = MakeFullLink(this.Page.ResolveUrl(string.Format(CultureInfo.CurrentUICulture, "~/Apps/MetaUIEntity/Pages/EntityList.aspx?ClassName={0}", listMetaClass.Name))); rssItem.Guid.IsPermaLink = "false"; rssItem.Guid.Text = item.PrimaryKeyId.Value.ToString(); rssItem.Description = RenderListEntityObjectDescription(listMetaClass, item); DateTime modified = (DateTime)item["Modified"]; if (modified > lastBuildDate) { lastBuildDate = modified; } rssItem.PubDate = RssXmlHelper.ToRfc822(modified); UserLight author = UserLight.Load((int)item["ModifierId"]); if (author != null) { rssItem.Author = string.Format("{0} <{1}>", author.DisplayName, author.Email); } rssChannel.Items.Add(rssItem); } if (lastBuildDate == DateTime.MinValue) { lastBuildDate = DateTime.Now; } return(RssXmlHelper.ToRfc822(lastBuildDate)); }
protected override void PopulateRss(string channelName, string userName) { // Get the data string qModuleId = HttpContext.Current.Request["moduleId"]; int moduleId; if (!int.TryParse(qModuleId, out moduleId) || moduleId <= 0) { throw new ArgumentException("Invalid or missing module id: " + moduleId); } WebModuleInfo MasterDetailListModule = WebModule.GetModule(moduleId); if (MasterDetailListModule.WebModuleType != MasterDetailList.ModuleType) { throw new ArgumentException(string.Format("Invalid module type '{0}'. Module type must be '{1}'", MasterDetailListModule.ModuleTypeName, MasterDetailList.ModuleType.Name)); } WebpageInfo MasterDetailListPage = MasterDetailListModule.Webpage; if (null == MasterDetailListModule) { throw new ArgumentException("Invalid module id: " + moduleId); } List <WebModuleInfo> MasterDetailItemModules = MasterDetailList.GetMasterDetailChildren(moduleId, true, true); // Build the feed Rss.Channel = new MasterDetailChannel(); Rss.Version = "2.0"; Rss.Channel.Title = MasterDetailListPage.Title; Rss.Channel.Description = MasterDetailListPage.MetaDescription; Rss.Channel.Link = MasterDetailListPage.Path; Rss.Channel.Items = new List <MasterDetailRssItem>(); if (!string.IsNullOrEmpty(channelName)) { Rss.Channel.Title += " '" + channelName + "'"; } if (!string.IsNullOrEmpty(userName)) { Rss.Channel.Title += " (generated for " + userName + ")"; } int maxItemsPerPage = 25; int i = 0; foreach (WebModuleInfo m in MasterDetailItemModules) { WebpageInfo p = m.Webpage; MasterDetailItem itemRes = MasterDetailItem.GetSafeResource(m.Id); //string postDateString = ""; //if (p.PostDate.HasValue) //{ //this is a hack // postDateString = p.PostDate.Value.GetDateTimeFormats( // System.Globalization.CultureInfo.GetCultureInfo("en-US"))[103]; //} MasterDetailRssItem item = new MasterDetailRssItem(); item.Title = p.Title; item.Description = itemRes.GetSummary(p); if (p.PostDate.HasValue) { item.PubDate = RssXmlHelper.ToRfc822(p.PostDate.Value); } item.Link = VirtualPathUtility.ToAbsolute(p.Path); Rss.Channel.Items.Add(item); i++; if (i == maxItemsPerPage) { break; } } }