예제 #1
0
 private void ascunde()
 {
     if (button1.InvokeRequired)
     {
         var d = new delegate2(ascunde);
         Invoke(d);
     }
     else
     {
         button1.Show();
         button2.Hide();
     }
 }
예제 #2
0
    void Start()
    {
        delegate1 d1 = new delegate1(show);

        d1 += new delegate1(hoge);
        d1 += new delegate1(fuga);
        d1();

        delegate2 d2 = new delegate2(piyo);

        print(d2(2, 10));

        //いままで 
        delegate3 d3 = new delegate3(ShowShow);

        d3(5);

        //匿名メソッド
        delegate3 d3s = delegate(int i){ print(i); };

        d3s(10);

        delegate3 d3ss = delegate(int i)
        {
            if (i > 10)
            {
                print("10より大きいです");
            }
            else
            {
                print("10以下です");
            }
        };

        d3ss(36);


        delegate6 d6 = () => { show(); };

        d6();
        delegate7 d7 = (x) => { return(ShowShowShow(x)); };

        d7(3);
    }
예제 #3
0
 void f2()
 {
     try
     {
         if (coada.InvokeRequired)
         {
             var d = new delegate2(f2);
             Invoke(d);
         }
         else
         {
             foreach (Control da in coada.DaPiese())
             {
                 da.SetBounds(da.Location.X - 1, da.Location.Y, da.Width, da.Height);
             }
         }
     }
     catch (NullReferenceException)
     {
     }
 }
예제 #4
0
        public void deleteURL()
        {
            if (urlList.InvokeRequired)
            {
                delegate2 sl = new delegate2(delegate()
                {
                    for (int i = urlList.CheckedItems.Count - 1; i >= 0; i--)
                    {
                        urlList.Items.Remove(urlList.CheckedItems[i]);
                    }
                });
                urlList.Invoke(sl);
            }
            else
            {
                for (int i = urlList.CheckedItems.Count - 1; i >= 0; i--)
                {
                    urlList.Items.Remove(urlList.CheckedItems[i]);
                }
            }

            /*
             * string strCollected = string.Empty;
             * for (int i = 0; i < urlList.Items.Count; i++)
             * {
             *  if (strCollected == string.Empty)
             *  {
             *      strCollected = urlList.GetItemText(urlList.Items[i]);
             *  }
             *  else
             *  {
             *      strCollected += "\n" + urlList.GetItemText(urlList.Items[i]);
             *  }
             * }
             * writeFile(System.Environment.CurrentDirectory + "\\" + "urlList", strCollected);
             * */
        }
예제 #5
0
파일: Form1.cs 프로젝트: daiyyr/yueavac
        private void textBox1_TextChanged(object sender, EventArgs e)
        {
            if (textBox1.Text.Length == 5)
            {
                gVerificationCode[gThreadNoOfVerificationCodeToBeEntered] = textBox1.Text.Substring(0, 5);
                if (textBox1.InvokeRequired)
                {
                    delegate2 sl = new delegate2(delegate()
                    {
                        textBox1.ReadOnly = true;
                        pictureBox1.Visible = false;
                        pictureBox1.ImageLocation = "";
                    });
                    textBox1.Invoke(sl);
                }
                else
                {
                    textBox1.ReadOnly = true;
                    pictureBox1.Visible = false;
                    pictureBox1.ImageLocation = "";
                }
                gThreadNoOfVerificationCodeToBeEntered = -1;

            //        ThreadStart starter = delegate { autoT2(gThreadNoOfVerificationCodeToBeEntered); };
            //        new Thread(starter).Start();

            }
        }
예제 #6
0
파일: Form1.cs 프로젝트: daiyyr/yueavac
 private void button1_Click(object sender, EventArgs e)
 {
     if (textBox1.InvokeRequired)
     {
         delegate2 sl = new delegate2(delegate()
         {
             textBox1.Text = "";
             textBox1.ReadOnly = false;
             textBox1.Focus();
             label6.Visible = true;
         });
         textBox1.Invoke(sl);
     }
     else
     {
         textBox1.Text = "";
         textBox1.ReadOnly = false;
         textBox1.Focus();
         label6.Visible = true;
     }
 }
예제 #7
0
파일: Form1.cs 프로젝트: daiyyr/yueavac
 public void showVerificationCode(string respHtml, int threadNo)
 {
     string cCodeGuid = "";
     reg = @"(?<=MyCaptchaImage.aspx\?guid=).*?(?="" border=)";
     myMatch = (new Regex(reg)).Match(respHtml);
     if (myMatch.Success)
     {
         cCodeGuid = myMatch.Groups[0].Value;
     }
     lock (pictureBox1)
     {
         while (gThreadNoOfVerificationCodeToBeEntered != -1)
         {
             Thread.Sleep(50);
         }
         gThreadNoOfVerificationCodeToBeEntered = threadNo;
         if (textBox1.InvokeRequired)
         {
             delegate2 sl = new delegate2(delegate()
             {
                 pictureBox1.ImageLocation = @"https://www.visaservices.in/DIAC-China-Appointment_new/AppScheduling/MyCaptchaImage.aspx?guid=" + cCodeGuid;
                 pictureBox1.Refresh();
                 pictureBox1.Visible = true;
                 textBox1.Text = "";
                 textBox1.ReadOnly = false;
                 textBox1.Focus();
                 label6.Text = "线程" + threadNo.ToString() + ":请输入验证码";
                 label6.Visible = true;
             });
             textBox1.Invoke(sl);
         }
         else
         {
             pictureBox1.ImageLocation = @"https://www.visaservices.in/DIAC-China-Appointment_new/AppScheduling/MyCaptchaImage.aspx?guid=" + cCodeGuid;
             pictureBox1.Refresh();
             pictureBox1.Visible = true;
             textBox1.Text = "";
             textBox1.ReadOnly = false;
             textBox1.Focus();
             label6.Text = "线程" + threadNo.ToString() + ":请输入验证码";
             label6.Visible = true;
         }
     }
 }
예제 #8
0
        public void addIds()
        {
            OpenFileDialog fileDialog = new OpenFileDialog();
            fileDialog.Filter = "(*.txt)|*.txt|(*.html)|*.html";

            if (urlList.InvokeRequired)
            {
                delegate2 sl = new delegate2(delegate()
                {
                    //打开对话框, 判断用户是否正确的选择了文件
                    if (fileDialog.ShowDialog() == DialogResult.OK)
                    {

                        //获取用户选择文件的后缀名
                        //    string extension = Path.GetExtension(fileDialog.FileName);
                        //声明允许的后缀名
                        //    string[] str = new string[] { ".txt", ".html" };
                        //    if (!str.Contains(extension))
                        //    {
                        //        MessageBox.Show("仅能上传txt,html格式的文件!");
                        //    }
                        //}

                        //获取用户选择的文件,并判断文件大小不能超过20K,fileInfo.Length是以字节为单位的
                        FileInfo fileInfo = new FileInfo(fileDialog.FileName);
                        if (fileInfo.Length > 204800)
                        {
                            MessageBox.Show("上传的文件不能大于200K");
                        }
                        else
                        {
                            //在这里就可以写获取到正确文件后的代码了
                            string[] lines = File.ReadAllLines(fileDialog.FileName);
                            foreach (string line in lines)
                            {
                                if (line.Length == 0)
                                {
                                    continue;
                                }
                                if ((line.Length>0 && line.Length < 4) ||!line.Substring(0, 4).Equals("1-1-"))
                                {
                                    MessageBox.Show("文件格式错误,导入中止!");
                                    break;
                                }
                                else
                                {
                                    urlList.Items.Add(line.Substring(4, line.Length - 4));
                                }
                            }
                        }
                    }
                });
                urlList.Invoke(sl);
            }
            else //do not use delegate
            {
                if (fileDialog.ShowDialog() == DialogResult.OK)
                    {
                        FileInfo fileInfo = new FileInfo(fileDialog.FileName);
                        if (fileInfo.Length > 204800)
                        {
                            MessageBox.Show("上传的文件不能大于200K");
                        }
                        else
                        {
                            string[] lines = File.ReadAllLines(fileDialog.SafeFileName);
                            foreach (string line in lines)
                            {
                                if (!line.Substring(0, 4).Equals("1-1-"))
                                {
                                    MessageBox.Show("文件格式错误!");
                                    break;
                                }
                                else
                                {
                                    urlList.Items.Add(line.Substring(4, line.Length - 4));
                                }
                            }
                        }
                    }
                }
        }
예제 #9
0
        public void multiBook()
        {
            string respHtml;

            if (!requireVeriCode)//        daiyyr
            {
                // jump to verification
            }
            else
            {
                //post eventId to get the verification code page
                respHtml = Form1.weLoveYue(
                    form1,
                    "http://aksale.advs.jp/cp/akachan_sale_pc/captcha.cgi",
                    "POST",
                    "http://aksale.advs.jp/cp/akachan_sale_pc/search_event_list.cgi?area2=" + countyForMulti + "&event_type=" + sizeType + "&sid=" + shopForMulti + "&kmws=",
                    false,
                    "sbmt=%97%5C%96%F1&event_id=" + eventId + "&event_type=6",
                    ref cookieContainer,
                    false
                    );


                //show verification code

                //<img src="./captcha/144445570520561.jpeg" alt="画像認証" /><br />
                //http://aksale.advs.jp/cp/akachan_sale_pc/captcha/144445570520561.jpeg

                string cCodeGuid = "";
                rgx     = @"(?<=img src=""\./captcha/)\d+?(?=\.jpeg)";
                myMatch = (new Regex(rgx)).Match(respHtml);
                if (myMatch.Success)
                {
                    cCodeGuid = myMatch.Groups[0].Value;
                }
                lock (form1.pictureBox1)
                {
                    if (form1.textBox2.InvokeRequired)
                    {
                        delegate2 sl = new delegate2(delegate()
                        {
                            form1.pictureBox1.ImageLocation = @"http://aksale.advs.jp/cp/akachan_sale_pc/captcha/" + cCodeGuid + ".jpeg";
                            form1.textBox2.Text             = "";
                            form1.textBox2.ReadOnly         = false;
                            form1.textBox2.Focus();
                            form1.label9.Text    = "cardNo" + appointment.CardNo + ":请输入验证码";
                            form1.label9.Visible = true;
                        });
                        form1.textBox2.Invoke(sl);
                    }
                    else
                    {
                        form1.pictureBox1.ImageLocation = @"http://aksale.advs.jp/cp/akachan_sale_pc/captcha/" + cCodeGuid + ".jpeg";
                        form1.textBox2.Text             = "";
                        form1.textBox2.ReadOnly         = false;
                        form1.textBox2.Focus();
                        form1.label9.Text    = "cardNo" + appointment.CardNo + ":请输入验证码";
                        form1.label9.Visible = true;
                    }

                    while (form1.textBox2.Text.Length < 5)
                    {
                        Thread.Sleep(30);
                    }

                    verificationCode = form1.textBox2.Text.Substring(0, 5);
                    if (form1.textBox2.InvokeRequired)
                    {
                        delegate2 sl = new delegate2(delegate()
                        {
                            form1.textBox2.ReadOnly         = true;
                            form1.pictureBox1.ImageLocation = @"";
                            form1.label9.Visible            = false;
                        });
                        form1.textBox2.Invoke(sl);
                    }
                    else
                    {
                        form1.textBox2.ReadOnly         = true;
                        form1.pictureBox1.ImageLocation = @"";
                        form1.label9.Visible            = false;
                    }
                }// end of lock picturebox1


                //submit the veri code
                respHtml = Form1.weLoveYue(
                    form1,
                    "http://aksale.advs.jp/cp/akachan_sale_pc/_mail.cgi",
                    "POST",
                    "http://aksale.advs.jp/cp/akachan_sale_pc/captcha.cgi",
                    false,
                    "input_captcha=" + verificationCode + "&sbmt=%8E%9F%82%D6&event_id=" + eventId + "&event_type=" + sizeType,
                    ref cookieContainer,
                    false
                    );



                while (respHtml.Contains("captcha"))
                {
                    form1.setLogT("CardNo" + appointment.CardNo + ", 验证码错误!请重新输入");
                    rgx     = @"(?<=img src=""\./captcha/)\d+?(?=\.jpeg)";
                    myMatch = (new Regex(rgx)).Match(respHtml);
                    if (myMatch.Success)
                    {
                        cCodeGuid = myMatch.Groups[0].Value;
                    }
                    lock (form1.pictureBox1)
                    {
                        if (form1.textBox2.InvokeRequired)
                        {
                            delegate2 sl = new delegate2(delegate()
                            {
                                form1.pictureBox1.ImageLocation = @"http://aksale.advs.jp/cp/akachan_sale_pc/captcha/" + cCodeGuid + ".jpeg";
                                form1.textBox2.Text             = "";
                                form1.textBox2.ReadOnly         = false;
                                form1.textBox2.Focus();
                                form1.label9.Text    = "CardNo" + appointment.CardNo + ":请输入验证码";
                                form1.label9.Visible = true;
                            });
                            form1.textBox2.Invoke(sl);
                        }
                        else
                        {
                            form1.pictureBox1.ImageLocation = @"http://aksale.advs.jp/cp/akachan_sale_pc/captcha/" + cCodeGuid + ".jpeg";
                            form1.textBox2.Text             = "";
                            form1.textBox2.ReadOnly         = false;
                            form1.textBox2.Focus();
                            form1.label9.Text    = "CardNo" + appointment.CardNo + ":请输入验证码";
                            form1.label9.Visible = true;
                        }

                        while (form1.textBox2.Text.Length < 5)
                        {
                            Thread.Sleep(30);
                        }

                        verificationCode = form1.textBox2.Text.Substring(0, 5);
                        if (form1.textBox2.InvokeRequired)
                        {
                            delegate2 sl = new delegate2(delegate()
                            {
                                form1.textBox2.ReadOnly         = true;
                                form1.pictureBox1.ImageLocation = @"";
                                form1.label9.Visible            = false;
                            });
                            form1.textBox2.Invoke(sl);
                        }
                        else
                        {
                            form1.textBox2.ReadOnly         = true;
                            form1.pictureBox1.ImageLocation = @"";
                            form1.label9.Visible            = false;
                        }
                    }// end of lock picturebox1

                    //submit the veri code
                    respHtml = Form1.weLoveYue(
                        form1,
                        "http://aksale.advs.jp/cp/akachan_sale_pc/_mail.cgi",
                        "POST",
                        "http://aksale.advs.jp/cp/akachan_sale_pc/captcha.cgi",
                        false,
                        "input_captcha=" + verificationCode + "&sbmt=%8E%9F%82%D6&event_id=" + eventId + "&event_type=" + sizeType,
                        ref cookieContainer,
                        false
                        );
                } //end of while wrong code
            }     //end of if need vervification code


            //post email
            respHtml = Form1.weLoveYue(
                form1,
                "https://aksale.advs.jp/cp/akachan_sale_pc/mail_form.cgi"
                ,
                "POST",
                requireVeriCode ? "http://aksale.advs.jp/cp/akachan_sale_pc/_mail.cgi" :
                ("http://aksale.advs.jp/cp/akachan_sale_pc/_mail.cgi?sbmt=%97%5C%96%F1&event_id=" + eventId + "&event_type=" + sizeType)
                ,
                false,
                "mail1=" + mail.address.Replace("@", "%40") + "&mail2=" + mail.address.Replace("@", "%40") + "&sbmt=%8E%9F%82%D6&event_id=" + eventId + "&event_type=" + sizeType,
                //    "mail1=15985830370%40163.com&mail2=15985830370%40163.com&sbmt=%8E%9F%82%D6&event_id=5393381489&event_type=6"
                ref cookieContainer,
                false
                );

            respHtml = Form1.weLoveYue(
                form1,
                "https://aksale.advs.jp/cp/akachan_sale_pc/mail_confirm.cgi"
                ,
                "POST",
                "https://aksale.advs.jp/cp/akachan_sale_pc/mail_form.cgi",
                false,
                "sbmt=%91%97%90M&mail1=" + mail.address.Replace("@", "%2540").Replace(".", "%252e") + "&mail2=" + mail.address.Replace("@", "%2540").Replace(".", "%252e") + "&event_id=" + eventId + "&event_type=" + sizeType,
                //    sbmt=%91%97%90M&mail1=15985830370%2540163%252ecom&mail2=15985830370%2540163%252ecom&event_id=7938283049&event_type=6
                ref cookieContainer,
                false
                );


            if (respHtml.Contains("下記メールアドレスにメールを送信しました"))
            {
                form1.setLogtRed("CardNo" + appointment.CardNo + ", step1 succeed, checking email: " + mail.address);
            }
            else
            {
                form1.setLogtRed("CardNo" + appointment.CardNo + ", email submitting failed: " + mail.address);
                return;
            }


            keyURL = mail.queery("ご注文予約案内", @"https://aksale(\s|\S)+?(?=\r)");

            setAppointment(mail.address, keyURL);

            return;
        }
