Ejemplo n.º 1
0
 protected override void OnShown(EventArgs e)
 {
     base.OnShown(e);
     PWLoading.Show(this, "正在获取相关数据,请稍后...", new Action(() =>
     {
         if (RequestSubmitOrder())
         {
             // 获取页面信息
             RequestPackage request = new RequestPackage();
             request.RequestURL     = "/otn/confirmPassenger/initDc";
             request.RefererURL     = "/otn/leftTicket/init";
             request.Params.Add("_json_att=", string.Empty);
             request.Method = "post";
             ArrayList list = HttpContext.GetHtmlData(request);
             if (IsInit = (list.Count == 3))
             {
                 GetValidateCode();
                 string html_text = list[1].ToString();
                 // 获取 Token
                 SubmitToken = StringExt.FindJsValue(html_text, "globalRepeatSubmitToken");
                 // 获取 ticketInfoForPassengerForm
                 string ticketInfoForPassenger = StringExt.FindJsValue(html_text, "ticketInfoForPassengerForm");
                 TicketInfo = JsonConvert.DeserializeObject <TicketInfoForPassengerForm>(ticketInfoForPassenger);
                 if (this.InvokeRequired)
                 {
                     this.Invoke(new Action(() =>
                     {
                         this.LoadData();
                         this.UpdatePassengers();
                     }));
                 }
                 else
                 {
                     this.LoadData();
                     this.UpdatePassengers();
                 }
             }
             else
             {
                 Log.Log.Write(list);
             }
         }
     }));
 }
