public List<String> QuerySingle(Uri queryUri,SchAirlineQueryJsonModel model)
        {
            if (String.IsNullOrEmpty(_passkey))
            {
                GetPassKey(model);
            }
            model.PassKey = _passkey;
            List<String> lists = new List<string>();
            WebClient client = InitClient();
            client.Headers.Add(HttpRequestHeader.Referer, "http://www.scal.com.cn/Web/ETicket/AirlineList");
            Validation();
            _log.Debug(model.ToString());
            client = InitClient();
            client.Headers.Add(HttpRequestHeader.Referer, "http://www.scal.com.cn/Web/ETicket/AirlineList");
            var rdata = client.UploadData(queryUri, "POST", Encoding.UTF8.GetBytes(model.ToString()));
             String resultheml = Encoding.UTF8.GetString(rdata);
            try
            {
                if (resultheml.Contains("系统繁忙"))
                {
                    return QuerySingle(queryUri, model);
                }
                else if (resultheml.Contains("查询当日无航班"))
                {
                    if (_cnt < 3)
                    {
                        return QuerySingle(queryUri, model);
                        _cnt++;
                    }
                    else
                    {
                        _cnt = 0;
                        return lists;
                    }
                }
                else
                {
                    _jsonModel = JsonConvert.DeserializeObject<SchAilrLineJsonModel>(resultheml);
                    _jsonModel.AirlineListJSONModel =
                        JsonConvert.DeserializeObject<AirlineListJSONModel>(_jsonModel.AirlineListJSON);

                    JObject jobj=(JObject) JsonConvert.DeserializeObject(resultheml);
                }
            }
            catch (Exception ex)
            {
                _log.Debug("AirLineInformationModel to model", ex);
            }
            //_log.Debug(resultheml);
            return lists;
        }
Ejemplo n.º 2
0
 private void JsonTest()
 {
     if (String.IsNullOrEmpty(_json))
     {
         String path = Application.StartupPath + "\\Res\\Json.txt";
         if (File.Exists(path))
         {
             _json = File.ReadAllText(path);
             string str = _json;
             JsonTest();
         }
     }
     else
     {
         try
         {
             SchAilrLineJsonModel informationModel = new SchAilrLineJsonModel();
             informationModel = JsonConvert.DeserializeObject<SchAilrLineJsonModel>(_json);
             informationModel.AirlineListJSONModel =JsonConvert.DeserializeObject<AirlineListJSONModel>(informationModel.AirlineListJSON);
         }
         catch (Exception ex)
         {
             _log.Debug(ex);
         }
     }
 }