예제 #1
0
 /// <summary>
 /// Adds history entry with specific key.
 /// </summary>
 /// <param name="key">Key to add to history entry.</param>
 protected override void Add(string key)
 {
     using (var model = new NCrawlerModel())
     {
         var historyEntry = new CrawlHistory();
         historyEntry.Key     = key;
         historyEntry.GroupId = this.groupId;
         model.CrawlHistories.Add(historyEntry);
         model.SaveChanges();
     }
 }
 /// <summary>
 /// Adds history entry with specific key.
 /// </summary>
 /// <param name="key">Key to add to history entry.</param>
 protected override void Add(string key)
 {
     using (var model = new NCrawlerModel())
     {
         var historyEntry = new CrawlHistory();
         historyEntry.Key = key;
         historyEntry.GroupId = this.groupId;
         model.CrawlHistories.Add(historyEntry);
         model.SaveChanges();
     }
 }
예제 #3
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();
            }
        }
예제 #4
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();
            }
        }
예제 #5
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())
            {
                var 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>());
            }
        }
예제 #6
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>();
            }
        }