public static void AddTask(DItem item)
 {
     list.Add(item);
     item.SetNo(index);
     index++;
     threadPool.QueueUserWorkItem(() => { item.Run(1); });
 }
Beispiel #2
0
        private void 导入全部任务ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (openFileDialog1.ShowDialog() != DialogResult.OK)
            {
                return;
            }
            string       filename = openFileDialog1.FileName;
            StreamReader reader   = new StreamReader(filename);

            while (true)
            {
                string line = reader.ReadLine();

                if (string.IsNullOrEmpty(line))
                {
                    MessageBox.Show("Load completed!");
                    break;
                }

                string l1       = line;
                string url      = reader.ReadLine();
                string title    = reader.ReadLine();
                string progress = reader.ReadLine();
                string status   = reader.ReadLine();
                string l2       = reader.ReadLine();

                url      = url.Replace("URL:", "");
                title    = title.Replace("Title:", "");
                progress = progress.Replace("Progress:", "");

                //// 总记录为零 说明下载错误
                //if(progress.Substring(progress.IndexOf("/") + 1)=="0")
                //{
                //    continue;
                //}
                DInfo info = new DInfo();
                info.URL     = url;
                info.Title   = title;
                info.Current = int.Parse(progress.Substring(0, progress.IndexOf("/")));

                if (status.Contains("Limit Error") && info.Current > 1)
                {
                    info.Current--;
                }

                info.CNT = int.Parse(progress.Substring(progress.IndexOf("/") + 1));

                //if (!line.StartsWith("URL:"))
                //{
                //    continue;
                //}

                url = url.Replace("URL:", "");

                DItem item = new DItem(info);

                AddTask(item);
            }
        }
Beispiel #3
0
        private void AddTask(string url)
        {
            DItem item = new DItem(url);

            item.Width = this.flowLayoutPanel1.Width - 25;
            this.flowLayoutPanel1.Controls.Add(item);
            ThreadManager.AddTask(item);
        }
Beispiel #4
0
        private void 导入任务记录ToolStripMenuItem1_Click(object sender, EventArgs e)
        {
            MessageBox.Show("导入任务记录会将任务记录数据全部重新下载,用来处理Ehentai,每日限量导致错误。");

            if (openFileDialog1.ShowDialog() != DialogResult.OK)
            {
                return;
            }
            string       filename = openFileDialog1.FileName;
            StreamReader reader   = new StreamReader(filename);

            while (true)
            {
                string line = reader.ReadLine();

                if (string.IsNullOrEmpty(line))
                {
                    MessageBox.Show("Load completed!");
                    break;
                }

                string l1       = line;
                string url      = reader.ReadLine();
                string title    = reader.ReadLine();
                string progress = reader.ReadLine();
                string status   = reader.ReadLine();
                string l2       = reader.ReadLine();

                //if (!line.StartsWith("URL:"))
                //{
                //    continue;
                //}

                url      = url.Replace("URL:", "");
                title    = title.Replace("Title:", "");
                progress = progress.Replace("Progress:", "");
                bool needImp = status.Contains("Error") || status.Contains("running") || status.Contains("waiting");
                if (!needImp)
                {
                    continue;
                }
                DInfo info = new DInfo();
                info.URL     = url;
                info.Title   = title;
                info.Current = int.Parse(progress.Substring(0, progress.IndexOf("/")));
                if (info.Current > 1)
                {
                    info.Current--;
                }
                info.CNT = int.Parse(progress.Substring(progress.IndexOf("/") + 1));
                DItem item = new DItem(info);

                AddTask(item);
            }
        }
 public static void Remove(DItem item)
 {
     list.Remove(item);
 }
 public static void ReStart(DItem item)
 {
     threadPool.QueueUserWorkItem(() => { item.Run(1); });
 }
Beispiel #7
0
 private void AddTask(DItem item)
 {
     item.Width = this.flowLayoutPanel1.Width - 25;
     this.flowLayoutPanel1.Controls.Add(item);
     ThreadManager.AddTask(item);
 }
Beispiel #8
0
 public void RemoveTask(DItem item)
 {
     this.flowLayoutPanel1.Controls.Remove(item);
     ThreadManager.Remove(item);
     ThreadManager.FlushNo();
 }