Exemplo n.º 1
0
 public string Name() => InputElement.GetAttribute("data-line-name");
Exemplo n.º 2
0
 public string Id() => InputElement.GetAttribute("data-line-id");
Exemplo n.º 3
0
 public bool IsSelected() => InputElement.GetAttribute("checked") != null;
Exemplo n.º 4
0
        // 禁入英文網頁
        private async void button1_Click(object sender, EventArgs e)
        {
            webBrowser1.Navigate("http://140.130.28.17/online_test/word_examine/custom_home.asp");
            if (!repeat)
            {
                isData = SearchOrderNotUse(); // 搜尋已繳費及未完成之訂單info帳號未使用及以驗證
            }

            //將帳密輸入
            HtmlElement           element;
            HtmlElementCollection elementlist;

            try
            {
                if (isData)
                {
                    JObject LinqSearchOrder = JObject.Parse(orderDataJson); // {} 物件json LINQ查詢
                    await Task.Delay(1000);

                    element           = this.webBrowser1.Document.All.GetElementsByName("cust_id")[0];
                    element.InnerText = LinqSearchOrder["nfu_acc"].ToString();

                    element           = this.webBrowser1.Document.All.GetElementsByName("cust_pass")[0];
                    element.InnerText = LinqSearchOrder["nfu_pass"].ToString();

                    elementlist = webBrowser1.Document.GetElementsByTagName("input");
                    foreach (HtmlElement InputElement in elementlist)
                    {
                        //MessageBox.Show(InputElement.GetAttribute("type").ToString());
                        if (InputElement.GetAttribute("type").ToString() == "image")
                        {
                            await Task.Delay(1000);

                            InputElement.InvokeMember("click");
                            await Task.Delay(5000);

                            bool islogin = AccIsLogin();
                            if (islogin)
                            {
                                webBrowser1.Navigate("http://140.130.28.17/online_test/word_examine/index.asp?tid=1096");
                                await Task.Delay(5000);

                                element = this.webBrowser1.Document.GetElementsByTagName("a")[5];
                                element.InvokeMember("click");

                                if (checkBox1.Checked)
                                {
                                    await Task.Delay(5000);

                                    button2_Click(this, e);
                                }
                                //MessageBox.Show(element.GetAttribute("href"));
                            }

                            // 登入失敗之重複登入
                            if (repeat)
                            {
                                // 限定最多次數重登,超過者換下一位
                                if (CheckLoginCount < CheckLoginMaxCount)
                                {
                                    await Task.Delay(5000);

                                    button1_Click(this, e);
                                }
                                else
                                {
                                    await Task.Delay(5000);

                                    repeat = false;
                                    button1_Click(this, e);
                                }
                            }
                        }
                    }
                }
                else
                {
                    await Task.Delay(1000);

                    button1_Click(this, e);
                }
            }
            catch (Exception ex)
            {
                webBrowser1.Navigate("http://140.130.28.17/online_test/word_examine/custom_home.asp");
                richTextBox1.AppendText("登入錯誤!");
                type  = 0;
                count = 0;

                if (isData)
                {
                    JObject LinqSearchOrder = JObject.Parse(orderDataJson); // {} 物件json LINQ查詢

                    //登入失敗,訂單狀態-1(失敗),單字量(0)
                    ChangeOrderInfoStatus(Int32.Parse(LinqSearchOrder["id"].ToString()), 0, -1, 0);

                    //order_log 紀錄登入失敗
                    OrderLogSave(Int32.Parse(LinqSearchOrder["order_id"].ToString()), Int32.Parse(LinqSearchOrder["id"].ToString()), "登入失敗");
                }
            }
        }