Ejemplo n.º 1
0
        void AutoOrderWindow_Loaded(object sender, RoutedEventArgs e)
        {
            LoginWindow window = new LoginWindow(_client);
            if (window.ShowDialog() == true)
            {
                _client.Store();

                //button1.IsEnabled = false;
            }
            else
            {
                Close();
                return;
            }

            _12306Proxy proxy = new _12306Proxy(_client);


            //_ctlListPassenger.ItemsSource = proxy.GetOfflinePassengers();
            _ctlListPassenger.ItemsSource = proxy.GetPassengers();
            _ctlListTrain.ItemsSource = proxy.GetOfflineTrains();

            List<SeatModel> seats = new List<SeatModel>();
            #region 软卧
            SeatModel seatRWTop = new SeatModel();
            seatRWTop.caption = "软卧-上铺";
            seatRWTop.seat = "4";
            seatRWTop.seat_detail = "0";
            seatRWTop.seat_detail_select = "3";
            seats.Add(seatRWTop);
            SeatModel seatRWMiddle = new SeatModel();
            seatRWMiddle.caption = "软卧-中铺";
            seatRWMiddle.seat = "4";
            seatRWMiddle.seat_detail = "0";
            seatRWMiddle.seat_detail_select = "2";
            seats.Add(seatRWMiddle);
            SeatModel seatRWBottom = new SeatModel();
            seatRWBottom.caption = "软卧-下铺";
            seatRWBottom.seat = "4";
            seatRWBottom.seat_detail = "0";
            seatRWBottom.seat_detail_select = "1";
            seats.Add(seatRWBottom);
            #endregion

            #region 硬卧
            SeatModel seatYWTop = new SeatModel();
            seatYWTop.caption = "硬卧-上铺";
            seatYWTop.seat = "3";
            seatYWTop.seat_detail = "0";
            seatYWTop.seat_detail_select = "3";
            seats.Add(seatYWTop);
            SeatModel seatYWMiddle = new SeatModel();
            seatYWMiddle.caption = "硬卧-中铺";
            seatYWMiddle.seat = "3";
            seatYWMiddle.seat_detail = "0";
            seatYWMiddle.seat_detail_select = "2";
            seats.Add(seatYWMiddle);
            SeatModel seatYWBottom = new SeatModel();
            seatYWBottom.caption = "硬卧-下铺";
            seatYWBottom.seat = "3";
            seatYWBottom.seat_detail = "0";
            seatYWBottom.seat_detail_select = "1";
            seats.Add(seatYWBottom);
            #endregion

            SeatModel seatYZ = new SeatModel();
            seatYZ.caption = "硬座";
            seatYZ.seat = "1";
            seatYZ.seat_detail = "0";
            seatYZ.seat_detail_select = "0";
            seats.Add(seatYZ);
            _ctlListSeat.ItemsSource = seats;

            DateTime limitDate = new DateTime(2013,1,7);
            
            for (int index = 0; index < 20 && DateTime.Now.Date.AddDays(index) < limitDate; index++)
            {
                Button btn = new Button();
                btn.Width = 100;
                btn.Height = 14;
                btn.Margin = new Thickness(5,3,0,0);
                StackPanel sp = new StackPanel();
                btn.Content = sp;
                TextBlock t1 = new TextBlock();
                t1.HorizontalAlignment = System.Windows.HorizontalAlignment.Center;
                t1.FontSize = 10;
                t1.Text = string.Format("{0}", DateTime.Now.AddDays(index).ToString("yyyy年MM月dd日"));
                TextBlock t2 = new TextBlock();
                t2.HorizontalAlignment = System.Windows.HorizontalAlignment.Center;
                t2.Text = GetDayCountString(index);
                sp.Children.Add(t1);
                sp.Children.Add(t2);
                btn.Tag = index;
                btn.Click += new RoutedEventHandler(btn_Click);
                _ctlWrapPanel.Children.Add(btn);
            }
        }
