예제 #1
0
 private static void readRssItem(RssItem item, XmlReader reader)
 {
     if (equal(reader, "title"))
     {
         item.Title = reader.ReadString();
     }
     else if (equal(reader, "link"))
     {
         item.Link = reader.ReadString();
     }
     else if (equal(reader, "content:encoded"))
     {
         item.Description = reader.ReadString();
     }
     else if (equal(reader, "description") && strUtil.IsNullOrEmpty(item.Description))
     {
         item.Description = reader.ReadString();
     }
     else if (equal(reader, "pubdate"))
     {
         item.PubDate = parseTime(reader.ReadString());
     }
     else if (equal(reader, "author"))
     {
         item.Author = reader.ReadString();
     }
     else if (equal(reader, "category"))
     {
         item.Category = reader.ReadString();
     }
 }
예제 #2
0
 public static RssChannel Create( String rssUrl ) {
     RssChannel feed = new RssChannel();
     RssImage img = new RssImage();
     XmlTextReader reader = new XmlTextReader( rssUrl );
     Boolean isNewItem = false;
     Boolean isImage = false;
     RssItem rssItem = new RssItem();
     reader.MoveToContent();
     while (reader.Read()) {
         if (!reader.Name.Equals( "channel" ) && ((reader.NodeType != XmlNodeType.Whitespace) && (reader.NodeType != XmlNodeType.Comment))) {
             if (((reader.NodeType == XmlNodeType.EndElement) && reader.Name.Equals( "item" )) && strUtil.HasText( rssItem.Title )) {
                 feed.RssItems.Add( rssItem );
                 rssItem = new RssItem();
                 isNewItem = false;
             }
             else {
                 if ((reader.NodeType == XmlNodeType.EndElement) && reader.Name.Equals( "image" )) {
                     isImage = false;
                     continue;
                 }
                 if (equal( reader, "image" )) {
                     isImage = true;
                     isNewItem = false;
                     continue;
                 }
                 if (equal( reader, "item" )) {
                     isNewItem = true;
                     isImage = false;
                     continue;
                 }
                 if (reader.NodeType == XmlNodeType.Element) {
                     if (!(isNewItem || isImage)) {
                         readRssChannel( feed, reader );
                     }
                     else if (isNewItem) {
                         readRssItem( rssItem, reader );
                     }
                     else if (isImage) {
                         readRssImage( img, reader );
                     }
                 }
             }
         }
     }
     feed.RssImage = img;
     reader.Close();
     return feed;
 }
예제 #3
0
        public String GetRenderContent()
        {
            RssChannel channel = this;

            StringBuilder sb = new StringBuilder();

            sb.Append("<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\"?>");
            sb.Append("<rss version=\"2.0\" xmlns:dc=\"http://purl.org/dc/elements/1.1/\">");
            sb.Append("<channel>");
            sb.AppendFormat("<title>{0}</title>", channel.Title);
            sb.AppendFormat("<link>{0}</link>", channel.Link);
            sb.AppendFormat("<description>{0}</description>", channel.Description);
            sb.AppendFormat("<language>{0}</language>", channel.Language);
            sb.AppendFormat("<pubDate>{0}</pubDate>", channel.PubDate.ToUniversalTime().ToString("r"));
            sb.AppendFormat("<lastBuildDate>{0}</lastBuildDate>", channel.LastBuildDate.ToUniversalTime().ToString("r"));
            sb.AppendFormat("<generator>{0}</generator>", channel.Generator);
            sb.AppendFormat("<ttl>{0}</ttl>", channel.Ttl);
            for (int i = 0; i < this.RssItems.Count; i++)
            {
                RssItem item = this.RssItems[i];
                sb.Append("<item>");

                sb.AppendFormat("<title>{0}</title>", item.Title);
                sb.AppendFormat("<link>{0}</link>", item.Link);
                sb.AppendFormat("<description>{0}</description>", item.DescriptionCDATA);
                sb.AppendFormat("<author>{0}</author>", item.Author);
                sb.AppendFormat("<pubDate>{0}</pubDate>", item.PubDate.ToUniversalTime().ToString("r"));
                sb.AppendFormat("<category>{0}</category>", item.Category);

                sb.Append("</item>");
            }

            sb.Append("</channel>");

            sb.Append("</rss>");
            return(sb.ToString());
        }
