protected override void Render(HtmlTextWriter writer) { RssChannel channel = new RssChannel(); TopicCollection topics = RepositoryRegistry.TopicRepository.FindByForumId(forumID); foreach (Topic topic in topics) { RssItem item = new RssItem(); item.Title = topic.Name; item.Description = topic.Name; item.PubDate = DateTime.Now.ToUniversalTime(); item.Author = topic.Author.Name; item.Link = new Uri(ForumApplication.Instance.GetLink(SharePointForumControls.ViewMessages, "topic={0}", topic.Id)); channel.Items.Add(item); } channel.Title = ForumApplication.Instance.Title; channel.Description = ForumApplication.Instance.Title; channel.LastBuildDate = channel.Items.LatestPubDate(); channel.Link = new Uri(ForumApplication.Instance.BasePath); RssFeed feed = new RssFeed(); feed.Channels.Add(channel); Page.Response.Clear(); Page.Response.ContentType = "text/xml"; feed.Write(Page.Response.OutputStream); Page.Response.End(); }
static void Main(string[] args) { #region Write Update RSS Feed #region 101 RssItem item = new RssItem(); item.Title = "105"; item.Comments = "1.0.0.105"; item.Description = "Freies Funknetz Switcher Version 1.0.0.105\n\n" + "* \"Bake wiederholen\" Text in \"Bake aktiviert\" geändert\n" + "* Fehler gefixt der dazu geführt hat dass eine Bake ununterbrochen wiederholt wurde\n"+ "* Voice Schaltung nocheinmal überarbeitet jetzt erfolgt nurnoch eine Deaktiviert/Aktiviert\n"+ " Meldung und sonst keine Änderung im Verhalten des Switchers\n"; item.PubDate = DateTime.Now.ToUniversalTime(); item.Link = new System.Uri("http://dropbox.schrankmonster.de/dropped/FFN-Switcher-105.zip"); #endregion RssChannel channel = new RssChannel(); channel.Items.Add(item); channel.Title = "Freies Funknetz Switcher Tool Update Channel"; channel.Description = "Updates for FFN Switcher"; channel.Link = new System.Uri("http://dropbox.schrankmonster.de/FFNSwitcher.xml"); channel.Generator = "FFN Switcher Update Tool"; channel.LastBuildDate = DateTime.Now; RssFeed feed = new RssFeed(); feed.Channels.Add(channel); feed.Write("FFNSwitcher.xml"); #endregion }
/// <summary>Closes connection to file.</summary> /// <remarks>This method also releases any resources held while reading.</remarks> public void Close() { image = null; channel = null; enclosure = null; item = null; if (reader != null) { reader.Close(); reader = null; } elementText = null; xmlNodeStack = null; }
/// <summary> /// Use a typical RssItem as data source. /// </summary> public RssNewsItem(RssNewsSource source, RssItem item) : base(source) { // If created from an rss item this means this is a new item, not known to the DB yet. this.IsRead = false; Author = item.Author; Comments = item.Comments; Description = item.Description; if (item.Guid != null) { Guid = item.Guid.Name; } Link = item.Link; DateTime = item.PubDate; Title = item.Title.Trim(); }
/// <summary> /// Use a typical RssItem as data source. /// </summary> public RssNewsEvent(RssItem item) { // If created from an rss item this means this is a new item, not known to the DB yet. this.IsRead = false; Author = item.Author; Comments = item.Comments; Description = item.Description; if (item.Guid != null) { EventId = item.Guid.Name; } Link = item.Link.ToString(); DateTime = item.PubDate; Title = item.Title.Trim(); }
/// <summary>Closes connection to file.</summary> /// <remarks>This method also releases any resources held while reading.</remarks> public void Close() { textInput = null; image = null; cloud = null; channel = null; source = null; enclosure = null; category = null; item = null; if (reader != null) { reader.Close(); reader = null; } elementText = null; xmlNodeStack = null; }
/// <summary>Closes connection to file.</summary> /// <remarks>This method also releases any resources held while reading.</remarks> public void Close() { this.textInput = null; this.image = null; this.cloud = null; this.channel = null; this.source = null; this.enclosure = null; this.category = null; this.item = null; if (this.reader != null) { this.reader.Close(); this.reader = null; } this.elementText = null; this.xmlNodeStack = null; }
private RssItem ParseItem(XmlNodeList itemNodes) { RssItem item = new RssItem(); foreach (XmlNode itemNode in itemNodes) { switch (itemNode.Name.ToLower()) { case "title": item.Title = itemNode.InnerText; break; case "link": item.Link = itemNode.InnerText; break; case "description": item.Description = itemNode.InnerText; break; case "content:encoded": item.Description = itemNode.InnerText; break; case "guid": item.Guid = ParseGuid(itemNode.Attributes); break; case "pubdate": item.PubDate = ParseDate(itemNode.InnerText); break; case "enclosure": item.Enclosure = ParseEnclosure(itemNode.Attributes); break; case "dc:date": item.PubDate = ParseDcDate(itemNode.InnerText); break; } } return(item); }
public static RssChannel ConvertToRssChannel(StoryCollection stories, string title, string description, string link, Host host) { RssChannel channel = new RssChannel(); channel.Title = title; channel.Description = description; channel.Link = new System.Uri(link); channel.Language = "en-us"; channel.Generator = host.SiteTitle + " - " + host.TagLine; channel.Docs = ""; channel.TimeToLive = 30; channel.Copyright = "Atweb Publishing Ltd."; if (stories.Count == 0) { RssItem item = new RssItem(); item.Title = " "; item.Description = " "; item.PubDate = DateTime.Now.ToUniversalTime(); channel.Items.Add(item); } else { foreach (Story story in stories) { string storyUrl = host.RootUrl + UrlFactory.CreateUrl(UrlFactory.PageName.ViewStory, story.StoryIdentifier, CategoryCache.GetCategory(story.CategoryID, host.HostID).CategoryIdentifier); //TODO: GJ: add category info RssItem item = new RssItem(); item.Title = story.Title; item.Description = story.Description + " <br /><br /><br />" + Incremental.Common.Web.Helpers.ControlHelper.RenderControl(new Incremental.Kick.Web.Controls.StoryDynamicImage(story.Url, host)); item.PubDate = story.PublishedOn.ToUniversalTime(); RssGuid guid = new RssGuid(); guid.Name = storyUrl; guid.PermaLink = true; item.Guid = guid; item.Link = new Uri(storyUrl); channel.Items.Add(item); } } return channel; }
private RssItem BuildCommentRssItem(Comment item) { item.Post = _postRepository.Get(item.PostId); var link = string.Format("{0}/#!/post/{1}", Config.URL.Domain, item.Post.Url); var rssItem = new RssItem { Title = item.Content, Link = new Uri(link), Description = string.Format("{0}<br />发表于:{1}", item.Content, item.Post.Title), PubDate = item.CreateDate, Author = item.Author, Guid = new RssGuid {Name = item.CommentId.ToString()} }; foreach (var cat in item.Post.Categorys) { rssItem.Categories.Add(new RssCategory { Name = string.Format("{0} - {1}", item.Post.Group.Name, cat.Name) }); } return rssItem; }
/// <summary>Adds a specified item to this collection.</summary> /// <param name="item">The item to add.</param> /// <returns>The zero-based index of the added item.</returns> public int Add(RssItem item) { pubDateChanged = true; return List.Add(item); }
static void Main(string[] args) { RssFeed r = new RssFeed(); r.Version = RssVersion.RSS20; RssItem ri1a = new RssItem(); ri1a.Author = "Test Author 1a"; ri1a.Title = "Test Title 1a"; ri1a.Description = "Test Description 1a"; ri1a.Link = new Uri("http://www.yourserver.com/"); ri1a.PubDate = DateTime.Now; RssItem ri1b = new RssItem(); ri1b.Author = "Test Author 1b"; ri1b.Title = "Test Title 1b"; ri1b.Description = "Test Description 1b"; ri1b.Link = new Uri("http://www.yourserver.com/"); ri1b.PubDate = DateTime.Now; RssChannel rc1 = new RssChannel(); rc1.Items.Add(ri1a); rc1.Items.Add(ri1b); rc1.Title = "Test Channel Title 1"; rc1.Description = "Test Channel Description 1"; rc1.Link = new Uri("http://www.yourserver.com/channel.html"); rc1.PubDate = DateTime.Now; r.Channels.Add(rc1); RssPhotoAlbumCategoryPhotoPeople pacpp = new RssPhotoAlbumCategoryPhotoPeople("John Doe"); RssPhotoAlbumCategoryPhoto pacp1 = new RssPhotoAlbumCategoryPhoto(DateTime.Now.Subtract(new TimeSpan(2, 12, 0, 0)), "Test Photo Description 1", new Uri("http://www.yourserver.com/PhotoAlbumWeb/GetPhoto.aspx?PhotoID=123"), pacpp); RssPhotoAlbumCategoryPhoto pacp2 = new RssPhotoAlbumCategoryPhoto(DateTime.Now.Subtract(new TimeSpan(2, 10, 0, 0)), "Test Photo Description 2", new Uri("http://www.yourserver.com/PhotoAlbumWeb/GetPhoto.aspx?PhotoID=124")); RssPhotoAlbumCategoryPhoto pacp3 = new RssPhotoAlbumCategoryPhoto(DateTime.Now.Subtract(new TimeSpan(2, 10, 0, 0)), "Test Photo Description 2", new Uri("http://www.yourserver.com/PhotoAlbumWeb/GetPhoto.aspx?PhotoID=125")); RssPhotoAlbumCategoryPhotos pacps = new RssPhotoAlbumCategoryPhotos(); pacps.Add(pacp1); pacps.Add(pacp2); RssPhotoAlbumCategory pac1 = new RssPhotoAlbumCategory("Test Photo Album Category 1", "Test Photo Album Category Description 1", DateTime.Now.Subtract(new TimeSpan(5, 10, 0, 0)), DateTime.Now, pacps); RssPhotoAlbumCategory pac2 = new RssPhotoAlbumCategory("Test Photo Album Category 2", "Test Photo Album Category Description 2", DateTime.Now.Subtract(new TimeSpan(9, 10, 0, 0)), DateTime.Now, pacp3); RssPhotoAlbumCategories pacs = new RssPhotoAlbumCategories(); pac1.BindTo(ri1a.GetHashCode()); pac2.BindTo(ri1b.GetHashCode()); pacs.Add(pac1); pacs.Add(pac2); RssPhotoAlbum pa = new RssPhotoAlbum(new Uri("http://your.web.server/PhotoAlbumWeb"), pacs); pa.BindTo(rc1.GetHashCode()); r.Modules.Add(pa); RssItem ri2 = new RssItem(); ri2.Author = "Test Author 2"; ri2.Title = "Test Title 2"; ri2.Description = "Test Description 2"; ri2.Link = new Uri("http://www.yourotherserver.com/"); ri2.PubDate = DateTime.Now; RssChannel rc2 = new RssChannel(); rc2.Items.Add(ri2); rc2.Title = "Test Channel Title 2"; rc2.Description = "Test Channel Description 2"; rc2.Link = new Uri("http://www.yourotherserver.com/channel.html"); rc2.PubDate = DateTime.Now; r.Channels.Add(rc2); r.Write("out.xml"); RssBlogChannel rbc = new RssBlogChannel(new Uri("http://www.google.com"), new Uri("http://www.google.com"), new Uri("http://www.google.com"), new Uri("http://www.google.com")); }
/// <summary>Removes a specified item from this collection.</summary> /// <param name="item">The item to remove.</param> public void Remove(RssItem item) { pubDateChanged = true; List.Remove(item); }
/// <summary>Determines whether the RssItemCollection contains a specific element.</summary> /// <param name="rssItem">The RssItem to locate in the RssItemCollection.</param> /// <returns>true if the RssItemCollection contains the specified value; otherwise, false.</returns> public bool Contains(RssItem rssItem) { return(List.Contains(rssItem)); }
/// <summary>Inserts an item into this collection at a specified index.</summary> /// <param name="index">The zero-based index of the collection at which to insert the item.</param> /// <param name="item">The item to insert into this collection.</param> public void Insert(int index, RssItem item) { pubDateChanged = true; List.Insert(index, item); }
private void writeItem(RssItem.RssItem item, int channelHashCode) { if (writer == null) throw new InvalidOperationException("RssWriter has been closed, and can not be written to."); if (item == null) throw new ArgumentNullException("Item must be instanciated with data to be written."); if (!wroteChannel) throw new InvalidOperationException("Channel must be written first, before writing an item."); BeginDocument(); writer.WriteStartElement("item"); switch (rssVersion) { case RssVersion.RSS090: case RssVersion.RSS10: case RssVersion.RSS091: WriteElement("title", item.Title, true); WriteElement("description", item.Description, false); WriteElement("link", item.Link, true); break; case RssVersion.RSS20: if ((item.Title == RssDefault.String) && (item.Description == RssDefault.String)) throw new ArgumentException("item title and description cannot be null"); goto case RssVersion.RSS092; case RssVersion.RSS092: WriteElement("title", item.Title, false); WriteElement("description", item.Description, false); WriteElement("link", item.Link, false); if (item.Source != null) { writer.WriteStartElement("source"); WriteAttribute("url", item.Source.Url, true); writer.WriteString(item.Source.Name); writer.WriteEndElement(); } if (item.Enclosure != null) { writer.WriteStartElement("enclosure"); WriteAttribute("url", item.Enclosure.Url, true); WriteAttribute("length", item.Enclosure.Length, true); WriteAttribute("type", item.Enclosure.Type, true); writer.WriteEndElement(); } foreach (RssCategory category in item.Categories) if (category.Name != RssDefault.String) { writer.WriteStartElement("category"); WriteAttribute("domain", category.Domain, false); writer.WriteString(category.Name); writer.WriteEndElement(); } break; } if (rssVersion == RssVersion.RSS20) { WriteElement("author", item.Author, false); WriteElement("comments", item.Comments, false); if ((item.Guid != null) && (item.Guid.Name != RssDefault.String)) { writer.WriteStartElement("guid"); try { WriteAttribute("isPermaLink", (bool) item.Guid.PermaLink, false); } catch { } writer.WriteString(item.Guid.Name); writer.WriteEndElement(); } WriteElement("pubDate", item.PubDate, false); foreach (RssModule rssModule in _rssModules) { if (rssModule.IsBoundTo(channelHashCode)) { foreach (RssModuleItemCollection rssModuleItemCollection in rssModule.ItemExtensions) { if (rssModuleItemCollection.IsBoundTo(item.GetHashCode())) writeSubElements(rssModuleItemCollection, rssModule.NamespacePrefix); } } } } writer.WriteEndElement(); writer.Flush(); }
private static NzbInfo ParseNzbInfo(FeedInfo feed, RssItem item) { NzbSite site = NzbSite.Parse(feed.Url.ToLower()); return new NzbInfo { Id = site.ParseId(item.Link.ToString()), Title = item.Title, Site = site, Link = item.Link, Description = item.Description, }; }
private void writeItem(RssItem item, int channelHashCode) { if (this.Writer == null) { throw new InvalidOperationException("RssWriter has been closed, and can not be written to."); } if (item == null) { throw new ArgumentNullException("Item must be instanciated with data to be written."); } if (!this.ChannelBegun) { throw new InvalidOperationException("Channel must be written first, before writing an item."); } this.BeginDocument(); this.Writer.WriteStartElement("item"); if ((item.Title == RssDefault.String) && (item.Description == RssDefault.String)) { throw new ArgumentException("item title and description cannot be null"); } this.WriteElement("title", item.Title, false); this.WriteElement("description", item.Description, false); this.WriteElement("link", item.Link, false); if (item.Source != null) { this.Writer.WriteStartElement("source"); this.WriteAttribute("url", item.Source.Url, true); this.Writer.WriteString(item.Source.Name); this.Writer.WriteEndElement(); } if (item.Enclosure != null) { this.Writer.WriteStartElement("enclosure"); this.WriteAttribute("url", item.Enclosure.Url, true); this.WriteAttribute("length", item.Enclosure.Length, true); this.WriteAttribute("type", item.Enclosure.Type, true); this.Writer.WriteEndElement(); } foreach (RssCategory category in item.Categories) { if (category.Name != RssDefault.String) { this.Writer.WriteStartElement("category"); this.WriteAttribute("domain", category.Domain, false); this.Writer.WriteString(category.Name); this.Writer.WriteEndElement(); } } this.WriteElement("author", item.Author, false); this.WriteElement("comments", item.Comments, false); if ((item.Guid != null) && (item.Guid.Name != RssDefault.String)) { this.Writer.WriteStartElement("guid"); if (!item.Guid.PermaLink.IsNull) { this.WriteAttribute("isPermaLink", (bool)item.Guid.PermaLink, false); } this.Writer.WriteString(item.Guid.Name); this.Writer.WriteEndElement(); } this.WriteElement("pubDate", item.PubDate, false); foreach (RssModule rssModule in this._rssModules) { if (rssModule.IsBoundTo(channelHashCode)) { foreach (RssModuleItemCollection rssModuleItemCollection in rssModule.ItemExtensions) { if (rssModuleItemCollection.IsBoundTo(item.GetHashCode())) { this.writeSubElements(rssModuleItemCollection, rssModule.NamespacePrefix); } } } } this.Writer.WriteEndElement(); this.Writer.Flush(); }
/// <summary>Reads the next RssElement from the stream.</summary> /// <returns>An RSS Element</returns> /// <exception cref="InvalidOperationException">RssReader has been closed, and can not be read.</exception> /// <exception cref="System.IO.FileNotFoundException">RSS file not found.</exception> /// <exception cref="System.Xml.XmlException">Invalid XML syntax in RSS file.</exception> /// <exception cref="System.IO.EndOfStreamException">Unable to read an RssElement. Reached the end of the stream.</exception> public RssElement Read() { bool readData = false; bool pushElement = true; RssElement rssElement = null; int lineNumber = -1; int linePosition = -1; if (reader == null) { throw new InvalidOperationException("RssReader has been closed, and can not be read."); } do { pushElement = true; try { readData = reader.Read(); } catch (System.IO.EndOfStreamException e) { throw new System.IO.EndOfStreamException("Unable to read an RssElement. Reached the end of the stream.", e); } catch (System.Xml.XmlException e) { if (lineNumber != -1 || linePosition != -1) { if (reader.LineNumber == lineNumber && reader.LinePosition == linePosition) { throw exceptions.LastException; } } lineNumber = reader.LineNumber; linePosition = reader.LinePosition; exceptions.Add(e); // just add to list of exceptions and continue :) } if (readData) { string readerName = reader.Name.ToLower(); switch (reader.NodeType) { case XmlNodeType.Element: { if (reader.IsEmptyElement && reader.AttributeCount == 0) { break; } elementText = new StringBuilder(); switch (readerName) { case "item": // is this the end of the channel element? (absence of </channel> before <item>) if (!wroteChannel) { wroteChannel = true; rssElement = channel; // return RssChannel readData = false; } item = new RssItem(); // create new RssItem channel.Items.Add(item); break; //case "source": // source = new RssSource(); // item.Source = source; // for (int i = 0; i < reader.AttributeCount; i++) // { // reader.MoveToAttribute(i); // switch (reader.Name.ToLower()) // { // case "url": // try // { // source.Url = reader.Value; // } // catch (Exception e) // { // exceptions.Add(e); // } // break; // } // } // break; //case "pubdate": // try // { // item.PubDate = W3CDateTime.Parse(elementText.ToString()).DateTime; // } // catch (Exception e) // { // try // { // string tmp = elementText.ToString(); // tmp = tmp.Substring(0, tmp.LastIndexOf(" ")); // tmp += " GMT"; // item.PubDate = DateTime.Parse(tmp); // } // catch // { // exceptions.Add(e); // } // } // break; case "enclosure": enclosure = new RssEnclosure(); item.Enclosure = enclosure; for (int i = 0; i < reader.AttributeCount; i++) { reader.MoveToAttribute(i); switch (reader.Name.ToLower()) { case "url": try { enclosure.Url = reader.Value; } catch (Exception e) { exceptions.Add(e); } break; case "length": try { enclosure.Length = int.Parse(reader.Value); } catch (Exception) { enclosure.Length = 0; //exceptions.Add(e); } break; case "type": enclosure.Type = reader.Value; break; } } break; case "guid": guid = new RssGuid(); item.Guid = guid; for (int i = 0; i < reader.AttributeCount; i++) { reader.MoveToAttribute(i); switch (reader.Name.ToLower()) { case "ispermalink": try { guid.PermaLink = bool.Parse(reader.Value); } catch (Exception e) { exceptions.Add(e); } break; } } break; case "channel": channel = new RssChannel(); image = null; enclosure = null; item = null; break; case "image": image = new RssImage(); channel.Image = image; break; case "rss": for (int i = 0; i < reader.AttributeCount; i++) { reader.MoveToAttribute(i); if (reader.Name.ToLower() == "version") { switch (reader.Value) { case "0.91": rssVersion = RssVersion.RSS091; break; case "0.92": rssVersion = RssVersion.RSS092; break; case "2.0": rssVersion = RssVersion.RSS20; break; default: rssVersion = RssVersion.NotSupported; break; } } } break; case "rdf": for (int i = 0; i < reader.AttributeCount; i++) { reader.MoveToAttribute(i); if (reader.Name.ToLower() == "version") { switch (reader.Value) { case "0.90": rssVersion = RssVersion.RSS090; break; case "1.0": rssVersion = RssVersion.RSS10; break; default: rssVersion = RssVersion.NotSupported; break; } } } break; } if (pushElement) { xmlNodeStack.Push(readerName); } break; } case XmlNodeType.EndElement: { if (xmlNodeStack.Count == 1) { break; } string childElementName = (string)xmlNodeStack.Pop(); string parentElementName = (string)xmlNodeStack.Peek(); switch (childElementName) // current element { // item classes case "item": rssElement = item; readData = false; break; //case "source": // source.Name = elementText.ToString(); // rssElement = source; // readData = false; // break; case "enclosure": rssElement = enclosure; readData = false; break; case "guid": guid.Name = elementText.ToString(); rssElement = guid; readData = false; break; case "pubdate": rssElement = channel; readData = false; break; case "channel": if (wroteChannel) { wroteChannel = false; } else { wroteChannel = true; rssElement = channel; readData = false; } break; } switch (parentElementName) // parent element { case "item": switch (childElementName) { case "pubdate": try { item.PubDate = W3CDateTime.Parse(elementText.ToString()).DateTime; } catch (Exception e) { try { string tmp = elementText.ToString(); tmp = tmp.Substring(0, tmp.LastIndexOf(" ")); tmp += " GMT"; item.PubDate = DateTime.Parse(tmp); } catch { exceptions.Add(e); } } break; case "title": item.Title = elementText.ToString(); break; case "link": item.Link = elementText.ToString(); break; case "description": item.Description = elementText.ToString(); break; } break; case "channel": switch (childElementName) { case "title": channel.Title = elementText.ToString(); break; case "link": try { channel.Link = elementText.ToString(); } catch (Exception e) { exceptions.Add(e); } break; case "description": channel.Description = elementText.ToString(); break; case "pubdate": try { channel.PubDate = W3CDateTime.Parse(elementText.ToString()).DateTime; } catch (Exception) { if (elementText.ToString() == "") { channel.PubDate = DateTime.Now; } else { try { channel.PubDate = DateTime.Parse(elementText.ToString()); } catch (Exception e) { try { string tmp = elementText.ToString(); tmp = tmp.Substring(0, tmp.LastIndexOf(" ")); tmp += " GMT"; channel.PubDate = DateTime.Parse(tmp); } catch { exceptions.Add(e); } } } } break; case "lastbuilddate": try { channel.LastBuildDate = W3CDateTime.Parse(elementText.ToString()).DateTime; //channel.LastBuildDate = DateTime.Parse(elementText.ToString()); } catch (Exception) { if (elementText.ToString() == "") { channel.LastBuildDate = DateTime.Now; } else { try { channel.LastBuildDate = DateTime.Parse(elementText.ToString()); } catch (Exception e) { try { string tmp = elementText.ToString(); tmp = tmp.Substring(0, tmp.LastIndexOf(" ")); tmp += " GMT"; channel.LastBuildDate = DateTime.Parse(tmp); } catch { exceptions.Add(e); } } } } break; } break; case "image": switch (childElementName) { case "url": try { image.Url = elementText.ToString(); } catch (Exception e) { exceptions.Add(e); } break; case "title": image.Title = elementText.ToString(); break; case "link": try { image.Link = elementText.ToString(); } catch (Exception e) { exceptions.Add(e); } break; case "content:encoded": item.Content = elementText.ToString(); break; case "description": image.Description = elementText.ToString(); break; } break; } break; } case XmlNodeType.Text: elementText.Append(reader.Value); break; case XmlNodeType.CDATA: elementText.Append(reader.Value); break; } } }while (readData); return(rssElement); }
private RssItem BuildPostRssItem(Post item) { var link = string.Format("{0}/#!/post/{1}", Config.URL.Domain, item.Url); var rssItem = new RssItem { Title = item.Title, Link = new Uri(link), Description = item.Content, PubDate = item.PubDate, //Author = item.PubAdmin.Name, //TODO:ef出错 Guid = new RssGuid {Name = item.PostId.ToString()} }; foreach (var cat in item.Categorys) { rssItem.Categories.Add(new RssCategory { Name = string.Format("{0} - {1}", item.Group.Name, cat.Name) }); } return rssItem; }
/// <summary>Reads the next RssElement from the stream.</summary> /// <returns>An RSS Element</returns> /// <exception cref="InvalidOperationException">RssReader has been closed, and can not be read.</exception> /// <exception cref="System.IO.FileNotFoundException">RSS file not found.</exception> /// <exception cref="System.Xml.XmlException">Invalid XML syntax in RSS file.</exception> /// <exception cref="System.IO.EndOfStreamException">Unable to read an RssElement. Reached the end of the stream.</exception> public RssElement Read() { bool readData = false; bool pushElement = true; RssElement rssElement = null; int lineNumber = -1; int linePosition = -1; if (this.reader == null) { throw new InvalidOperationException("RssReader has been closed, and can not be read."); } do { pushElement = true; try { readData = this.reader.Read(); } catch (EndOfStreamException e) { throw new EndOfStreamException("Unable to read an RssElement. Reached the end of the stream.", e); } catch (XmlException e) { if (lineNumber != -1 || linePosition != -1) { if (this.reader.LineNumber == lineNumber && this.reader.LinePosition == linePosition) { throw this.exceptions.LastException; } } lineNumber = this.reader.LineNumber; linePosition = this.reader.LinePosition; this.exceptions.Add(e); // just add to list of exceptions and continue :) } if (readData) { string readerName = this.reader.Name.ToLower(); switch (this.reader.NodeType) { case XmlNodeType.Element: { if (this.reader.IsEmptyElement) { break; } this.elementText = new StringBuilder(); switch (readerName) { case "item": // is this the end of the channel element? (absence of </channel> before <item>) if (!this.wroteChannel) { this.wroteChannel = true; rssElement = this.channel; // return RssChannel readData = false; } this.item = new RssItem(); // create new RssItem this.channel.Items.Add(this.item); break; case "source": this.source = new RssSource(); this.item.Source = this.source; for (int i = 0; i < this.reader.AttributeCount; i++) { this.reader.MoveToAttribute(i); switch (this.reader.Name.ToLower()) { case "url": try { this.source.Url = new Uri(this.reader.Value); } catch (Exception e) { this.exceptions.Add(e); } break; } } break; case "enclosure": this.enclosure = new RssEnclosure(); this.item.Enclosure = this.enclosure; for (int i = 0; i < this.reader.AttributeCount; i++) { this.reader.MoveToAttribute(i); switch (this.reader.Name.ToLower()) { case "url": try { this.enclosure.Url = new Uri(this.reader.Value); } catch (Exception e) { this.exceptions.Add(e); } break; case "length": try { this.enclosure.Length = int.Parse(this.reader.Value); } catch (Exception e) { this.exceptions.Add(e); } break; case "type": this.enclosure.Type = this.reader.Value; break; } } break; case "guid": this.guid = new RssGuid(); this.item.Guid = this.guid; for (int i = 0; i < this.reader.AttributeCount; i++) { this.reader.MoveToAttribute(i); switch (this.reader.Name.ToLower()) { case "ispermalink": try { this.guid.PermaLink = bool.Parse(this.reader.Value); } catch (Exception e) { this.exceptions.Add(e); } break; } } break; case "category": this.category = new RssCategory(); if ((string)this.xmlNodeStack.Peek() == "channel") { this.channel.Categories.Add(this.category); } else { this.item.Categories.Add(this.category); } for (int i = 0; i < this.reader.AttributeCount; i++) { this.reader.MoveToAttribute(i); switch (this.reader.Name.ToLower()) { case "url": goto case "domain"; case "domain": this.category.Domain = this.reader.Value; break; } } break; case "channel": this.channel = new RssChannel(); this.textInput = null; this.image = null; this.cloud = null; this.source = null; this.enclosure = null; this.category = null; this.item = null; break; case "image": this.image = new RssImage(); this.channel.Image = this.image; break; case "textinput": this.textInput = new RssTextInput(); this.channel.TextInput = this.textInput; break; case "cloud": pushElement = false; this.cloud = new RssCloud(); this.channel.Cloud = this.cloud; for (int i = 0; i < this.reader.AttributeCount; i++) { this.reader.MoveToAttribute(i); switch (this.reader.Name.ToLower()) { case "domain": this.cloud.Domain = this.reader.Value; break; case "port": try { this.cloud.Port = ushort.Parse(this.reader.Value); } catch (Exception e) { this.exceptions.Add(e); } break; case "path": this.cloud.Path = this.reader.Value; break; case "registerprocedure": this.cloud.RegisterProcedure = this.reader.Value; break; case "protocol": switch (this.reader.Value.ToLower()) { case "xml-rpc": this.cloud.Protocol = RssCloudProtocol.XmlRpc; break; case "soap": this.cloud.Protocol = RssCloudProtocol.Soap; break; case "http-post": this.cloud.Protocol = RssCloudProtocol.HttpPost; break; default: this.cloud.Protocol = RssCloudProtocol.Empty; break; } break; } } break; case "rss": for (int i = 0; i < this.reader.AttributeCount; i++) { this.reader.MoveToAttribute(i); if (this.reader.Name.ToLower() == "version") { switch (this.reader.Value) { case "0.91": this.rssVersion = RssVersion.RSS091; break; case "0.92": this.rssVersion = RssVersion.RSS092; break; case "2.0": this.rssVersion = RssVersion.RSS20; break; default: this.rssVersion = RssVersion.NotSupported; break; } } } break; case "rdf": for (int i = 0; i < this.reader.AttributeCount; i++) { this.reader.MoveToAttribute(i); if (this.reader.Name.ToLower() == "version") { switch (this.reader.Value) { case "0.90": this.rssVersion = RssVersion.RSS090; break; case "1.0": this.rssVersion = RssVersion.RSS10; break; default: this.rssVersion = RssVersion.NotSupported; break; } } } break; case "geo:lat": case "geo:long": case "geo:point": case "georss:point": case "georss:elev": case "georss:radius": if (this.item.GeoPoint == null) { this.item.GeoPoint = new RssGeoPoint(); } break; } if (pushElement) { this.xmlNodeStack.Push(readerName); } break; } case XmlNodeType.EndElement: { if (this.xmlNodeStack.Count == 1) { break; } string childElementName = (string)this.xmlNodeStack.Pop(); string parentElementName = (string)this.xmlNodeStack.Peek(); switch (childElementName) // current element { // item classes case "item": rssElement = this.item; readData = false; break; case "source": this.source.Name = this.elementText.ToString(); rssElement = this.source; readData = false; break; case "enclosure": rssElement = this.enclosure; readData = false; break; case "guid": this.guid.Name = this.elementText.ToString(); rssElement = this.guid; readData = false; break; case "category": // parent is either item or channel this.category.Name = this.elementText.ToString(); rssElement = this.category; readData = false; break; // channel classes case "channel": if (this.wroteChannel) { this.wroteChannel = false; } else { this.wroteChannel = true; rssElement = this.channel; readData = false; } break; case "textinput": rssElement = this.textInput; readData = false; break; case "image": rssElement = this.image; readData = false; break; case "cloud": rssElement = this.cloud; readData = false; break; } switch (parentElementName) // parent element { case "item": switch (childElementName) { case "title": this.item.Title = this.elementText.ToString(); break; case "link": this.item.Link = new Uri(this.elementText.ToString()); break; case "description": this.item.Description = this.elementText.ToString(); break; case "author": this.item.Author = this.elementText.ToString(); break; case "comments": this.item.Comments = this.elementText.ToString(); break; case "pubdate": try { this.item.PubDate = DateTime.Parse(this.elementText.ToString()); } catch (Exception e) { try { string tmp = this.elementText.ToString(); tmp = tmp.Substring(0, tmp.Length - 5); tmp += "GMT"; this.item.PubDate = DateTime.Parse(tmp); } catch { this.exceptions.Add(e); } } break; case "geo:lat": try { this.item.GeoPoint.Lat = float.Parse(this.elementText.ToString()); } catch (Exception e) { this.exceptions.Add(e); } break; case "geo:long": try { this.item.GeoPoint.Lon = float.Parse(this.elementText.ToString()); } catch (Exception e) { this.exceptions.Add(e); } break; case "georss:point": try { string[] coords = this.elementText.ToString().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); if (coords.Length == 2) { this.item.GeoPoint.Lat = float.Parse(coords[0]); this.item.GeoPoint.Lon = float.Parse(coords[1]); } } catch (Exception e) { this.exceptions.Add(e); } break; } break; case "channel": switch (childElementName) { case "title": this.channel.Title = this.elementText.ToString(); break; case "link": try { this.channel.Link = new Uri(this.elementText.ToString()); } catch (Exception e) { this.exceptions.Add(e); } break; case "description": this.channel.Description = this.elementText.ToString(); break; case "language": this.channel.Language = this.elementText.ToString(); break; case "copyright": this.channel.Copyright = this.elementText.ToString(); break; case "managingeditor": this.channel.ManagingEditor = this.elementText.ToString(); break; case "webmaster": this.channel.WebMaster = this.elementText.ToString(); break; case "rating": this.channel.Rating = this.elementText.ToString(); break; case "pubdate": try { this.channel.PubDate = DateTime.Parse(this.elementText.ToString()); } catch (Exception e) { this.exceptions.Add(e); } break; case "lastbuilddate": try { this.channel.LastBuildDate = DateTime.Parse(this.elementText.ToString()); } catch (Exception e) { this.exceptions.Add(e); } break; case "generator": this.channel.Generator = this.elementText.ToString(); break; case "docs": this.channel.Docs = this.elementText.ToString(); break; case "ttl": try { this.channel.TimeToLive = int.Parse(this.elementText.ToString()); } catch (Exception e) { this.exceptions.Add(e); } break; } break; case "image": switch (childElementName) { case "url": try { this.image.Url = new Uri(this.elementText.ToString()); } catch (Exception e) { this.exceptions.Add(e); } break; case "title": this.image.Title = this.elementText.ToString(); break; case "link": try { this.image.Link = new Uri(this.elementText.ToString()); } catch (Exception e) { this.exceptions.Add(e); } break; case "description": this.image.Description = this.elementText.ToString(); break; case "width": try { this.image.Width = Byte.Parse(this.elementText.ToString()); } catch (Exception e) { this.exceptions.Add(e); } break; case "height": try { this.image.Height = Byte.Parse(this.elementText.ToString()); } catch (Exception e) { this.exceptions.Add(e); } break; } break; case "textinput": switch (childElementName) { case "title": this.textInput.Title = this.elementText.ToString(); break; case "description": this.textInput.Description = this.elementText.ToString(); break; case "name": this.textInput.Name = this.elementText.ToString(); break; case "link": try { this.textInput.Link = new Uri(this.elementText.ToString()); } catch (Exception e) { this.exceptions.Add(e); } break; } break; case "skipdays": if (childElementName == "day") { this.channel.SkipDays |= Day.Parse(this.elementText.ToString()); } break; case "skiphours": if (childElementName == "hour") { this.channel.SkipHours |= Hour.Parse(this.elementText.ToString()); } break; } break; } case XmlNodeType.Text: this.elementText.Append(this.reader.Value); break; case XmlNodeType.CDATA: this.elementText.Append(this.reader.Value); break; } } }while (readData); return(rssElement); }
// Token: 0x060005B6 RID: 1462 RVA: 0x000226FB File Offset: 0x000208FB public void Remove(RssItem item) { this.pubDateChanged = true; base.List.Remove(item); }
// Token: 0x060005B5 RID: 1461 RVA: 0x000226E5 File Offset: 0x000208E5 public void Insert(int index, RssItem item) { this.pubDateChanged = true; base.List.Insert(index, item); }
// Token: 0x060005B1 RID: 1457 RVA: 0x000226A5 File Offset: 0x000208A5 public int Add(RssItem item) { this.pubDateChanged = true; return(base.List.Add(item)); }
/// <summary>Determines whether the RssItemCollection contains a specific element.</summary> /// <param name="rssItem">The RssItem to locate in the RssItemCollection.</param> /// <returns>true if the RssItemCollection contains the specified value; otherwise, false.</returns> public bool Contains(RssItem rssItem) { return List.Contains(rssItem); }
private RssChannel ParseChannel(XmlNodeList channelBody) { channel = new RssChannel(); try { XmlNodeList channelNodes = channelBody.Item(0).ChildNodes; // find the rss channel in this feed //XmlDocument doc = new XmlDocument(); //doc.Load(reader); //XmlNode body = doc.DocumentElement.SelectSingleNode("channel"); //if (body != null) //{ // loop through the items and pick the important ones foreach (XmlNode channelItemNode in channelNodes) { switch (channelItemNode.Name.ToLower()) { case "title": channel.Title = channelItemNode.InnerText; break; case "link": channel.Link = channelItemNode.InnerText; break; case "description": channel.Description = channelItemNode.InnerText; break; case "pubdate": channel.PubDate = ParseDate(channelItemNode.InnerText); break; case "lastbuilddate": channel.LastBuildDate = ParseDate(channelItemNode.InnerText); break; case "image": if (channelItemNode.ChildNodes.Count > 0) { channel.Image = ParseImage(channelItemNode.ChildNodes); } else { if (channelItemNode.InnerText != null && channelItemNode.InnerText != "") { RssImage rssImage = new RssImage(); rssImage.Url = channelItemNode.InnerText; channel.Image = rssImage; } } break; case "item": RssItem item = ParseItem(channelItemNode.ChildNodes); channel.Items.Add(item); break; } //} } } catch (Exception ex) { exceptions.Add(ex); } return(channel); }
/// <summary>Copies the entire RssItemCollection to a compatible one-dimensional <see cref="Array"/>, starting at the specified index of the target array.</summary> /// <param name="array">The one-dimensional RssItem Array that is the destination of the elements copied from RssItemCollection. The Array must have zero-based indexing.</param> /// <param name="index">The zero-based index in array at which copying begins.</param> /// <exception cref="ArgumentNullException">array is a null reference (Nothing in Visual Basic).</exception> /// <exception cref="ArgumentOutOfRangeException">index is less than zero.</exception> /// <exception cref="ArgumentException">array is multidimensional. -or- index is equal to or greater than the length of array.-or-The number of elements in the source RssItemCollection is greater than the available space from index to the end of the destination array.</exception> public void CopyTo(RssItem[] array, int index) { List.CopyTo(array, index); }
/// <summary>Closes connection to file.</summary> /// <remarks>This baseMethod also releases any resources held while reading.</remarks> public void Close() { textInput = null; image = null; cloud = null; channel = null; source = null; enclosure = null; category = null; item = null; if (reader!=null) { reader.Close(); reader = null; } elementText = null; xmlNodeStack = null; }
/// <summary>Writes an RSS item</summary> /// <exception cref="InvalidOperationException">Either the RssWriter has already been closed, or the caller is attempting to write an RSS item before an RSS channel.</exception> /// <exception cref="ArgumentNullException">Item must be instanciated with data, before calling Write.</exception> /// <param name="item">RSS item to write</param> public void Write(RssItem.RssItem item) { // NOTE: Standalone items cannot adhere to modules, hence -1 is passed. This may not be the case, however, no examples have been seen where this is legal. writeItem(item, -1); }
private DownloadPackage GetDownloadPackage(Rss.RssItem rssItem, FeedItem feedItem, string strDownloadlocation) { bool boolAcceptableFile = false; bool byteRanging = true; string strFilenameWithoutExt = null; string strFilenameExt = null; string strPath = null; DirectoryInfo dirInfo = null; FileInfo[] fileInfo = null; long longReturn = 0; //bool boolGuid = false; string strFilename = null; // new WebResponse response = null; // first try a HEAD call (less intrusive) if (feedItem.Authenticate == true) { string strPassword = EncDec.Decrypt(feedItem.Password, feedItem.Username); response = GetWebResponseObjectHEAD(rssItem.Enclosure.Url, feedItem.Username, strPassword); } else { response = GetWebResponseObjectHEAD(rssItem.Enclosure.Url, "", ""); } // the HEAD call didn't seem to work. We'll use a GET now if (response == null) { if (feedItem.Authenticate == true) { string strPassword = EncDec.Decrypt(feedItem.Password, feedItem.Username); response = GetWebResponseObjectGET(rssItem.Enclosure.Url, feedItem.Username, strPassword); } else { response = GetWebResponseObjectGET(rssItem.Enclosure.Url, "", ""); } } if (response != null) { long longDownloadsize = response.ContentLength; if (longDownloadsize == -1) { longDownloadsize = 1; } WebHeaderCollection responseHeaders = response.Headers; string[] strAcceptRange = responseHeaders.GetValues("Accept-Ranges"); if (strAcceptRange != null && strAcceptRange[0] == "none") { // no byte ranging byteRanging = false; } // check if there is content-disposition header string[] strContDisp = responseHeaders.GetValues("content-disposition"); string strAttachment = ""; string strHeader = ""; if (strContDisp != null && strContDisp.Length > 0) { for (int l = 0; l < strContDisp.Length; l++) { strHeader = strContDisp[l]; if (strHeader.ToLower().StartsWith("attachment")) { // attachment header strAttachment = strHeader.Substring(strHeader.ToLower().IndexOf("filename=") + 9); } } } if (strAttachment != "") { if (feedItem.UseTitleForFiles) { FileInfo f = new FileInfo(strAttachment); strPath = Utils.GetValidFileName(rssItem.Title + f.Extension); } else { strPath = strAttachment; strPath = Utils.GetValidFileName(strPath); } strFilename = strDownloadlocation + "\\" + strPath; if (strFilename.IndexOf(".") > 0) { FileInfo f = new FileInfo(strFilename); strFilenameWithoutExt = f.FullName.Substring(0, f.FullName.Length - f.Extension.Length); //strFilenameWithoutExt = strFilename.Substring(0, strFilename.LastIndexOf(".")); strFilenameExt = f.Extension.Substring(1); //strFilenameExt = strFilename.Substring(strFilename.LastIndexOf(".") + 1); } else { strFilenameWithoutExt = strFilename; strFilenameExt = ""; } } else { try { Uri uriEnclosure = new Uri(rssItem.Enclosure.Url); string strEnclosureUrl = uriEnclosure.GetLeftPart(UriPartial.Path); if (feedItem.UseTitleForFiles) { strPath = strEnclosureUrl.Substring(strEnclosureUrl.LastIndexOf("/") + 1); FileInfo f = new FileInfo(strPath); strPath = Utils.GetValidFileName(rssItem.Title + f.Extension); } else { strPath = strEnclosureUrl.Substring(strEnclosureUrl.LastIndexOf("/") + 1); } if (strPath == "") { // check the query strEnclosureUrl = uriEnclosure.GetLeftPart(UriPartial.Query); if (feedItem.UseTitleForFiles) { strPath = strEnclosureUrl.Substring(strEnclosureUrl.LastIndexOf("/") + 1); FileInfo f = new FileInfo(strPath); strPath = Utils.GetValidFileName(rssItem.Title + f.Extension); } else { strPath = strEnclosureUrl.Substring(strEnclosureUrl.LastIndexOf("/") + 1); } } // empty path? not good. Generate one //strPath = System.Web.HttpUtility.UrlDecode(strPath); strFilename = strDownloadlocation + "\\" + strPath; FileInfo fileInfo1 = new FileInfo(strFilename); strFilenameWithoutExt = fileInfo1.FullName.Substring(0, fileInfo1.FullName.Length - fileInfo1.Extension.Length); //strFilenameWithoutExt = strFilename.Substring(0, strFilename.LastIndexOf(".")); strFilenameExt = fileInfo1.Extension.Substring(1); //strFilenameExt = strFilename.Substring(strFilename.LastIndexOf(".") + 1); //strFilenameWithoutExt = strFilename.Substring(0, strFilename.LastIndexOf(".")); //strFilenameExt = strFilename.Substring(strFilename.LastIndexOf(".") + 1); } catch { strFilename = ""; strFilenameExt = ""; strFilenameWithoutExt = ""; boolAcceptableFile = false; } } if (Settings.Default.DefaultMediaAction == 0) { boolAcceptableFile = true; } else { foreach (string extension in Utils.AudioExtensions) { if (extension.ToUpper() == strFilenameExt.ToUpper()) { boolAcceptableFile = true; break; } } if (!boolAcceptableFile) { // check if it is a video file foreach (string extension in Utils.VideoExtensions) { if (extension.ToUpper() == strFilenameExt.ToUpper()) { boolAcceptableFile = true; break; } } } } if (boolAcceptableFile) { try { dirInfo = new System.IO.DirectoryInfo(strDownloadlocation); fileInfo = dirInfo.GetFiles(strPath); } catch (Exception fex) { if (Settings.Default.LogLevel > 0) { log.Error("Retriever", fex); } strFilenameExt = ""; } // check if the file is available on the filesystem bool boolContinue = true; if (fileInfo.Length > 0) { if ((fileInfo.Length > 0 && fileInfo[0].Length != longDownloadsize)) { // there is a file with the same name switch (Settings.Default.DuplicateAction) { case 1: strFilename = strFilenameWithoutExt + DateTime.Now.ToString("yyyyMMddTHHMMss") + "." + strFilenameExt; boolContinue = true; break; default: boolContinue = false; break; } } else if (fileInfo.Length > 0) { // add the item to the history HistoryItem historyItem = new HistoryItem(); historyItem.FeedGUID = feedItem.GUID; historyItem.FeedUrl = feedItem.Url; historyItem.Title = rssItem.Title; historyItem.Hashcode = rssItem.GetHashCode(); //historyItem.LocalFilename = fileInfo[0].FullName; historyItem.ItemDate = fileInfo[0].CreationTime.ToString("yyyy-MM-dd HH:MM:ss"); historyItem.FileName = fileInfo[0].Name; //historyItem.URL = enc.EnclosureURL; Settings.Default.History.Add(historyItem); boolContinue = false; } else { boolContinue = false; } } if (boolContinue) { // did the user specify a text filter on the item? if (feedItem.Textfilter != null && feedItem.Textfilter != "") { System.Text.RegularExpressions.Regex regEx = new System.Text.RegularExpressions.Regex(feedItem.Textfilter); if (regEx.Match(rssItem.Description).Success || regEx.Match(rssItem.Title).Success) { // if(rssItem.Description.ToUpper().IndexOf(feedItem.textFilter.ToUpper()) >= 0 || rssItem.Title.ToUpper().IndexOf(feedItem.textFilter.ToUpper()) >= 0) // { longReturn = longDownloadsize; } else if (rssItem.Description.ToUpper().IndexOf(feedItem.Textfilter.ToUpper()) >= 0 || rssItem.Title.ToUpper().IndexOf(feedItem.Textfilter.ToUpper()) >= 0) { longReturn = longDownloadsize; } } else { longReturn = longDownloadsize; } } } } DownloadPackage downloadPackage = new DownloadPackage(); downloadPackage.ByteRanging = byteRanging; downloadPackage.DownloadSize = longReturn; downloadPackage.strFilename = strFilename; return(downloadPackage); }
private RssItem BuildIssueItem(Issue item, string template) { var rssItem = new RssItem { Title = item.Project+" - "+item.Title, Link = new Uri(string.Format("{0}/issue", Config.URL.Domain)), Description = Razor.Parse(template, new { Title = item.Title, Project = item.Project, Statu = item.Statu, Content = item.Content, Author = item.Author, CreateDate = item.CreateDate, Result = item.Result ?? string.Empty, User=item.LastEditUser??string.Empty, EditDate = item.LastEditDate ?? DateTime.Now, }), PubDate = item.CreateDate, Author = item.CreateUser, Guid = new RssGuid { Name = item.IssueId.ToString() } }; if (item.Result!=null) rssItem.Description += string.Format("<br /><br />{0}:<br />{1}", item.LastEditUser, item.Result != null ? item.Result.Replace("\r", "<br />") : ""); return rssItem; }
/// <summary> /// Creates an RSS news feed for Issues By category /// </summary> private void CategoryFeed() { CategoryTree objComps = new CategoryTree(); List<Category> al = objComps.GetCategoryTreeByProjectId(projectId); foreach (Category c in al) { RssItem item = new RssItem(); item.Title = c.Name; item.Description = string.Concat(Issue.GetIssueCountByProjectAndCategory(projectId, c.Id).ToString(), " Open Issues"); item.PubDate = DateTime.Now; item.Link = new System.Uri(Page.ResolveUrl(string.Format("{2}/Issues/IssueList.aspx?pid={0}&s=0&c={1}", projectId, c.Id, HostSetting.GetHostSetting("DefaultUrl")))); channel.Items.Add(item); } channel.Title = projectName + " Issues By Category"; channel.Description = "A listing of all " + projectName + " issues grouped by category"; }
// Token: 0x060006AD RID: 1709 RVA: 0x000264E7 File Offset: 0x000246E7 public void Write(RssItem item) { this.writeItem(item, -1); }
private void FilteredIssuesFeed() { QueryClause q; bool isStatus = false; string BooleanOperator = "AND"; List<QueryClause> queryClauses = new List<QueryClause>(); //if (!string.IsNullOrEmpty(IssueCategoryId)) //{ // q = new QueryClause(BooleanOperator, "IssueCategoryId", "=", IssueCategoryId.ToString(), SqlDbType.Int, false); // queryClauses.Add(q); //} if (!string.IsNullOrEmpty(IssueTypeId)) { q = new QueryClause(BooleanOperator, "IssueTypeId", "=", IssueTypeId.ToString(), SqlDbType.Int, false); queryClauses.Add(q); } if (!string.IsNullOrEmpty(IssueMilestoneId)) { //if zero, do a null comparison. if (IssueMilestoneId == "0") q = new QueryClause(BooleanOperator, "IssueMilestoneId", "IS", null, SqlDbType.Int, false); else q = new QueryClause(BooleanOperator, "IssueMilestoneId", "=", IssueMilestoneId, SqlDbType.Int, false); queryClauses.Add(q); } if (!string.IsNullOrEmpty(IssueResolutionId)) { q = new QueryClause(BooleanOperator, "IssueResolutionId", "=", IssueResolutionId.ToString(), SqlDbType.Int, false); queryClauses.Add(q); } if (!string.IsNullOrEmpty(IssuePriorityId)) { q = new QueryClause(BooleanOperator, "IssuePriorityId", "=", IssuePriorityId.ToString(), SqlDbType.Int, false); queryClauses.Add(q); } if (!string.IsNullOrEmpty(IssueStatusId)) { isStatus = true; q = new QueryClause(BooleanOperator, "IssueStatusId", "=", IssueStatusId.ToString(), SqlDbType.Int, false); queryClauses.Add(q); } if (!string.IsNullOrEmpty(AssignedUserName)) { if(AssignedUserName == "0") q = new QueryClause(BooleanOperator, "IssueAssignedUserId", "IS",null, SqlDbType.NVarChar, false); else q = new QueryClause(BooleanOperator, "IssueAssignedUserId", "=", AssignedUserName, SqlDbType.NVarChar, false); queryClauses.Add(q); } //exclude all closed status's if (!isStatus) { List<Status> status = Status.GetStatusByProjectId(projectId).FindAll(delegate(Status s) { return s.IsClosedState == true; }); foreach (Status st in status) { q = new QueryClause(BooleanOperator, "IssueStatusId", "<>", st.Id.ToString(), SqlDbType.Int, false); queryClauses.Add(q); } } //q = new QueryClause(BooleanOperator, "new", "=", "another one", SqlDbType.NVarChar, true); //queryClauses.Add(q); colIssues = Issue.PerformQuery(projectId, queryClauses); foreach (Issue issue in colIssues) { RssItem item = new RssItem(); item.Title = string.Format("{0} - {1}", issue.FullId, issue.Title); item.Description = issue.Description; item.Author = issue.CreatorUserName; item.PubDate = issue.DateCreated; item.Link = new System.Uri(string.Format("{0}Issues/IssueDetail.aspx?id={1}", HostSetting.GetHostSetting("DefaultUrl"), issue.Id.ToString())); channel.Items.Add(item); } channel.Title = projectName + " - Issues"; if (!string.IsNullOrEmpty(User.Identity.Name)) { channel.Title += " (generated for " + Security.GetDisplayName() + ")"; } channel.Description = string.Format("Issues for {0}",projectName); }
/// <summary>Writes an RSS item</summary> /// <exception cref="InvalidOperationException">Either the RssWriter has already been closed, or the caller is attempting to write an RSS item before an RSS channel.</exception> /// <exception cref="ArgumentNullException">Item must be instanciated with data, before calling Write.</exception> /// <param name="item">RSS item to write</param> public void Write(RssItem item) { // NOTE: Standalone items cannot adhere to modules, hence -1 is passed. This may not be the case, however, no examples have been seen where this is legal. this.writeItem(item, -1); }
/// <summary> /// Mies the issues owned feed. /// </summary> private void MyIssuesOwnedFeed() { List<QueryClause> queryClauses = new List<QueryClause>(); MembershipUser user = Membership.GetUser(); queryClauses.Add(new QueryClause("AND", "IssueOwnerUserId", "=", user.ProviderUserKey.ToString(), SqlDbType.NVarChar, false)); if (ExcludeClosedIssues) { foreach (Project p in Project.GetProjectsByMemberUserName(Security.GetUserName())) { List<Status> status = Status.GetStatusByProjectId(p.Id).FindAll(s => s.IsClosedState); foreach (Status st in status) queryClauses.Add(new QueryClause("AND", "IssueStatusId", "<>", st.Id.ToString(), SqlDbType.Int, false)); } } colIssues = Issue.PerformQuery(0, queryClauses); foreach (Issue issue in colIssues) { RssItem item = new RssItem(); item.Title = string.Format("{0} - {1}", issue.FullId, issue.Title); item.Description = issue.Description; item.Author = issue.CreatorUserName; item.PubDate = issue.DateCreated; item.Link = new System.Uri(string.Format("{0}Issues/IssueDetail.aspx?id={1}", HostSetting.GetHostSetting("DefaultUrl"), issue.Id.ToString())); channel.Items.Add(item); } channel.Title = projectName + " - Issues"; if (!string.IsNullOrEmpty(User.Identity.Name)) { channel.Title += " (generated for " + Security.GetDisplayName() + ")"; } channel.Description = string.Format("Owned Issues for {0}", projectName); }
/// <summary>Reads the next RssElement from the stream.</summary> /// <returns>An RSS Element</returns> /// <exception cref="InvalidOperationException">RssReader has been closed, and can not be read.</exception> /// <exception cref="System.IO.FileNotFoundException">RSS file not found.</exception> /// <exception cref="System.Xml.XmlException">Invalid XML syntax in RSS file.</exception> /// <exception cref="System.IO.EndOfStreamException">Unable to read an RssElement. Reached the end of the stream.</exception> public RssElement Read() { bool readData = false; bool pushElement = true; RssElement rssElement = null; int lineNumber = -1; int linePosition = -1; if (reader == null) { throw new InvalidOperationException("RssReader has been closed, and can not be read."); } do { pushElement = true; try { readData = reader.Read(); } catch (System.IO.EndOfStreamException e) { throw new System.IO.EndOfStreamException("Unable to read an RssElement. Reached the end of the stream.", e); } catch (System.Xml.XmlException e) { if (lineNumber != -1 || linePosition != -1) { if (reader.LineNumber == lineNumber && reader.LinePosition == linePosition) { throw exceptions.LastException; } } lineNumber = reader.LineNumber; linePosition = reader.LinePosition; exceptions.Add(e); // just add to list of exceptions and continue :) } if (readData) { string readerName = reader.Name.ToLower(); switch (reader.NodeType) { case XmlNodeType.Element: { if (reader.IsEmptyElement) { break; } elementText = new StringBuilder(); switch (readerName) { case "item": // is this the end of the channel element? (absence of </channel> before <item>) if (!wroteChannel) { wroteChannel = true; rssElement = channel; // return RssChannel readData = false; } item = new RssItem(); // create new RssItem channel.Items.Add(item); break; case "source": source = new RssSource(); item.Source = source; for (int i = 0; i < reader.AttributeCount; i++) { reader.MoveToAttribute(i); switch (reader.Name.ToLower()) { case "url": try { source.Url = new Uri(reader.Value); } catch (Exception e) { exceptions.Add(e); } break; } } break; case "enclosure": enclosure = new RssEnclosure(); item.Enclosure = enclosure; for (int i = 0; i < reader.AttributeCount; i++) { reader.MoveToAttribute(i); switch (reader.Name.ToLower()) { case "url": try { enclosure.Url = new Uri(reader.Value); } catch (Exception e) { exceptions.Add(e); } break; case "length": try { enclosure.Length = int.Parse(reader.Value); } catch (Exception e) { exceptions.Add(e); } break; case "type": enclosure.Type = reader.Value; break; } } break; case "guid": guid = new RssGuid(); item.Guid = guid; for (int i = 0; i < reader.AttributeCount; i++) { reader.MoveToAttribute(i); switch (reader.Name.ToLower()) { case "ispermalink": try { guid.PermaLink = bool.Parse(reader.Value); } catch (Exception e) { exceptions.Add(e); } break; } } break; case "category": category = new RssCategory(); if ((string)xmlNodeStack.Peek() == "channel") { channel.Categories.Add(category); } else { item.Categories.Add(category); } for (int i = 0; i < reader.AttributeCount; i++) { reader.MoveToAttribute(i); switch (reader.Name.ToLower()) { case "url": goto case "domain"; case "domain": category.Domain = reader.Value; break; } } break; case "channel": channel = new RssChannel(RssDefault.String, RssDefault.String, RssDefault.Uri); textInput = null; image = null; cloud = null; source = null; enclosure = null; category = null; item = null; break; case "image": image = new RssImage(); channel.Image = image; break; case "textinput": textInput = new RssTextInput(); channel.TextInput = textInput; break; case "cloud": pushElement = false; cloud = new RssCloud(); channel.Cloud = cloud; for (int i = 0; i < reader.AttributeCount; i++) { reader.MoveToAttribute(i); switch (reader.Name.ToLower()) { case "domain": cloud.Domain = reader.Value; break; case "port": try { cloud.Port = ushort.Parse(reader.Value); } catch (Exception e) { exceptions.Add(e); } break; case "path": cloud.Path = reader.Value; break; case "registerprocedure": cloud.RegisterProcedure = reader.Value; break; case "protocol": switch (reader.Value.ToLower()) { case "xml-rpc": cloud.Protocol = RssCloudProtocol.XmlRpc; break; case "soap": cloud.Protocol = RssCloudProtocol.Soap; break; case "http-post": cloud.Protocol = RssCloudProtocol.HttpPost; break; default: cloud.Protocol = RssCloudProtocol.Empty; break; } break; } } break; case "rss": for (int i = 0; i < reader.AttributeCount; i++) { reader.MoveToAttribute(i); if (reader.Name.ToLower() == "version") { switch (reader.Value) { case "0.91": rssVersion = RssVersion.RSS091; break; case "0.92": rssVersion = RssVersion.RSS092; break; case "2.0": rssVersion = RssVersion.RSS20; break; default: rssVersion = RssVersion.NotSupported; break; } } } break; case "rdf": for (int i = 0; i < reader.AttributeCount; i++) { reader.MoveToAttribute(i); if (reader.Name.ToLower() == "version") { switch (reader.Value) { case "0.90": rssVersion = RssVersion.RSS090; break; case "1.0": rssVersion = RssVersion.RSS10; break; default: rssVersion = RssVersion.NotSupported; break; } } } break; } if (pushElement) { xmlNodeStack.Push(readerName); } break; } case XmlNodeType.EndElement: { if (xmlNodeStack.Count == 1) { break; } string childElementName = (string)xmlNodeStack.Pop(); string parentElementName = (string)xmlNodeStack.Peek(); switch (childElementName) // current element { // item classes case "item": rssElement = item; readData = false; break; case "source": source.Name = elementText.ToString(); rssElement = source; readData = false; break; case "enclosure": rssElement = enclosure; readData = false; break; case "guid": guid.Name = elementText.ToString(); rssElement = guid; readData = false; break; case "category": // parent is either item or channel category.Name = elementText.ToString(); rssElement = category; readData = false; break; // channel classes case "channel": if (wroteChannel) { wroteChannel = false; } else { wroteChannel = true; rssElement = channel; readData = false; } break; case "textinput": rssElement = textInput; readData = false; break; case "image": rssElement = image; readData = false; break; case "cloud": rssElement = cloud; readData = false; break; } switch (parentElementName) // parent element { case "item": switch (childElementName) { case "title": item.Title = elementText.ToString(); break; case "link": item.Link = new Uri(elementText.ToString()); break; case "description": item.Description = elementText.ToString(); break; case "author": item.Author = elementText.ToString(); break; case "comments": item.Comments = elementText.ToString(); break; case "pubdate": try { item.PubDate_GMT = DateTime.Parse(elementText.ToString()); } catch (Exception e) { try { string tmp = elementText.ToString(); tmp = tmp.Substring(0, tmp.Length - 5); tmp += "GMT"; item.PubDate_GMT = DateTime.Parse(tmp); } catch { exceptions.Add(e); } } break; } break; case "channel": switch (childElementName) { case "title": channel.Title = elementText.ToString(); break; case "link": try { channel.Link = new Uri(elementText.ToString()); } catch (Exception e) { exceptions.Add(e); } break; case "description": channel.Description = elementText.ToString(); break; case "language": channel.Language = elementText.ToString(); break; case "copyright": channel.Copyright = elementText.ToString(); break; case "managingeditor": channel.ManagingEditor = elementText.ToString(); break; case "webmaster": channel.WebMaster = elementText.ToString(); break; case "rating": channel.Rating = elementText.ToString(); break; case "pubdate": try { channel.PubDate = DateTime.Parse(elementText.ToString()); } catch (Exception e) { exceptions.Add(e); } break; case "lastbuilddate": try { channel.LastBuildDate = DateTime.Parse(elementText.ToString()); } catch (Exception e) { exceptions.Add(e); } break; case "generator": channel.Generator = elementText.ToString(); break; case "docs": channel.Docs = elementText.ToString(); break; case "ttl": try { channel.TimeToLive = int.Parse(elementText.ToString()); } catch (Exception e) { exceptions.Add(e); } break; } break; case "image": switch (childElementName) { case "url": try { image.Url = new Uri(elementText.ToString()); } catch (Exception e) { exceptions.Add(e); } break; case "title": image.Title = elementText.ToString(); break; case "link": try { image.Link = new Uri(elementText.ToString()); } catch (Exception e) { exceptions.Add(e); } break; case "description": image.Description = elementText.ToString(); break; case "width": try { image.Width = Byte.Parse(elementText.ToString()); } catch (Exception e) { exceptions.Add(e); } break; case "height": try { image.Height = Byte.Parse(elementText.ToString()); } catch (Exception e) { exceptions.Add(e); } break; } break; case "textinput": switch (childElementName) { case "title": textInput.Title = elementText.ToString(); break; case "description": textInput.Description = elementText.ToString(); break; case "name": textInput.Name = elementText.ToString(); break; case "link": try { textInput.Link = new Uri(elementText.ToString()); } catch (Exception e) { exceptions.Add(e); } break; } break; case "skipdays": if (childElementName == "day") { switch (elementText.ToString().ToLower()) { case "monday": channel.SkipDays[0] = true; break; case "tuesday": channel.SkipDays[1] = true; break; case "wednesday": channel.SkipDays[2] = true; break; case "thursday": channel.SkipDays[3] = true; break; case "friday": channel.SkipDays[4] = true; break; case "saturday": channel.SkipDays[5] = true; break; case "sunday": channel.SkipDays[6] = true; break; } } break; case "skiphours": if (childElementName == "hour") { channel.SkipHours[Byte.Parse(elementText.ToString().ToLower())] = true; } break; } break; } case XmlNodeType.Text: elementText.Append(reader.Value); break; case XmlNodeType.CDATA: elementText.Append(reader.Value); break; } } }while (readData); return(rssElement); }
/// <summary> /// Relevants the feed. /// </summary> private void RelevantFeed() { colIssues = Issue.GetIssuesByRelevancy(projectId, User.Identity.Name); foreach (Issue issue in colIssues) { RssItem item = new RssItem(); item.Title = string.Format("{0} - {1}", issue.FullId, issue.Title); item.Description = issue.Description; item.Author = issue.CreatorUserName; item.PubDate = issue.DateCreated; item.Link = new System.Uri(string.Format("{0}Issues/IssueDetail.aspx?id={1}", HostSetting.GetHostSetting("DefaultUrl"), issue.Id.ToString())); channel.Items.Add(item); } channel.Title = projectName + " - Issues"; if (!string.IsNullOrEmpty(User.Identity.Name)) { channel.Title += " (generated for " + Security.GetDisplayName() + ")"; } channel.Description = string.Format("Relevant Issues for {0}", projectName); }
/// <summary>Reads the next RssElement from the stream.</summary> /// <returns>An RSS Element</returns> /// <exception cref="InvalidOperationException">RssReader has been closed, and can not be read.</exception> /// <exception cref="System.IO.FileNotFoundException">RSS file not found.</exception> /// <exception cref="System.Xml.XmlException">Invalid XML syntax in RSS file.</exception> /// <exception cref="System.IO.EndOfStreamException">Unable to read an RssElement. Reached the end of the stream.</exception> public RssElement Read() { bool readData = false; bool pushElement = true; RssElement rssElement = null; int lineNumber = -1; int linePosition = -1; if (reader == null) throw new InvalidOperationException("RssReader has been closed, and can not be read."); do { pushElement = true; try { readData = reader.Read(); } catch (System.IO.EndOfStreamException e) { throw new System.IO.EndOfStreamException("Unable to read an RssElement. Reached the end of the stream.", e); } catch (System.Xml.XmlException e) { if (lineNumber != -1 || linePosition != -1) if (reader.LineNumber == lineNumber && reader.LinePosition == linePosition) throw exceptions.LastException; lineNumber = reader.LineNumber; linePosition = reader.LinePosition; exceptions.Add(e); // just add to list of exceptions and continue :) //// Added, OFxP //if (readData) //{ // continue; //} } if (readData) { string readerName = reader.Name.ToLower(); switch (reader.NodeType) { case XmlNodeType.Element: { if (reader.IsEmptyElement) break; elementText = new StringBuilder(); switch (readerName) { case "item": // is this the end of the channel element? (absence of </channel> before <item>) if (!wroteChannel) { wroteChannel = true; rssElement = channel; // return RssChannel readData = false; } item = new RssItem(); // create new RssItem channel.Items.Add(item); break; case "source": source = new RssSource(); item.Source = source; for (int i=0; i < reader.AttributeCount; i++) { reader.MoveToAttribute(i); switch (reader.Name.ToLower()) { case "url": try { // OFxP, fix //source.Url = new Uri(reader.Value); source.Url = new Uri(reader.Value, true); } catch (Exception e) { exceptions.Add(e); } break; } } break; case "enclosure": enclosure = new RssEnclosure(); item.Enclosure = enclosure; for (int i=0; i < reader.AttributeCount; i++) { reader.MoveToAttribute(i); switch (reader.Name.ToLower()) { case "url": try { // OFxP, fix //enclosure.Url = new Uri(reader.Value); enclosure.Url = new Uri(reader.Value, true); } catch (Exception e) { exceptions.Add(e); } break; case "length": try { enclosure.Length = int.Parse(reader.Value); } catch (Exception e) { exceptions.Add(e); } break; case "type": enclosure.Type = reader.Value; break; } } break; case "guid": guid = new RssGuid(); item.Guid = guid; for (int i=0; i < reader.AttributeCount; i++) { reader.MoveToAttribute(i); switch (reader.Name.ToLower()) { case "ispermalink": try { guid.PermaLink = bool.Parse(reader.Value); } catch (Exception e) { exceptions.Add(e); } break; } } break; case "category": category = new RssCategory(); if ((string)xmlNodeStack.Peek() == "channel") channel.Categories.Add(category); else item.Categories.Add(category); for (int i=0; i < reader.AttributeCount; i++) { reader.MoveToAttribute(i); switch (reader.Name.ToLower()) { case "url": goto case "domain"; case "domain": category.Domain = reader.Value; break; } } break; case "channel": channel = new RssChannel(); textInput = null; image = null; cloud = null; source = null; enclosure = null; category = null; item = null; break; case "image": image = new RssImage(); channel.Image = image; break; case "textinput": textInput = new RssTextInput(); channel.TextInput = textInput; break; case "cloud": pushElement = false; cloud = new RssCloud(); channel.Cloud = cloud; for (int i=0; i < reader.AttributeCount; i++) { reader.MoveToAttribute(i); switch (reader.Name.ToLower()) { case "domain": cloud.Domain = reader.Value; break; case "port": try { cloud.Port = ushort.Parse(reader.Value); } catch (Exception e) { exceptions.Add(e); } break; case "path": cloud.Path = reader.Value; break; case "registerprocedure": cloud.RegisterProcedure = reader.Value; break; case "protocol": switch (reader.Value.ToLower()) { case "xml-rpc": cloud.Protocol = RssCloudProtocol.XmlRpc; break; case "soap": cloud.Protocol = RssCloudProtocol.Soap; break; case "http-post": cloud.Protocol = RssCloudProtocol.HttpPost; break; default: cloud.Protocol = RssCloudProtocol.Empty; break; } break; } } break; case "rss": for (int i=0; i < reader.AttributeCount; i++) { reader.MoveToAttribute(i); if (reader.Name.ToLower() == "version") switch (reader.Value) { case "0.91": rssVersion = RssVersion.RSS091; break; case "0.92": rssVersion = RssVersion.RSS092; break; case "2.0": rssVersion = RssVersion.RSS20; break; default: rssVersion = RssVersion.NotSupported; break; } } break; case "rdf": for (int i=0; i < reader.AttributeCount; i++) { reader.MoveToAttribute(i); if (reader.Name.ToLower() == "version") switch (reader.Value) { case "0.90": rssVersion = RssVersion.RSS090; break; case "1.0": rssVersion = RssVersion.RSS10; break; default: rssVersion = RssVersion.NotSupported; break; } } break; } if (pushElement) xmlNodeStack.Push(readerName); break; } case XmlNodeType.EndElement: { if (xmlNodeStack.Count == 1) break; string childElementName = (string)xmlNodeStack.Pop(); string parentElementName = (string)xmlNodeStack.Peek(); switch (childElementName) // current element { // item classes case "item": rssElement = item; readData = false; break; case "source": source.Name = elementText.ToString(); rssElement = source; readData = false; break; case "enclosure": rssElement = enclosure; readData = false; break; case "guid": guid.Name = elementText.ToString(); rssElement = guid; readData = false; break; case "category": // parent is either item or channel category.Name = elementText.ToString(); rssElement = category; readData = false; break; // channel classes case "channel": if (wroteChannel) wroteChannel = false; else { wroteChannel = true; rssElement = channel; readData = false; } break; case "textinput": rssElement = textInput; readData = false; break; case "image": rssElement = image; readData = false; break; case "cloud": rssElement = cloud; readData = false; break; } switch (parentElementName) // parent element { case "item": switch (childElementName) { case "title": item.Title = elementText.ToString(); break; case "link": // OFxP, fix //item.Link = new Uri(elementText.ToString()); item.Link = new Uri(elementText.ToString(), true); break; case "description": item.Description = elementText.ToString(); break; case "author": item.Author = elementText.ToString(); break; case "comments": item.Comments = elementText.ToString(); break; case "dc:date": // Fix for the federalreserve feed. case "pubdate": item.PubDate = GeneralHelper.ParseDateTimeWithZone(elementText.ToString()); break; } break; case "channel": switch (childElementName) { case "title": channel.Title = elementText.ToString(); break; case "link": try { // OFxP, fix //channel.Link = new Uri(elementText.ToString()); channel.Link = new Uri(elementText.ToString(), true); } catch (Exception e) { exceptions.Add(e); } break; case "description": channel.Description = elementText.ToString(); break; case "language": channel.Language = elementText.ToString(); break; case "copyright": channel.Copyright = elementText.ToString(); break; case "managingeditor": channel.ManagingEditor = elementText.ToString(); break; case "webmaster": channel.WebMaster = elementText.ToString(); break; case "rating": channel.Rating = elementText.ToString(); break; case "dc:date": // Fix for the federalreserve feed. case "pubdate": channel.PubDate = GeneralHelper.ParseDateTimeWithZone(elementText.ToString()); break; case "lastbuilddate": channel.LastBuildDate = GeneralHelper.ParseDateTimeWithZone(elementText.ToString()); break; case "generator": channel.Generator = elementText.ToString(); break; case "docs": channel.Docs = elementText.ToString(); break; case "ttl": try { channel.TimeToLive = int.Parse(elementText.ToString()); } catch (Exception e) { exceptions.Add(e); } break; } break; case "image": switch (childElementName) { case "url": try { // OFxP, fix //image.Url = new Uri(elementText.ToString()); image.Url = new Uri(elementText.ToString(), true); } catch (Exception e) { exceptions.Add(e); } break; case "title": image.Title = elementText.ToString(); break; case "link": try { // OFxP, fix //image.Link = new Uri(elementText.ToString()); image.Link = new Uri(elementText.ToString(), true); } catch (Exception e) { exceptions.Add(e); } break; case "description": image.Description = elementText.ToString(); break; case "width": try { image.Width = Byte.Parse(elementText.ToString()); } catch (Exception e) { exceptions.Add(e); } break; case "height": try { image.Height = Byte.Parse(elementText.ToString()); } catch (Exception e) { exceptions.Add(e); } break; } break; case "textinput": switch (childElementName) { case "title": textInput.Title = elementText.ToString(); break; case "description": textInput.Description = elementText.ToString(); break; case "name": textInput.Name = elementText.ToString(); break; case "link": try { // OFxP, fix //textInput.Link = new Uri(elementText.ToString()); textInput.Link = new Uri(elementText.ToString(), true); } catch (Exception e) { exceptions.Add(e); } break; } break; case "skipdays": if (childElementName == "day") channel.SkipDays |= Day.Parse(elementText.ToString()); break; case "skiphours": if (childElementName == "hour") channel.SkipHours |= Hour.Parse(elementText.ToString()); break; } break; } case XmlNodeType.Text: elementText.Append(reader.Value); break; case XmlNodeType.CDATA: elementText.Append(reader.Value); break; } } } while (readData); return rssElement; }
/// <summary> /// Creates an RSS news feed for Issues By Type /// </summary> private void TypeFeed() { List<IssueCount> al = Issue.GetIssueTypeCountByProject(projectId); foreach (IssueCount issueCount in al) { RssItem item = new RssItem(); item.Title = issueCount.Name; item.Description = string.Concat(issueCount.Count, " Open Issues"); item.PubDate = DateTime.Now; item.Link = new System.Uri(Page.ResolveUrl(string.Format("{2}/Issues/IssueList.aspx?pid={0}&s=0&t={1}", projectId, issueCount.Id, HostSetting.GetHostSetting("DefaultUrl")))); channel.Items.Add(item); } channel.Title = projectName + " Open Issues By Type"; channel.Description = "A listing of all " + projectName + " issues grouped by type"; }
/// <summary>Adds a specified item to this collection.</summary> /// <param name="item">The item to add.</param> /// <returns>The zero-based index of the added item.</returns> public int Add(RssItem item) { pubDateChanged = true; return(List.Add(item)); }
/// <summary>Searches for the specified RssItem and returns the zero-based index of the first occurrence within the entire RssItemCollection.</summary> /// <param name="rssItem">The RssItem to locate in the RssItemCollection.</param> /// <returns>The zero-based index of the first occurrence of RssItem within the entire RssItemCollection, if found; otherwise, -1.</returns> public int IndexOf(RssItem rssItem) { return List.IndexOf(rssItem); }
/// <summary>Searches for the specified RssItem and returns the zero-based index of the first occurrence within the entire RssItemCollection.</summary> /// <param name="rssItem">The RssItem to locate in the RssItemCollection.</param> /// <returns>The zero-based index of the first occurrence of RssItem within the entire RssItemCollection, if found; otherwise, -1.</returns> public int IndexOf(RssItem rssItem) { return(List.IndexOf(rssItem)); }