Ejemplo n.º 2
0
        void btn_Click(object sender, RoutedEventArgs e)
        {
            if (_isRunning)
            {
                return;
            }

            _selectedPassenger = new List<PassengerModel>();
            foreach (PassengerModel item in _ctlListPassenger.SelectedItems)
            {
                _selectedPassenger.Add(item);
            }
            _selectedTrain = _ctlListTrain.SelectedItem as TrainInfo;
            _selectedSeat = (_ctlListSeat.SelectedItem as SeatModel);
            if (_selectedPassenger.Count == 0 || _selectedSeat == null || _selectedTrain == null)
            {
                return;
            }

            InputRandCodeWindow window = new InputRandCodeWindow(_client);
            if (window.ShowDialog() == true)
            {
                _ctlBtnCancel.IsEnabled = true;
                _borderMask.Visibility = System.Windows.Visibility.Visible;

                _randCode = window.RandCode;
                _day = Convert.ToInt32((sender as Button).Tag);
                _isRunning = true;
                _thread = new Thread(Run);
                _thread.Start();
            }
        }
Ejemplo n.º 3
0
        public bool GoPay(string orderNo, ConfirmModel model, List<PassengerModel> passengers, SeatModel seat)
        {
            Dictionary<string, string> parameters = new Dictionary<string, string>();
            parameters["org.apache.struts.taglib.html.TOKEN"] = model.org_apache_struts_taglib_html_TOKEN;
            parameters["leftTicketStr"] = model.leftTicketStr;
            parameters["textfield"] = Uri.EscapeUriString("中文或拼音首字母");
            //parameters["checkbox0"]=
            //parameters["checkbox2"]=
            parameters["orderRequest.train_date"] = model.orderRequest_train_date;
            parameters["orderRequest.train_no"] = model.orderRequest_train_no;
            parameters["orderRequest.station_train_code"] = model.orderRequest_station_train_code;
            parameters["orderRequest.from_station_telecode"] = model.orderRequest_from_station_telecode;
            parameters["orderRequest.to_station_telecode"] = model.orderRequest_to_station_telecode;
            parameters["orderRequest.seat_type_code"] = model.orderRequest_seat_type_code;
            parameters["orderRequest.seat_detail_type_code"] = model.orderRequest_seat_detail_type_code;
            parameters["orderRequest.ticket_type_order_num"] = model.orderRequest_ticket_type_order_num;
            parameters["orderRequest.bed_level_order_num"] = model.orderRequest_bed_level_order_num;
            parameters["orderRequest.start_time"] = model.orderRequest_start_time;
            parameters["orderRequest.end_time"] = model.orderRequest_end_time;
            parameters["orderRequest.from_station_name"] = Uri.EscapeUriString(model.orderRequest_from_station_name);
            parameters["orderRequest.to_station_name"] = Uri.EscapeUriString(model.orderRequest_to_station_name);
            parameters["orderRequest.cancel_flag"] = model.orderRequest_cancel_flag;
            parameters["orderRequest.id_mode"] = model.orderRequest_id_mode;

            //passengerTickets
            //oldPassengers
            //passenger_1_seat
            //passenger_1_seat_detail_select
            //passenger_1_seat_detail
            //passenger_1_ticket
            //passenger_1_name
            //passenger_1_cardtype
            //passenger_1_cardno
            //passenger_1_mobileno
            //checkbox9
            //passengerTickets
            //oldPassengers
            //passenger_2_seat
            //passenger_2_seat_detail_select
            //passenger_2_seat_detail
            //passenger_2_ticket
            //passenger_2_name
            //passenger_2_cardtype
            //passenger_2_cardno
            //passenger_2_mobileno
            //checkbox9
            //oldPassengers
            //checkbox9
            //oldPassengers
            //checkbox9
            //oldPassengers
            //checkbox9
            StringBuilder passengerTickets = new StringBuilder();
            for (int index = 0; index < 5; index++)
            {
                if (index < passengers.Count)
                {
                    if (index == 0)
                    {
                        passengerTickets.AppendFormat(
                            "{0},{1},{2},{3},{4},{5},{6},{7}",
                            seat.seat,
                            seat.seat_detail_select,
                            passengers[index].passenger_ticket,
                            Uri.EscapeUriString(passengers[index].passenger_name),
                            passengers[index].passenger_cardtype,
                            passengers[index].passenger_cardno,
                            passengers[index].passenger_mobileno,
                            passengers[index].checkbox9);
                    }
                    else
                    {
                        passengerTickets.AppendFormat(
                            "&passengerTickets={0},{1},{2},{3},{4},{5},{6},{7}",
                            seat.seat,
                            seat.seat_detail_select,
                            passengers[index].passenger_ticket,
                            Uri.EscapeUriString(passengers[index].passenger_name),
                            passengers[index].passenger_cardtype,
                            passengers[index].passenger_cardno,
                            passengers[index].passenger_mobileno,
                            passengers[index].checkbox9);
                    }
                    passengerTickets.AppendFormat(
                        "&oldPassengers={0},{1},{2}",
                        Uri.EscapeUriString(passengers[index].passenger_name),
                        passengers[index].passenger_cardtype,
                        passengers[index].passenger_cardno);
                    passengerTickets.AppendFormat(
                        "&passenger_{0}_seat={1}&passenger_{0}_seat_detail_select={2}&passenger_{0}_seat_detail={3}&passenger_{0}_ticket={4}&passenger_{0}_name={5}&passenger_{0}_cardtype={6}&passenger_{0}_cardno={7}&passenger_{0}_mobileno={8}&checkbox9={9}",
                        index + 1,
                        seat.seat,
                        seat.seat_detail_select,
                        seat.seat_detail,
                        passengers[index].passenger_ticket,
                        Uri.EscapeUriString(passengers[index].passenger_name),
                        passengers[index].passenger_cardtype,
                        passengers[index].passenger_cardno,
                        passengers[index].passenger_mobileno,
                        passengers[index].checkbox9);
                }
                else
                {
                    passengerTickets.AppendFormat("&oldPassengers=&checkbox9=Y");
                }
            }
            parameters["passengerTickets"] = passengerTickets.ToString();
            parameters["randCode"] = model.randCode;
            parameters["orderRequest.reserve_flag"] = model.orderRequest_reserve_flag;


            string content = _client.Post(
                "https://dynamic.12306.cn/otsweb/order/confirmPassengerAction.do?method=payOrder&orderSequence_no=" + orderNo,
                parameters,
                "https://dynamic.12306.cn/otsweb/order/confirmPassengerAction.do?method=init");
            if (!string.IsNullOrEmpty(content))
            {
                //{\"errMsg\":\"Y\"}
                return true;
            }
            else
            {
                return false;
            }
        }
