/// <summary> /// 获取服务器地址 /// </summary> /// <param name="request"></param> /// <returns></returns> private string ServerUrl <T>(Command <T> request) where T : new() { List <Config> list = RedisHelper.tGet <List <Config> >("140106_140110_EtermUrl"); if (list != null) { list.RemoveAll(l => l == null); } if (list == null || list.Count == 0) { list = new JetermClient.DAL.EtermConfig().GetConfigs(); if (list != null && list.Count > 0) { RedisHelper.tSet("140106_140110_EtermUrl", list, TimeSpan.FromDays(30)); } } if (list == null || list.Count == 0) { return(string.Empty); } string method = request.request.GetType().Name; IEnumerable <Config> configs = from l in list where l.cmdType.Contains((EtermCommand.CmdType)Enum.Parse(typeof(EtermCommand.CmdType), method)) select l; if (!string.IsNullOrEmpty(request.officeNo)) { configs = from l in configs where l.OfficeNo == request.officeNo select l; } if (!string.IsNullOrEmpty(request.ConfigName)) { configs = from l in configs where l.ConfigList.Contains(request.ConfigName) select l; } if (method.Equals(EtermCommand.CmdType.Booking.ToString())) { if (request.request != null) { JetermEntity.Request.Booking booking = (request.request as JetermEntity.Request.Booking); if (booking != null && booking.FlightList.Count > 0) { string FlightNo = booking.FlightList.FirstOrDefault().FlightNo; if (!string.IsNullOrEmpty(FlightNo) && FlightNo.Length > 2) { configs = from l in configs where l.AllowAirLine.Contains(FlightNo.Substring(0, 2)) select l; } } } } else if (method.Equals(EtermCommand.CmdType.AV.ToString())) { if (request.request != null) { JetermEntity.Request.AV av = (request.request as JetermEntity.Request.AV); if (av != null) { if (!string.IsNullOrEmpty(av.FlightNo) && av.FlightNo.Length > 2) { configs = from l in configs where l.AllowAirLine.Contains(av.FlightNo.Substring(0, 2)) select l; } } } } else if (method.Equals(EtermCommand.CmdType.AVH.ToString())) { if (request.request != null) { JetermEntity.Request.AVH avh = (request.request as JetermEntity.Request.AVH); if (avh != null && !string.IsNullOrWhiteSpace(avh.Airline)) { configs = from l in configs where l.AllowAirLine.Contains(avh.Airline) select l; } } } if (configs == null || configs.Count() == 0) { return(string.Empty); } return(((Config)configs.ElementAt(new Random(DateTime.Now.GetHashCode()).Next(0, configs.Count()))).ServerUrl); }
/// <summary> /// 主方法:【订位】指令返回结果解析 /// </summary> /// <param name="request">请求对象</param> /// <returns>解析结果</returns> public override CommandResult <JetermEntity.Response.Booking> BusinessDispose(JetermEntity.Request.Booking request) { _booking = new JetermEntity.Parser.Booking(this.config, this.OfficeNo); try { this.Cmd = _booking.ParseCmd(request); if (string.IsNullOrEmpty(this.Cmd)) { return(_booking.Response); } ExcuteCmd(); _booking.ParseCmdResult(this.CmdResult); if (_booking.Response.state) { GetBigPnr(_booking.Response.result.Pnr); } } catch (Exception e) { _booking.Response.error = new Error(EtermCommand.ERROR.PARSE_FAIL); _booking.Response.error.CmdResultBag = this.CmdResult; _booking.Response.state = false; LogWrite.WriteLog(e); } return(_booking.Response); }