Пример #1
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);
            }
        }
Пример #2
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);
            }
        }
Пример #3
0
        public DItem(string url)
        {
            dInfo     = new DInfo();
            dInfo.URL = url;

            //获取UI线程同步上下文
            m_SyncContext = SynchronizationContext.Current;

            InitializeComponent();
            lbURL.Text = url;
            IsCancel   = false;
        }
Пример #4
0
        public DItem(DInfo info)
        {
            this.dInfo = info;
            //获取UI线程同步上下文
            m_SyncContext = SynchronizationContext.Current;

            InitializeComponent();
            lbURL.Text      = info.URL;
            lbTitle.Text    = info.Title;
            lbStatus.Text   = "waiting";
            lbProgress.Text = info.Current + "/" + info.CNT;
            IsCancel        = false;
        }