Ejemplo n.º 4
0
        private bool Confirm2_2(ConfirmModel model, List<PassengerModel> passengers, SeatModel seat, out string message)
        {
            #region https://dynamic.12306.cn/otsweb/order/confirmPassengerAction.do?method=getQueueCount
              
            //&train_date=2012-12-30&train_no=24000000T90I&station=T9&seat=1&from=BXP&to=CUW
            //&ticket=1023103293406420000010231004493040500000

            Dictionary<string, string> parameters2 = new Dictionary<string, string>();
            parameters2["method"] = "getQueueCount";
            parameters2["train_date"] = model.orderRequest_train_date;
            parameters2["station"] = model.orderRequest_station_train_code;
            parameters2["seat"] = seat.seat;
            parameters2["from"] =model.orderRequest_from_station_telecode;
            parameters2["to"] = model.orderRequest_to_station_telecode;
            parameters2["ticket"] = model.leftTicketStr;
            try
            {
                string content = _client.Get(
                    "https://dynamic.12306.cn/otsweb/order/confirmPassengerAction.do",
                    parameters2,
                    "https://dynamic.12306.cn/otsweb/order/confirmPassengerAction.do?method=init");
                message = content;
                return true;
            }
            catch(Exception ex)
            {
                message = ex.Message + "\r\n" + ex.StackTrace;
                return false;
            }
            #endregion
        }
Ejemplo n.º 5
0
        public bool Confirm2(ConfirmModel model, List<PassengerModel> passengers, SeatModel seat, out string message)
        {
            if (!Confirm2_1(model, passengers, seat, out message))
            {
                return false;
            }
            if (!Confirm2_2(model, passengers, seat, out message))
            {
                return false;
            }

            return Confirm2_3(model, passengers, seat, out message);
        }
Ejemplo n.º 6
0
        private void _btnOrderYZ_Click(object sender, RoutedEventArgs e)
        {
            SeatModel seat = new SeatModel();
            seat.seat = "1";
            seat.seat_detail = "0";
            seat.seat_detail_select = "0";

            _12306Proxy proxy = new _12306Proxy(_client);
            InputRandCodeWindow window = new InputRandCodeWindow(_client);
            if (window.ShowDialog() == true)
            {
                TicketModel ticket = (sender as Button).DataContext as TicketModel;
                ConfirmModel confirmModel = proxy.Submit(_query, ticket, window.RandCode);

                confirmModel.randCode = window.RandCode;
                if (proxy.Confirm(confirmModel, new List<PassengerModel>(Passengers.Data), seat))
                {
                    MessageBox.Show("订票成功!");
                }
                else
                {
                    MessageBox.Show("订票失败!");
                }
            }
        }