public void TranslationHtml(string html, Action<List<TrainData>> callback) { string tmpHtml = html; List<TrainData> trainData = new List<TrainData>(); var rawStatus = tmpHtml.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); if (rawStatus.Length > 0 && (rawStatus.Length - 1) % 16 == 0) { int count = (rawStatus.Length - 1) >> 4; for (int i = 0; i < count; i++) { var status = new string[16]; Array.Copy(rawStatus, 1 + (i << 4), status, 0, 16); var trainItem = new TrainData(status); trainData.Add(trainItem); } callback(trainData); } }
public OrderData(TrainData trainInfo) { End_time = trainInfo.Arrive_time; From_station_name = trainInfo.From_station_name; From_station_telecode = trainInfo.From_station_telecode; Start_time = trainInfo.Start_time; Station_train_code = trainInfo.Station_train_code; To_station_name = trainInfo.To_station_name; To_station_telecode = trainInfo.To_station_telecode; Train_date = trainInfo.Train_date; Train_no = trainInfo.Trainno4; Bed_level_order_num = "000000000000000000000000000000"; Cancel_flag = "1"; Id_mode = "Y"; Reserve_flag = "A"; Seat_type_code = ""; Ticket_type_order_num = ""; }
public void TranslationHtml(string html, Action <List <TrainData> > callback) { string tmpHtml = html; List <TrainData> trainData = new List <TrainData>(); var rawStatus = tmpHtml.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); if (rawStatus.Length > 0 && (rawStatus.Length - 1) % 16 == 0) { int count = (rawStatus.Length - 1) >> 4; for (int i = 0; i < count; i++) { var status = new string[16]; Array.Copy(rawStatus, 1 + (i << 4), status, 0, 16); var trainItem = new TrainData(status); trainData.Add(trainItem); } callback(trainData); } }
public formSubmitOrder(string postData, TrainData trainInfo, List <PassengersData> passengers, string trainDate, CookieContainer cookie, string defaultseat = "") { InitializeComponent(); formStyle.MakeShadow(this.Handle); this._postData = postData; this._trainData = trainInfo; this._cookieContainer = cookie; this._passengers = passengers; this._trainDate = trainDate; this._defaultSeat = defaultseat; if (this._defaultSeat != "") { string path = System.IO.Directory.GetCurrentDirectory() + "\\Sound_GetTicket.wav"; if (System.IO.File.Exists(path)) { sp = new System.Media.SoundPlayer(path); sp.Play(); } } }
public formSubmitOrder(string postData,TrainData trainInfo, List<PassengersData> passengers, string trainDate, CookieContainer cookie,string defaultseat="") { InitializeComponent(); formStyle.MakeShadow(this.Handle); this._postData = postData; this._trainData = trainInfo; this._cookieContainer = cookie; this._passengers = passengers; this._trainDate = trainDate; this._defaultSeat = defaultseat; if (this._defaultSeat != "") { string path = System.IO.Directory.GetCurrentDirectory() + "\\Sound_GetTicket.wav"; if (System.IO.File.Exists(path)) { sp = new System.Media.SoundPlayer(path); sp.Play(); } } }
//过滤余票 //public bool CheckLeftTicketEnough(TrainData data, string seat = "") //{ // if (seat != "" && Convert.ToInt16(data.SeatOwener[seat]) > selectPassengerCount) // { // return true; // } // else if (seat == "") // { // foreach (string v in data.SeatOwener.Keys) // { // if (Convert.ToInt16(data.SeatOwener[v]) > selectPassengerCount) // { // return true; // } // } // return false; // } // else // return false; //} //开始预定 public void RunBook(TrainData data,string seat="") { DeterMineCall(() => { if (data.Bookable) { string postData = GetPostDataString(data, dtpRiqi.Value.Date); if (seat != "") { StopListenning(); var form = new formSubmitOrder(postData, data, _passengersData, dtpRiqi.Value.Date.ToString("yyyy-MM-dd"), cookieContainer, seat); this.Visible = true; form.ShowDialog(); notice.ShowBalloonTip(5 * 1000, "提示", "抢到票啦!赶紧预定吧.", ToolTipIcon.Info); } else { StopListenning(); var form1 = new formSubmitOrder(postData, data, _passengersData, dtpRiqi.Value.Date.ToString("yyyy-MM-dd"), cookieContainer); this.Visible = true; form1.ShowDialog(); notice.ShowBalloonTip(5 * 1000, "提示", "抢到票啦!赶紧预定吧.", ToolTipIcon.Info); } } else { MessageBox.Show(this, "该车次无票可定", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } }); }
//生成PostData public string GetPostDataString(TrainData data,DateTime trainDate) { data.Train_date = trainDate.ToString("yyyy-MM-dd"); string postData = string.Format("arrive_time={0}&from_station_name={1}&from_station_no={2}&from_station_telecode={3}&from_station_telecode_name={4}&include_student={5}&lishi={6}&locationCode={7}&mmStr={8}&round_start_time_str={9}&round_train_date={10}&seattype_num={11}&single_round_type={12}&start_time_str={13}&station_train_code={14}&to_station_name={15}&to_station_no={16}&to_station_telecode={17}&to_station_telecode_name={18}&train_class_arr={19}&train_date={20}&train_pass_type={21}&train_start_time={22}&trainno4={23}&ypInfoDetail={24}", data.Arrive_time.Replace(":", "%3A"), translation.UtfEncode(data.From_station_name), data.From_station_no, data.From_station_telecode, translation.UtfEncode(data.From_station_telecode_name), data.Include_student, data.Cost_time.Replace(":", "%3A"), data.LocationCode, data.mmStr, cboShijian.Text.Replace(":", "%3A"), data.Train_date, data.seattype_num, data.single_round_type, cboShijian.Text.Replace(":", "%3A"), data.Station_train_code, translation.UtfEncode(data.To_station_name), data.To_station_no, data.To_station_telecode, translation.UtfEncode(data.To_station_telecode_name), trainClassType, data.Train_date, rbtnQuanbu.Checked ? "QB" : rbtnShifa.Checked ? "SF" : "GL", data.Start_time.Replace(":", "%3A"), data.Trainno4, data.ypInfoDetail); return postData; }