public void Redis_QueueTest()
        {
            RedisScheduler redisScheduler = new RedisScheduler("localhost", "");

            ISpider spider   = new TestSpider();
            Request request1 = new Request("http://www.ibm.com/1", 1, null);
            Request request2 = new Request("http://www.ibm.com/2", 1, null);
            Request request3 = new Request("http://www.ibm.com/3", 1, null);
            Request request4 = new Request("http://www.ibm.com/4", 1, null);

            redisScheduler.Push(request1, spider);
            redisScheduler.Push(request2, spider);
            redisScheduler.Push(request3, spider);
            redisScheduler.Push(request4, spider);

            Request result = redisScheduler.Poll(spider);

            Assert.AreEqual("http://www.ibm.com/4", result.Url.ToString());
            Request result1 = redisScheduler.Poll(spider);

            Assert.AreEqual("http://www.ibm.com/3", result1.Url.ToString());
            redisScheduler.Dispose();

            RedisSchedulerManager m = new RedisSchedulerManager("localhost");

            m.RemoveTask(spider.Identity);
        }
Exemple #2
0
        public void RedisTest()
        {
            RedisScheduler redisScheduler = new RedisScheduler("localhost", "");

            ISpider spider          = new TestSpider();
            RedisSchedulerManager m = new RedisSchedulerManager("localhost");

            m.RemoveTask(spider.Identity);

            Request request = new Request("http://www.ibm.com/developerworks/cn/java/j-javadev2-22/", 1, null);

            request.PutExtra("1", "2");
            redisScheduler.Push(request, spider);
            Request result = redisScheduler.Poll(spider);

            Assert.AreEqual("http://www.ibm.com/developerworks/cn/java/j-javadev2-22/", result.Url.ToString());
            Request result1 = redisScheduler.Poll(spider);

            Assert.IsNull(result1);
            redisScheduler.Dispose();


            m.RemoveTask(spider.Identity);
        }
Exemple #3
0
 private void  除ToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (MessageBox.Show(this, @"您确定要删除此任务的记录吗?", @"警告", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) ==
         DialogResult.Yes)
     {
         //SpiderStatus spiderStatus = manager.GetTaskStatus(_selectedIdentify);
         //if (spiderStatus.Status != "Running" && spiderStatus.Status != "Init")
         //{
         manager.RemoveTask(_selectedIdentify);
         RefreshTask();
         //}
         //else
         //{
         //	MessageBox.Show(this, @"只能删除已完成或停止的任务", @"错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
         //}
     }
 }