Ejemplo n.º 1
0
 public TransitFeedItem(DBlog.Data.FeedItem o)
     : base(o.Id)
 {
     Link        = o.Link;
     Title       = o.Title;
     Description = o.Description;
     FeedId      = o.Feed.Id;
 }
Ejemplo n.º 2
0
        public FeedItemTest()
        {
            FeedTest feed = new FeedTest();
            AddDependentObject(feed);

            mFeedItem = new FeedItem();
            mFeedItem.Description = Guid.NewGuid().ToString();
            mFeedItem.Feed = feed.Feed;
            mFeedItem.Link = Guid.NewGuid().ToString();
            mFeedItem.Title = Guid.NewGuid().ToString();
        }
Ejemplo n.º 3
0
        protected override int UpdateFeedItems(ISession session)
        {
            int result = 0;

            if (! string.IsNullOrEmpty(mFeed.Xsl))
            {
                StringBuilder TransformedString = new StringBuilder();
                XslCompiledTransform FeedXsl = new XslCompiledTransform();
                FeedXsl.Load(new XmlTextReader(new StringReader(mFeed.Xsl)), null, null);
                StringWriter StringWriter = new StringWriter(TransformedString);
                XmlTextWriter TextWriter = new XmlTextWriter(StringWriter);
                FeedXsl.Transform(new XmlNodeReader(XmlFeed.DocumentElement), TextWriter);
                XmlFeed.LoadXml(TransformedString.ToString());
            }

            XmlNodeList FeedXmlItems = XmlFeed.SelectNodes("descendant::channel/item");

            List<FeedItem> updated = new List<FeedItem>();

            foreach (XmlNode XmlNodeItem in FeedXmlItems)
            {
                XmlNode xmlLink = XmlNodeItem.SelectSingleNode("link");
                string link = (xmlLink != null) ? xmlLink.InnerText : null;

                FeedItem current = null;

                if (!string.IsNullOrEmpty(link))
                {
                    for (int i = 0; i < mFeed.FeedItems.Count; i++)
                    {
                        FeedItem item = (FeedItem)mFeed.FeedItems[i];
                        if (item.Link == link)
                        {
                            current = item;
                            updated.Add(item);
                            mFeed.FeedItems.RemoveAt(i);
                            break;
                        }
                    }
                }

                if (current == null)
                {
                    result++;
                    current = new FeedItem();
                    current.Feed = mFeed;
                    current.Link = link;
                }

                XmlNode xmlDescription = XmlNodeItem.SelectSingleNode("description");
                current.Description = (xmlDescription != null) ? xmlDescription.InnerText : null;

                XmlNode xmlTitle = XmlNodeItem.SelectSingleNode("title");
                current.Title = (xmlTitle != null) ? xmlTitle.InnerText : null;

                session.Save(current);
            }

            foreach (FeedItem item in mFeed.FeedItems)
            {
                session.Delete(item);
            }

            mFeed.FeedItems = updated;
            return result;
        }