예제 #10
0
        public void multiBook()
        {
            string respHtml;

            if (!requireVeriCode)//        daiyyr
            {
                // jump to verification
            }
            else
            {

                //post eventId to get the verification code page
                respHtml = Form1.weLoveYue(
                form1,
                "http://aksale.advs.jp/cp/akachan_sale_pc/captcha.cgi",
                "POST",
                "http://aksale.advs.jp/cp/akachan_sale_pc/search_event_list.cgi?area2=" + countyForMulti + "&event_type=" + sizeType + "&sid=" + shopForMulti + "&kmws=",
                false,
                "sbmt=%97%5C%96%F1&event_id=" + eventId + "&event_type=6",
               ref  cookieContainer,
                false
                );

                //show verification code

                //<img src="./captcha/144445570520561.jpeg" alt="画像認証" /><br />
                //http://aksale.advs.jp/cp/akachan_sale_pc/captcha/144445570520561.jpeg

                string cCodeGuid = "";
                rgx = @"(?<=img src=""\./captcha/)\d+?(?=\.jpeg)";
                myMatch = (new Regex(rgx)).Match(respHtml);
                if (myMatch.Success)
                {
                    cCodeGuid = myMatch.Groups[0].Value;
                }
                lock (form1.pictureBox1)
                {

                    if (form1.textBox2.InvokeRequired)
                    {
                        delegate2 sl = new delegate2(delegate()
                        {
                            form1.pictureBox1.ImageLocation = @"http://aksale.advs.jp/cp/akachan_sale_pc/captcha/" + cCodeGuid + ".jpeg";
                            form1.textBox2.Text = "";
                            form1.textBox2.ReadOnly = false;
                            form1.textBox2.Focus();
                            form1.label9.Text = "cardNo" + appointment.CardNo + ":请输入验证码";
                            form1.label9.Visible = true;
                        });
                        form1.textBox2.Invoke(sl);
                    }
                    else
                    {
                        form1.pictureBox1.ImageLocation = @"http://aksale.advs.jp/cp/akachan_sale_pc/captcha/" + cCodeGuid + ".jpeg";
                        form1.textBox2.Text = "";
                        form1.textBox2.ReadOnly = false;
                        form1.textBox2.Focus();
                        form1.label9.Text = "cardNo" + appointment.CardNo + ":请输入验证码";
                        form1.label9.Visible = true;
                    }

                    while (form1.textBox2.Text.Length < 5)
                    {
                        Thread.Sleep(30);
                    }

                    verificationCode = form1.textBox2.Text.Substring(0, 5);
                    if (form1.textBox2.InvokeRequired)
                    {
                        delegate2 sl = new delegate2(delegate()
                        {
                            form1.textBox2.ReadOnly = true;
                            form1.pictureBox1.ImageLocation = @"";
                            form1.label9.Visible = false;
                        });
                        form1.textBox2.Invoke(sl);
                    }
                    else
                    {
                        form1.textBox2.ReadOnly = true;
                        form1.pictureBox1.ImageLocation = @"";
                        form1.label9.Visible = false;
                    }
                }// end of lock picturebox1

                //submit the veri code
                respHtml = Form1.weLoveYue(
                form1,
                "http://aksale.advs.jp/cp/akachan_sale_pc/_mail.cgi",
                "POST",
                "http://aksale.advs.jp/cp/akachan_sale_pc/captcha.cgi",
                false,
                "input_captcha=" + verificationCode + "&sbmt=%8E%9F%82%D6&event_id=" + eventId + "&event_type=" + sizeType,
               ref  cookieContainer,
                false
                );

                while (respHtml.Contains("captcha"))
                {
                    form1.setLogT("CardNo" + appointment.CardNo + ", 验证码错误!请重新输入");
                    rgx = @"(?<=img src=""\./captcha/)\d+?(?=\.jpeg)";
                    myMatch = (new Regex(rgx)).Match(respHtml);
                    if (myMatch.Success)
                    {
                        cCodeGuid = myMatch.Groups[0].Value;
                    }
                    lock (form1.pictureBox1)
                    {

                        if (form1.textBox2.InvokeRequired)
                        {
                            delegate2 sl = new delegate2(delegate()
                            {
                                form1.pictureBox1.ImageLocation = @"http://aksale.advs.jp/cp/akachan_sale_pc/captcha/" + cCodeGuid + ".jpeg";
                                form1.textBox2.Text = "";
                                form1.textBox2.ReadOnly = false;
                                form1.textBox2.Focus();
                                form1.label9.Text = "CardNo" + appointment.CardNo + ":请输入验证码";
                                form1.label9.Visible = true;
                            });
                            form1.textBox2.Invoke(sl);
                        }
                        else
                        {
                            form1.pictureBox1.ImageLocation = @"http://aksale.advs.jp/cp/akachan_sale_pc/captcha/" + cCodeGuid + ".jpeg";
                            form1.textBox2.Text = "";
                            form1.textBox2.ReadOnly = false;
                            form1.textBox2.Focus();
                            form1.label9.Text = "CardNo" + appointment.CardNo + ":请输入验证码";
                            form1.label9.Visible = true;
                        }

                        while (form1.textBox2.Text.Length < 5)
                        {
                            Thread.Sleep(30);
                        }

                        verificationCode = form1.textBox2.Text.Substring(0, 5);
                        if (form1.textBox2.InvokeRequired)
                        {
                            delegate2 sl = new delegate2(delegate()
                            {
                                form1.textBox2.ReadOnly = true;
                                form1.pictureBox1.ImageLocation = @"";
                                form1.label9.Visible = false;
                            });
                            form1.textBox2.Invoke(sl);
                        }
                        else
                        {
                            form1.textBox2.ReadOnly = true;
                            form1.pictureBox1.ImageLocation = @"";
                            form1.label9.Visible = false;
                        }
                    }// end of lock picturebox1

                    //submit the veri code
                    respHtml = Form1.weLoveYue(
                    form1,
                    "http://aksale.advs.jp/cp/akachan_sale_pc/_mail.cgi",
                    "POST",
                    "http://aksale.advs.jp/cp/akachan_sale_pc/captcha.cgi",
                    false,
                    "input_captcha=" + verificationCode + "&sbmt=%8E%9F%82%D6&event_id=" + eventId + "&event_type=" + sizeType,
                    ref cookieContainer,
                    false
                );

                }//end of while wrong code
            }//end of if need vervification code

            //post email
            respHtml = Form1.weLoveYue(
                form1,
                "https://aksale.advs.jp/cp/akachan_sale_pc/mail_form.cgi"
                ,
                "POST",
                requireVeriCode ? "http://aksale.advs.jp/cp/akachan_sale_pc/_mail.cgi" :
                ("http://aksale.advs.jp/cp/akachan_sale_pc/_mail.cgi?sbmt=%97%5C%96%F1&event_id=" + eventId + "&event_type=" + sizeType)
                ,
                false,
                "mail1=" + mail.address.Replace("@", "%40") + "&mail2=" + mail.address.Replace("@", "%40") + "&sbmt=%8E%9F%82%D6&event_id=" + eventId + "&event_type=" + sizeType,
                //    "mail1=15985830370%40163.com&mail2=15985830370%40163.com&sbmt=%8E%9F%82%D6&event_id=5393381489&event_type=6"
                ref cookieContainer,
                false
                );

            respHtml = Form1.weLoveYue(
                form1,
                "https://aksale.advs.jp/cp/akachan_sale_pc/mail_confirm.cgi"
                ,
                "POST",
                "https://aksale.advs.jp/cp/akachan_sale_pc/mail_form.cgi",
                false,
                "sbmt=%91%97%90M&mail1=" + mail.address.Replace("@", "%2540").Replace(".", "%252e") + "&mail2=" + mail.address.Replace("@", "%2540").Replace(".", "%252e") + "&event_id=" + eventId + "&event_type=" + sizeType,
                //    sbmt=%91%97%90M&mail1=15985830370%2540163%252ecom&mail2=15985830370%2540163%252ecom&event_id=7938283049&event_type=6
                ref cookieContainer,
                false
              );

            if (respHtml.Contains("下記メールアドレスにメールを送信しました"))
            {
                form1.setLogtRed("CardNo" + appointment.CardNo + ", step1 succeed, checking email: " + mail.address);
            }
            else
            {
                form1.setLogtRed("CardNo" + appointment.CardNo + ", email submitting failed: " + mail.address);
                return;
            }

            keyURL = mail.queery("ご注文予約案内", @"https://aksale(\s|\S)+?(?=\r)");

            setAppointment(mail.address, keyURL);

            return;
        }
