Exemple #1
0
        public QueryTicketResponseInfo QueryTicket(QueryTicketRequestInfo request)
        {
            QueryTicketResponseInfo info = RequestMessage <QueryTicketResponseInfo>(request);

            if ((info.ErrInfo != null) && (info.ErrInfo.TransCode != null))
            {
                throw new GatewayException(info.ErrInfo.Message);
            }
            return(info);
        }
Exemple #2
0
        public QueryTicketResponseInfo QueryLeftTicketDTO(string train_date, string from_station, string to_station)
        {
            HttpClient client = new HttpClient(Cookies);

            if (StaticValues.Proxy != "")
            {
                client.Proxy = new WebProxy(StaticValues.Proxy);
            }
            string url = "https://kyfw.12306.cn/otn/leftTicket/query?leftTicketDTO.train_date={0}&leftTicketDTO.from_station={1}&leftTicketDTO.to_station={2}&purpose_codes=ADULT";

            url = string.Format(url, train_date, from_station, to_station);
            string result = client.Get(url);

            if (result != "")
            {
                QueryTicketResponseInfo ri = JsonHelper.JsonDeserialize <QueryTicketResponseInfo>(result);
                return(ri);
            }
            else
            {
                return(null);
            }
        }
Exemple #3
0
        public static DataTable GetLeftTicket(ref QueryEntity qe)
        {
            DataTable dtTicket = CreateTicketDt();

            if (qe.optionDates.Contains(qe.train_date))
            {
                qe.optionDates.Remove(qe.train_date);
            }
            qe.optionDates.Insert(0, qe.train_date);
            TicketService service = new TicketService(StaticValues.MyCookies);

            for (int i = 0; i < qe.optionDates.Count; i++)
            {
                string date = qe.optionDates[i];
                qe.train_date = date;
                QueryTicketResponseInfo rspInfo = service.QueryLeftTicketDTO(qe.train_date, qe.from_station_telecode, qe.to_station_telecode);
                if (rspInfo != null && rspInfo.status)
                {
                    if (rspInfo.data != null && rspInfo.data.Count > 0)
                    {
                        string[] timeArray = qe.start_time_str.Split("--".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
                        int      beginTime = Convert.ToInt32(timeArray[0].Replace(":", ""));
                        int      endTime   = Convert.ToInt32(timeArray[1].Replace(":", ""));
                        foreach (QueryLeftNewDTOData q in rspInfo.data)
                        {
                            bool flag = CheckTrainClass(q, qe);
                            if (flag)
                            {
                                int startTime = Convert.ToInt32(q.queryLeftNewDTO.start_time.Replace(":", ""));
                                if (startTime >= beginTime && endTime >= startTime)
                                {
                                    if ((qe.trainNoList != null && qe.trainNoList.Count > 0 && qe.trainNoList.Contains(q.queryLeftNewDTO.station_train_code)) || qe.trainNoList == null || qe.trainNoList.Count == 0)
                                    {
                                        DataRow row = dtTicket.NewRow();
                                        row["TrainCode"]    = q.queryLeftNewDTO.station_train_code;
                                        row["TrainCodeKey"] = q.queryLeftNewDTO.train_no + "#" + q.queryLeftNewDTO.start_station_telecode + "#" + q.queryLeftNewDTO.to_station_telecode;
                                        row["StartStation"] = q.queryLeftNewDTO.from_station_name + "(" + q.queryLeftNewDTO.start_time + ")";
                                        row["AimStation"]   = q.queryLeftNewDTO.to_station_name + "(" + q.queryLeftNewDTO.arrive_time + ")";
                                        row["TakeTime"]     = q.queryLeftNewDTO.lishi;
                                        row["ShangWu"]      = q.queryLeftNewDTO.swz_num;
                                        row["TeDeng"]       = q.queryLeftNewDTO.tz_num;
                                        row["YiDeng"]       = q.queryLeftNewDTO.zy_num;
                                        row["ErDeng"]       = q.queryLeftNewDTO.ze_num;
                                        row["GaoJiRuanWo"]  = q.queryLeftNewDTO.gr_num;
                                        row["RuanWo"]       = q.queryLeftNewDTO.rw_num;
                                        row["YingWo"]       = q.queryLeftNewDTO.yw_num;
                                        row["RuanZuo"]      = q.queryLeftNewDTO.rz_num;
                                        row["YingZuo"]      = q.queryLeftNewDTO.yz_num;
                                        row["WuZuo"]        = q.queryLeftNewDTO.wz_num;
                                        row["QiTa"]         = q.queryLeftNewDTO.qt_num;
                                        row["OrderKey"]     = q.secretStr;
                                        bool last = q.queryLeftNewDTO.to_station_name == q.queryLeftNewDTO.end_station_name;
                                        row["Last"] = last;
                                        bool first = q.queryLeftNewDTO.from_station_name == q.queryLeftNewDTO.start_station_name;
                                        row["First"] = first;
                                        row["Order"] = Images.Order;
                                        dtTicket.Rows.Add(row);
                                    }
                                }
                            }
                        }
                        dtTicket = FilterResultBySeat(dtTicket, qe);
                    }
                }
                if (dtTicket.Rows.Count > 0)
                {
                    break;
                }
            }
            return(dtTicket);
        }