/// <summary> /// Push item in the queue. /// </summary> /// <param name="crawlerQueueEntry">Queue entry.</param> protected override void PushImpl(CrawlerQueueEntry crawlerQueueEntry) { using (var model = new NCrawlerModel()) { var entry = new CrawlQueue { GroupId = this.groupId, SerializedData = crawlerQueueEntry.ToJson(), }; model.CrawlQueues.Add(entry); model.SaveChanges(); } }
/// <summary> /// Pop item from the queue. /// </summary> /// <returns>Last item in the queue if present; null otherwise.</returns> protected override CrawlerQueueEntry PopImpl() { using (var model = new NCrawlerModel()) { CrawlQueue result = model.CrawlQueues.FirstOrDefault(q => q.GroupId == this.groupId); if (result.IsNull()) { return(null); } model.CrawlQueues.Remove(result); model.SaveChanges(); return(result.SerializedData.FromJson <CrawlerQueueEntry>()); } }