コード例 #1
0
        /// <summary>
        /// 根据Type获取自己的收藏,只能由MainThread执行
        /// </summary>
        /// <param name="reParame"></param>
        /// <param name="type"></param>
        protected void GetCollectionByType(RequestParameEntity reParame, string type, string url)
        {
            GetTypeStr = type;

            var listUrl = url + type;

            EachListPage(listUrl, DownContentType.OwnCollection, new Action <string>(itemUrl =>
            {
                if (!Mut.IsContinue)
                {
                    return;
                }

                itemUrl = HtmlHelp.NeedHost(listUrl, itemUrl);

                var ri = new RequestItemParameEntity()
                {
                    ItemUrl = itemUrl, SavePath = reParame.SavePath
                };

                if (IsSingle)
                {
                    GetWorksItem(ri);
                }
                else
                {
                    while (!Mut.DoDownAction(ri, GetWorksItem) && Mut.IsContinue)
                    {
                        Thread.Sleep(1000);
                    }
                }
            }));
        }
コード例 #2
0
        /// <summary>
        /// 获取单个画师,只能由DoGetThread执行
        /// </summary>
        /// <param name="listUrl">画师作品列表页</param>
        protected void GetSingle(object objParame)
        {
            try
            {
                if (!Mut.IsContinue)
                {
                    return;
                }

                //因为循环里没有做修改,所有可以放外面
                var parame = (RequestParameEntity)objParame;

                MyForm.BeginInvoke(new Action(() => { MyForm.RtxtSuccess.Text = ""; }));

                if (IsSingle)
                {
                    MyForm.Invoke(new Action(() => { MyForm.TxtSavePath.Text = parame.SavePath; }));
                }

                EachListPage(parame.ListUrl, DownContentType.SinglePainter, new Action <string>(itemUrl =>
                {
                    if (!Mut.IsContinue)
                    {
                        return;
                    }

                    itemUrl = HtmlHelp.NeedHost(parame.ListUrl, itemUrl);

                    var ri = new RequestItemParameEntity()
                    {
                        ItemUrl = itemUrl, SavePath = parame.SavePath
                    };

                    if (IsSingle)
                    {
                        GetWorksItem(ri);
                    }
                    else
                    {
                        while (!Mut.DoDownAction(ri, GetWorksItem) && Mut.IsContinue)
                        {
                            Thread.Sleep(1000);
                        }
                    }
                }));
            }
            catch (Exception ex)
            {
                AddErrorMsg(ex.Message + "\r\n");
                HtmlHelp.SaveStringToTxt(ex.Message + "\r\n" + ex.StackTrace + "\r\n\r\n", "Error.txt");
            }
            finally
            {
                //if (!IsSingle)
                //{
                //    Mut.RemoveGThread();
                //}
            }
        }
コード例 #3
0
        /// <summary>
        /// 下载搜索
        /// Url 必须是完整的地址,只能由MainThread执行
        /// </summary>
        /// <param name="objParame"></param>
        private void GetSearch(object objParame)
        {
            try
            {
                var parame = (RequestParameEntity)objParame;
                EachListPage(parame.ListUrl, DownContentType.GetSearch, new Action <string>(itemUrl =>
                {
                    if (!Mut.IsContinue)
                    {
                        return;
                    }

                    itemUrl = "/member_illust.php?mode=medium&illust_id=" + itemUrl;
                    itemUrl = HtmlHelp.NeedHost(parame.ListUrl, itemUrl);

                    //都下载同一个地方,不用克隆
                    var ri = new RequestItemParameEntity()
                    {
                        ItemUrl = itemUrl, SavePath = parame.SavePath
                    };

                    if (IsSingle)
                    {
                        GetWorksItem(ri);
                    }
                    else
                    {
                        while (!Mut.DoDownAction(ri, GetWorksItem) && Mut.IsContinue)
                        {
                            Thread.Sleep(1000);
                        }
                    }
                }));
            }
            catch (Exception ex)
            {
                AddErrorMsg(ex.Message + "\r\n");
                HtmlHelp.SaveStringToTxt(ex.Message + "\r\n" + ex.StackTrace + "\r\n\r\n", "Error.txt");
            }
            finally
            {
                if (MainThread != null && MainThread.IsAlive)
                {
                    MainThread.Abort();
                }
            }
        }