예제 #1
0
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);
            chePiaoCellInfo cell = e.Parameter as chePiaoCellInfo;

            if (cell != null)
            {
                labForCheCi.Text = cell.checi;


                labForLiCheng.Text = cell.liShiShiJian + cell.jieshuTime + "到达";

                chePiaoCell obj           = cell.cell;
                string      qishiAddress  = obj.queryLeftNewDTO.from_station_name + (obj.queryLeftNewDTO.start_station_name.Equals(obj.queryLeftNewDTO.from_station_name) ? "[始发]" : "[路过]");
                string      jieshuAddress = obj.queryLeftNewDTO.to_station_name + (obj.queryLeftNewDTO.end_station_name.Equals(obj.queryLeftNewDTO.to_station_name) ? "[终到]" : "[路过]");
                labForFaDaoZhan.Text = qishiAddress + "-" + jieshuAddress;

                labForKaiCheShiJian.Text = cell.train_date + " " + cell.qishiTime;
                labForLiCheng.Text       = "历时" + obj.queryLeftNewDTO.lishi + "," + (obj.queryLeftNewDTO.day_difference.Equals("0") ? "当天" : "第" + ((int.Parse(obj.queryLeftNewDTO.day_difference) + 1) + "天")) + cell.jieshuTime + "到达";

                //string jieguo =   getYuPiao(obj.queryLeftNewDTO.yp_info);
                //添加预定车票信息
                addYuPiao(obj.queryLeftNewDTO.yp_info, cell);
                HTTPRequest.init().getTouken(true);
                //查询这个车次的时刻表
                string shiKeUri = "https://kyfw.12306.cn/otn/czxx/queryByTrainNo";
                Dictionary <string, string> dicShiKe = new Dictionary <string, string>();
                dicShiKe.Add("train_no", obj.queryLeftNewDTO.train_no);
                dicShiKe.Add("from_station_telecode", obj.queryLeftNewDTO.from_station_telecode);
                dicShiKe.Add("to_station_telecode", obj.queryLeftNewDTO.to_station_telecode);
                dicShiKe.Add("depart_date", cell.train_date);
                HTTPRequest.init().sendGet(shiKeUri, dicShiKe, (JsonObject json) =>
                {
                    Debug.WriteLine(json.ToString());
                    JsonObject data   = json["data"].GetObject();
                    JsonArray dataArr = data["data"].GetArray();
                    for (int i = -1; i < dataArr.Count; i++)
                    {
                        if (i >= 0)
                        {
                            JsonObject cellshike               = dataArr[i].GetObject();
                            shiKeCell cellMode                 = JsonHelper <shiKeCell> .Deserialize(cellshike.ToString(), typeof(shiKeCell)) as shiKeCell;
                            JYHuoCheShiKeCell huocheview       = new JYHuoCheShiKeCell();
                            huocheview.labForZhanMing.Text     = cellMode.station_name;
                            huocheview.labForDaoShi.Text       = cellMode.arrive_time;
                            huocheview.labForFaShi.Text        = cellMode.start_time;
                            huocheview.LabForTingLiu.Text      = cellMode.stopover_time;
                            huocheview.labForShiGuo.Visibility = cellMode.isEnabled.Equals("true") ? Visibility.Visible : Visibility.Collapsed;
                            stackPanel.Children.Add(huocheview);
                        }
                        else if (i == -1)
                        {
                            JYHuoCheShiKeCell huocheview   = new JYHuoCheShiKeCell();
                            huocheview.labForZhanMing.Text = "站名";
                            huocheview.labForDaoShi.Text   = "到达时间(到站)";
                            huocheview.labForFaShi.Text    = "发车时间(离站)";
                            huocheview.LabForTingLiu.Text  = "停留时间";
                            huocheview.labForShiGuo.Text   = "是否驶过";
                            stackPanel.Children.Add(huocheview);
                        }
                    }
                }, (string err) =>
                {
                    Debug.WriteLine(err.ToString());
                });
            }
        }