예제 #4
0
        public virtual RssChannel getRssByApp(long appId, int count) {

            List<BlogPost> newListAll = null;

            if (appId > 0)
                newListAll = this.GetNewBlog( appId, count );
            else
                newListAll = this.GetNewListAll( count );

            BlogApp app = BlogApp.findById( appId );
            User user = User.findById( app.OwnerId );
            IMemberApp uapp = new UserAppService().GetByApp( app );

            RssChannel channel = new RssChannel();
            channel.Title = uapp.Name + " -- " + user.Name + "'s blog";
            channel.Link = Link.ToMember( user );

            foreach (BlogPost post in newListAll) {

                RssItem rssItem = new RssItem();
                rssItem.Title = post.Title;
                rssItem.Description = post.Content;
                rssItem.Category = post.Category.Name;
                rssItem.PubDate = post.Created;
                rssItem.Author = post.Creator.Name;

                rssItem["CreatorLink"] = channel.Link;
                rssItem["CreatorFace"] = post.Creator.PicSmall;
                rssItem.Link = alink.ToAppData( post );

                channel.RssItems.Add( rssItem );
            }


            return channel;
        }
예제 #5
0
 private static void readRssItem( RssItem item, XmlReader reader )
 {
     if (equal( reader, "title" )) {
         item.Title = reader.ReadString();
     }
     else if (equal( reader, "link" )) {
         item.Link = reader.ReadString();
     }
     else if (equal( reader, "content:encoded" )) {
         item.Description = reader.ReadString();
     }
     else if (equal( reader, "description" ) && strUtil.IsNullOrEmpty( item.Description )) {
         item.Description = reader.ReadString();
     }
     else if (equal( reader, "pubdate" )) {
         item.PubDate = parseTime( reader.ReadString() );
     }
     else if (equal( reader, "author" )) {
         item.Author = reader.ReadString();
     }
     else if (equal( reader, "category" )) {
         item.Category = reader.ReadString();
     }
 }
예제 #6
0
        public static RssChannel Create(String rssUrl)
        {
            RssChannel    feed      = new RssChannel();
            RssImage      img       = new RssImage();
            XmlTextReader reader    = new XmlTextReader(rssUrl);
            Boolean       isNewItem = false;
            Boolean       isImage   = false;
            RssItem       rssItem   = new RssItem();

            reader.MoveToContent();
            while (reader.Read())
            {
                if (!reader.Name.Equals("channel") && ((reader.NodeType != XmlNodeType.Whitespace) && (reader.NodeType != XmlNodeType.Comment)))
                {
                    if (((reader.NodeType == XmlNodeType.EndElement) && reader.Name.Equals("item")) && strUtil.HasText(rssItem.Title))
                    {
                        feed.RssItems.Add(rssItem);
                        rssItem   = new RssItem();
                        isNewItem = false;
                    }
                    else
                    {
                        if ((reader.NodeType == XmlNodeType.EndElement) && reader.Name.Equals("image"))
                        {
                            isImage = false;
                            continue;
                        }
                        if (equal(reader, "image"))
                        {
                            isImage   = true;
                            isNewItem = false;
                            continue;
                        }
                        if (equal(reader, "item"))
                        {
                            isNewItem = true;
                            isImage   = false;
                            continue;
                        }
                        if (reader.NodeType == XmlNodeType.Element)
                        {
                            if (!(isNewItem || isImage))
                            {
                                readRssChannel(feed, reader);
                            }
                            else if (isNewItem)
                            {
                                readRssItem(rssItem, reader);
                            }
                            else if (isImage)
                            {
                                readRssImage(img, reader);
                            }
                        }
                    }
                }
            }
            feed.RssImage = img;
            reader.Close();
            return(feed);
        }
예제 #7
0
 public void Remove(RssItem value)
 {
     base.List.Remove(value);
 }
예제 #8
0
 public void Insert(int index, RssItem value)
 {
     base.List.Insert(index, value);
 }
예제 #9
0
 public int IndexOf(RssItem value)
 {
     return(base.List.IndexOf(value));
 }
예제 #10
0
 public Boolean Contains(RssItem value)
 {
     return(base.List.Contains(value));
 }
예제 #11
0
 public int Add(RssItem rssItem)
 {
     return(base.List.Add(rssItem));
 }
예제 #12
0
 public void Remove( RssItem value )
 {
     base.List.Remove( value );
 }
예제 #13
0
 public void Insert( int index, RssItem value )
 {
     base.List.Insert( index, value );
 }
예제 #14
0
 public int IndexOf( RssItem value )
 {
     return base.List.IndexOf( value );
 }
예제 #15
0
 public Boolean Contains( RssItem value )
 {
     return base.List.Contains( value );
 }
예제 #16
0
 public int Add( RssItem rssItem )
 {
     return base.List.Add( rssItem );
 }