Ejemplo n.º 1
0
        public static Feed AddFeed(Feed feed)
        {
            if (feed.Name == null)
            {
                throw new Exception("Must give the feed a name");
            }

            if (feed.Id == Guid.Empty)
            {
                feed.Id = Guid.NewGuid();
            }

            if (feed.RequestInterval == 0)
            {
                feed.RequestInterval = 60;
            }

            if (feed.Document == null)
            {
                feed.ReLoad();
            }

            ObjectStore os = new ObjectStore();

            os.UniqueId    = feed.Id;
            os.Name        = "Feed: " + feed.Name;
            os.Data        = ObjectManager.ConvertToString(feed);
            os.ContentType = "feed/xml";
            os.Type        = typeof(Feed).FullName;
            os.Save();

            ZCache.RemoveCache("Feed-Objects");

            return(feed);
        }
Ejemplo n.º 2
0
        public static Feed GetFeed(string url, bool throwExceptionOnError)
        {
            Dictionary <Guid, Feed> feeds = GetFeeds();

            foreach (Feed feed in feeds.Values)
            {
                if (Util.AreEqualIgnoreCase(feed.Url, url))
                {
                    return(feed);
                }
            }

            Log.Warn("Feed", "Feed with name: {0} was requested but not found. It was added to the queue.", url);

            Feed newFeed = new Feed();

            newFeed.Url             = url;
            newFeed.Id              = Guid.NewGuid();
            newFeed.RequestInterval = 60;
            newFeed.ReLoad(throwExceptionOnError);
            if (newFeed.Document != null)
            {
                newFeed.Name = "Feed: " + newFeed.Document.Channel.Title;
            }
            else
            {
                newFeed.Name = "Feed:" + url;
            }

            AddFeed(newFeed);

            return(newFeed);
        }
Ejemplo n.º 3
0
        public static Feed AddFeed(Feed feed)
        {
            if (feed.Name == null)
                throw new Exception("Must give the feed a name");

            if (feed.Id == Guid.Empty)
                feed.Id = Guid.NewGuid();

            if (feed.RequestInterval == 0)
                feed.RequestInterval = 60;

               if(feed.Document == null)
               feed.ReLoad();

            ObjectStore os = new ObjectStore();
            os.UniqueId = feed.Id;
            os.Name = "Feed: " + feed.Name;
            os.Data = ObjectManager.ConvertToString(feed);
            os.ContentType = "feed/xml";
            os.Type = typeof (Feed).FullName;
            os.Save();

            ZCache.RemoveCache("Feed-Objects");

            return feed;
        }
Ejemplo n.º 4
0
        public static Feed GetFeed(string url, bool throwExceptionOnError)
        {
            Dictionary<Guid, Feed> feeds = GetFeeds();
            foreach (Feed feed in feeds.Values)
                if (Util.AreEqualIgnoreCase(feed.Url, url))
                    return feed;

            Log.Warn("Feed", "Feed with name: {0} was requested but not found. It was added to the queue.", url);

            Feed newFeed = new Feed();
            newFeed.Url = url;
            newFeed.Id = Guid.NewGuid();
            newFeed.RequestInterval =60;
            newFeed.ReLoad(throwExceptionOnError);
            if (newFeed.Document != null)
                newFeed.Name = "Feed: " + newFeed.Document.Channel.Title;
            else
                newFeed.Name = "Feed:" + url;

            AddFeed(newFeed);

            return newFeed;
        }