예제 #11
0
        public void addDetails()
        {
            Applist = new List<Appointment>();

            OpenFileDialog fileDialog = new OpenFileDialog();
            fileDialog.Filter = "(*.txt)|*.txt|(*.html)|*.html";

            if (appointmentGrid.InvokeRequired)
            {
                delegate2 sl = new delegate2(delegate()
                {
                    //打开对话框, 判断用户是否正确的选择了文件
                    if (fileDialog.ShowDialog() == DialogResult.OK)
                    {
                        //获取用户选择的文件,并判断文件大小不能超过20K,fileInfo.Length是以字节为单位的
                        FileInfo fileInfo = new FileInfo(fileDialog.FileName);
                        if (fileInfo.Length > 504800)
                        {
                            MessageBox.Show("上传的文件不能大于500K");
                        }
                        else
                        {
                            //在这里就可以写获取到正确文件后的代码了
                            string[] lines = File.ReadAllLines(fileDialog.FileName, System.Text.Encoding.GetEncoding("GB18030"));
                            foreach (string line in lines)
                            {
                                if (line.Length == 0)
                                {
                                    continue;
                                }
                                else
                                {
                                    Regex regex = new Regex(@"( ){2,}");
                                    string[] s = regex.Replace(line.Trim(), " ").Split(' ');
                                    if (s.Length != 5)
                                    {
                                        setLogT("ignore invalid line: " + line); //500
                                    }
                                    else
                                    {
                                        Applist.Add(new Appointment(s[0], s[1], s[2], s[3], s[4]));
                                    }
                                }
                            }
                            if (Applist.Count > 0)
                            {
                                var source = new BindingSource();
                                source.DataSource = Applist;
                                appointmentGrid.DataSource = source;
                            }
                        }
                    }
                });
                appointmentGrid.Invoke(sl);
            }
            else //do not use delegate
            {
                if (fileDialog.ShowDialog() == DialogResult.OK)
                {
                    FileInfo fileInfo = new FileInfo(fileDialog.FileName);
                    if (fileInfo.Length > 204800)
                    {
                        MessageBox.Show("上传的文件不能大于200K");
                    }
                    else
                    {
                        string[] lines = File.ReadAllLines(fileDialog.SafeFileName);
                        foreach (string line in lines)
                        {
                            if (line.Length == 0)
                            {
                                continue;
                            }
                            else
                            {
                                Regex regex = new Regex(@"( ){2,}");
                                string[] s = regex.Replace(line.Trim(), " ").Split(' ');
                                if (s.Length != 5)
                                {
                                    setLogT("ignore invalid line: " + line); //500
                                }
                                else
                                {
                                    Applist.Add(new Appointment(s[0], s[1], s[2], s[3], s[5]));
                                }
                            }
                        }
                        if (Applist.Count > 0)
                        {
                            var source = new BindingSource();
                            source.DataSource = Applist;
                            appointmentGrid.DataSource = source;
                //            dataGridView1.
                        }
                    }
                }
            }
        }
예제 #12
0
        public void showNextAppTime()
        {
            string county = form1.selecteCounty.Shops[form1.selectedShop];        //big surprise!!! the official entrance is the encoding with s-jis of county's name, BUT, shop's name also works! And now I use shop's name with others' will narely do

            string shop = form1.selecteCounty.Sids[form1.selectedShop];
            string forTest = Form1.ToUrlEncode(
                        county,
                        System.Text.Encoding.GetEncoding("shift-jis")
                     );

            DateTime dateTime = DateTime.MinValue;
            string day = "";
            string time = "";

            string html = Form1.weLoveYue(
                form1,
                "http://aksale.advs.jp/cp/akachan_sale_pc/search_event_list.cgi?area2="
                + Form1.ToUrlEncode(
                        county,
                        System.Text.Encoding.GetEncoding("shift-jis")
                     )
                + "&event_type=" + sizeType + "&sid=" + shop + "&kmws=",

                "GET", "", false, "", ref  cookieContainer,
                false
                );

            //available
            //   <th>予約受付期間</th>
            //					<td>
            //						10/12<font color="#ff0000">(月)</font>&nbsp;13:30~10/12<font color="#ff0000">(月)</font>&nbsp;22:00<br />

            if (county == form1.selecteCounty.Shops[form1.selectedShop]
                && shop == form1.selecteCounty.Sids[form1.selectedShop]
                && sizeType == form1.selectedType)
            {
                rgx = @"(?<=<th>予約受付期間</th>\n.*\n\s*)\d+\/\d+(?=\D)";
                myMatch = (new Regex(rgx)).Match(html);
                while (myMatch.Success)
                {
                    day = myMatch.Groups[0].Value;// no available appointment
                    rgx = @"(?<=<th>予約受付期間</th>\n.*\n\s*" + day + @"(\s|\S)+?)\d+\:\d+(?=\D)";
                    Match match2 = (new Regex(rgx)).Match(html);
                    if (match2.Success)
                    {
                        time = match2.Groups[0].Value;

                        DateTimeFormatInfo dtFormat = new DateTimeFormatInfo();
                        dtFormat.ShortDatePattern = "yyyy-M-d hh:mm:ss";
                        dateTime = Convert.ToDateTime("2015-" + Regex.Match(day, @"\d+(?=\/)") + "-" + Regex.Match(day, @"(?<=\/)\d+") + " " + time + ":00");

                        //how to find the year ?

                        TimeZoneInfo jst = TimeZoneInfo.FindSystemTimeZoneById("Tokyo Standard Time");
                        TimeZoneInfo cst = TimeZoneInfo.FindSystemTimeZoneById("China Standard Time");
                        DateTime nowInTokyoTime = TimeZoneInfo.ConvertTime(DateTime.Now, jst);
                        if ((dateTime - nowInTokyoTime).TotalMinutes > -15)
                        {
                            delegate2 d111 = new delegate2(
                                delegate() {
                                    form1.label14.Text = "the nearest booking on type " + (sizeType == "6" ? "M" : "L") + " in " + form1.selecteCounty.Name + " " + county
                                    + " is on: \n" + dateTime.ToString("MM/dd HH:mm") + " Tokyo Standard Time\n"
                                    + TimeZoneInfo.ConvertTimeFromUtc(TimeZoneInfo.ConvertTimeToUtc(dateTime, jst), cst).ToString("MM/dd HH:mm")
                                    + " China Standard Time"
                                    ;
                                 }
                            );
                            form1.label14.Invoke(d111);
                            return;
                        }
                    }
                    myMatch = myMatch.NextMatch();
                }
                delegate2 d222 = new delegate2(
                    delegate() {
                        if (Regex.Match(html, @"条件に一致する予約販売が存在しません").Success)
                        {
                            form1.label14.Text = "There is no type " + (sizeType == "6" ? "M" : "L") + " in " + form1.selecteCounty.Name + " " + county;
                        }
                        else
                        {
                            form1.label14.Text = "No available booking these days on type " + (sizeType == "6" ? "M" : "L") + " in " + form1.selecteCounty.Name + " " + county;
                        }
                    }
                );
                form1.label14.Invoke(d222);
            }//end of if the search option not changed
        }
예제 #13
0
        public void startProbe()
        {
            if (form1.mailGrid.InvokeRequired)
            {
                delegate2 sl = new delegate2(delegate()
                {
                    form1.deleteMail.Enabled = false;
                    form1.deleteApp.Enabled = false;
                });
                form1.mailGrid.Invoke(sl);
            }
            else
            {
                form1.deleteMail.Enabled = false;
                form1.deleteApp.Enabled = false;
            }
            form1.setLogT("probe started. CardNo:" + appointment.CardNo + ", " + form1.selecteCounty.Name
                + " " + form1.selecteCounty.Shops[form1.selectedShop]);
            while (true)
            {
                if (Form1.gForceToStop)
                {
                    break;
                }

                int r1 = 0;
            //新潟亀田アピタ店  M
            //   http://aksale.advs.jp/cp/akachan_sale_pc/search_event_list.cgi?area2=%90V%8a%83%8c%a7&event_type=6&sid=37140&kmws=

                //アリオ上田店 M
            //   http://aksale.advs.jp/cp/akachan_sale_pc/search_event_list.cgi?area2=%92%b7%96%ec%8c%a7&event_type=6&sid=37194&kmws=
            //songben M
            //   http://aksale.advs.jp/cp/akachan_sale_pc/search_event_list.cgi?area2=%92%b7%96%ec%8c%a7&event_type=6&sid=37196&kmws=

                //ららぽーと横浜店
               // http://aksale.advs.jp/cp/akachan_sale_pc/search_event_list.cgi?area2=%90_%93%de%90%ec%8c%a7&event_type=6&sid=37139&kmws=

                //春日井店
                //http://aksale.advs.jp/cp/akachan_sale_pc/search_event_list.cgi?area2=%88%a4%92m%8c%a7&event_type=6&sid=37038&kmws=
                while ((r1 = this.probe(
                    Form1.ToUrlEncode(
                        form1.selecteCounty.Shops[form1.selectedShop],
                        System.Text.Encoding.GetEncoding("shift-jis")
                     ),
                    form1.selecteCounty.Sids[form1.selectedShop])
                    ) == -1)   //"%88%a4%92m%8c%a7", "37038"
                {

                }
                if (r1 == -5) //no available appointment
                {
                    goto delay;
                }

            delay://不写在while的开头,避免第一次就延时
                if (form1.rate.Text.Equals(""))
                {
                    Thread.Sleep(100);
                }
                else
                {
                    try{
                        if (Convert.ToInt32(form1.rate.Text) > 0){
                            Thread.Sleep(Convert.ToInt32(form1.rate.Text));
                        }
                        else
                        {
                            Thread.Sleep(100);
                        }
                    }
                    catch (Exception)
                    {
                        Thread.Sleep(100);
                    }
                }
            }//end of while
            if (form1.mailGrid.InvokeRequired)
            {
                delegate2 sl = new delegate2(delegate()
                {
                    form1.deleteMail.Enabled = true;
                });
                form1.mailGrid.Invoke(sl);
            }
            else
            {
                form1.deleteMail.Enabled = true;
            }

            Form1.gForceToStop = false;
            return;
        }
