/// <summary> /// 获取联系人列表 /// </summary> private void GetAllPassenger() { modifyAction.GetUnfinishedOrder((strr) => { }, _cookieContainer); modifyAction.InitUsualPassenger12306((str) => { if (str == "获取信息失败" || str == string.Empty) { MessageBox.Show("信息获取失败,请重试", "获取联系人信息(编辑)", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } TokenInit = System.Text.RegularExpressions.Regex.Match(str, "[0-9abcdefABCDEF]{32}").ToString(); modifyAction.PostData = "pageIndex=0&pageSize=50&passenger_name=%E8%AF%B7%E8%BE%93%E5%85%A5%E6%B1%89%E5%AD%97%E6%88%96%E6%8B%BC%E9%9F%B3%E9%A6%96%E5%AD%97%E6%AF%8D"; modifyAction.GetPagePassengerAll((str1) => { if (str1 != "") { translation.TranslationHtml(str1, (passengers) => { DeterMineCall(() => { passenger = passengers; _bindingList = new BindingList <PassengersAllData>(passenger); dgvPassenger.DataSource = _bindingList; dgvPassenger.Refresh(); }); }); } }, _cookieContainer); }, _cookieContainer); }
private void GetLeftTicket() { lock (locker) { autoSelectAction.QueryString = GetQueryString(); autoSelectAction.GetLeftTickets((resultList) => { string htmlList = ""; if (resultList != null && resultList != string.Empty) { htmlList = resultList; autoTranslation.TranslationHtml(htmlList, (listSource) => { LastSelectTime = DateTime.Now.ToLongTimeString(); _trainData = listSource; DeleteFormSelectTicket(() => { formSelectTicket.FormThis.DgvDataBind(_trainData); }); BeginFilter(); }); } }, (expires) => { DeleteFormSelectTicket(() => { formSelectTicket.FormThis.UpdateCacheExpires(expires); }); }, cookieContainer); } }
private void BindQuickTrainInfo() { dgvQuickTrainInfo.DataSource = null; selectAction.QueryString = string.Format("train_no={0}&from_station_telecode={1}&to_station_telecode={2}&depart_date={3}", _trainNo, _fromStationTelcode, _toStationTelcode, _departDate); selectAction.GetArriveStationInfo((str) => { if (str == string.Empty || str == "") { MessageBox.Show("加载信息失败", "加载过站信息", MessageBoxButtons.OK, MessageBoxIcon.Information); //new MessageBoxEx("加载过站信息失败!", MessageboxExIcon.ERROR) { NewPrivateInterval = 1000 }.Show(); return; } translation.TranslationHtml(str, (traininfo) => { if (traininfo != null) { DeterMineCall(() => { quickTrainData = traininfo; dgvQuickTrainInfo.DataSource = quickTrainData; DeterMineCall(() => { foreach (DataGridViewRow row in dgvQuickTrainInfo.Rows) { if (row.Cells[1].Value.ToString() == _from || row.Cells[1].Value.ToString() == _to) { row.DefaultCellStyle.ForeColor = Color.Blue; } } }); }); } }); }, _cookie); }
private void ConfirmOrder() { getPostData.GetOrderPostData((data) => { if (_trainData.SpecialSeatType != null && _trainData.SpecialSeatType.Count != 0) { //适应一等软座和二等软座的代码 data = data.Replace("passengerTickets=M", "passengerTickets=7").Replace("passengerTickets=O", "passengerTickets=8"); } submitAction.PostData = data; submitAction.QueryString = "&rand=" + txtRandCode1.Text; submitAction.ConfirmOrder((str) => { if (str == "获取信息失败" || str == string.Empty) { MessageBox.Show("信息获取失败,请重试", "订单确认", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } var result = translation.TranslationHtml(str); if (result["checkHuimd"] as string == "N") { DetermineCall(() => { MessageBox.Show(this, result["msg"] as string, "确认订单 Huimd", MessageBoxButtons.OK, MessageBoxIcon.Error); StopSubmit(); return; }); } else if (result["check608"] as string == "N") { DetermineCall(() => { MessageBox.Show(this, "本车为实名制列车,实行一日一车一证一票制!", "确认订单 608", MessageBoxButtons.OK, MessageBoxIcon.Error); StopSubmit(); return; }); } else if (result["errMsg"] as string != "Y") { if ((result["errMsg"] as string).Contains("验证码输入错误")) { decimal i = _submitSpan; while (i-- > 0) { DetermineCall(() => { lblState1.Text = string.Format("检测订单失败,请勿关闭窗口,{0}秒后将重新提交,请稍候.........", i); //btnStopSubmit.Enabled = true; }); Thread.Sleep(1000); } ConfirmOrder(); } else if ((result["errMsg"] as string).Contains("输入的验证码不正确")) { DetermineCall(() => { StopSubmit("输入的验证码不正确,请重试........."); return; }); } else { DetermineCall(() => { if (!string.IsNullOrEmpty(result["errMsg"] as string)) { MessageBox.Show(this, result["errMsg"] as string, "确认订单 msg!=Y", MessageBoxButtons.OK, MessageBoxIcon.Error); StopSubmit(); return; } else { MessageBox.Show(this, "铁道部在做怪,让你必需重新登陆了。", "提示 TD", MessageBoxButtons.OK, MessageBoxIcon.Error); StopSubmit(); return; } }); } } else { DetermineCall(() => { lblState1.Text = "正在查询订单余票信息,请稍候........."; }); Thread.Sleep(100); ConfirmSubmit(); } }, _cookieContainer); }); }
private void btnLogin_Click(object sender, EventArgs e) { DeterMineCall(()=> { if (txtName.Text.Length < 4) return; if (txtPwd.Text.Length < 4) return; if (txtRandCode.TextLength < 4) return; btnLogin.Enabled = false; btnLogin.Text = "正在登录"; Application.DoEvents(); //获取随机码 string loginRand=""; HTML_Translation htmlTran = new HTML_Translation(); la.GetLoginRand((strrand) => { if (strrand == "获取信息失败") { MessageBox.Show("信息获取失败,请重试", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } loginRand = htmlTran.TranslationHtml(strrand, "loginRand"); //登录 string result=""; la.PostData = string.Format(@"loginRand={0}&loginUser.user_name={1}&nameErrorFocus=&passwordErrorFocus=&randCode={2}&randErrorFocus=&refundFlag=Y&refundLogin=N&user.password={3}", loginRand, txtName.Text, txtRandCode.Text, txtPwd.Text); la.BeginLogin((str) => { result = str; DeterMineCall(() => { //登录返回结果 if (result.IndexOf("请输入正确的验证码") > -1) { lblInfomation.Text = "验证码不正确"; GetRandCodeImg(); txtRandCode.Text = ""; btnLogin.Enabled = true; btnLogin.Text = "登录"; txtRandCode.Focus(); return; } if (result.IndexOf("系统维护") > -1) { lblInfomation.Text = "系统维护中....."; GetRandCodeImg(); txtRandCode.Text = ""; btnLogin.Enabled = true; btnLogin.Text = "登录"; txtRandCode.Focus(); return; } if (result.IndexOf("登录名不存在") > -1) { lblInfomation.Text = "登录名不存在"; GetRandCodeImg(); txtRandCode.Text = ""; btnLogin.Enabled = true; btnLogin.Text = "登录"; txtRandCode.Focus(); return; } else if (result.IndexOf("密码输入错误") > -1) { lblInfomation.Text = "密码输入错误"; GetRandCodeImg(); txtPwd.Text = ""; btnLogin.Enabled = true; btnLogin.Text = "登录"; txtPwd.Focus(); return; } else if (result.IndexOf("锁定") > -1) { lblInfomation.Text = "帐号被锁定"; GetRandCodeImg(); btnLogin.Enabled = true; btnLogin.Text = "登录"; return; } else if (result.IndexOf("网络") > -1) { lblInfomation.Text = "网站又挂了"; GetRandCodeImg(); btnLogin.Enabled = true; btnLogin.Text = "登录"; return; } else if (result.IndexOf("欢迎您登录") != -1) { if (chkUserInfo.Checked) { ConfigInfo.conf.username = EncodeAndDecode.EncodeBase64(EncodeAndDecode.EncodeBase64(txtName.Text)); ConfigInfo.conf.password = EncodeAndDecode.EncodeBase64(EncodeAndDecode.EncodeBase64(txtPwd.Text)); ConfigInfo.savetofile(); LocalCookie.WriteCookiesToDisk(AppDomain.CurrentDomain.BaseDirectory + "usrCookie.cfg", la.cookieContainer); } btnLogin.Enabled = true; btnLogin.Text = "登录"; this.Hide(); formSelectTicket selectForm = new formSelectTicket(); selectForm.user = txtName.Text; selectForm.Show(); } else { lblInfomation.Text = "登录失败"; GetRandCodeImg(); txtRandCode.Text = ""; btnLogin.Enabled = true; btnLogin.Text = "登录"; txtRandCode.Focus(); return; } }); }); }); }); }
private void btnLogin_Click(object sender, EventArgs e) { DeterMineCall(() => { if (txtName.Text.Length < 4) { return; } if (txtPwd.Text.Length < 4) { return; } if (txtRandCode.TextLength < 4) { return; } btnLogin.Enabled = false; btnLogin.Text = "正在登录"; Application.DoEvents(); //获取随机码 string loginRand = ""; HTML_Translation htmlTran = new HTML_Translation(); la.GetLoginRand((strrand) => { if (strrand == "获取信息失败") { MessageBox.Show("信息获取失败,请重试", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } loginRand = htmlTran.TranslationHtml(strrand, "loginRand"); //登录 string result = ""; la.PostData = string.Format(@"loginRand={0}&loginUser.user_name={1}&nameErrorFocus=&passwordErrorFocus=&randCode={2}&randErrorFocus=&refundFlag=Y&refundLogin=N&user.password={3}", loginRand, txtName.Text, txtRandCode.Text, txtPwd.Text); la.BeginLogin((str) => { result = str; DeterMineCall(() => { //登录返回结果 if (result.IndexOf("请输入正确的验证码") > -1) { lblInfomation.Text = "验证码不正确"; GetRandCodeImg(); txtRandCode.Text = ""; btnLogin.Enabled = true; btnLogin.Text = "登录"; txtRandCode.Focus(); return; } if (result.IndexOf("系统维护") > -1) { lblInfomation.Text = "系统维护中....."; GetRandCodeImg(); txtRandCode.Text = ""; btnLogin.Enabled = true; btnLogin.Text = "登录"; txtRandCode.Focus(); return; } if (result.IndexOf("登录名不存在") > -1) { lblInfomation.Text = "登录名不存在"; GetRandCodeImg(); txtRandCode.Text = ""; btnLogin.Enabled = true; btnLogin.Text = "登录"; txtRandCode.Focus(); return; } else if (result.IndexOf("密码输入错误") > -1) { lblInfomation.Text = "密码输入错误"; GetRandCodeImg(); txtPwd.Text = ""; btnLogin.Enabled = true; btnLogin.Text = "登录"; txtPwd.Focus(); return; } else if (result.IndexOf("锁定") > -1) { lblInfomation.Text = "帐号被锁定"; GetRandCodeImg(); btnLogin.Enabled = true; btnLogin.Text = "登录"; return; } else if (result.IndexOf("网络") > -1) { lblInfomation.Text = "网站又挂了"; GetRandCodeImg(); btnLogin.Enabled = true; btnLogin.Text = "登录"; return; } else if (result.IndexOf("欢迎您登录") != -1) { if (chkUserInfo.Checked) { ConfigInfo.conf.username = EncodeAndDecode.EncodeBase64(EncodeAndDecode.EncodeBase64(txtName.Text)); ConfigInfo.conf.password = EncodeAndDecode.EncodeBase64(EncodeAndDecode.EncodeBase64(txtPwd.Text)); ConfigInfo.savetofile(); LocalCookie.WriteCookiesToDisk(AppDomain.CurrentDomain.BaseDirectory + "usrCookie.cfg", la.cookieContainer); } btnLogin.Enabled = true; btnLogin.Text = "登录"; this.Hide(); formSelectTicket selectForm = new formSelectTicket(); selectForm.user = txtName.Text; selectForm.Show(); } else { lblInfomation.Text = "登录失败"; GetRandCodeImg(); txtRandCode.Text = ""; btnLogin.Enabled = true; btnLogin.Text = "登录"; txtRandCode.Focus(); return; } }); }); }); }); }