Esempio n. 1
0
        private void btnSaveV2_Click(object sender, EventArgs e)
        {
            //使用带参数的进行传递数据
            ParameterizedThreadStart pt = new ParameterizedThreadStart(SaveASV2);

            thSaveV2 = new Thread(pt);
            object obj = new Pobject()
            {
                alist         = this.afile,
                scookie       = this.txtCookie.Text.Trim(),
                scookiepath   = "/",
                scookieDomain = "www.yunfile.com"
            };

            thSaveV2.Start(obj);
        }
Esempio n. 2
0
        public void SaveASV2(object obj)
        {
            MyYunfileDelegate d = new MyYunfileDelegate(UpdateUI);

            Pobject p = (Pobject)obj;

            string[] arrList = p.alist.ToArray(); //文件的地址列表

            string strL        = string.Empty;
            string strUID      = string.Empty; //用户的ID
            string strFID      = string.Empty; //文件的ID
            string strFileName = string.Empty; //文件的名字
            string PostData    = string.Empty;

            //设置cookie
            string strCookies = p.scookie;

            //转换为Cookie对象
            CookieCollection cookies = VTS.Common.NetHelper.CreateCookies(strCookies, p.scookiepath, p.scookieDomain);

            Random rm = new Random();

            int i = 0;

            foreach (string item in arrList)
            {
                #region 1.阶段一:获取文件的ID和用户的ID

                strL        = item.Split('#')[0];
                strFileName = item.Split('#')[1];

                string[] atmep = PostClass.GetUIDFid(strL.Trim(), cookies);

                if (atmep == null)
                {
                    continue;
                }
                strUID = atmep[0];
                strFID = atmep[1];

                this.Invoke(d, "\r\n正在处理用户ID:" + strUID + ",文件ID:" + strFID + "\r\n");

                #endregion

                //让当前的线程歇一会
                if (thSaveV2 != null)
                {
                    this.Invoke(d, "第一次休息中...\n");
                    thSaveV2.Join(rm.Next(400, 900));
                }

                #region 2.阶段二:转存用户的文件信息

                //1.获得Post数据
                PostData = PostClass.CreatePOSTData(strFID, strUID, "/Share", strFileName);

                i++;

                //开始转存
                this.Invoke(d, "\r\n开始转存第" + i + "个文件...\r\n");

                string strCode = VTS.Common.NetHelper.HttpPost(strPOSTUrl, "", PostData, cookies, 1);

                this.Invoke(d, "\r\n成功啦!返回代码:" + strCode + "\r\n");

                this.Invoke(d, "\n********************分割线*******************\n");
                #endregion

                //让当前的线程歇一会
                if (thSaveV2 != null)
                {
                    this.Invoke(d, "第二次在休息中...\n");
                    thSaveV2.Join(rm.Next(300, 900));
                }
            }
            this.Invoke(d, "已经全部搞定了...\n");
        }