public override void Invoke(ISplitHandlerContext context) { try { QunarSplitPolicyRequest request = context.Get <QunarSplitPolicyRequest>("QunarSplitPolicyRequest"); Policies policy = context.RequestPolicy; string[] flightOut = policy.FlightOut.Split('/').Where(s => !string.IsNullOrEmpty(s)).ToArray();//最多为25个 //适用航班 List <Policies> lst = new List <Policies>(); if (flightOut.Length <= request.MaxFlightInCount) { lst.Add(policy); lst.ToList().ForEach(x => { context = context.SetRequestPolicy(x); Next.Invoke(context); }); return; } int yuShu = flightOut.Length % request.MaxFlightInCount; //余数 int shang = flightOut.Length / request.MaxFlightInCount; //商 shang = yuShu != 0 ? shang + 1 : shang; for (int i = 0; i < shang; i++) { string[] groupArrCity = flightOut.ToList().Skip(i * request.MaxFlightInCount).Take(request.MaxFlightInCount).ToArray(); Policies pl = policy.DeepClone(); pl.FlightOut = string.Join(",", groupArrCity); lst.Add(pl); } lst.ForEach(y => { context = context.SetRequestPolicy(y); this.Invoke(context); }); } catch (Exception ex) { LogContext logContext = new LogContext(); string logPath = System.IO.Directory.GetCurrentDirectory() + "\\LogContext\\ND.PolicySplitService\\ErrSplitPolicyRec\\" + DateTime.Now.ToString("yyyy-MM-dd") + ".txt"; logContext.AddLogInfo(logPath, JsonConvert.SerializeObject(context.RequestPolicy) + "\r\n错误信息:" + JsonConvert.SerializeObject(ex), true); //this.Invoke(context);//当前急需循环拆分 return; } }
public override void Invoke(ISplitHandlerContext context) { try { QunarSplitPolicyRequest request = context.Get <QunarSplitPolicyRequest>("QunarSplitPolicyRequest"); Policies policy = context.RequestPolicy; List <string> seatList = policy.Seat.Split('/').Where(s => !string.IsNullOrEmpty(s)).ToList();//抵达城市,最多为25个 List <Policies> lstArr = new List <Policies>(); if (seatList.Count <= request.MaxSeatCount)//已经不可拆分,添加到最终处理的集合并交给下一项条件拆分 { lstArr.Add(policy); lstArr.ToList().ForEach(x => { context = context.SetRequestPolicy(x); Next.Invoke(context); }); return; } string[] seatArr = policy.Seat.Split('/'); for (int i = 0; i < seatArr.Length; i++) { Policies pl = policy.DeepClone(); pl.Seat = seatArr[i]; lstArr.Add(pl); } lstArr.ForEach(y =>//循环遍历自己 { context = context.SetRequestPolicy(y); this.Invoke(context); }); } catch (Exception ex) { LogContext logContext = new LogContext(); string logPath = System.IO.Directory.GetCurrentDirectory() + "\\LogContext\\ND.PolicySplitService\\ErrSplitPolicyRec\\" + DateTime.Now.ToString("yyyy-MM-dd") + ".txt"; logContext.AddLogInfo(logPath, JsonConvert.SerializeObject(context.RequestPolicy) + "\r\n错误信息:" + JsonConvert.SerializeObject(ex), true); // this.Invoke(context); return; } }
public override void Invoke(ISplitHandlerContext context) { try { Policies policy = context.RequestPolicy; string effctDate = policy.SaleEffectDate.EnsureDateRight(); //销售开始日期 string expireDate = policy.SaleExpireDate.EnsureDateRight(); //销售结束日期 string forbidEffectDate = policy.SaleForbidEffectDate.EnsureDateRight().ToString(); //销售禁止开始日期 string forbidExpireDate = policy.SaleForbidExpireDate.EnsureDateRight().ToString(); //销售禁止结束日期 List <Policies> lst = new List <Policies>(); if (string.IsNullOrEmpty(forbidEffectDate) && string.IsNullOrEmpty(forbidExpireDate)) { // lst.Add(policy); //if (lst.Count > 0) // { lst.Add(policy); lst.ToList().ForEach(x => { context = context.SetRequestPolicy(x); Next.Invoke(context); }); // } //else //{ // context = context.SetRequestPolicy(policy); // Next.Invoke(context); //} return; } if (!string.IsNullOrEmpty(forbidEffectDate))//不为空 { #region 判断禁止开始时间 if (Convert.ToDateTime(forbidEffectDate) >= Convert.ToDateTime(effctDate) && Convert.ToDateTime(forbidEffectDate) < Convert.ToDateTime(forbidExpireDate)) { Policies pl = policy.DeepClone(); pl.SaleEffectDate = Convert.ToDateTime(effctDate); pl.SaleExpireDate = Convert.ToDateTime(forbidEffectDate); pl.SaleForbidEffectDate = Convert.ToDateTime("2099-12-30"); pl.SaleForbidExpireDate = Convert.ToDateTime("2099-12-30"); lst.Add(pl); } #endregion } if (!string.IsNullOrEmpty(forbidExpireDate)) { #region 判断禁止过期时间 if (Convert.ToDateTime(forbidExpireDate) > Convert.ToDateTime(forbidEffectDate) && Convert.ToDateTime(forbidExpireDate) <= Convert.ToDateTime(expireDate)) { Policies pl = policy.DeepClone(); pl.SaleEffectDate = Convert.ToDateTime(forbidExpireDate); pl.SaleExpireDate = Convert.ToDateTime(expireDate); pl.SaleForbidEffectDate = Convert.ToDateTime("2099-12-30"); pl.SaleForbidExpireDate = Convert.ToDateTime("2099-12-30"); lst.Add(pl); } #endregion } lst.ForEach(y => { context = context.SetRequestPolicy(y); this.Invoke(context); }); }catch (Exception ex) { LogContext logContext = new LogContext(); string logPath = System.IO.Directory.GetCurrentDirectory() + "\\LogContext\\ND.PolicySplitService\\ErrSplitPolicyRec\\" + DateTime.Now.ToString("yyyy-MM-dd") + ".txt"; logContext.AddLogInfo(logPath, JsonConvert.SerializeObject(context.RequestPolicy) + "\r\n错误信息:" + JsonConvert.SerializeObject(ex), true); return; } }
public override void Invoke(ISplitHandlerContext context) { try { QunarSplitPolicyRequest request = context.Get <QunarSplitPolicyRequest>("QunarSplitPolicyRequest"); Policies policy = context.RequestPolicy; List <string> dptCity = policy.DptCity.Split('/').Where(s => !string.IsNullOrEmpty(s)).ToList();//出发城市,限制只能为一个 //List<string> dptCityNew = new List<string>(); //dptCity.ForEach(x => //{ // if(request.LstQunarCodes.Contains(x)) // { // dptCityNew.Add(x); // } //}); //dptCity.Clear(); //dptCity = dptCityNew; //if(dptCity.Count <= 0) //{ // return; //} List <Policies> lst = new List <Policies>(); if (policy.AirlineCode.ToUpper() == "G5") { lst.Add(policy); lst.ToList().ForEach(x => { context = context.SetRequestPolicy(x); //重新设置请求政策 Next.Invoke(context); //交给下个拆分程序处理 }); return; } if (dptCity.Count <= request.MaxDptCityCount) { //context.ResponsePolicy.Add(policy); //lst.Add(policy); lst.Add(policy); lst.ToList().ForEach(x => { context = context.SetRequestPolicy(x); //重新设置请求政策 Next.Invoke(context); //交给下个拆分程序处理 }); return; } foreach (var item in dptCity) { Policies pl = policy.DeepClone(); pl.DptCity = item.Replace("/", "").ToUpper(); lst.Add(pl); } lst.ForEach(y => { context = context.SetRequestPolicy(y); //重新设置请求政策 this.Invoke(context); //当前急需循环拆分 }); } catch (Exception ex) { LogContext logContext = new LogContext(); string logPath = System.IO.Directory.GetCurrentDirectory() + "\\LogContext\\ND.PolicySplitService\\ErrSplitPolicyRec\\" + DateTime.Now.ToString("yyyy-MM-dd") + ".txt"; logContext.AddLogInfo(logPath, JsonConvert.SerializeObject(context.RequestPolicy) + "\r\n错误信息:" + JsonConvert.SerializeObject(ex), true); return; // this.Invoke(context);//当前急需循环拆分 } }
public override void Invoke(ISplitHandlerContext context) { try { QunarSplitPolicyRequest request = context.Get <QunarSplitPolicyRequest>("QunarSplitPolicyRequest"); Policies policy = context.RequestPolicy; List <string> arrCity = policy.ArrCity.Split('/').Where(s => !string.IsNullOrEmpty(s)).ToList();//抵达城市,最多为25个 //List<string> arrCityNew = new List<string>(); //arrCity.ForEach(x => //{ // if(request.LstQunarCodes.Contains(x)) // { // arrCityNew.Add(x); // } //}); //arrCity.Clear(); //arrCity = arrCityNew; //if(arrCity.Count <= 0) //{ // return; //} List <Policies> lstArr = new List <Policies>(); if (policy.AirlineCode.ToUpper() == "G5") { lstArr.Add(policy); lstArr.ToList().ForEach(x => { context = context.SetRequestPolicy(x); //重新设置请求政策 Next.Invoke(context); //交给下个拆分程序处理 }); return; } if (arrCity.Count <= request.MaxArrCityCount)//已经不可拆分,添加到最终处理的集合并交给下一项条件拆分 { lstArr.Add(policy); lstArr.ToList().ForEach(x => { context = context.SetRequestPolicy(x); Next.Invoke(context); }); return; } int yuShu = arrCity.Count % request.MaxArrCityCount; //余数 int shang = arrCity.Count / request.MaxArrCityCount; //商 shang = yuShu != 0 ? shang + 1 : shang; for (int i = 0; i < shang; i++) { string[] groupArrCity = arrCity.ToList().Skip(i * request.MaxArrCityCount).Take(request.MaxArrCityCount).ToArray(); Policies pl = policy.DeepClone(); pl.ArrCity = string.Join(",", groupArrCity); lstArr.Add(pl); } lstArr.ForEach(y =>//循环遍历自己 { context = context.SetRequestPolicy(y); this.Invoke(context); }); } catch (Exception ex) { LogContext logContext = new LogContext(); string logPath = System.IO.Directory.GetCurrentDirectory() + "\\LogContext\\ND.PolicySplitService\\ErrSplitPolicyRec\\" + DateTime.Now.ToString("yyyy-MM-dd") + ".txt"; logContext.AddLogInfo(logPath, JsonConvert.SerializeObject(context.RequestPolicy) + "\r\n错误信息:" + JsonConvert.SerializeObject(ex), true); return; } }