예제 #14
0
        //big surprise!!! the official entrance is the encoding with s-jis of county's name, BUT, shop's name also works! And now I use shop's name with others' will narely do
        //And the response body between them are 3 lines:
        //<a href="http://aksale.advs.jp/cp/akachan_sale_pc/search_event_detail.cgi?event_id=9782391339&area1=&area2=北海道&area3=&event_open_date=201510&kmws=">
        //<a href="http://aksale.advs.jp/cp/akachan_sale_pc/search_event_detail.cgi?event_id=9782391339&area1=&area2=旭川店&area3=&event_open_date=201510&kmws=">
        //<a href="http://aksale.advs.jp/cp/akachan_sale_pc/search_event_detail.cgi?event_id=5637179822&area1=&area2=北海道&area3=&event_open_date=201510&kmws=">
        //<a href="http://aksale.advs.jp/cp/akachan_sale_pc/search_event_detail.cgi?event_id=5637179822&area1=&area2=旭川店&area3=&event_open_date=201510&kmws=">
        //<a href="./search_shop_list.cgi?event_type=6&area1=&area2=%96k%8aC%93%b9&area3=&kmws=">戻る</a>
        //<a href="./search_shop_list.cgi?event_type=6&area1=&area2=%88%ae%90%ec%93X&area3=&kmws=">戻る</a>
        public int probe(string county, string shop)
        {
            string respHtml = Form1.weLoveYue(
                form1,
                "http://aksale.advs.jp/cp/akachan_sale_pc/search_event_list.cgi?area2=" + county + "&event_type=" + sizeType + "&sid=" + shop + "&kmws=",

                "GET", "", true, "", ref  cookieContainer,
                false
                );

            if (respHtml.Equals("Found"))
            {
                form1.setLogT("CardNo" + appointment.CardNo + ", first GET eccur an error!");
               //         return -1;
            }

            //       <input type="submit" name="sbmt" value="予約" >
            rgx = @"<input type=""submit"" name=""sbmt"" value=""";
            myMatch = (new Regex(rgx)).Match(respHtml);
            if (!myMatch.Success)
            {
                form1.setLogT("CardNo" + appointment.CardNo + ", no available appointment.");
                return -5;// no available appointment
            }

            if (respHtml.Contains("eventId") && !respHtml.Contains("captcha"))
            {
                rgx = @"(?<=\[\]\,{""eventId"":)\d+?(?=\,)";  //there will be no veri code
                requireVeriCode = false;
            }
            else
            {
                rgx = @"(?<=予約"" >\n.+event_id"" value="")\d+?(?="")";  //there will be a veri code, and we can cheeck up with captcha
                //name="event_id" value="2543729870"
                requireVeriCode = true;
            }
            myMatch = (new Regex(rgx)).Match(respHtml);
            if (myMatch.Success)
            {
                eventId = myMatch.Groups[0].Value;
            }

            //one day's book in one card, for gong cheng county
            myMatch = myMatch.NextMatch();
            while (myMatch.Success)
            {
                PaperDiaper paper = new PaperDiaper(form1, appointment, mail, county, shop , myMatch.Groups[0].Value, requireVeriCode);
                Thread t = new Thread(paper.multiBook);
                t.Start();
                myMatch = myMatch.NextMatch();
            }

            if (!respHtml.Contains("captcha"))//        daiyyr
            {
                // jump to verification
            }
            else
            {

                //post eventId to get the verification code page
                respHtml = Form1.weLoveYue(
                form1,
                "http://aksale.advs.jp/cp/akachan_sale_pc/captcha.cgi",
                "POST",
                "http://aksale.advs.jp/cp/akachan_sale_pc/search_event_list.cgi?area2=" + county + "&event_type=" + sizeType + "&sid=" + shop + "&kmws=",
                false,
                "sbmt=%97%5C%96%F1&event_id="+eventId+"&event_type=6",
               ref  cookieContainer,
                false
                );

                //show verification code

                //<img src="./captcha/144445570520561.jpeg" alt="画像認証" /><br />
                //http://aksale.advs.jp/cp/akachan_sale_pc/captcha/144445570520561.jpeg

                string cCodeGuid = "";
                rgx = @"(?<=img src=""\./captcha/)\d+?(?=\.jpeg)";
                myMatch = (new Regex(rgx)).Match(respHtml);
                if (myMatch.Success)
                {
                    cCodeGuid = myMatch.Groups[0].Value;
                }
                lock (form1.pictureBox1)
                {

                    if (form1.textBox2.InvokeRequired)
                    {
                        delegate2 sl = new delegate2(delegate()
                        {
                            form1.pictureBox1.ImageLocation = @"http://aksale.advs.jp/cp/akachan_sale_pc/captcha/" + cCodeGuid + ".jpeg";
                            form1.textBox2.Text = "";
                            form1.textBox2.ReadOnly = false;
                            form1.textBox2.Focus();
                            form1.label9.Text = "cardNo" + appointment.CardNo + ":请输入验证码";
                            form1.label9.Visible = true;
                        });
                        form1.textBox2.Invoke(sl);
                    }
                    else
                    {
                        form1.pictureBox1.ImageLocation = @"http://aksale.advs.jp/cp/akachan_sale_pc/captcha/" + cCodeGuid + ".jpeg";
                        form1.textBox2.Text = "";
                        form1.textBox2.ReadOnly = false;
                        form1.textBox2.Focus();
                        form1.label9.Text = "cardNo" + appointment.CardNo + ":请输入验证码";
                        form1.label9.Visible = true;
                    }

                    while (form1.textBox2.Text.Length < 5)
                    {
                        Thread.Sleep(30);
                    }

                    verificationCode = form1.textBox2.Text.Substring(0, 5);
                    if (form1.textBox2.InvokeRequired)
                    {
                        delegate2 sl = new delegate2(delegate()
                        {
                            form1.textBox2.ReadOnly = true;
                            form1.label9.Visible = false;
                            form1.pictureBox1.ImageLocation = @"";
                        });
                        form1.textBox2.Invoke(sl);
                    }
                    else
                    {
                        form1.textBox2.ReadOnly = true;
                        form1.label9.Visible = false;
                        form1.pictureBox1.ImageLocation = @"";
                    }
                }// end of lock picturebox1

                //submit the veri code
                respHtml = Form1.weLoveYue(
                form1,
                "http://aksale.advs.jp/cp/akachan_sale_pc/_mail.cgi",
                "POST",
                "http://aksale.advs.jp/cp/akachan_sale_pc/captcha.cgi",
                false,
                "input_captcha=" + verificationCode + "&sbmt=%8E%9F%82%D6&event_id=" + eventId + "&event_type=" + sizeType ,
               ref  cookieContainer,
                false
                );

                while (respHtml.Contains("captcha"))
                {
                    form1.setLogT("CardNo" + appointment.CardNo + ", 验证码错误!请重新输入");
                    rgx = @"(?<=img src=""\./captcha/)\d+?(?=\.jpeg)";
                    myMatch = (new Regex(rgx)).Match(respHtml);
                    if (myMatch.Success)
                    {
                        cCodeGuid = myMatch.Groups[0].Value;
                    }
                    lock (form1.pictureBox1)
                    {

                        if (form1.textBox2.InvokeRequired)
                        {
                            delegate2 sl = new delegate2(delegate()
                            {
                                form1.pictureBox1.ImageLocation = @"http://aksale.advs.jp/cp/akachan_sale_pc/captcha/" + cCodeGuid + ".jpeg";
                                form1.textBox2.Text = "";
                                form1.textBox2.ReadOnly = false;
                                form1.textBox2.Focus();
                                form1.label9.Text = "CardNo" + appointment.CardNo + ":请输入验证码";
                                form1.label9.Visible = true;
                            });
                            form1.textBox2.Invoke(sl);
                        }
                        else
                        {
                            form1.pictureBox1.ImageLocation = @"http://aksale.advs.jp/cp/akachan_sale_pc/captcha/" + cCodeGuid + ".jpeg";
                            form1.textBox2.Text = "";
                            form1.textBox2.ReadOnly = false;
                            form1.textBox2.Focus();
                            form1.label9.Text = "CardNo" + appointment.CardNo + ":请输入验证码";
                            form1.label9.Visible = true;
                        }

                        while (form1.textBox2.Text.Length < 5)
                        {
                            Thread.Sleep(30);
                        }

                        verificationCode = form1.textBox2.Text.Substring(0, 5);
                        if (form1.textBox2.InvokeRequired)
                        {
                            delegate2 sl = new delegate2(delegate()
                            {
                                form1.textBox2.ReadOnly = true;
                                form1.label9.Visible = false;
                                form1.pictureBox1.ImageLocation = @"";
                            });
                            form1.textBox2.Invoke(sl);
                        }
                        else
                        {
                            form1.textBox2.ReadOnly = true;
                            form1.label9.Visible = false;
                            form1.pictureBox1.ImageLocation = @"";
                        }
                    }// end of lock picturebox1

                    //submit the veri code
                    respHtml = Form1.weLoveYue(
                    form1,
                    "http://aksale.advs.jp/cp/akachan_sale_pc/_mail.cgi",
                    "POST",
                    "http://aksale.advs.jp/cp/akachan_sale_pc/captcha.cgi",
                    false,
                    "input_captcha=" + verificationCode + "&sbmt=%8E%9F%82%D6&event_id=" + eventId + "&event_type=" + sizeType,
                    ref cookieContainer,
                    false
                    );

                }//end of while wrong code
            }//end of if need vervification code

            //post email
            respHtml = Form1.weLoveYue(
                form1,
                "https://aksale.advs.jp/cp/akachan_sale_pc/mail_form.cgi"
                ,
                "POST",
                requireVeriCode ? "http://aksale.advs.jp/cp/akachan_sale_pc/_mail.cgi" :
                ("http://aksale.advs.jp/cp/akachan_sale_pc/_mail.cgi?sbmt=%97%5C%96%F1&event_id=" + eventId + "&event_type=" + sizeType)
                ,
                false,
                "mail1=" + mail.address.Replace("@", "%40") + "&mail2=" + mail.address.Replace("@", "%40") + "&sbmt=%8E%9F%82%D6&event_id=" + eventId + "&event_type=" + sizeType,
              //    "mail1=15985830370%40163.com&mail2=15985830370%40163.com&sbmt=%8E%9F%82%D6&event_id=5393381489&event_type=6"
                ref cookieContainer,
                false
                );

            //post email again
            respHtml = Form1.weLoveYue(
                form1,
                "https://aksale.advs.jp/cp/akachan_sale_pc/mail_confirm.cgi"
                ,
                "POST",
                "https://aksale.advs.jp/cp/akachan_sale_pc/mail_form.cgi",
                false,
                "sbmt=%91%97%90M&mail1=" + mail.address.Replace("@", "%2540").Replace(".", "%252e") + "&mail2=" + mail.address.Replace("@", "%2540").Replace(".", "%252e") + "&event_id=" + eventId + "&event_type=" + sizeType ,
              //    sbmt=%91%97%90M&mail1=15985830370%2540163%252ecom&mail2=15985830370%2540163%252ecom&event_id=7938283049&event_type=6
                ref cookieContainer,
                false
              );

            if (respHtml.Contains("下記メールアドレスにメールを送信しました"))
            {
                form1.setLogT("CardNo" + appointment.CardNo+ ", step1 succeed, checking email: " + mail.address);
            }
            else
            {
                form1.setLogtRed("CardNo" + appointment.CardNo + ", appointments closed: " + mail.address);
                return -1;
            }

            keyURL = mail.queery("ご注文予約案内", @"https://aksale(\s|\S)+?(?=\r)");
            if (keyURL == null | keyURL == "")
            {
                form1.setLogT("NULL url from email");
            }
            setAppointment(mail.address, keyURL);

            return 1;
        }
