예제 #1
0
        /// <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();
            }
        }
예제 #2
0
        /// <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();
            }
        }
예제 #3
0
        /// <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>());
            }
        }