Пример #1
0
 public void Run()
 {
     using (var db = new NishkriyaContext())
     {
         var hasher = new Sha1Provider();
         var scrapers = new List<IForumScraper> {new YAFScavenger(hasher, db), new VBulletinScavenger(hasher,db)};
         scrapers.ForEach(s => s.Scrape());
     }
 }
Пример #2
0
        public void Scrape()
        {
            using (var db = new NishkriyaContext())
            {
                var session = new ScraperSession { Start = DateTime.Now };

                db.Accounts.Where(a => a.Active).ToList().ForEach(account =>
                    {
                        var toAdd = GetNewPosts(account, db.Threads.ToList(), session).ToList();
                        session.PostsAdded += toAdd.Count;
                        account.Posts.AddRange(toAdd);
                        db.SaveChanges(); //Pesky thread duplication avoided
                    });

                session.Finish = DateTime.Now;

                db.Stats.Add(session);
                db.SaveChanges();
            }
        }
Пример #3
0
 public VBulletinScavenger(IHashProvider hashProvider, NishkriyaContext db)
 {
     _db = db;
     _hashProvider = hashProvider;
     _log = LogManager.GetLogger("ScavengerLord");
 }
Пример #4
0
 public YAFScavenger(IHashProvider hashProvider, NishkriyaContext db)
 {
     _hashProvider = hashProvider;
     _db = db;
 }