示例#1
0
 /// <summary>
 /// Cleans group queue.
 /// </summary>
 private void CleanQueue()
 {
     using (var model = new NCrawlerModel())
     {
         model.Database.ExecuteSqlCommand("DELETE FROM CrawlQueues WHERE GroupId = {0}", this.groupId);
     }
 }
 /// <summary>
 /// Gets count of registered entries.
 /// </summary>
 /// <returns>Count of registered history entries.</returns>
 protected override long GetRegisteredCount()
 {
     using (var model = new NCrawlerModel())
     {
         return(model.CrawlHistories.Count(h => h.GroupId == this.groupId));
     }
 }
示例#3
0
 /// <summary>
 /// Get count of items in the queue.
 /// </summary>
 /// <returns>Count of items in the queue.</returns>
 protected override long GetCount()
 {
     using (var model = new NCrawlerModel())
     {
         return(model.CrawlQueues.Count(h => h.GroupId == this.groupId));
     }
 }
 /// <summary>
 /// Get count of items in the queue.
 /// </summary>
 /// <returns>Count of items in the queue.</returns>
 protected override long GetCount()
 {
     using (var model = new NCrawlerModel())
     {
         return model.CrawlQueues.Count(h => h.GroupId == this.groupId);
     }
 }
 /// <summary>
 /// Tests whether item with given key present in the current crawling group.
 /// </summary>
 /// <param name="key">Key of the item to test.</param>
 /// <returns>True if item is present in the history; false otherwise.</returns>
 protected override bool Exists(string key)
 {
     using (var model = new NCrawlerModel())
     {
         return(model.CrawlHistories.Where(h => h.GroupId == this.groupId && h.Key == key).Any());
     }
 }
 /// <summary>
 /// Tests whether item with given key present in the current crawling group.
 /// </summary>
 /// <param name="key">Key of the item to test.</param>
 /// <returns>True if item is present in the history; false otherwise.</returns>
 protected override bool Exists(string key)
 {
     using (var model = new NCrawlerModel())
     {
         return model.CrawlHistories.Where(h => h.GroupId == this.groupId && h.Key == key).Any();
     }
 }
 /// <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();
     }
 }
示例#9
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();
            }
        }
        /// <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();
            }
        }
示例#11
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>());
            }
        }
        /// <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>();
            }
        }
 /// <summary>
 /// Cleans group queue.
 /// </summary>
 private void CleanQueue()
 {
     using (var model = new NCrawlerModel())
     {
         model.Database.ExecuteSqlCommand("DELETE FROM CrawlQueues WHERE GroupId = {0}", this.groupId);
     }
 }
 /// <summary>
 /// Gets count of registered entries.
 /// </summary>
 /// <returns>Count of registered history entries.</returns>
 protected override long GetRegisteredCount()
 {
     using (var model = new NCrawlerModel())
     {
         return model.CrawlHistories.Count(h => h.GroupId == this.groupId);
     }
 }