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(); }
private void getPassenger() { addLog("初始化常用联系人...", true); string tem1 = null; JObject json = null; while (true) { tem1 = getText("https://dynamic.12306.cn/otsweb/order/confirmPassengerAction.do?method=getpassengerJson", true); if (tem1 == null) { addLog("初始化常用联系人错误,稍候重试", true); Thread.Sleep(500); continue; } try { json = (JObject)JsonConvert.DeserializeObject(tem1); } catch { addLog("初始化常用联系人错误,稍候重试", true); Thread.Sleep(500); continue; } break; } addLog(tem1, false); JArray jsonPassengersArray = (JArray)json["passengerJson"]; allPassengers.Clear(); foreach (JObject p in jsonPassengersArray) { passengerTicketItem item = new passengerTicketItem(0); item.Cardno = p["passenger_id_no"].ToString(); item.Cardtype = p["passenger_id_type_code"].ToString(); item.Mobileno = p["mobile_no"].ToString(); item.Name = p["passenger_name"].ToString(); item.Ticket = p["passenger_type"].ToString(); allPassengers.Add(item); } AddPassengerToList(); }
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(); }