Пример #1
0
        void QueryTicket()
        {
            #region--参数检测
            rtbTip.Text = string.Empty;
            ResourceManager rm = Lang.ResourceManager;
            List<string> nullItem = new List<string>();
            if (string.IsNullOrEmpty(ticketParam.from_station))
            {
                nullItem.Add(rm.GetString(langTipFix + cmbBeginStation.Tag));
            }
            if (string.IsNullOrEmpty(ticketParam.to_station))
            {
                nullItem.Add(rm.GetString(langTipFix + cmbToStation.Tag));
            }
            if (nullItem.Count > 0)
            {
                List<string> requireItem = new List<string>();
                requireItem.Add(rm.GetString(langTipFix + cmbBeginStation.Tag));
                requireItem.Add(rm.GetString(langTipFix + cmbToStation.Tag));
                rtbTip.Text = string.Format(Lang.Tip_12306_QueryTicketIsRequired, string.Join(",", requireItem), string.Join(",", nullItem));
                return;
            }
            #endregion
            string url = InitQueryTicketParam(ticketParam);
            string json = HttpClientExtend.HttpClientGet(url);
            LoggerWriter.CreateLogFile(json, LogDir, ELogType.DataLog, DateTime.Now.ToString(CommonFormat.DateTimeIntFormat) + ".txt");
            leftTicketDTOResponse response = json.ConvertObject<leftTicketDTOResponse>();//不能序列化字典
            JObject jr = JObject.Parse(json);
            JObject jd = (JObject)jr["data"];//字典为data下数据  map
            //由于json序列化时不能将节点下的字典型json串进行逆序列化,次出使用中转形式先读取取字典内容,在填充到对象
            JObject jdic = (JObject)jd["map"];
            Dictionary<string, string> _Data = Newtonsoft.Json.JsonConvert.DeserializeObject<Dictionary<string, string>>(jdic.ToString());
            if (response != null && response.data != null)
            {
                response.data.map = _Data;
            }
            //leftTicketDTOResponse responseNew= Newtonsoft.Json.JsonConvert.DeserializeObject<leftTicketDTOResponse>(json);
            /*
             * Newtonsoft
             其他信息: Cannot deserialize the current JSON object (e.g. {"name":"value"}) into type 'System.String[]' because the type requires a JSON array (e.g. [1,2,3]) to deserialize correctly.
             */
            foreach (var item in response.data.result)
            {
                GetCarTicket(item, response);
            }
            //存储列车座位信息
            //反射时构造函数没有提供参数可以进行创建
            ISyncTicketDataManage sync = IocHelper.CreateObjectCtorWithParam<ISyncTicketDataManage>(
                new object[]{AppCategory.WinApp,"Conn" },
                typeof(SyncTicketDataManage).Name,
                "TicketData.Manage",
                "CaptureManage.AppWin",//此为程序集,而不是命名空间
                NowAppDirHelper.GetNowAppDir(AppCategory.WinApp));
             
            //由于实现类中对于构造函数存在参数限定,此处需要特殊参数的传递
            sync.SaveCarWithSeatData(response);
            //读取列车过站信息
            //存储列车过站信息,绘制运动轨迹图

        }
Пример #2
0
 void GetCarTicket(string tick,leftTicketDTOResponse response) 
 {
     string[] cn=tick.Split('|');
     TicketSeatDataDto cr = new TicketSeatDataDto();
     if (!string.IsNullOrEmpty(cn[0]))
     {//本列车当前可以进行售票 
         cr.CanBuyTicket = true;
     }
     //ct.secretStr = cn[0];//secretStr 有车票供购买时使用的安全关键字
     //ct.buttonTextInfo = cn[1]; //按钮的文本内容//可能出现系统维护情况,直接在界面上显示不进行购票
     cr.train_no = cn[2];
     cr.station_train_code = cn[3];
     cr.start_station_telecode = cn[4];//始发站
     cr.end_station_telecode = cn[5];//终点站
     cr.from_station_telecode = cn[6];//乘客出发站
     cr.to_station_telecode = cn[7];//乘客目的地站
     cr.start_time = cn[8];//乘客随车出发时间
     cr.arrive_time = cn[9];//乘客到达时间
     cr.lishi = cn[10];//耗时
     cr.canWebBuy = cn[11];//IS_TIME_NOT_BUY 这样的字符串标识
     cr.yp_info = cn[12];//随机串
     cr.start_train_date = cn[13];//出发日期
     cr.train_seat_feature = cn[14];
     cr.location_code = cn[15];
     cr.from_station_no = cn[16];
     cr.to_station_no = cn[17];
     cr.is_support_card = cn[18];//可凭二代身份证直接进出站(不用取票)
     cr.controlled_train_flag = cn[19];//是否显示票价(1|2不显示票价)
     cr.gg_num =string.IsNullOrEmpty( cn[20]) ? cn[20] : "--";
     cr.gr_num = string.IsNullOrEmpty(cn[21]) ? cn[21] : "--";//高级软卧
     cr.qt_num = string.IsNullOrEmpty(cn[22]) ? cn[22] : "--";
     cr.rw_num = string.IsNullOrEmpty(cn[23]) ? cn[23] : "--";//软卧
     cr.rz_num = string.IsNullOrEmpty(cn[24]) ? cn[24] : "--";//软座
     cr.tz_num = string.IsNullOrEmpty(cn[25]) ? cn[25] : "--";//特等座
     cr.wz_num = string.IsNullOrEmpty(cn[26]) ? cn[26] : "--";//无座
     cr.yb_num = string.IsNullOrEmpty(cn[27]) ? cn[27] : "--";
     cr.yw_num = string.IsNullOrEmpty(cn[28]) ? cn[28] : "--";//硬卧
     cr.yz_num = string.IsNullOrEmpty(cn[29]) ? cn[29] : "--";//硬座
     cr.ze_num = string.IsNullOrEmpty(cn[30]) ? cn[30] : "--";//二等座
     cr.zy_num = string.IsNullOrEmpty(cn[31]) ? cn[31] : "--";//一等座
     cr.swz_num = string.IsNullOrEmpty(cn[32]) ? cn[32] : "--";//商务座特等座
     cr.srrb_num = string.IsNullOrEmpty(cn[33]) ? cn[33] : "--";//动卧
     //yyrw_num 高级动卧已取消?
     cr.yp_ex = cn[34];
     cr.seat_types = cn[35];
     Dictionary<string, string> station = response.data.map;
     cr.from_station_name = station[cn[6]];
     cr.to_station_name = station[cn[7]];
   //  ct.queryLeftNewDTO = cr;
     response.ticketData.Add(cr);
 }
Пример #3
0
 public void SaveCarWithSeatData(leftTicketDTOResponse record)
 {
     //throw new NotImplementedException();
 }