Exemplo n.º 1
0
 private void Button_Click_5(object sender, RoutedEventArgs e)  //stop
 {
     SetStateStop();
     spider = new HttpImageBfsSpider();
     text_completecnt.Text = "0";
     text_queuecnt.Text    = "0";
     text_errorcnt.Text    = "0";
 }
Exemplo n.º 2
0
        private void Button_Click_7(object sender, RoutedEventArgs e)  //open task
        {
            OpenFileDialog ofd = new OpenFileDialog();

            ofd.Filter     = "任务|*.task";
            ofd.DefaultExt = "task";
            bool ret = ofd.ShowDialog(this) ?? false;

            if (!ret)
            {
                return;
            }
            spider = new HttpImageBfsSpider();


            FileStream     fs  = new FileStream(ofd.FileName, FileMode.Open);
            ZipInputStream zis = new ZipInputStream(fs);
            ZipEntry       ze  = zis.GetNextEntry();

            MemoryStream ms = new MemoryStream();

            byte[] buff = new byte[1024 * 128];

            while (true)
            {
                int readlen = zis.Read(buff, 0, 1024 * 128);
                if (readlen == 0)
                {
                    break;
                }
                ms.Write(buff, 0, readlen);
            }
            zis.Close();
            fs.Close();

            ms.Seek(0, SeekOrigin.Begin);

            StreamReader sr = new StreamReader(ms);

            edit_url.Text           = sr.ReadLine();
            edit_savepath.Text      = sr.ReadLine();
            edit_proxy.Text         = sr.ReadLine();
            slider_timeout.Value    = int.Parse(sr.ReadLine());
            slider_trycnt.Value     = int.Parse(sr.ReadLine());
            slider_parallecnt.Value = int.Parse(sr.ReadLine());
            string[] que_url, com_url;
            int      que_cnt = int.Parse(sr.ReadLine());
            int      com_cnt = int.Parse(sr.ReadLine());

            text_completecnt.Text = com_cnt.ToString();
            text_queuecnt.Text    = que_cnt.ToString();
            text_errorcnt.Text    = "0";
            que_url = new string[que_cnt];
            com_url = new string[com_cnt];
            for (int i = 0; i < que_cnt; i++)
            {
                que_url[i] = sr.ReadLine();
            }
            for (int i = 0; i < com_cnt; i++)
            {
                com_url[i] = sr.ReadLine();
            }
            spider.ApplyTaskState(que_url, com_url);
            sr.Close();
            ms.Close();
        }