예제 #15
0
        //big surprise!!! the official entrance is the encoding with s-jis of county's name, BUT, shop's name also works! And now I use shop's name with others' will narely do
        //And the response body between them are 3 lines:

        //<a href="http://aksale.advs.jp/cp/akachan_sale_pc/search_event_detail.cgi?event_id=9782391339&area1=&area2=北海道&area3=&event_open_date=201510&kmws=">
        //<a href="http://aksale.advs.jp/cp/akachan_sale_pc/search_event_detail.cgi?event_id=9782391339&area1=&area2=旭川店&area3=&event_open_date=201510&kmws=">

        //<a href="http://aksale.advs.jp/cp/akachan_sale_pc/search_event_detail.cgi?event_id=5637179822&area1=&area2=北海道&area3=&event_open_date=201510&kmws=">
        //<a href="http://aksale.advs.jp/cp/akachan_sale_pc/search_event_detail.cgi?event_id=5637179822&area1=&area2=旭川店&area3=&event_open_date=201510&kmws=">

        //<a href="./search_shop_list.cgi?event_type=6&area1=&area2=%96k%8aC%93%b9&area3=&kmws=">戻る</a>
        //<a href="./search_shop_list.cgi?event_type=6&area1=&area2=%88%ae%90%ec%93X&area3=&kmws=">戻る</a>



        public int probe(string county, string shop)
        {
            string respHtml = Form1.weLoveYue(
                form1,
                "http://aksale.advs.jp/cp/akachan_sale_pc/search_event_list.cgi?area2=" + county + "&event_type=" + sizeType + "&sid=" + shop + "&kmws=",

                "GET", "", true, "", ref cookieContainer,
                false
                );



            if (respHtml.Equals("Found"))
            {
                form1.setLogT("CardNo" + appointment.CardNo + ", first GET eccur an error!");
                //         return -1;
            }

            //       <input type="submit" name="sbmt" value="予約" >
            rgx     = @"<input type=""submit"" name=""sbmt"" value=""";
            myMatch = (new Regex(rgx)).Match(respHtml);
            if (!myMatch.Success)
            {
                form1.setLogT("CardNo" + appointment.CardNo + ", no available appointment.");
                return(-5);// no available appointment
            }



            if (respHtml.Contains("eventId") && !respHtml.Contains("captcha"))
            {
                rgx             = @"(?<=\[\]\,{""eventId"":)\d+?(?=\,)"; //there will be no veri code
                requireVeriCode = false;
            }
            else
            {
                rgx = @"(?<=予約"" >\n.+event_id"" value="")\d+?(?="")";  //there will be a veri code, and we can cheeck up with captcha
                //name="event_id" value="2543729870"
                requireVeriCode = true;
            }
            myMatch = (new Regex(rgx)).Match(respHtml);
            if (myMatch.Success)
            {
                eventId = myMatch.Groups[0].Value;
            }

            //one day's book in one card, for gong cheng county
            myMatch = myMatch.NextMatch();
            while (myMatch.Success)
            {
                PaperDiaper paper = new PaperDiaper(form1, appointment, mail, county, shop, myMatch.Groups[0].Value, requireVeriCode);
                Thread      t     = new Thread(paper.multiBook);
                t.Start();
                myMatch = myMatch.NextMatch();
            }

            if (!respHtml.Contains("captcha"))//        daiyyr
            {
                // jump to verification
            }
            else
            {
                //post eventId to get the verification code page
                respHtml = Form1.weLoveYue(
                    form1,
                    "http://aksale.advs.jp/cp/akachan_sale_pc/captcha.cgi",
                    "POST",
                    "http://aksale.advs.jp/cp/akachan_sale_pc/search_event_list.cgi?area2=" + county + "&event_type=" + sizeType + "&sid=" + shop + "&kmws=",
                    false,
                    "sbmt=%97%5C%96%F1&event_id=" + eventId + "&event_type=6",
                    ref cookieContainer,
                    false
                    );


                //show verification code

                //<img src="./captcha/144445570520561.jpeg" alt="画像認証" /><br />
                //http://aksale.advs.jp/cp/akachan_sale_pc/captcha/144445570520561.jpeg

                string cCodeGuid = "";
                rgx     = @"(?<=img src=""\./captcha/)\d+?(?=\.jpeg)";
                myMatch = (new Regex(rgx)).Match(respHtml);
                if (myMatch.Success)
                {
                    cCodeGuid = myMatch.Groups[0].Value;
                }
                lock (form1.pictureBox1)
                {
                    if (form1.textBox2.InvokeRequired)
                    {
                        delegate2 sl = new delegate2(delegate()
                        {
                            form1.pictureBox1.ImageLocation = @"http://aksale.advs.jp/cp/akachan_sale_pc/captcha/" + cCodeGuid + ".jpeg";
                            form1.textBox2.Text             = "";
                            form1.textBox2.ReadOnly         = false;
                            form1.textBox2.Focus();
                            form1.label9.Text    = "cardNo" + appointment.CardNo + ":请输入验证码";
                            form1.label9.Visible = true;
                        });
                        form1.textBox2.Invoke(sl);
                    }
                    else
                    {
                        form1.pictureBox1.ImageLocation = @"http://aksale.advs.jp/cp/akachan_sale_pc/captcha/" + cCodeGuid + ".jpeg";
                        form1.textBox2.Text             = "";
                        form1.textBox2.ReadOnly         = false;
                        form1.textBox2.Focus();
                        form1.label9.Text    = "cardNo" + appointment.CardNo + ":请输入验证码";
                        form1.label9.Visible = true;
                    }

                    while (form1.textBox2.Text.Length < 5)
                    {
                        Thread.Sleep(30);
                    }

                    verificationCode = form1.textBox2.Text.Substring(0, 5);
                    if (form1.textBox2.InvokeRequired)
                    {
                        delegate2 sl = new delegate2(delegate()
                        {
                            form1.textBox2.ReadOnly         = true;
                            form1.label9.Visible            = false;
                            form1.pictureBox1.ImageLocation = @"";
                        });
                        form1.textBox2.Invoke(sl);
                    }
                    else
                    {
                        form1.textBox2.ReadOnly         = true;
                        form1.label9.Visible            = false;
                        form1.pictureBox1.ImageLocation = @"";
                    }
                }// end of lock picturebox1


                //submit the veri code
                respHtml = Form1.weLoveYue(
                    form1,
                    "http://aksale.advs.jp/cp/akachan_sale_pc/_mail.cgi",
                    "POST",
                    "http://aksale.advs.jp/cp/akachan_sale_pc/captcha.cgi",
                    false,
                    "input_captcha=" + verificationCode + "&sbmt=%8E%9F%82%D6&event_id=" + eventId + "&event_type=" + sizeType,
                    ref cookieContainer,
                    false
                    );



                while (respHtml.Contains("captcha"))
                {
                    form1.setLogT("CardNo" + appointment.CardNo + ", 验证码错误!请重新输入");
                    rgx     = @"(?<=img src=""\./captcha/)\d+?(?=\.jpeg)";
                    myMatch = (new Regex(rgx)).Match(respHtml);
                    if (myMatch.Success)
                    {
                        cCodeGuid = myMatch.Groups[0].Value;
                    }
                    lock (form1.pictureBox1)
                    {
                        if (form1.textBox2.InvokeRequired)
                        {
                            delegate2 sl = new delegate2(delegate()
                            {
                                form1.pictureBox1.ImageLocation = @"http://aksale.advs.jp/cp/akachan_sale_pc/captcha/" + cCodeGuid + ".jpeg";
                                form1.textBox2.Text             = "";
                                form1.textBox2.ReadOnly         = false;
                                form1.textBox2.Focus();
                                form1.label9.Text    = "CardNo" + appointment.CardNo + ":请输入验证码";
                                form1.label9.Visible = true;
                            });
                            form1.textBox2.Invoke(sl);
                        }
                        else
                        {
                            form1.pictureBox1.ImageLocation = @"http://aksale.advs.jp/cp/akachan_sale_pc/captcha/" + cCodeGuid + ".jpeg";
                            form1.textBox2.Text             = "";
                            form1.textBox2.ReadOnly         = false;
                            form1.textBox2.Focus();
                            form1.label9.Text    = "CardNo" + appointment.CardNo + ":请输入验证码";
                            form1.label9.Visible = true;
                        }

                        while (form1.textBox2.Text.Length < 5)
                        {
                            Thread.Sleep(30);
                        }

                        verificationCode = form1.textBox2.Text.Substring(0, 5);
                        if (form1.textBox2.InvokeRequired)
                        {
                            delegate2 sl = new delegate2(delegate()
                            {
                                form1.textBox2.ReadOnly         = true;
                                form1.label9.Visible            = false;
                                form1.pictureBox1.ImageLocation = @"";
                            });
                            form1.textBox2.Invoke(sl);
                        }
                        else
                        {
                            form1.textBox2.ReadOnly         = true;
                            form1.label9.Visible            = false;
                            form1.pictureBox1.ImageLocation = @"";
                        }
                    }// end of lock picturebox1

                    //submit the veri code
                    respHtml = Form1.weLoveYue(
                        form1,
                        "http://aksale.advs.jp/cp/akachan_sale_pc/_mail.cgi",
                        "POST",
                        "http://aksale.advs.jp/cp/akachan_sale_pc/captcha.cgi",
                        false,
                        "input_captcha=" + verificationCode + "&sbmt=%8E%9F%82%D6&event_id=" + eventId + "&event_type=" + sizeType,
                        ref cookieContainer,
                        false
                        );
                } //end of while wrong code
            }     //end of if need vervification code


            //post email
            respHtml = Form1.weLoveYue(
                form1,
                "https://aksale.advs.jp/cp/akachan_sale_pc/mail_form.cgi"
                ,
                "POST",
                requireVeriCode ? "http://aksale.advs.jp/cp/akachan_sale_pc/_mail.cgi" :
                ("http://aksale.advs.jp/cp/akachan_sale_pc/_mail.cgi?sbmt=%97%5C%96%F1&event_id=" + eventId + "&event_type=" + sizeType)
                ,
                false,
                "mail1=" + mail.address.Replace("@", "%40") + "&mail2=" + mail.address.Replace("@", "%40") + "&sbmt=%8E%9F%82%D6&event_id=" + eventId + "&event_type=" + sizeType,
                //    "mail1=15985830370%40163.com&mail2=15985830370%40163.com&sbmt=%8E%9F%82%D6&event_id=5393381489&event_type=6"
                ref cookieContainer,
                false
                );

            //post email again
            respHtml = Form1.weLoveYue(
                form1,
                "https://aksale.advs.jp/cp/akachan_sale_pc/mail_confirm.cgi"
                ,
                "POST",
                "https://aksale.advs.jp/cp/akachan_sale_pc/mail_form.cgi",
                false,
                "sbmt=%91%97%90M&mail1=" + mail.address.Replace("@", "%2540").Replace(".", "%252e") + "&mail2=" + mail.address.Replace("@", "%2540").Replace(".", "%252e") + "&event_id=" + eventId + "&event_type=" + sizeType,
                //    sbmt=%91%97%90M&mail1=15985830370%2540163%252ecom&mail2=15985830370%2540163%252ecom&event_id=7938283049&event_type=6
                ref cookieContainer,
                false
                );


            if (respHtml.Contains("下記メールアドレスにメールを送信しました"))
            {
                form1.setLogT("CardNo" + appointment.CardNo + ", step1 succeed, checking email: " + mail.address);
            }
            else
            {
                form1.setLogtRed("CardNo" + appointment.CardNo + ", appointments closed: " + mail.address);
                return(-1);
            }


            keyURL = mail.queery("ご注文予約案内", @"https://aksale(\s|\S)+?(?=\r)");
            if (keyURL == null | keyURL == "")
            {
                form1.setLogT("NULL url from email");
            }
            setAppointment(mail.address, keyURL);

            return(1);
        }
예제 #16
0
        public void showNextAppTime()
        {
            string county = form1.selecteCounty.Shops[form1.selectedShop];        //big surprise!!! the official entrance is the encoding with s-jis of county's name, BUT, shop's name also works! And now I use shop's name with others' will narely do

            string shop    = form1.selecteCounty.Sids[form1.selectedShop];
            string forTest = Form1.ToUrlEncode(
                county,
                System.Text.Encoding.GetEncoding("shift-jis")
                );

            DateTime dateTime = DateTime.MinValue;
            string   day      = "";
            string   time     = "";

            string html = Form1.weLoveYue(
                form1,
                "http://aksale.advs.jp/cp/akachan_sale_pc/search_event_list.cgi?area2="
                + Form1.ToUrlEncode(
                    county,
                    System.Text.Encoding.GetEncoding("shift-jis")
                    )
                + "&event_type=" + sizeType + "&sid=" + shop + "&kmws=",

                "GET", "", false, "", ref cookieContainer,
                false
                );

            //available
            //   <th>予約受付期間</th>
            //					<td>
            //						10/12<font color="#ff0000">(月)</font>&nbsp;13:30~10/12<font color="#ff0000">(月)</font>&nbsp;22:00<br />

            if (county == form1.selecteCounty.Shops[form1.selectedShop] &&
                shop == form1.selecteCounty.Sids[form1.selectedShop] &&
                sizeType == form1.selectedType)
            {
                rgx     = @"(?<=<th>予約受付期間</th>\n.*\n\s*)\d+\/\d+(?=\D)";
                myMatch = (new Regex(rgx)).Match(html);
                while (myMatch.Success)
                {
                    day = myMatch.Groups[0].Value;// no available appointment
                    rgx = @"(?<=<th>予約受付期間</th>\n.*\n\s*" + day + @"(\s|\S)+?)\d+\:\d+(?=\D)";
                    Match match2 = (new Regex(rgx)).Match(html);
                    if (match2.Success)
                    {
                        time = match2.Groups[0].Value;

                        DateTimeFormatInfo dtFormat = new DateTimeFormatInfo();
                        dtFormat.ShortDatePattern = "yyyy-M-d hh:mm:ss";
                        dateTime = Convert.ToDateTime("2015-" + Regex.Match(day, @"\d+(?=\/)") + "-" + Regex.Match(day, @"(?<=\/)\d+") + " " + time + ":00");


                        //how to find the year ?

                        TimeZoneInfo jst            = TimeZoneInfo.FindSystemTimeZoneById("Tokyo Standard Time");
                        TimeZoneInfo cst            = TimeZoneInfo.FindSystemTimeZoneById("China Standard Time");
                        DateTime     nowInTokyoTime = TimeZoneInfo.ConvertTime(DateTime.Now, jst);
                        if ((dateTime - nowInTokyoTime).TotalMinutes > -15)
                        {
                            delegate2 d111 = new delegate2(
                                delegate() {
                                form1.label14.Text = "the nearest booking on type " + (sizeType == "6" ? "M" : "L") + " in " + form1.selecteCounty.Name + " " + county
                                                     + " is on: \n" + dateTime.ToString("MM/dd HH:mm") + " Tokyo Standard Time\n"
                                                     + TimeZoneInfo.ConvertTimeFromUtc(TimeZoneInfo.ConvertTimeToUtc(dateTime, jst), cst).ToString("MM/dd HH:mm")
                                                     + " China Standard Time"
                                ;
                            }
                                );
                            form1.label14.Invoke(d111);
                            return;
                        }
                    }
                    myMatch = myMatch.NextMatch();
                }
                delegate2 d222 = new delegate2(
                    delegate() {
                    if (Regex.Match(html, @"条件に一致する予約販売が存在しません").Success)
                    {
                        form1.label14.Text = "There is no type " + (sizeType == "6" ? "M" : "L") + " in " + form1.selecteCounty.Name + " " + county;
                    }
                    else
                    {
                        form1.label14.Text = "No available booking these days on type " + (sizeType == "6" ? "M" : "L") + " in " + form1.selecteCounty.Name + " " + county;
                    }
                }
                    );
                form1.label14.Invoke(d222);
            }//end of if the search option not changed
        }
