Exemplo n.º 1
0
        private void commit(string lefttick, string token, string code)
        {
            canPlaySound = false;
            initSelectedPassenger();
            TrainInfo.Date = dtpDate.Value.ToString("yyyy-MM-dd");
            string yuanshi =
            @"org.apache.struts.taglib.html.TOKEN#1f0aa644944e5073ff550f8cb51df8908
            leftTicketStr#O023650277O023653084M037950005
            textfield#中文或拼音首字母
            orderRequest.train_date#2013-02-08
            orderRequest.train_no#380000D62403
            orderRequest.station_train_code#D624
            orderRequest.from_station_telecode#ZZF
            orderRequest.to_station_telecode#AOH
            orderRequest.seat_type_code#
            orderRequest.ticket_type_order_num#
            orderRequest.bed_level_order_num#000000000000000000000000000000
            orderRequest.start_time#12:38
            orderRequest.end_time#19:20
            orderRequest.from_station_name#郑州
            orderRequest.to_station_name#上海虹桥
            orderRequest.cancel_flag#1
            orderRequest.id_mode#Y";

            commitForm.QueryString.Clear();

            commitForm.QueryString.Add(new KeyValue("rand", code));
            commitForm.ClearTag();

            using (StringReader reader = new StringReader(yuanshi))
            {

                string line = null;
                while ((line = reader.ReadLine()) != null)
                {
                    string[] tags = line.Split('#');
                    commitForm.setTagValue(tags[0], tags[1]);
                }
            }
            int i = 0;
            for (; i < selectedPassengers.Count; i++)
            {
                passengerTicketItem item = selectedPassengers[i];
                item.Index = i + 1;
                item.addToForm(commitForm);
            }

            passengerTicketItem empty = new passengerTicketItem(3);

            for (; i < 5; i++)
            {
                empty.addToForm(commitForm);
            }

            string yushi2 =
            @"randCode#cccc
            orderRequest.reserve_flag#A
            tFlag#dc";

            using (StringReader reader = new StringReader(yushi2))
            {
                string line = null;
                while ((line = reader.ReadLine()) != null)
                {
                    string[] tags = line.Split('#');
                    commitForm.setTagValue(tags[0], tags[1]);
                }
            }

            commitForm.setTagValue("orderRequest.train_date", TrainInfo.Date);
            commitForm.setTagValue("orderRequest.train_no", currTrainInfo.TrainCode);
            commitForm.setTagValue("orderRequest.station_train_code", currTrainInfo.TrainName);
            commitForm.setTagValue("orderRequest.from_station_telecode", currTrainInfo.FromStationCode);
            commitForm.setTagValue("orderRequest.to_station_telecode", currTrainInfo.TotationCode);
            commitForm.setTagValue("orderRequest.from_station_name", currTrainInfo.FromStationName);
            commitForm.setTagValue("orderRequest.to_station_name", currTrainInfo.ToStationName);
            commitForm.setTagValue("orderRequest.start_time", currTrainInfo.StartTime);
            commitForm.setTagValue("orderRequest.end_time", currTrainInfo.ArriveTime);
            commitForm.setTagValue("org.apache.struts.taglib.html.TOKEN", token);
            commitForm.setTagValue("leftTicketStr", lefttick);
            commitForm.setTagValue("randCode", code);
            //getImage("https://dynamic.12306.cn/otsweb/images/long_button_u_over.jpg", "https://dynamic.12306.cn/otsweb/order/confirmPassengerAction.do?method=init");
            File.WriteAllText("commit.txt", commitForm.debug());
            commitForm.post();
        }
Exemplo n.º 2
0
        private void checkTick(string lefttick, string token, string code)
        {
            string yuanshi =
            @"org.apache.struts.taglib.html.TOKEN#1f0aa644944e5073ff550f8cb51df8908
            leftTicketStr#O023650277O023653084M037950005
            textfield#中文或拼音首字母
            orderRequest.train_date#2013-02-08
            orderRequest.train_no#380000D62403
            orderRequest.station_train_code#D624
            orderRequest.from_station_telecode#ZZF
            orderRequest.to_station_telecode#AOH
            orderRequest.seat_type_code#
            orderRequest.ticket_type_order_num#
            orderRequest.bed_level_order_num#000000000000000000000000000000
            orderRequest.start_time#12:38
            orderRequest.end_time#19:20
            orderRequest.from_station_name#郑州
            orderRequest.to_station_name#上海虹桥
            orderRequest.cancel_flag#1
            orderRequest.id_mode#Y";

            checkForm.ClearTag();

            using (StringReader reader = new StringReader(yuanshi))
            {
                string line = null;

                while ((line = reader.ReadLine()) != null)
                {
                    string[] tags = line.Split('#');
                    checkForm.AddTag(tags[0], tags[1]);
                }
            }
            int i = 0;
            for (; i < selectedPassengers.Count; i++)
            {
                passengerTicketItem item = selectedPassengers[i];
                item.Index = i + 1;
                item.addToForm(checkForm);
            }

            passengerTicketItem empty = new passengerTicketItem(3);

            for (; i < 5; i++)
            {
                empty.addToForm(checkForm);
            }

            string yushi2 =
            @"randCode#cccc
            orderRequest.reserve_flag#A";

            using (StringReader reader = new StringReader(yushi2))
            {
                string line = null;
                while ((line = reader.ReadLine()) != null)
                {
                    string[] tags = line.Split('#');
                    checkForm.AddTag(tags[0], tags[1]);
                }
            }

            checkForm.setTagValue("orderRequest.train_date", TrainInfo.Date);
            checkForm.setTagValue("orderRequest.train_no", currTrainInfo.TrainCode);
            checkForm.setTagValue("orderRequest.station_train_code", currTrainInfo.TrainName);
            checkForm.setTagValue("orderRequest.from_station_telecode", currTrainInfo.FromStationCode);
            checkForm.setTagValue("orderRequest.to_station_telecode", currTrainInfo.TotationCode);
            checkForm.setTagValue("orderRequest.from_station_name", currTrainInfo.FromStationName);
            checkForm.setTagValue("orderRequest.to_station_name", currTrainInfo.ToStationName);
            checkForm.setTagValue("orderRequest.start_time", currTrainInfo.StartTime);
            checkForm.setTagValue("orderRequest.end_time", currTrainInfo.ArriveTime);
            checkForm.setTagValue("org.apache.struts.taglib.html.TOKEN", token);
            checkForm.setTagValue("leftTicketStr", lefttick);
            checkForm.setTagValue("randCode", code);
            File.WriteAllText("post_check.txt", checkForm.debug());
            checkForm.post();
        }