Ejemplo n.º 2
0
 /// <summary>
 /// 查询
 /// </summary>
 void btnQuery_Click(object sender, EventArgs e)
 {
     try
     {
         if (this.ValidateQuery())
         {
             this.btnQuery.Enabled = false;
             PWLoading.Show(this, "正在查询...", new Action(() =>
             {
                 QueryTrainData[] data = TrainTicket.Query(
                     this.txtFromStation.Tag.ToString(),
                     this.txtToStation.Tag.ToString(),
                     this.dtpTrainDate.Value.ToString("yyyy-MM-dd"));
                 if (this.InvokeRequired)
                 {
                     this.Invoke(new Action(() =>
                     {
                         this.LoadQueryData(data);
                     }));
                 }
                 else
                 {
                     this.LoadQueryData(data);
                 }
             }));
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(this, "错误:" + ex.Message, "系统错误");
         this.ResetQuery();
     }
     finally
     {
         this.ResetQuery();
     }
 }
Ejemplo n.º 3
0
 /// <summary>
 /// 登录 12306
 /// </summary>
 void btnLogin_Click(object sender, EventArgs e)
 {
     try
     {
         this.btnLogin.Enabled = false;
         AppContext.Tip.Show(
             "正在登录...",
             this,
             this.btnLogin.Location.X, this.btnLogin.Location.Y - 20);
         string loginName = this.txtLoginName.Text.Trim();
         string loginPwd  = this.txtLoginPwd.Text.Trim();
         string code      = this.txtCode.Text.Trim();
         PWLoading.Show(this, "正在登录...", new Action(() =>
         {
             RequestPackage request = new RequestPackage();
             request.Params.Add("loginUserDTO.user_name", System.Web.HttpUtility.UrlEncode(loginName));
             request.Params.Add("userDTO.password", System.Web.HttpUtility.UrlEncode(loginPwd));
             request.Params.Add("randCode", System.Web.HttpUtility.UrlEncode(code));
             request.RequestURL = "/otn/login/loginAysnSuggest";
             request.RefererURL = "/otn/login/init";
             request.Method     = "post";
             ArrayList list     = HttpContext.Send(request);
             if (list.Count == 2)
             {
                 string jsonResult     = Encoding.UTF8.GetString(list[1] as byte[]);
                 ResponseLogin package = JsonConvert.DeserializeObject <ResponseLogin>(jsonResult);
                 if (package.Data != null && package.Data.loginCheck == "Y")
                 {
                     AppContext.LoginUser = new LoginUser()
                     {
                         UserName = loginName,
                         Password = loginPwd,
                     };
                     this.DialogResult = DialogResult.OK;
                 }
                 else
                 {
                     if (package.messages != null && package.messages.Length > 0)
                     {
                         if (this.InvokeRequired)
                         {
                             this.Invoke(new Action(() =>
                             {
                                 MessageBox.Show(this, package.messages[0], "提示");
                                 this.btnLogin.Enabled = true;
                                 this.GetValidateCode();
                                 this.txtCode.Focus();
                             }));
                         }
                     }
                 }
             }
             else
             {
                 Log.Log.Write(list);
             }
         }));
     }
     catch (Exception ex)
     {
         MessageBox.Show(this, "错误:" + ex.Message, "系统错误");
         this.btnLogin.Enabled = true;
     }
 }
Ejemplo n.º 4
0
        /// <summary>
        /// 提交订单
        /// </summary>
        private bool SubmitOrder(string passengerTicketStr, string oldPassengerStr, string code)
        {
            bool result = false;

            PWLoading.Show(this, "正在检查订单,请稍后...", new Action(() =>
            {
                RequestPackage request = new RequestPackage();
                request.Encoding       = Encoding.UTF8;
                request.Method         = "post";
                request.RefererURL     = "/otn/confirmPassenger/initDc";
                request.RequestURL     = "/otn/confirmPassenger/checkOrderInfo";
                request.Params.Add("cancel_flag", "2");
                request.Params.Add("bed_level_order_num", "000000000000000000000000000000");
                request.Params.Add("passengerTicketStr", passengerTicketStr);
                request.Params.Add("oldPassengerStr", oldPassengerStr);
                request.Params.Add("tour_flag", TicketInfo.tour_flag);
                request.Params.Add("randCode", code);
                request.Params.Add("_json_att", string.Empty);
                request.Params.Add("REPEAT_SUBMIT_TOKEN", SubmitToken);
                ArrayList list = HttpContext.Send(request);
                if (list.Count == 2)
                {
                    PWLoading.UpdateMessage("正在查询余票数量...");
                    string jsonResult     = Encoding.UTF8.GetString(list[1] as byte[]);
                    ResponseBase response = JsonConvert.DeserializeObject <ResponseCheckOrderInfo>(jsonResult);
                    if (response.status)
                    {
                        ResponseCheckOrderInfo res_check_order = response as ResponseCheckOrderInfo;
                        if (res_check_order.Data.submitStatus)
                        {
                            string date = TicketInfo.queryLeftTicketRequestDTO.TrainDate.ToString("ddd MMM dd yyyy 00:00:00 ",
                                                                                                  System.Globalization.CultureInfo.CreateSpecificCulture("en-US")) + "GMT + 0800(中国标准时间)";
                            string train_date = Data.QueryLeftNewDTO.StartTrainDate.ToString(
                                "ddd MMM dd yyyy 00:00:00 ",
                                System.Globalization.CultureInfo.CreateSpecificCulture("en-US")) + "GMT + 0800(中国标准时间)";
                            request.RequestURL = "/otn/confirmPassenger/getQueueCount";
                            request.RefererURL = "/otn/confirmPassenger/initDc";
                            request.Params.Clear();
                            request.Params.Add("train_date", System.Web.HttpUtility.UrlEncode(train_date));
                            request.Params.Add("train_no", System.Web.HttpUtility.UrlEncode(Data.QueryLeftNewDTO.train_no));
                            request.Params.Add("stationTrainCode", System.Web.HttpUtility.UrlEncode(Data.QueryLeftNewDTO.station_train_code));
                            request.Params.Add("seatType", System.Web.HttpUtility.UrlEncode("0"));
                            request.Params.Add("fromStationTelecode", System.Web.HttpUtility.UrlEncode(Data.QueryLeftNewDTO.from_station_telecode));
                            request.Params.Add("toStationTelecode", System.Web.HttpUtility.UrlEncode(Data.QueryLeftNewDTO.to_station_telecode));
                            request.Params.Add("leftTicket", System.Web.HttpUtility.UrlEncode(Data.QueryLeftNewDTO.yp_info));
                            request.Params.Add("purpose_codes", System.Web.HttpUtility.UrlEncode("00"));
                            request.Params.Add("_json_att", string.Empty);
                            request.Params.Add("REPEAT_SUBMIT_TOKEN", System.Web.HttpUtility.UrlEncode(SubmitToken));
                            list = HttpContext.Send(request);
                            if (list.Count == 2)
                            {
                                PWLoading.UpdateMessage("正在确认订单...");
                                jsonResult = Encoding.UTF8.GetString(list[1] as byte[]);
                                response   = JsonConvert.DeserializeObject <ResponseQueueCount>(jsonResult);
                                if (response.status)
                                {
                                    request.RequestURL = "/otn/confirmPassenger/confirmSingleForQueue";
                                    request.RefererURL = "/otn/confirmPassenger/initDc";
                                    request.Params.Clear();
                                    request.Params.Add("passengerTicketStr", passengerTicketStr);
                                    request.Params.Add("oldPassengerStr", oldPassengerStr);
                                    request.Params.Add("randCode", code);
                                    request.Params.Add("purpose_codes", TicketInfo.purpose_codes);
                                    request.Params.Add("key_check_isChange", TicketInfo.key_check_isChange);
                                    request.Params.Add("leftTicketStr", TicketInfo.leftTicketStr);
                                    request.Params.Add("train_location", TicketInfo.train_location);
                                    request.Params.Add("_json_att", string.Empty);
                                    request.Params.Add("REPEAT_SUBMIT_TOKEN", SubmitToken);
                                    list       = HttpContext.Send(request);
                                    jsonResult = Encoding.UTF8.GetString(list[1] as byte[]);
                                    response   = JsonConvert.DeserializeObject <ResponseSubmit>(jsonResult);
                                    if (response.status)
                                    {
                                        if ((response as ResponseSubmit).Data.submitStatus)
                                        {
                                            result = true;
                                        }
                                    }
                                }
                            }
                            else
                            {
                                Log.Log.Write(list);
                            }
                        }
                        else
                        {
                            Log.Log.Write(list);
                            throw new Exception(res_check_order.Data.errMsg);
                        }
                    }
                    else if (response.messages != null && response.messages.Length > 0)
                    {
                        string message = response.messages[0];
                        Log.Log.Write(list);
                        throw new Exception(message);
                    }
                }
                else
                {
                    Log.Log.Write(list);
                }
            }));
            return(result);
        }