예제 #17
0
파일: Form1.cs 프로젝트: daiyyr/yueavac
        public int apply1(int threadNo)
        {
            setLogT(threadNo, "step1");

            firstpage:
            setLogT(threadNo, "get first page..");

            string respHtml = weLoveYue(
                threadNo,
                "https://www.visaservices.in/DIAC-China-Appointment_new/AppScheduling/AppWelcome.aspx?p=Gta39GFZnstZVCxNVy83zTlkvzrXE95fkjmft28XjNg%3d",
                "GET",
                "",
                true,
                "");

            reg = @"(?<=name=""__EVENTVALIDATION"" id=""__EVENTVALIDATION"" value="").*?(?="" />)";
            myMatch = (new Regex(reg)).Match(respHtml);
            if (myMatch.Success)
            {
                gEventvalidation[threadNo] = ToUrlEncode(myMatch.Groups[0].Value);
            }
            else
            {
                if (gForceToStop)
                {
                    return -4;
                }
                setLogtRed(threadNo, "getting page failed, retry..");
                goto firstpage;
            }

            reg = @"(?<=id=""__VIEWSTATE"" value="").*?(?="" />)";
            myMatch = (new Regex(reg)).Match(respHtml);
            if (myMatch.Success)
            {
                gViewstate[threadNo] = ToUrlEncode(myMatch.Groups[0].Value);
            }
            else
            {
                if (gForceToStop)
                {
                    return -4;
                }
                setLogtRed(threadNo, "getting page failed, retry..");
                goto firstpage;
            }

            makeapointment:
            setLogT(threadNo, "make a pointment..");
            respHtml = weLoveYue(
                threadNo,
                "https://www.visaservices.in/DIAC-China-Appointment_new/AppScheduling/AppWelcome.aspx?p=Gta39GFZnstZVCxNVy83zTlkvzrXE95fkjmft28XjNg%3d",
                "POST",
                "https://www.visaservices.in/DIAC-China-Appointment_new/AppScheduling/AppWelcome.aspx?p=Gta39GFZnstZVCxNVy83zTlkvzrXE95fkjmft28XjNg%3d",
                true,
                "__EVENTTARGET=ctl00%24plhMain%24lnkSchApp&__EVENTARGUMENT=&__VIEWSTATE=" + gViewstate[threadNo]
                + "&____Ticket=" + gTicket[threadNo].ToString()
                + "&__EVENTVALIDATION=" + gEventvalidation[threadNo]
                );
            gTicket[threadNo]++;

            reg = @"(?<=name=""__EVENTVALIDATION"" id=""__EVENTVALIDATION"" value="").*?(?="" />)";
            myMatch = (new Regex(reg)).Match(respHtml);
            if (myMatch.Success)
            {
                gEventvalidation[threadNo] = ToUrlEncode( myMatch.Groups[0].Value);
            }
            else
            {
                if (gForceToStop)
                {
                    return -4;
                }
                setLogtRed(threadNo, "getting page failed, retry..");
                goto makeapointment;
            }
            reg = @"(?<=id=""__VIEWSTATE"" value="").*?(?="" />)";
            myMatch = (new Regex(reg)).Match(respHtml);
            if (myMatch.Success)
            {
                gViewstate[threadNo] = ToUrlEncode( myMatch.Groups[0].Value);
            }
            else
            {
                if (gForceToStop)
                {
                    return -4;
                }
                setLogtRed(threadNo, "getting page failed, retry..");
                goto makeapointment;
            }

            setLogT(threadNo, "selecting Location: " + gVACity_raw);

            verification1:
            ThreadStart starter = delegate { showVerificationCode(respHtml, threadNo); };
            new Thread(starter).Start();

            while (gVerificationCode[threadNo] == null || gVerificationCode[threadNo] == "")
            {
                Thread.Sleep(50);
            }

            selectingLocation:
            respHtml = weLoveYue(
                threadNo,
                "https://www.visaservices.in/DIAC-China-Appointment_new/AppScheduling/AppScheduling.aspx",
                "POST",
                "https://www.visaservices.in/DIAC-China-Appointment_new/AppScheduling/AppWelcome.aspx?p=Gta39GFZnstZVCxNVy83zTlkvzrXE95fkjmft28XjNg%3d",
                true,
                "__VIEWSTATE="+gViewstate[threadNo]
                + "&ctl00%24plhMain%24cboVAC=" + gVACity
                + "&ctl00%24plhMain%24btnSubmit=%E6%8F%90%E4%BA%A4&ctl00%24plhMain%24hdnValidation1"
                + "=%E8%AF%B7%E9%80%89%E6%8B%A9%EF%BC%9A&ctl00%24plhMain%24hdnValidation2=%E7%AD%BE%E8%AF%81%E7%94%B3%E8"
                + "%AF%B7%E4%B8%AD%E5%BF%83&ctl00%24plhMain%24hdnValidation3=%E5%B1%85%E4%BD%8F%E5%9B%BD&____Ticket="+gTicket[threadNo].ToString()
                + "&__EVENTVALIDATION=" + gEventvalidation[threadNo]
                + "&ctl00%24plhMain%24mycaptchacontrol1=" + gVerificationCode[threadNo]
                );
            gTicket[threadNo]++;
            gVerificationCode[threadNo] = "";//不论输入得正确与否, 都需要清空

            reg = @"(?<=name=""__EVENTVALIDATION"" id=""__EVENTVALIDATION"" value="").*?(?="" />)";
            myMatch = (new Regex(reg)).Match(respHtml);
            if (myMatch.Success)
            {
                gEventvalidation[threadNo] = ToUrlEncode( myMatch.Groups[0].Value);
            }
            else
            {
                if (gForceToStop)
                {
                    return -4;
                }
                setLogtRed(threadNo, "getting page failed, retry..");
                goto selectingLocation;
            }

            reg = @"(?<=id=""__VIEWSTATE"" value="").*?(?="" />)";
            myMatch = (new Regex(reg)).Match(respHtml);
            if (myMatch.Success)
            {
                gViewstate[threadNo] = ToUrlEncode( myMatch.Groups[0].Value);
            }
            else
            {
                if (gForceToStop)
                {
                    return -4;
                }
                setLogtRed(threadNo, "getting page failed, retry..");
                goto selectingLocation;
            }
            if (respHtml.Contains("Please enter the correct verification code"))
            {
                if (gForceToStop)
                {
                    return -4;
                }
                setLogT(threadNo, "验证码错误!请重新输入");
                goto verification1;
            }

            delegate2 s0 = new delegate2(delegate()
            {
                setLogT(threadNo, "submitting the visa type: " + comboBox1.SelectedItem.ToString());
            });
            textBox1.Invoke(s0);

            visatype:
            respHtml = weLoveYue(
                threadNo,
                "https://www.visaservices.in/DIAC-China-Appointment_new/AppScheduling/AppSchedulingGetInfo.aspx",
                "POST",
                "https://www.visaservices.in/DIAC-China-Appointment_new/AppScheduling/AppSchedulingGetInfo.aspx",
                true,
                "__EVENTTARGET=&__EVENTARGUMENT=&__LASTFOCUS=&__VIEWSTATE=" + gViewstate[threadNo]
                +"&ctl00%24plhMain%24tbxNumOfApplicants"
                +"=1&ctl00%24plhMain%24cboVisaCategory=" + gCategory //13 for general, 17 for working and holiday
                +"&ctl00%24plhMain%24btnSubmit=%E6%8F%90%E4%BA%A4&ctl00%24plhMain"
                +"%24hdnValidation1=%E8%AF%B7%E8%BE%93%E5%85%A5%EF%BC%9A&ctl00%24plhMain%24hdnValidation2=%E6%9C%89%E6"
                +"%95%88%E4%BA%BA%E6%95%B0%E3%80%82&ctl00%24plhMain%24hdnValidation3=%E6%8A%A5%E5%90%8D%E4%BA%BA%E6%95"
                +"%B0%E5%BF%85%E9%A1%BB%E4%BB%8B%E4%BA%8E1%E5%92%8C++&ctl00%24plhMain%24hdnValidation4=%E7%AD%BE%E8%AF"
                +"%81%E7%B1%BB%E5%88%AB&____Ticket="+gTicket[threadNo].ToString()
                + "&__EVENTVALIDATION=" + gEventvalidation[threadNo]
                );
            gTicket[threadNo]++;
            gVerificationCode[threadNo] = "";//不论输入得正确与否, 都需要清空

            if (respHtml.Contains("No date(s) available for appointment.") || respHtml.Contains("无日期(S)委任"))
            {
                setLogT(threadNo, "该类别名额已满,不要灰心,备战下一次");
                return -9;
            }

            reg = @"(?<=name=""__EVENTVALIDATION"" id=""__EVENTVALIDATION"" value="").*?(?="" />)";
            myMatch = (new Regex(reg)).Match(respHtml);
            if (myMatch.Success)
            {
                gEventvalidation[threadNo] = ToUrlEncode( myMatch.Groups[0].Value);
            }
            else
            {
                if (gForceToStop)
                {
                    return -4;
                }
                setLogtRed(threadNo, "getting page failed, retry..");
                goto visatype;
            }

            reg = @"(?<=id=""__VIEWSTATE"" value="").*?(?="" />)";
            myMatch = (new Regex(reg)).Match(respHtml);
            if (myMatch.Success)
            {
                gViewstate[threadNo] = ToUrlEncode( myMatch.Groups[0].Value);
            }
            else
            {
                if (gForceToStop)
                {
                    return -4;
                }
                setLogtRed(threadNo, "getting page failed, retry..");
                goto visatype;
            }

            setLogT(threadNo, "filling in email address..");

            verification3:
            starter = delegate { showVerificationCode(respHtml, threadNo); };
            new Thread(starter).Start();

            while (gVerificationCode[threadNo] == null || gVerificationCode[threadNo] == "")
            {
                Thread.Sleep(50);
            }
            emailaddress:
            respHtml = weLoveYue(
                threadNo,
                "https://www.visaservices.in/DIAC-China-Appointment_new/AppScheduling/EmailRegistration.aspx",
                "POST",
                "https://www.visaservices.in/DIAC-China-Appointment_new/AppScheduling/AppSchedulingGetInfo.aspx",
                true,
                "__VIEWSTATE=" + gViewstate[threadNo]
                + "&__EVENTVALIDATION=" + gEventvalidation[threadNo]
                + "&ctl00%24plhMain%24txtCnfPassword="******"&ctl00%24plhMain%24txtEmailID="
                + gEmail
                + "&ctl00%24plhMain%24txtPassword="******"&ctl00%24plhMain%24ImageButton1=%E6%8F%90%E4%BA%A4"
                + "&____Ticket=" + gTicket[threadNo].ToString()
                + "&ctl00%24plhMain%24mycaptchacontrol1=" + gVerificationCode[threadNo]
                );
            gTicket[threadNo]++;
            gVerificationCode[threadNo] = "";//不论输入得正确与否, 都需要清空
            if (respHtml == "" || String.IsNullOrEmpty(respHtml)) //由于网络原因请求失败
            {
                if (gForceToStop)
                {
                    return -4;
                }
                setLogtRed(threadNo, "getting page failed, retry..");
                goto emailaddress;
            }

            if (respHtml.Contains("Please enter the correct verification code"))
            {
                setLogT(threadNo, "验证码错误!请重新输入");

                //因为这是step1的最后一步,所以只有在验证码输错的情况下才需要去获取Viewstate和Eventvalidation
                reg = @"(?<=name=""__EVENTVALIDATION"" id=""__EVENTVALIDATION"" value="").*?(?="" />)";
                myMatch = (new Regex(reg)).Match(respHtml);
                if (myMatch.Success)
                {
                    gEventvalidation[threadNo] = ToUrlEncode(myMatch.Groups[0].Value);
                }

                reg = @"(?<=id=""__VIEWSTATE"" value="").*?(?="" />)";
                myMatch = (new Regex(reg)).Match(respHtml);
                if (myMatch.Success)
                {
                    gViewstate[threadNo] = ToUrlEncode(myMatch.Groups[0].Value);
                }
                if (gForceToStop)
                {
                    return -4;
                }
                goto verification3;
            }
            else if (respHtml.Contains("请登录您的注册邮箱打开该网址"))
            {
                setLogT(threadNo, "邮件已送出, step1 finish");
                Mail163 myMail = new Mail163(threadNo, gEmail, emailPassword, this);
                urlForStep2[threadNo] = myMail.queery("Appointment Registration URL", @"https://www\.visaservices(\s|\S)+?(?=</a>)");
                return 1;
            }
            else
            {
                setLogtRed(threadNo, "未收到邮件送出回执, 仍然尝试接收邮件, 同时请再开软件继续申请");
                Thread.Sleep(3000);
                Mail163 myMail = new Mail163(threadNo, gEmail, emailPassword, this);
                urlForStep2[threadNo] = myMail.queery("Appointment Registration URL", @"https://www\.visaservices(\s|\S)+?(?=</a>)");
                return 1;
            }

            return -1;
        }
 static FileParser()
 {
     customParsingCallbacks["points"] = new delegate1(geometryContentParser);
     customParsingCallbacks["period"] = new delegate2(function2);
 }
