/// <summary> /// 根据查询的城市获取爱飞信息并记录到数据库并返回单程和双程的参数数据 /// </summary> /// <param name="result1"></param> /// <param name="result2"></param> protected void getKABERealTimeTiceket(out System.Xml.XmlNode result1, out System.Xml.XmlNode result2) { result1 = null; result2 = null; KABE.Service service = new KABE.Service(); if (this.tripType == 0) { result1 = this.GetKabe_InterDetailFlt(this.fromcityCode, this.tocityCode, this.tripDate, "", "", "Y", "1"); if (result1 != null) { return; } result1 = service.getInterDetailFltValuesV3(this.fromcityCode, this.tocityCode, this.tripDate, "", "", "Y", "1", "437c1d948857da89467d2428c408f3d9"); if (result1.SelectSingleNode("code").InnerText == "0")//成功记录到数据库 { kabe_InterDetailFltEntity model = new kabe_InterDetailFltEntity(); model.sc = this.fromcityCode; model.ec = this.tocityCode; model.sd = this.tripDate; model.ed = string.Empty; model.classtype = "Y"; model.ft = "1"; model.result = result1; this.InsertKabe_InterDetailFlt(model); } } else if (this.tripType == 1) { result1 = this.GetKabe_InterDetailFlt(this.fromcityCode, this.tocityCode, this.tripDate, this.backDate, "", "Y", "2"); if (result1 != null) { return; } result1 = service.getInterDetailFltValuesV3(this.fromcityCode, this.tocityCode, this.tripDate, this.backDate, "", "Y", "2", "437c1d948857da89467d2428c408f3d9"); if (result1.SelectSingleNode("code").InnerText == "0")//成功记录到数据库 { kabe_InterDetailFltEntity model = new kabe_InterDetailFltEntity(); model.sc = this.fromcityCode; model.ec = this.tocityCode; model.sd = this.tripDate; model.ed = this.backDate; model.classtype = "Y"; model.ft = "2"; model.result = result1; this.InsertKabe_InterDetailFlt(model); } } else if (this.tripType == 2) { result1 = this.GetKabe_InterDetailFlt(this.fromcityCode, this.tocityCode, this.tripDate, "", "", "Y", "1"); result2 = this.GetKabe_InterDetailFlt(this.fromcityCode, this.tocityCode, this.tripDate, this.backDate, "", "Y", "2"); System.Xml.XmlNode res1 = result1, res2 = result2; System.Threading.AutoResetEvent resetEvent = new System.Threading.AutoResetEvent(false); System.Xml.XmlNode result3 = null, result4 = null; IAsyncResult iar1 = null, iar2 = null; AsyncCallback back1 = delegate(IAsyncResult iar) { try { result3 = service.EndgetInterDetailFltValuesV3(iar1); if (result3.SelectSingleNode("code").InnerText == "0")//成功记录到数据库 { kabe_InterDetailFltEntity model = new kabe_InterDetailFltEntity(); model.sc = this.fromcityCode; model.ec = this.tocityCode; model.sd = this.tripDate; model.ed = string.Empty; model.classtype = "Y"; model.ft = "1"; model.result = result3; this.InsertKabe_InterDetailFlt(model); } if ((iar2 != null && iar2.IsCompleted) || res2 != null) { resetEvent.Set(); } } catch { resetEvent.Set(); } }; AsyncCallback back2 = delegate(IAsyncResult iar) { try { result4 = service.EndgetInterDetailFltValuesV3(iar2); if (result4.SelectSingleNode("code").InnerText == "0")//成功记录到数据库 { kabe_InterDetailFltEntity model = new kabe_InterDetailFltEntity(); model.sc = this.fromcityCode; model.ec = this.tocityCode; model.sd = this.tripDate; model.ed = this.backDate; model.classtype = "Y"; model.ft = "2"; model.result = result4; this.InsertKabe_InterDetailFlt(model); } if ((iar1 != null && iar1.IsCompleted) || res1 != null) { resetEvent.Set(); } } catch { resetEvent.Set(); } }; if (result1 == null) { iar1 = service.BegingetInterDetailFltValuesV3(this.fromcityCode, this.tocityCode, this.tripDate, "", "", "Y", "1", "437c1d948857da89467d2428c408f3d9", back1, null); } if (result2 == null) { iar2 = service.BegingetInterDetailFltValuesV3(this.fromcityCode, this.tocityCode, this.tripDate, this.backDate, "", "Y", "2", "437c1d948857da89467d2428c408f3d9", back2, null); } if (result1 == null || result2 == null) { if (resetEvent.WaitOne(5000, true)) { resetEvent.Close(); } } if (result1 == null) { result1 = result3; } if (result2 == null) { result2 = result4; } } }
protected void InsertKabe_InterDetailFlt(kabe_InterDetailFltEntity model) { string str = "insert into kabe_InterDetailFlt(sc,ec,sd,ed,classtype,ft,result) values('" + model.sc + "','" + model.ec + "','" + model.sd + "', '" + model.ed + "','" + model.classtype + "','" + model.ft + "','" + model.result.OuterXml + "')"; int result = SqlHelper.ExecuteNonQuery(SqlHelper.ConnString_insert, CommandType.Text, str); }