コード例 #1
0
 private void timer2_Tick(object sender, EventArgs e)
 {
     timer2.Stop();
     DetermineCall(() =>
     {
         if (_orderNo == "" || _orderNo != "null")
         {
             GetSeat();
             timer2.Start();
         }
         else
         {
             if (MessageBox.Show(string.Format("订票成功,赶紧到网站上支付吧~~订单号{0}", _orderNo), "提示", MessageBoxButtons.OK, MessageBoxIcon.Information) == DialogResult.OK)
             {
                 OpenIE_API.OpenIE(_cookieContainer);
                 this.Close();
             }
         }
     });
 }
コード例 #2
0
        //获取坐席信息
        private void GetSeat()
        {
            submitAction.QueryString = getPostData.GetQueryOrderWaitTimeQueryString();
            submitAction.GetSeatAsync((str) =>
            {
                var returnString = translation.TranslationHtmlEx(str);
                if (returnString["messages"].Any())
                {
                    GetRandCodeImg();
                    DeterMineCall(() =>
                    {
                        lblState1.Text = returnString["messages"][0].ToString();
                        Application.DoEvents();
                        txtRandCode1.Text = "";
                        txtRandCode1.Focus();
                        timer2.Stop();
                        AutoSubmitPage();
                    });
                    return;
                }

                if (returnString["data"]["msg"] != null && returnString["data"]["msg"].ToString() != "")
                {
                    GetRandCodeImg();
                    DeterMineCall(() =>
                    {
                        MessageBox.Show(returnString["data"]["msg"].ToString(), "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        lblState1.Text    = returnString["data"]["msg"].ToString();
                        txtRandCode1.Text = "";
                        txtRandCode1.Focus();
                        timer2.Stop();
                        AutoSubmitPage();
                    });
                    return;
                }

                string waitCount = "";
                if (returnString["data"]["orderId"] != null && returnString["data"]["orderId"].ToString() != "" && returnString["data"]["orderId"].ToString() != "null")
                {
                    DetermineCall(() =>
                    {
                        _orderNo = returnString["data"]["orderId"].ToString();
                        if (_orderNo != "" && flag == 0)
                        {
                            flag++;
                            timer2.Enabled = false;
                            lblState1.Text = "订票成功~~!订单号为:" + _orderNo;
                            string path    = System.IO.Directory.GetCurrentDirectory() + "\\Sound_Sucessed.wav";
                            if (System.IO.File.Exists(path))
                            {
                                sp = new System.Media.SoundPlayer(path);
                                sp.Play();
                            }
                            if (MessageBox.Show(string.Format("订票成功,赶紧到网站上支付吧~~订单号{0}", _orderNo), "提示", MessageBoxButtons.OK, MessageBoxIcon.Information) == DialogResult.OK)
                            {
                                OpenIE_API.OpenIE(_cookieContainer);
                                this.Close();
                            }
                        }
                    });
                }
                else
                {
                    DetermineCall(() =>
                    {
                        //waitCount = Regex.Match(result, "(?<=\"waitCount\":)[\\-]?\\d{1,}(?=,\")").ToString();
                        waitCount      = returnString["data"]["waitCount"].ToString();
                        lblState1.Text = "据说前面还有 " + waitCount + " 个人,估计还需要等上 " + returnString["data"]["waitTime"] as string + " 秒"; // Regex.Match(result, "(?<=\"waitTime\":)[\\-]?\\d{1,}(?=,\")").ToString() + " 秒";
                        Application.DoEvents();
                        timer2.Interval = 1000;                                                                                      //Convert.ToInt32(_submitSpan)
                        timer2.Start();
                    });
                }
            }, _cookieContainer);
        }