예제 #19
0
        // test button
        private void button1_Click(object sender, EventArgs e)
        {
            // for texting indexer begin
            Form1 stringCollection = new Form1();
            // Use [] notation on the type.
            stringCollection[0] = "test indexer";
            System.Console.WriteLine(stringCollection[0]);
            // for texting indexer end

            //for safe call window form
            delegate2 tttt8987 = new delegate2(
                delegate() { }
                );
            appointmentGrid.Invoke(tttt8987);

            //new thread to run an anominous function
            Thread thread1111 = new System.Threading.Thread(
                delegate()
              {

                  string[] aaa = new string[] { "222", "333"};

                  Console.Write((int)aaaa.f);

                  //test Mail Reading
                  Mail163<PaperDiaper> testMailReading = new Mail163<PaperDiaper>("*****@*****.**", "dyyr7921129", this);
                  //      setLogT(testMailReading.queery("20151117test1", @"(\s|\S)*"));
                  setLogT(testMailReading.queeryReaded("20151117test1", @"(\s|\S)*"));

                  /*
                  foreach (TimeZoneInfo z in TimeZoneInfo.GetSystemTimeZones())
                      setLogT(z.Id);
                  */

                    rgx = @"(?<=予約"" >\n.+event_id"" value="")\d+?(?="")";  //there will be a veri code, and we can cheeck up with captcha

                    Match myM33atch = (new Regex(rgx)).Match("<input type=\"submit\" name=\"sbmt\" value=\"予約\" >\n<input type=\"hidden\" name=\"event_id\" value=\"4500175502\" ><input type=\"submit\" name=\"sbmt\" value=\"予約キャンセル\" >\n<input type=\"hidden\" name=\"event_id\" value=\"4500175502\" >");
                    while (myM33atch.Success)
                    {
                        setLogT(myM33atch.Value);
                        myM33atch = myM33atch.NextMatch();
                    }

                  /*
                  //searchMailDirectely
                  PaperDiaper paper = new PaperDiaper(
                            this,
                            new Appointment("2800056599132", "guoguo01", "李花", "りはな", "090-1234-2580"),
                            new Mail163<PaperDiaper>("*****@*****.**", "dyyr7921129", this));
                  //paper.searchMailDirectely();
                  paper.searchMailDirectelyFromReaded();
                  */

                  /*
               // let code help me making code -- get counties
                   //<option value="%96k%8aC%93%b9" >北海道</option>
                   string result22="";
                   string html = weLoveYue(
                       this,
                   "http://aksale.advs.jp/cp/akachan_sale_pc/search_shop_top.cgi?event_type=7",
                   "GET",
                   "",
                   false,
                   "",
                   ref cookieContainerForTest,
                   false);
                                           //      <option value="%96k%8aC%93%b9" >北海道</option>
                   Match match = (new Regex(@"(?<=\<option value=""(\s|\S)+?"" \>).+?(?=\<\/option)")).Match(html);
                   while(match.Success){
                       string t_county = match.Groups[0].Value;
                       result22+="Countylist.Add(new County("+"\n\""+t_county+"\",\n";
                       html = weLoveYue(
                       this,
                       "http://aksale.advs.jp/cp/akachan_sale_pc/search_shop_area3.cgi",
                       "POST",
                       "",
                       false,
                       "area2="
                           +Form1.ToUrlEncode(t_county, System.Text.Encoding.GetEncoding("shift-jis"))
                           + "&sbmt=%81%40%8C%9F%8D%F5%81%40&event_type=7",
                       ref cookieContainerForTest,
                       false
                       );
                       //<a href="./search_event_list.cgi?area2=%96k%8aC%93%b9&event_type=7&sid=37116&kmws=">旭川店</a><br />
                       string r1 = @"(?<=area2=(\s|\S)+?\&event_type=7\&sid=)\d+";
                       Match match2 = (new Regex(r1)).Match(html);
                       {
                           string t_shop = "";
                           string t_sid = "";
                           while (match2.Success)
                           {
                               t_sid += "\""+ match2.Groups[0].Value+"\", ";
                               string r2 = @"(?<=" + match2.Groups[0].Value + @"\&kmws=""\>).+?(?=\<\/a\>)";
                               Match match3 = (new Regex(r2)).Match(html);
                               t_shop += "\""+ match3.Groups[0].Value+"\", ";

                               match2 = match2.NextMatch();
                           }

                           t_shop = t_shop.Substring(0,t_shop.Length-2);
                           t_sid = t_sid.Substring(0, t_sid.Length - 2);

                           result22 += "new List<string> { " + t_shop + " },\n";
                           result22 += "new List<string> { " + t_sid + " })\n);\n";

                       }

                       match = match.NextMatch();
                   }
                   setLogT(result22);

                  */

             //       setLogT(Form1.ToUrlEncode("北海道", System.Text.Encoding.GetEncoding("shift-jis")));

                    //     %9b%c1     %94%f2%94%f2          %83t          %83C%83q%83q      090      8619      3569
                    //"&sei=%9B%C1&mei=%94%F2%94%F2&sei_kana=%83T&mei_kana=%83C%83q%83q&tel1=090&tel2=8619&tel3=3569"

                    string x1 = Form1.ToUrlEncode("崔飛飛".Substring(0, 1), System.Text.Encoding.GetEncoding("shift-jis")),
                            x2 = Form1.ToUrlEncode("崔飛飛".Substring(1, "崔飛飛".Length - 1), System.Text.Encoding.GetEncoding("shift-jis")),
                            y1 = Form1.ToUrlEncode("サイヒヒ".Substring(0, 1), System.Text.Encoding.GetEncoding("shift-jis")),
                            y2 = Form1.ToUrlEncode("サイヒヒ".Substring(1, "サイヒヒ".Length - 1), System.Text.Encoding.GetEncoding("shift-jis")),
                            z1 = Regex.Match("090-8619-3569", @"\d+(?=\-)").Value,
                            z2 = Regex.Match("090-8619-3569", @"(?<=\d+\-)\d+(?=-)").Value,
                            z3 = Regex.Match("090-8619-3569", @"(?<=\d+\-\d+\-)\d+").Value;
                    setLogT(x1 + " " + x2 + " " + y1 + " " + y2 + " " + z1 + " " + z2 + " " + z3);

                /*
                    string pattern = @"^";
                    string replacement = "1-1-";
                    string result = Regex.Replace("12345", pattern, replacement);
                    setLogT(result);

                    rgx = @"(?<=aa).*?(?=aa)";
                    myMatch = (new Regex(rgx)).Match("qqqqqaaqwdsfaafferaafe222aa2222444aa444444222faaloveaa");
                    while (myMatch.Success)
                    {
                        setLogT(myMatch.Groups[0].Value);
                        myMatch = myMatch.NextMatch();
                    }

                    string message = "4344.34334.23.24.";
                    Regex rex = new Regex(@"^(\.|\d)+$");
                    if (rex.IsMatch(message))
                    {
                        //float result2 = float.Parse(message);
                        setLogT("match");
                    }
                    else
                        setLogT("not match");

                    int aa;
                    if ((aa = 4) == 4)
                    {
                        setLogT(aa.ToString());
                    }

                    Regex regex = new Regex(@"( ){2,}");
                    setLogT(regex.Replace("22      22", " "));
                    string[] s = regex.Replace(" abc def kkk   333 ppp ".Trim(), " ").Split(' ');
                    setLogT(s.Length.ToString());

                    string test2 = "abc";
                    //       testCall(test2);
                    setLogT(test2);

                    Appointment test3 = new Appointment("159", "", "", "", "");
                    testCall(ref test3);
                    setLogT(test3.CardNo);

                    setLogT("崔飛飛 " + Form1.ToUrlEncode("崔飛飛", System.Text.Encoding.GetEncoding("shift-jis")));//Shift_JIS     ??
                    setLogT("サイヒヒ " + Form1.ToUrlEncode("サイヒヒ"));
                    setLogT("090-8619-3569 " + Form1.ToUrlEncode("090-8619-3569"));

                string respHtml = Form1.weLoveYue(
                    this,
                    "https://aksale.advs.jp/cp/akachan_sale_pc/form_card_no.cgi"
                    ,
                    "POST",
                    "https://aksale.advs.jp/cp/akachan_sale_pc/mail_form.cgi",
                    false,
                    "card_no=" + "1234567890123" + "&sbmt=%8E%9F%82%D6",
                    ref cookieContainerForTest,
                    false
                    );

                setLogT("崔飛飛 ".Length.ToString());

                    */

              });
            thread1111.Start();
        }
예제 #20
0
파일: Form1.cs 프로젝트: daiyyr/yuescount
 public void addURL()
 {
     //string P = @"^http(s)?:\/\/([\w-]+\.)+[\w-]+$";//无法匹配下级页面
     string P = @"^(https?|ftp|file)://[-a-zA-Z0-9+&@#/%?=~_|!:,.;]*[-a-zA-Z0-9+&@#/%=~_|]";
     Match M = (new Regex(P)).Match(inputT.Text);
     if (M.Success)
     {
     }else{
         MessageBox.Show("invalid url!");
         return;
     }
     if (urlList.InvokeRequired)
     {
         delegate2 sl = new delegate2(delegate()
         {
             urlList.Items.Add(inputT.Text);
             inputT.Text = "";
         });
         urlList.Invoke(sl);
     }
     else
     {
         urlList.Items.Add(inputT.Text);
         inputT.Text = "";
     }
     string strCollected = string.Empty;
     for (int i = 0; i < urlList.Items.Count; i++)
     {
         if (strCollected == string.Empty)
         {
             strCollected = urlList.GetItemText(urlList.Items[i]);
         }
         else
         {
             strCollected += "\n" + urlList.GetItemText(urlList.Items[i]) ;
         }
     }
     writeFile(System.Environment.CurrentDirectory + "\\" + "urlList", strCollected);
 }
예제 #21
0
        public void addEmails()
        {
            Maillist = new List<Mail163<PaperDiaper>>();

            OpenFileDialog fileDialog = new OpenFileDialog();
            fileDialog.Filter = "(*.txt)|*.txt|(*.html)|*.html";

            List<EmailForshow> mailForshow = new List<EmailForshow>();

            if (mailGrid.InvokeRequired)
            {
                delegate2 sl = new delegate2(delegate()
                {
                    //打开对话框, 判断用户是否正确的选择了文件
                    if (fileDialog.ShowDialog() == DialogResult.OK)
                    {
                        //获取用户选择的文件,并判断文件大小不能超过20K,fileInfo.Length是以字节为单位的
                        FileInfo fileInfo = new FileInfo(fileDialog.FileName);
                        if (fileInfo.Length > 504800)
                        {
                            MessageBox.Show("上传的文件不能大于500K");
                        }
                        else
                        {
                            //在这里就可以写获取到正确文件后的代码了
                            string[] lines = File.ReadAllLines(fileDialog.FileName, System.Text.Encoding.GetEncoding("GB18030"));
                            foreach (string line in lines)
                            {
                                if (line.Length == 0)
                                {
                                    continue;
                                }
                                else
                                {
                                    Regex regex = new Regex(@"( ){2,}");
                                    string[] s = regex.Replace(line.Trim(), " ").Split(' ');
                                    if (s.Length != 2)
                                    {
                                        setLogT("ignore invalid line: " + line);
                                    }
                                    else
                                    {
                                        Maillist.Add(new Mail163<PaperDiaper>(s[0], s[1], this));
                                        mailForshow.Add(new EmailForshow(s[0], s[1]));
                                    }
                                }
                            }
                            if (Maillist.Count > 0)
                            {
                                var source = new BindingSource();
                                source.DataSource = mailForshow;
                                mailGrid.DataSource = source;
                            }
                        }
                    }
                });
                mailGrid.Invoke(sl);
            }
            else //do not use delegate
            {
                if (fileDialog.ShowDialog() == DialogResult.OK)
                {
                    FileInfo fileInfo = new FileInfo(fileDialog.FileName);
                    if (fileInfo.Length > 204800)
                    {
                        MessageBox.Show("上传的文件不能大于200K");
                    }
                    else
                    {
                        string[] lines = File.ReadAllLines(fileDialog.SafeFileName);
                        foreach (string line in lines)
                        {
                            if (line.Length == 0)
                            {
                                continue;
                            }
                            else
                            {
                                Regex regex = new Regex(@"( ){2,}");
                                string[] s = regex.Replace(line.Trim(), " ").Split(' ');
                                if (s.Length != 2)
                                {
                                    setLogT("ignore invalid line: " + line);
                                }
                                else
                                {
                                    Maillist.Add(new Mail163<PaperDiaper>(s[0], s[1], this));
                                }
                            }
                        }
                        if (Maillist.Count > 0)
                        {
                            var source = new BindingSource();
                            source.DataSource = Maillist;
                            DataGridViewTextBoxColumn txtCol = new DataGridViewTextBoxColumn();
                            txtCol.DataPropertyName = txtCol.Name = txtCol.HeaderText = "email";
                            //daiyyr
                            mailGrid.Columns.Add(txtCol);
                            txtCol.DataPropertyName = txtCol.Name = txtCol.HeaderText = "password";
                            mailGrid.Columns.Add(txtCol);
                            mailGrid.DataSource = source;
                        }
                    }
                }
            }
        }
예제 #22
0
        public void startProbe()
        {
            if (form1.mailGrid.InvokeRequired)
            {
                delegate2 sl = new delegate2(delegate()
                {
                    form1.deleteMail.Enabled = false;
                    form1.deleteApp.Enabled  = false;
                });
                form1.mailGrid.Invoke(sl);
            }
            else
            {
                form1.deleteMail.Enabled = false;
                form1.deleteApp.Enabled  = false;
            }
            form1.setLogT("probe started. CardNo:" + appointment.CardNo + ", " + form1.selecteCounty.Name
                          + " " + form1.selecteCounty.Shops[form1.selectedShop]);
            while (true)
            {
                if (Form1.gForceToStop)
                {
                    break;
                }

                int r1 = 0;
                //新潟亀田アピタ店  M
                //   http://aksale.advs.jp/cp/akachan_sale_pc/search_event_list.cgi?area2=%90V%8a%83%8c%a7&event_type=6&sid=37140&kmws=

                //アリオ上田店 M
                //   http://aksale.advs.jp/cp/akachan_sale_pc/search_event_list.cgi?area2=%92%b7%96%ec%8c%a7&event_type=6&sid=37194&kmws=
                //songben M
                //   http://aksale.advs.jp/cp/akachan_sale_pc/search_event_list.cgi?area2=%92%b7%96%ec%8c%a7&event_type=6&sid=37196&kmws=

                //ららぽーと横浜店
                // http://aksale.advs.jp/cp/akachan_sale_pc/search_event_list.cgi?area2=%90_%93%de%90%ec%8c%a7&event_type=6&sid=37139&kmws=

                //春日井店
                //http://aksale.advs.jp/cp/akachan_sale_pc/search_event_list.cgi?area2=%88%a4%92m%8c%a7&event_type=6&sid=37038&kmws=
                while ((r1 = this.probe(
                            Form1.ToUrlEncode(
                                form1.selecteCounty.Shops[form1.selectedShop],
                                System.Text.Encoding.GetEncoding("shift-jis")
                                ),
                            form1.selecteCounty.Sids[form1.selectedShop])
                        ) == -1) //"%88%a4%92m%8c%a7", "37038"
                {
                }
                if (r1 == -5) //no available appointment
                {
                    goto delay;
                }


delay:          //不写在while的开头,避免第一次就延时
                if (form1.rate.Text.Equals(""))
                {
                    Thread.Sleep(100);
                }
                else
                {
                    try{
                        if (Convert.ToInt32(form1.rate.Text) > 0)
                        {
                            Thread.Sleep(Convert.ToInt32(form1.rate.Text));
                        }
                        else
                        {
                            Thread.Sleep(100);
                        }
                    }
                    catch (Exception)
                    {
                        Thread.Sleep(100);
                    }
                }
            }//end of while
            if (form1.mailGrid.InvokeRequired)
            {
                delegate2 sl = new delegate2(delegate()
                {
                    form1.deleteMail.Enabled = true;
                });
                form1.mailGrid.Invoke(sl);
            }
            else
            {
                form1.deleteMail.Enabled = true;
            }

            Form1.gForceToStop = false;
            return;
        }