예제 #2
0
        void freashData(int days)
        {
            DateTime datePicker = Convert.ToDateTime(train_date);

            datePicker = datePicker.AddDays(days);
            train_date = datePicker.Date.Year + "-" + datePicker.Date.Month.ToString("00") + "-" + datePicker.Date.Day.ToString("00");
            Dictionary <string, string> dic = new Dictionary <string, string>();

            dic.Add("leftTicketDTO.train_date", train_date);
            dic.Add("leftTicketDTO.from_station", from_station);
            dic.Add("leftTicketDTO.to_station", to_station);
            dic.Add("purpose_codes", "ADULT");

            string uristr = "https://kyfw.12306.cn/otn/leftTicket/queryT";

            HTTPRequest.init().sendGet(uristr, dic, (JsonObject json) => {
                Debug.WriteLine(json.ToString());
                if (json["data"].GetArray().Count == 0)
                {
                    MessageDialog mes = new MessageDialog("没有相关车次");
                    mes.ShowAsync();
                    return;
                }
                JsonArray arr = json["data"].GetArray();
                bindingInfo.Clear();
                titleName.Text = train_date + "(" + arr.Count + "趟)";
                for (uint i = 0; i < arr.Count; i++)
                {
                    JsonObject jsonObj   = arr.GetObjectAt(i);
                    chePiaoCell obj      = JsonHelper <chePiaoCell> .Deserialize(jsonObj.ToString(), typeof(chePiaoCell)) as chePiaoCell;
                    chePiaoCellInfo info = new chePiaoCellInfo();
                    info.train_date      = train_date;

                    info.back_train_date = DateTime.Now.Date.Year + "-" + DateTime.Now.Date.Month.ToString("00") + "-" + DateTime.Now.Date.Day.ToString("00");
                    info.cell            = obj;
                    info.checi           = obj.queryLeftNewDTO.station_train_code;


                    info.qishiAddress  = (obj.queryLeftNewDTO.start_station_name.Equals(obj.queryLeftNewDTO.from_station_name) ? "始" : "过") + obj.queryLeftNewDTO.from_station_name;
                    info.jieshuAddress = (obj.queryLeftNewDTO.end_station_name.Equals(obj.queryLeftNewDTO.to_station_name) ? "终" : "过") + obj.queryLeftNewDTO.to_station_name;
                    info.qishiTime     = obj.queryLeftNewDTO.start_time + "开";
                    info.jieshuTime    = obj.queryLeftNewDTO.arrive_time + "到";
                    info.yuPiao        = obj.queryLeftNewDTO.yw_num;
                    info.liShiShiJian  = "历时:" + obj.queryLeftNewDTO.lishi + "(" + obj.queryLeftNewDTO.day_difference + "天)";

                    string yuPiao = "【余票】";
                    //if (!obj.queryLeftNewDTO.gr_num.Equals("--"))
                    //{
                    //    yuPiao += "  高级软卧:" + obj.queryLeftNewDTO.gr_num;
                    //}
                    //if (!obj.queryLeftNewDTO.qt_num.Equals("--"))
                    //{
                    //    yuPiao += "  其他:" + obj.queryLeftNewDTO.qt_num;
                    //}
                    //if (!obj.queryLeftNewDTO.rw_num.Equals("--"))
                    //{
                    //    yuPiao += "  软卧:" + obj.queryLeftNewDTO.rw_num;
                    //}
                    //if (!obj.queryLeftNewDTO.rz_num.Equals("--"))
                    //{
                    //    yuPiao += "  软座:" + obj.queryLeftNewDTO.rz_num;
                    //}
                    //if (!obj.queryLeftNewDTO.tz_num.Equals("--"))
                    //{
                    //    yuPiao += "  特等座:" + obj.queryLeftNewDTO.tz_num;
                    //}
                    //if (!obj.queryLeftNewDTO.wz_num.Equals("--"))
                    //{
                    //    yuPiao += "  无座:" + obj.queryLeftNewDTO.wz_num;
                    //}
                    //if (!obj.queryLeftNewDTO.yw_num.Equals("--"))
                    //{
                    //    yuPiao += "  硬卧:" + obj.queryLeftNewDTO.yw_num;
                    //}
                    //if (!obj.queryLeftNewDTO.yz_num.Equals("--"))
                    //{
                    //    yuPiao += "  硬座:" + obj.queryLeftNewDTO.yz_num;
                    //}
                    //if (!obj.queryLeftNewDTO.ze_num.Equals("--"))
                    //{
                    //    yuPiao += "  二等座:" + obj.queryLeftNewDTO.ze_num;
                    //}
                    //if (!obj.queryLeftNewDTO.zy_num.Equals("--"))
                    //{
                    //    yuPiao += "  一等座:" + obj.queryLeftNewDTO.zy_num;
                    //}
                    //if (!obj.queryLeftNewDTO.swz_num.Equals("--"))
                    //{
                    //    yuPiao += "  商务座:" + obj.queryLeftNewDTO.swz_num;
                    //}
                    yuPiao += getYuPiao(obj.queryLeftNewDTO.yp_info);
                    if (obj.buttonTextInfo.Equals("预订"))
                    {
                        info.yuPiao = yuPiao;
                    }
                    else
                    {
                        info.yuPiao = obj.buttonTextInfo;
                    }

                    bindingInfo.Add(info);
                }
            }, (string err) => {
                Debug.WriteLine(err);
            });
        }