private void LoadDownLoadRecord()
        {
            DateTime   time    = DateTime.Now;
            SqlOperate operate = new SqlOperate();

            operate.CreateOrOpenDataBase("task.db");
            var list = operate.GetRecordList();

            Console.WriteLine("查找消耗时间:{0}", DateTime.Now.Subtract(time).Milliseconds);
            time = DateTime.Now;
            operate.CloseDataBase();

            List <DownListBox> itemList = new List <DownListBox>();

            foreach (var i in list)
            {
                DownListBox downBox = new DownListBox();
                downBox.deleteEvent         += downItem_deleteEvent;
                downBox.resumeDownLoadEvent += downItem_resumeDownLoadEvent;
                downBox.SetMaxPage(i.PageCount);  //下载最大值
                downBox.Title       = i.TaskName; //漫画名字
                downBox.Pages       = i.PageCount;
                downBox.CurrentPage = i.DownLoadProgress;
                downBox.FilePath    = i.Path;
                itemList.Add(downBox);
                downlistCollection.Add(downBox);
            }

            filePanel.Controls.AddRange(itemList.ToArray());
            Console.WriteLine("绘制消耗时间:{0}", DateTime.Now.Subtract(time).Milliseconds);
        }
Exemple #2
0
        public override CategoryInfo GiveCategoryInfo(string response)//获取漫画分类列表,一个键值对
        {
            var          dataBaseName = "task.db";
            CategoryInfo info         = new CategoryInfo();
            SqlOperate   operate      = new SqlOperate();

            operate.CreateOrOpenDataBase(dataBaseName);
            Dictionary <string, string> dict = new Dictionary <string, string>();

            if (operate.isHasTable("jingmingyanDir") == false)
            {
                operate.CreateDirTemp("jingmingyanDir");
                Regex           regex   = new Regex(@"<a\s*href='(?<href>/\w+-\w+/)'>(?<title>\w+)");
                MatchCollection collect = regex.Matches(response);

                foreach (Match m in collect)
                {
                    if (dict.ContainsKey(m.Groups["title"].Value) == false)
                    {
                        dict.Add(m.Groups["title"].Value, hostName + m.Groups["href"].Value);
                        operate.InserDirectoryLink("jingmingyanDir", m.Groups["title"].Value, hostName + m.Groups["href"].Value);
                    }
                }
            }
            else
            {
                dict = operate.GetDirectory("jingmingyanDir");
            }

            operate.CloseDataBase();
            info.ComicList = dict;
            return(info);
        }
        //添加下载记录
        private void AddDownRecord(string TaskName, string downLoadUrl, string savePath, int pageCount, int progress, int finished)
        {
            SqlOperate operate = new SqlOperate();

            operate.CreateOrOpenDataBase("task.db");
            operate.InsertData("task", TaskName, downLoadUrl, savePath, pageCount, progress, finished);
            operate.CloseDataBase();
        }
        private void UpdateDownLoadProgress(string taskName, int progress)
        {
            SqlOperate operate = new SqlOperate();

            operate.CreateOrOpenDataBase("task.db");
            operate.UpdateData("pageDownLoad", progress.ToString(), taskName);
            operate.CloseDataBase();
        }
        //删除记录
        private void DeleteDownRecord(string TaskName)
        {
            SqlOperate operate = new SqlOperate();

            operate.CreateOrOpenDataBase("task.db");
            operate.DeleteComicsTask(TaskName);
            operate.CloseDataBase();
        }
        private void DownAllFinished(object sender, DownLoadArgs args)
        {
            string     caption = args.TaskName + " 下载完成!";
            SqlOperate operate = new SqlOperate();

            operate.CreateOrOpenDataBase("task.db");
            operate.UpdateData("isFinished", "1", args.TaskName);

            this.Invoke(new Action(() =>
            {
                this.Text = caption;
            }));

            operate.CloseDataBase();
            ShowMessage(caption);
        }
        void downItem_resumeDownLoadEvent(object sender, EventArgs args)//继续下载
        {
            DownTask    task    = null;
            DownListBox listBox = sender as DownListBox;

            foreach (var i in taskQueue)
            {
                if (i.ComicName == listBox.Title)
                {
                    task = i;
                }
            }

            if (task == null)
            {
                SqlOperate operate = new SqlOperate();
                operate.CreateOrOpenDataBase("task.db");
                var list = operate.GetRecordList();

                foreach (var i in list)
                {
                    if (i.TaskName == listBox.Title)
                    {
                        List <DownLoadFile> downList = new List <DownLoadFile>();
                        DownLoadFile        file     = new DownLoadFile();
                        file.ComicName = i.TaskName;
                        file.ComicUrl  = i.Url;
                        file.SavePath  = i.Path;
                        downList.Add(file);
                        StartNewDownLoad(downList, DecoderDistrution.GiveDecoder(i.Url), i.DownLoadProgress - 1);
                    }
                }

                operate.CloseDataBase();
            }
        }