예제 #23
0
파일: Form1.cs 프로젝트: daiyyr/yuescount
 public void deleteURL()
 {
     if (urlList.InvokeRequired)
     {
         delegate2 sl = new delegate2(delegate()
         {
             for (int i = urlList.CheckedItems.Count - 1; i >= 0; i--)
             {
                 urlList.Items.Remove(urlList.CheckedItems[i]);
             }
         });
         urlList.Invoke(sl);
     }
     else
     {
         for (int i = urlList.CheckedItems.Count - 1; i >= 0; i--)
         {
             urlList.Items.Remove(urlList.CheckedItems[i]);
         }
     }
     string strCollected = string.Empty;
     for (int i = 0; i < urlList.Items.Count; i++)
     {
         if (strCollected == string.Empty)
         {
             strCollected = urlList.GetItemText(urlList.Items[i]);
         }
         else
         {
             strCollected += "\n" + urlList.GetItemText(urlList.Items[i]);
         }
     }
     writeFile(System.Environment.CurrentDirectory + "\\" + "urlList", strCollected);
 }
예제 #24
0
        public void startProbe()
        {
            if (form1.urlList.InvokeRequired)
            {
                delegate2 sl = new delegate2(delegate()
                {
                    form1.deleteB.Enabled = false;
                });
                form1.urlList.Invoke(sl);
            }
            else
            {
                form1.deleteB.Enabled = false;
            }

            if (form1.urlList.Items.Count == 0)
            {
                form1.setLogT("empty user list! please import a userID file");
                if (form1.urlList.InvokeRequired)
                {
                    delegate2 sl = new delegate2(delegate()
                    {
                        form1.deleteB.Enabled = true;
                    });
                    form1.urlList.Invoke(sl);
                }
                else
                {
                    form1.deleteB.Enabled = true;
                }
                Form1.gForceToStop = false;
                return;
            }
            Login login = new Login(form1) { };

            if (!Form1.gLoginOkFlag)
            {
                login.loginT();
                if (!Form1.gLoginOkFlag)
                {
                    if (form1.urlList.InvokeRequired)
                    {
                        delegate2 sl = new delegate2(delegate()
                        {
                            form1.deleteB.Enabled = true;
                        });
                        form1.urlList.Invoke(sl);
                    }
                    else
                    {
                        form1.deleteB.Enabled = true;
                    }
                    Form1.gForceToStop = false;
                    return;
                }
            }

            form1.setLogT("开始扫描..");
            while (true)
            {
                for (int i = 0; i < form1.urlList.Items.Count; i++)
                {
                    int r1 = 0;
                    while ((r1 = this.probe(form1.urlList.GetItemText(form1.urlList.Items[i]))) == -1)
                    {
                        Form1.gLoginOkFlag = false;
                        login.loginT();
                        if (!Form1.gLoginOkFlag)
                        {
                            if (form1.urlList.InvokeRequired)
                            {
                                delegate2 sl = new delegate2(delegate()
                                {
                                    form1.deleteB.Enabled = true;
                                });
                                form1.urlList.Invoke(sl);
                            }
                            else
                            {
                                form1.deleteB.Enabled = true;
                            }
                            Form1.gForceToStop = false;
                            return;
                        }
                    }
                    if (form1.urlList.InvokeRequired)
                    {
                        delegate2 sl = new delegate2(delegate()
                        {
                            if (r1 == -2)
                            {
                                //red daiyyr
                                failed++;
                            }
                            else
                            {
                                form1.urlList.SetItemChecked(i, true);
                                succeed++;
                                form1.setLogT(" got from " + form1.urlList.GetItemText(form1.urlList.Items[i]) + ": " + successInOneProbe);
                                SUMsuccessInOneProbe += successInOneProbe;
                                successInOneProbe = 0;
                            }
                        });
                        form1.urlList.Invoke(sl);
                    }
                    else
                    {
                        if (r1 == -2)
                        {
                            //red
                            failed++;
                        }
                        else
                        {
                            form1.urlList.SetItemChecked(i, true);
                            succeed++;
                        }
                    }

                    if (form1.rate.Text.Equals(""))
                    {
                        Thread.Sleep(100);
                    }
                    else if (Convert.ToInt32(form1.rate.Text) > 0)
                    {
                        Thread.Sleep(Convert.ToInt32(form1.rate.Text));
                    }
                    else
                    {
                        Thread.Sleep(100);
                    }
                    if (Form1.gForceToStop)
                    {
                        break;
                    }
                }//end of 'for' for checklistbox
                break;//just proce once.
            }
            form1.setLogT( "列表扫描结束,成功列表项: " + succeed + ", 失败列表项: " + failed + ", 共收集好友: " + SUMsuccessInOneProbe);
            succeed = 0;
            failed = 0;
            SUMsuccessInOneProbe = 0;
            if (gFileName != null)
            {
                form1.setLogT("Result in " + System.Environment.CurrentDirectory + "\\" + gFileName);

            }
            gFriends.Clear();
            if (form1.urlList.InvokeRequired)
            {
                delegate2 sl = new delegate2(delegate()
                {
                    form1.deleteB.Enabled = true;
                });
                form1.urlList.Invoke(sl);
            }
            else
            {
                form1.deleteB.Enabled = true;
            }
            Form1.gForceToStop = false;
            return;
        }
예제 #25
0
        public void startProbe()
        {
            if (form1.urlList.InvokeRequired)
            {
                delegate2 sl = new delegate2(delegate()
                {
                    form1.deleteB.Enabled = false;
                });
                form1.urlList.Invoke(sl);
            }
            else
            {
                form1.deleteB.Enabled = false;
            }

            if (form1.urlList.Items.Count == 0)
            {
                form1.setLogT("empty user list! please import a userID file");
                if (form1.urlList.InvokeRequired)
                {
                    delegate2 sl = new delegate2(delegate()
                    {
                        form1.deleteB.Enabled = true;
                    });
                    form1.urlList.Invoke(sl);
                }
                else
                {
                    form1.deleteB.Enabled = true;
                }
                Form1.gForceToStop = false;
                return;
            }
            Login login = new Login(form1)
            {
            };

            if (!Form1.gLoginOkFlag)
            {
                login.loginT();
                if (!Form1.gLoginOkFlag)
                {
                    if (form1.urlList.InvokeRequired)
                    {
                        delegate2 sl = new delegate2(delegate()
                        {
                            form1.deleteB.Enabled = true;
                        });
                        form1.urlList.Invoke(sl);
                    }
                    else
                    {
                        form1.deleteB.Enabled = true;
                    }
                    Form1.gForceToStop = false;
                    return;
                }
            }

            form1.setLogT("开始扫描..");
            while (true)
            {
                for (int i = 0; i < form1.urlList.Items.Count; i++)
                {
                    int r1 = 0;
                    while ((r1 = this.probe(form1.urlList.GetItemText(form1.urlList.Items[i]))) == -1)
                    {
                        Form1.gLoginOkFlag = false;
                        login.loginT();
                        if (!Form1.gLoginOkFlag)
                        {
                            if (form1.urlList.InvokeRequired)
                            {
                                delegate2 sl = new delegate2(delegate()
                                {
                                    form1.deleteB.Enabled = true;
                                });
                                form1.urlList.Invoke(sl);
                            }
                            else
                            {
                                form1.deleteB.Enabled = true;
                            }
                            Form1.gForceToStop = false;
                            return;
                        }
                    }
                    if (form1.urlList.InvokeRequired)
                    {
                        delegate2 sl = new delegate2(delegate()
                        {
                            if (r1 == -2)
                            {
                                //red daiyyr
                                failed++;
                            }
                            else
                            {
                                form1.urlList.SetItemChecked(i, true);
                                succeed++;
                                form1.setLogT(" got from " + form1.urlList.GetItemText(form1.urlList.Items[i]) + ": " + successInOneProbe);
                                SUMsuccessInOneProbe += successInOneProbe;
                                successInOneProbe     = 0;
                            }
                        });
                        form1.urlList.Invoke(sl);
                    }
                    else
                    {
                        if (r1 == -2)
                        {
                            //red
                            failed++;
                        }
                        else
                        {
                            form1.urlList.SetItemChecked(i, true);
                            succeed++;
                        }
                    }


                    if (form1.rate.Text.Equals(""))
                    {
                        Thread.Sleep(100);
                    }
                    else if (Convert.ToInt32(form1.rate.Text) > 0)
                    {
                        Thread.Sleep(Convert.ToInt32(form1.rate.Text));
                    }
                    else
                    {
                        Thread.Sleep(100);
                    }
                    if (Form1.gForceToStop)
                    {
                        break;
                    }
                }//end of 'for' for checklistbox
                break;//just proce once.
            }
            form1.setLogT("列表扫描结束,成功列表项: " + succeed + ", 失败列表项: " + failed + ", 共收集好友: " + SUMsuccessInOneProbe);
            succeed = 0;
            failed  = 0;
            SUMsuccessInOneProbe = 0;
            if (gFileName != null)
            {
                form1.setLogT("Result in " + System.Environment.CurrentDirectory + "\\" + gFileName);
            }
            gFriends.Clear();
            if (form1.urlList.InvokeRequired)
            {
                delegate2 sl = new delegate2(delegate()
                {
                    form1.deleteB.Enabled = true;
                });
                form1.urlList.Invoke(sl);
            }
            else
            {
                form1.deleteB.Enabled = true;
            }
            Form1.gForceToStop = false;
            return;
        }
예제 #26
0
        public void addIds()
        {
            OpenFileDialog fileDialog = new OpenFileDialog();

            fileDialog.Filter = "(*.txt)|*.txt|(*.html)|*.html";

            if (urlList.InvokeRequired)
            {
                delegate2 sl = new delegate2(delegate()
                {
                    //打开对话框, 判断用户是否正确的选择了文件
                    if (fileDialog.ShowDialog() == DialogResult.OK)
                    {
                        //获取用户选择文件的后缀名
                        //    string extension = Path.GetExtension(fileDialog.FileName);
                        //声明允许的后缀名
                        //    string[] str = new string[] { ".txt", ".html" };
                        //    if (!str.Contains(extension))
                        //    {
                        //        MessageBox.Show("仅能上传txt,html格式的文件!");
                        //    }
                        //}

                        //获取用户选择的文件,并判断文件大小不能超过20K,fileInfo.Length是以字节为单位的
                        FileInfo fileInfo = new FileInfo(fileDialog.FileName);
                        if (fileInfo.Length > 204800)
                        {
                            MessageBox.Show("上传的文件不能大于200K");
                        }
                        else
                        {
                            //在这里就可以写获取到正确文件后的代码了
                            string[] lines = File.ReadAllLines(fileDialog.FileName);
                            foreach (string line in lines)
                            {
                                if (line.Length == 0)
                                {
                                    continue;
                                }
                                if ((line.Length > 0 && line.Length < 4) || !line.Substring(0, 4).Equals("1-1-"))
                                {
                                    MessageBox.Show("文件格式错误,导入中止!");
                                    break;
                                }
                                else
                                {
                                    urlList.Items.Add(line.Substring(4, line.Length - 4));
                                }
                            }
                        }
                    }
                });
                urlList.Invoke(sl);
            }
            else //do not use delegate
            {
                if (fileDialog.ShowDialog() == DialogResult.OK)
                {
                    FileInfo fileInfo = new FileInfo(fileDialog.FileName);
                    if (fileInfo.Length > 204800)
                    {
                        MessageBox.Show("上传的文件不能大于200K");
                    }
                    else
                    {
                        string[] lines = File.ReadAllLines(fileDialog.SafeFileName);
                        foreach (string line in lines)
                        {
                            if (!line.Substring(0, 4).Equals("1-1-"))
                            {
                                MessageBox.Show("文件格式错误!");
                                break;
                            }
                            else
                            {
                                urlList.Items.Add(line.Substring(4, line.Length - 4));
                            }
                        }
                    }
                }
            }
        }