public KeyValue(HtmlForm form, string key, string value, string type) { this.Key = key; this.Value = value; this.TagType = type; this._form = form; }
public void addToForm(HtmlForm form) { if (Name != null && Name != "") { form.AddTag("passengerTickets", Seat + ",0," + Ticket + "," + Name + "," + Cardtype + "," + Cardno + "," + Mobileno + ",N"); form.AddTag("oldPassengers", ""); form.AddTag("passenger_" + Index + "_seat", Seat); form.AddTag("passenger_" + Index + "_ticket", Ticket); form.AddTag("passenger_" + Index + "_name", Name); form.AddTag("passenger_" + Index + "_cardtype", Cardtype); form.AddTag("passenger_" + Index + "_cardno", Cardno); form.AddTag("passenger_" + Index + "_mobileno", Mobileno); } else { form.AddTag("oldPassengers", ""); form.AddTag("checkbox9", "Y"); } }
void commitForm_PostCallBack(HtmlForm sender, string result) { if (result.IndexOf("登录名") != -1) { reLogin(); return; } if (result.IndexOf("网络可能存在问题") != -1) { if (!queryCanRun) { addLog("网络错误,稍候重试", true); Thread.Sleep(1000); commit(lefttick, token, txtCommitCode.Text); } } JObject o = (JObject)JsonConvert.DeserializeObject(result); object error = o["errMsg"]; object msg = o["msg"]; object checkHuimd = o["checkHuimd"]; object check608 = o["check608"]; addLog(result, true); if (checkHuimd != null && checkHuimd.ToString() == ("Y") && check608 != null && check608.ToString() == ("Y") && error != null && error.ToString() == ("Y")) { //getImage("https://dynamic.12306.cn/otsweb/images/long_button_x.jpg", "https://dynamic.12306.cn/otsweb/order/confirmPassengerAction.do?method=init"); if (getTickCount()) { Thread.Sleep(checkDelay);//重点 checkTick(lefttick, token, txtCommitCode.Text); } else { if (!queryCanRun) { Thread.Sleep(3000); commit(lefttick, token, txtCommitCode.Text); } } } else { if (error != null && error.ToString() != "Y") { addLog(error.ToString(), true); } if (msg != null && msg.ToString() != "") { addLog(msg.ToString(), true); } if (error != null && error.ToString().IndexOf("验证码") != -1) { getCommitImgCode(); } else if (msg != null && msg.ToString().IndexOf("取消次数过多") != -1) { MessageBox.Show("取消次数过多,无法购票"); } else { if (!queryCanRun) { commit(lefttick, token, txtCommitCode.Text); } } } }
void checkForm_PostCallBack(HtmlForm sender, string result) { if (result.IndexOf("登录名") != -1) { reLogin(); return; } try { JObject o = (JObject)JsonConvert.DeserializeObject(result); string error = o["errMsg"].ToString(); addLog("check:" + error, true); if (error.IndexOf("验证码") != -1) { getCommitImgCode(); } else if (error.IndexOf("非法") != -1) { if (!queryCanRun) { Thread.Sleep(3000); commit(lefttick, token, txtCommitCode.Text); } } else if (error.IndexOf("重复提交") != -1) { if (!queryCanRun) { addLog("##########################", true); getCommitPage(); } } else if (error.IndexOf("已超过余票数") != -1) { if (!queryCanRun) { Thread.Sleep(3000); commit(lefttick, token, txtCommitCode.Text); } } else if (error.IndexOf("未付款订单") != -1) { OpenIE openite = new OpenIE("包含未付款订单,快去付款!"); openite.ShowDialog(); //MessageBox.Show("包含未付款订单,快去付款!"); } else if (error == "Y") { addLog("成功提交订单", true); getOrder(true); } } catch { if (!queryCanRun) { getCommitPage(); } } }
void yudingForm_PostCallBack(HtmlForm sender, string result) { if (result.IndexOf("登录名") != -1) { reLogin(); } else if (result.IndexOf("系统忙") != -1) { if (!queryCanRun) { addLog("系统忙,稍候重试", true); Thread.Sleep(1000); yuding(); } } else { if (!queryCanRun) { getCommitPage(); } } }
void setYuanshi(HtmlForm form, string yuanshi) { using (StringReader reader = new StringReader(yuanshi)) { string line = null; while ((line = reader.ReadLine()) != null) { string[] tags = line.Split('#'); form.setTagValue(tags[0], tags[1]); } } }
void loginForm_PostCallBack(HtmlForm sender, string result) { bool error = false; string errormsg = ""; if (result.IndexOf("请输入正确的验证码") != -1) { errormsg = "验证错误"; getLoginImgCode(); error = true; } else if (result.IndexOf("密码输入错误") != -1) { Regex reg = new Regex("\"(密码输入错误.*?)\"", RegexOptions.Singleline); Match m = reg.Match(result); if (m.Success) { errormsg = m.Groups[1].Value; } else { errormsg = "密码输入错误"; } setTextAndFocus(txtPassword, ""); error = true; } else if (result.IndexOf("您的用户已经被锁定") != -1) { Regex reg = new Regex("\"(您的用户已经被锁定.*?)\"", RegexOptions.Singleline); Match m = reg.Match(result); if (m.Success) { errormsg = m.Groups[1].Value; } else { errormsg = "您的用户已经被锁定"; } setTextAndFocus(txtPassword, ""); error = true; } else if (result.IndexOf("登录名不存在") != -1) { setText(txtPassword, ""); setTextAndFocus(txtUserName, ""); errormsg = "登录名不存在"; error = true; } //登录名不存在 if (result.IndexOf("我的订单") != -1) { addLog("登陆成功", true); isLogin = true; Regex re = new Regex("u_name = '(.*?)'", RegexOptions.Singleline); Match m = re.Match(result); if (m.Success) { setLable(lblLoginError, "【" + m.Groups[1].Value + "】已登录"); } else { setLable(lblLoginError, "登录成功"); } Config config = Config.getConfig(); config.Password = txtPassword.Text; config.UserName = txtUserName.Text; Config.SaveInfo(); getPassenger(); } else { if (error) { addLog(errormsg, true); setLable(lblLoginError, errormsg); } else { Thread.Sleep(2000); login(); } } }