Пример #1
0
 public FeedsController(AutodetectFeeds detector, FeedMaintenance reader, PierceConfig config, Mongo db)
     : base(db)
 {
     _detector = detector;
     _reader = reader;
     _config = config;
 }
Пример #2
0
 public AutodetectFeeds(Wget wget, FeedParser parser, ReadFeeds reader, Mongo db, ILogger logger)
 {
     _wget = wget;
     _parser = parser;
     _reader = reader;
     _db = db;
     _logger = logger;
 }
Пример #3
0
 public void Save(Mongo db)
 {
     bool noId = string.IsNullOrEmpty(Id);
     db.Chunks.Save(this);
     if (noId)
     {
         foreach (var article in Articles)
         {
             article.ChunkId = Id;
         }
         db.Chunks.Save(this);
     }
 }
Пример #4
0
 public static Chunk ById(string chunkId, Mongo db)
 {
     return db.Chunks.FindOneById(new ObjectId(chunkId));
 }
Пример #5
0
 public ChunkShuffler(Mongo db, ILogger logger)
 {
     _db = db;
     _logger = logger;
 }
Пример #6
0
 public SubscriptionsHandler(Mongo db, PierceConfig config)
 {
     _db = db;
     _config = config;
 }
Пример #7
0
 public BaseController(Mongo db)
 {
     this.db = db;
     log = LogManager.GetLogger(this.GetType());
 }
Пример #8
0
 public void Save(Mongo db)
 {
     if (string.IsNullOrEmpty(Id))
     {
         // Ensure we have an id that we can set for our chunks.
         db.Feeds.Save(this);
     }
     // shouldn't happen...
     if (_head != null && !_chunkCache.Contains(_head))
     {
         _chunkCache.Add(_head);
     }
     foreach (var chunk in _chunkCache.Where(x => !x.Articles.Any()))
     {
         Console.WriteLine("removing chunk {0} because it has {1} articles", chunk.Id, chunk.Articles.Count);
         ChunkIds.Remove(chunk.Id);
     }
     foreach (var chunk in _chunkCache.Where(x => x.Articles.Any()).OrderBy(x => x.Articles.First().PublishDate))
     {
         Console.WriteLine("saving chunk {0} with {1} articles", chunk.Id, chunk.Articles.Count);
         chunk.FeedId = this.Id;
         chunk.Save(db);
         if (!ChunkIds.Contains(chunk.Id))
         {
             ChunkIds.Add(chunk.Id);
         }
     }
     if (_head != null)
     {
         if (string.IsNullOrWhiteSpace(_head.Id))
         {
             _head = null;
             HeadChunkId = ChunkIds.LastOrDefault();
         }
         else if (HeadChunkId != _head.Id)
         {
             HeadChunkId = _head.Id;
         }
     }
     db.Feeds.Save(this);
 }
Пример #9
0
 public UsersController(Mongo db, PierceConfig config)
     : base(db)
 {
     _config = config;
 }
Пример #10
0
 public FeedMaintenance(IFeedTask[] tasks, Mongo db, ILogger logger)
 {
     _tasks = tasks.OrderBy(task => task.Priority).ToList();
     _db = db;
     _logger = logger;
 }
Пример #11
0
 public Chunk GetHeadChunk(Mongo db)
 {
     if (_head != null)
     {
         return _head;
     }
     if (string.IsNullOrEmpty(HeadChunkId))
     {
         HeadChunkId = ChunkIds.LastOrDefault();
         if (string.IsNullOrEmpty(HeadChunkId))
         {
             _head = new Chunk { FeedId = Id };
             CacheChunk(_head);
             return _head;
         }
     }
     _head = GetChunk(HeadChunkId, db);
     if (_head == null)
     {
         _head = new Chunk { FeedId = Id };
         CacheChunk(_head);
     }
     return _head;
 }
Пример #12
0
 public Chunk GetChunk(string id, Mongo db)
 {
     return _chunkCache.Where(x => x.Id == id).FirstOrDefault() ?? Chunk.ById(id, db);
 }
Пример #13
0
 public static Feed ByUri(string uri, Mongo db)
 {
     return db.Feeds.Find(Query.EQ("Uri", uri)).FirstOrDefault();
 }
Пример #14
0
 public static Feed ById(string id, Mongo db)
 {
     return db.Feeds.Find(Query.EQ("_id", new ObjectId(id))).FirstOrDefault();
 }
Пример #15
0
 public OrphanChunkKiller(Mongo db, ILogger logger)
 {
     _db = db;
     _logger = logger;
 }
Пример #16
0
 public GarbageCollector(Mongo db, PierceConfig config)
 {
     _db = db; _config = config;
 }
Пример #17
0
 public FeedParser(Mongo db, ILogger logger)
 {
     _db = db;
     _logger = logger;
 }