public QunarUploadConfigResponse LoadDefautConfig() { //string path = System.IO.Directory.GetCurrentDirectory(); string path = System.AppDomain.CurrentDomain.BaseDirectory; string xmlCodes = File.ReadAllText(path + "bin\\QunarUploadConfig.xml"); QunarUploadConfigResponse codeList = XmlHelper.Deserialize(typeof(QunarUploadConfigResponse), xmlCodes) as QunarUploadConfigResponse; return(codeList); }
public EmptyResponse SaveQunarDefautConfig(QunarUploadConfigResponse request) { // string path = System.IO.Directory.GetCurrentDirectory(); string path = System.AppDomain.CurrentDomain.BaseDirectory; string content = XmlHelper.Serializer(typeof(QunarUploadConfigResponse), request); File.WriteAllText(path + "bin\\QunarUploadConfig.xml", content); return(new EmptyResponse { ErrCode = PolicyService.Enums.ResultType.Sucess, ErrMsg = "" }); }
public static QunarUploadConfigResponse LoadQunarUploadConfig() { try { string responseContent = CoreHelper.DoPost(System.Configuration.ConfigurationManager.AppSettings["LoadDefautQunarConfigUrl"].ToString(), ""); QunarUploadConfigResponse config = JsonConvert.DeserializeObject <QunarUploadConfigResponse>(responseContent); return(config); } catch (Exception ex) { return(new QunarUploadConfigResponse()); } }
/// <summary> /// 转换成去哪儿新增政策格式 /// </summary> /// <param name="policy"></param> /// <returns></returns> private QunarPolicyListBase ChangeToQunarAddPolicy(Policies policy, QunarUploadConfigResponse defaultUploadConfig, QunarPolicyType policyType, List <SeatDiscountDto> seatDiscountList) { QunarPolicyListBase policyList = new QunarPolicyListBase(); #region 根据上传类型封装不同的政策节点 switch (policyType) { case QunarPolicyType.APPLY: //单程申请 break; case QunarPolicyType.COMMON: //单程普通 { policyList = ChangeToQunarCommonPolicy(policy, defaultUploadConfig); } break; case QunarPolicyType.CUSTOMER: //包机切位 break; case QunarPolicyType.LOWPRICE: //特价政策 break; case QunarPolicyType.PREPAY: //单程预付 { policyList = ChangeToQunarPrepayPolicy(policy, defaultUploadConfig, seatDiscountList); } break; case QunarPolicyType.ROUNDALL: //往返所有类型 break; case QunarPolicyType.ROUNDPREPAY: //往返预付 break; case QunarPolicyType.ROUNDSPECIAL: //往返特价 break; case QunarPolicyType.SINGLEALL: //单程所有类型 break; default: break; } #endregion return(policyList); }
public void UploadPolicy(List <Policies> lstPolicies, string queueName, string queueHost) { // Task.Factory.StartNew(() => //{ List <string> lstQunarCodes = CoreHelper.ReadQunarCodes(); QunarUploadConfigResponse config = CoreHelper.LoadQunarUploadConfig(); IUploadPolicy uplload = new QunarUpLoadPolicy(); uplload.OnWoking += uplload_OnWoking; QunarUploadPolicyRequest qunarRequest = new QunarUploadPolicyRequest() { FormatFilePath = ConfigurationManager.AppSettings["FormatQunarFilePath"].ToString(), //xml文件路径 FormatZipFilePath = ConfigurationManager.AppSettings["FormatQunarZipFilePath"].ToString(), //压缩包文件路径 MaxTaskCount = int.Parse(ConfigurationManager.AppSettings["MaxTaskCount"].ToString()), PerTaskCount = int.Parse(ConfigurationManager.AppSettings["PerTaskCount"].ToString()), PolicyType = QunarPolicyType.COMMON, SqlWhere = "", UploadType = UploadType.Incremental, //QunarUpLoadUrl = ConfigurationManager.AppSettings["QunarUpLoadUrl"].ToString(), CommisionMoney = 0, CommsionPoint = 0, OperName = "system", LstQunarCodes = lstQunarCodes, PageSize = 99999, PolicyDataOrgin = lstPolicies, DefaultUploadConfig = config }; UploadPolicyResponse rep = uplload.UpLoadIncrementPolicy(qunarRequest, false); if (rep.ErrCode == ResultType.Failed) { lstPolicies.ForEach(x => //统一加1 { x.Id += 1; }); new MessageQueueHelper().SendMsgToQueue(queueName, lstPolicies, MessagePriority.Normal, queueHost); ShowRunningLog(DateTime.Now + ":上传失败,更新失败次数并重新发回队列成功!"); } // }); }
private void btnSaveSpecialPolicyConfig_Click(object sender, EventArgs e) { QunarUploadConfigResponse config = new QunarUploadConfigResponse(); config.MaxAge = this.txtMaxAge.Text; config.MinAge = this.txtMinAge.Text; config.CardType = this.cbCardType.SelectedItem == "仅身份证"? "1" : "0"; config.CPCReturnPoint = this.txtCPCReturnPoint.Text; config.CPCReturnPrice = this.txtCPCReturnPrice.Text; config.SpecialConfig.CPAChange = this.txtCPAChange.Text; config.SpecialConfig.CPAIsEnrosement = this.chkCPCIsEndorsement.Checked == true ? "是" : "否"; config.SpecialConfig.CPAReturn = this.txtCPAReturn.Text; config.SpecialConfig.CPCChange = this.txtCPCChange.Text; config.SpecialConfig.CPCIsEnrosement = this.chkCPCIsEndorsement.Checked == true ? "是" : "否"; config.SpecialConfig.CPCReturn = this.txtCPCReturn.Text; List <string> specilaTicketRemrk = new List <string>(); foreach (var item in this.grpSpecialRemark.Controls) { if (item is CheckBox) { var chk = item as CheckBox; if (chk.Checked) { specilaTicketRemrk.Add(chk.Tag.ToString()); } } } foreach (var item in this.grpIsShare.Controls) { if (item is RadioButton) { var chk = item as RadioButton; if (chk.Checked) { config.IsShareFlight = chk.Text; } } } foreach (var item in this.grpIsStop.Controls) { if (item is RadioButton) { var chk = item as RadioButton; if (chk.Checked) { config.IsStopFlight = chk.Text; } } } if (specilaTicketRemrk.Count > 4) { MessageBox.Show("特殊票务说明不符合规定"); return; } config.SpecialConfig.SpecialTicketRemark = string.Join(",", specilaTicketRemrk.ToArray()); CoreHelper.DoPost(System.Configuration.ConfigurationManager.AppSettings["SaveQunarDefautConfigUrl"].ToString(), config); MessageBox.Show("保存成功!"); }
public void BindDefaultQunarConfig() { QunarUploadConfigResponse config = CoreHelper.LoadQunarUploadConfig(); this.cbCardType.SelectedIndex = int.Parse(config.CardType); this.txtMaxAge.Text = config.MaxAge.ToString(); this.txtMinAge.Text = config.MinAge.ToString(); this.txtCPCReturnPoint.Text = config.CPCReturnPoint.ToString(); this.txtCPCReturnPrice.Text = config.CPCReturnPrice.ToString(); this.txtCPAReturn.Text = config.SpecialConfig.CPAReturn; this.txtCPAChange.Text = config.SpecialConfig.CPAChange; if (config.SpecialConfig.CPAIsEnrosement == "是") { this.chkIsEndorsement.Checked = true; } else { this.chkIsEndorsement.Checked = false; } this.txtCPCReturn.Text = config.SpecialConfig.CPCReturn; this.txtCPCChange.Text = config.SpecialConfig.CPCChange; if (config.SpecialConfig.CPCIsEnrosement == "是") { this.chkCPCIsEndorsement.Checked = true; } else { this.chkCPCIsEndorsement.Checked = false; } if (string.IsNullOrEmpty(config.SpecialConfig.SpecialTicketRemark)) { return; } List <string> lstTicketRemark = config.SpecialConfig.SpecialTicketRemark.Split(',').ToList(); foreach (var item in this.grpSpecialRemark.Controls) { if (item is CheckBox) { var chk = item as CheckBox; foreach (var item2 in lstTicketRemark) { if (chk.Tag.ToString() == item2) { chk.Checked = true; } } } } foreach (var item in this.grpIsShare.Controls) { if (item is RadioButton) { var chk = item as RadioButton; if (chk.Text.ToString() == config.IsShareFlight) { chk.Checked = true; } } } foreach (var item in this.grpIsStop.Controls) { if (item is RadioButton) { var chk = item as RadioButton; if (chk.Text.ToString() == config.IsStopFlight) { chk.Checked = true; } } } }
// private bool isRealTimeUpload = false; // private PolicyRecord realTimePolicyRecord = new PolicyRecord(); public QunarUploadPolicyRequest() { PolicyData = new Dictionary <UploadTypeDetail, List <Policies> >(); DefaultUploadConfig = new QunarUploadConfigResponse(); }
private QunarPrepayPolicyList ChangeToQunarPrepayPolicy(Policies policy, QunarUploadConfigResponse defaultUploadConfig, List <SeatDiscountDto> seatDiscountList) { QunarPrepayPolicyList qunarPolicy = new QunarPrepayPolicyList(); qunarPolicy.flightcode = policy.AirlineCode.ToUpper(); //航空公司二字码 qunarPolicy.policyCode = policy.PartnerPolicyId.ToString(); qunarPolicy.dpt = policy.DptCity.Substring(0, 3).Replace("/", ",").ToUpper(); //出发机场?? //List<string> lstArr = policy.ArrCity.Replace("/", ",").Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries).ToList(); //ArrayList arrArrCity = new ArrayList(); //int index = 0; //lstArr.ForEach(x => //{ // if (index < 25) // { // arrArrCity.Add(x); // } // index++; //}); qunarPolicy.arr = policy.ArrCity.Substring(0, 3).Replace("/", ",").ToUpper(); #region 包含航班不包含航班 if (policy.FlightIn == "" && policy.FlightOut == "") { qunarPolicy.flightcondition = ""; //航班限制所有 qunarPolicy.flightNumLimit = "所有"; // } else if (policy.FlightIn != "") { List <string> lstFlightIn = policy.FlightIn.Replace("/", ",").Split(',').ToList(); ArrayList arrFlightIn = new ArrayList(); int n = 0; lstFlightIn.ForEach(x => { if (n < 25) { arrFlightIn.Add(qunarPolicy.flightcode + x); } n++; }); qunarPolicy.flightcondition = arrFlightIn.Count <= 0 ? "" : string.Join(",", arrFlightIn.ToArray()); qunarPolicy.flightNumLimit = "适用";// } else if (policy.FlightOut != "") { List <string> lstFlightOut = policy.FlightOut.Replace("/", ",").Split(',').ToList(); ArrayList arrFlightOut = new ArrayList(); int m = 0; lstFlightOut.ForEach(x => { if (m < 25) { arrFlightOut.Add(qunarPolicy.flightcode + x); } m++; }); qunarPolicy.flightcondition = arrFlightOut.Count <= 0 ? "" : string.Join(",", arrFlightOut.ToArray()); qunarPolicy.flightNumLimit = "不适用";// } #endregion qunarPolicy.daycondition = policy.FlightCycle.Replace("/", ""); string seat = string.Join(",", policy.Seat.Split(new char[] { '/' }, StringSplitOptions.RemoveEmptyEntries).ToArray())[0].ToString().ToUpper(); //舱位 qunarPolicy.cabin = seat; qunarPolicy.discountType = "Y舱折扣"; //折扣类型 SeatDiscountDto seatDto = seatDiscountList.Where(x => x.AirlineCode == policy.AirlineCode && x.Seat == seat).FirstOrDefault(); if (seatDto == null) { return(null); } qunarPolicy.discountValue = seatDto.Discount; //折扣信息?? qunarPolicy.returnpoint = Convert.ToDouble(policy.CommisionPoint).ToString("0.00"); // Convert.ToDouble(policy.CommisionPoint).ToString("0.00");//返点 qunarPolicy.returnprice = decimal.Floor(policy.CommisionMoney).ToString(); //decimal.Floor(policy.CommisionMoney).ToString();//留钱 qunarPolicy.startdate_ticket = policy.SaleEffectDate.EnsureDateRight(); //销售开始日期 qunarPolicy.enfdata_ticket = policy.SaleExpireDate.EnsureDateRight(); //销售结束日期 qunarPolicy.startdate = policy.FlightEffectDate.ToString("yyyy-MM-dd"); qunarPolicy.enddate = policy.FlightExpireDate.EnsureDateRight(); //旅行结束日期 qunarPolicy.deptTimeSlot = "0000-2359"; //航班起飞时间 qunarPolicy.beforeValidDay = policy.EarliestIssueDays.ToString(); //提前预定天数 //qunarPolicy.earliestBeforeValidDay = "";//正整数,大于等于0。表示用户至多需要提前几天预订机票 qunarPolicy.backnote = string.IsNullOrEmpty(policy.TuiGaiRule) ? "无" :policy.TuiGaiRule; //退改签规则 qunarPolicy.cabinnote = policy.Comment == "" ? "无" : policy.Comment; //舱位说明 qunarPolicy.autoTicket = policy.IsAutoIssue == 1 ? "是" : "否"; //是否自动出票 qunarPolicy.canPay = "是"; qunarPolicy.needPnr = "是"; qunarPolicy.pata = "是"; qunarPolicy.officeno = policy.OfficeNo.ToString(); //授权officeNo qunarPolicy.xcd = "2"; //是否提供行程单 qunarPolicy.flyerpoints = policy.IsProviderScore == 0 ? "否" : "是"; //是否提供常旅客积分 qunarPolicy.cardType = defaultUploadConfig.CardType.ToString(); //证件类型,默认支持所有 qunarPolicy.maxAge = defaultUploadConfig.MaxAge.ToString(); qunarPolicy.minAge = defaultUploadConfig.MinAge.ToString(); qunarPolicy.returnRule = defaultUploadConfig.SpecialConfig.CPAReturn; qunarPolicy.changeRule = defaultUploadConfig.SpecialConfig.CPAChange; qunarPolicy.endorsement = defaultUploadConfig.SpecialConfig.CPAIsEnrosement; qunarPolicy.specialRule = defaultUploadConfig.SpecialConfig.SpecialTicketRemark; qunarPolicy.sharedNew = defaultUploadConfig.IsShareFlight; qunarPolicy.stop = defaultUploadConfig.IsStopFlight; qunarPolicy.cpcReturnPoint = defaultUploadConfig.CPCReturnPoint; //返点 qunarPolicy.cpcReturnPrice = decimal.Floor(Convert.ToDecimal(defaultUploadConfig.CPCReturnPrice)).ToString(); //留钱 qunarPolicy.cpcReturnRule = defaultUploadConfig.SpecialConfig.CPCReturn; qunarPolicy.cpcChangeRule = defaultUploadConfig.SpecialConfig.CPCChange; qunarPolicy.cpcEndorsement = defaultUploadConfig.SpecialConfig.CPCIsEnrosement; qunarPolicy.specialRule = defaultUploadConfig.SpecialConfig.SpecialTicketRemark; return(qunarPolicy); }
private QunarCommonPolicyList ChangeToQunarCommonPolicy(Policies policy, QunarUploadConfigResponse defaultUploadConfig) { QunarCommonPolicyList qunarPolicy = new QunarCommonPolicyList(); List <string> lstArr = policy.ArrCity.Replace("/", ",").Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries).ToList(); ArrayList arrArrCity = new ArrayList(); int index = 0; lstArr.ForEach(x => { if (index < 25) { arrArrCity.Add(x); } index++; }); qunarPolicy.arr = lstArr.Count > 25 ? string.Join(",", arrArrCity.ToArray()).ToUpper() : policy.ArrCity.Replace("/", ",").ToUpper(); //抵达机场?? qunarPolicy.autoTicket = policy.IsAutoIssue == 1 ? "是" : "否"; //是否自动出票 qunarPolicy.backnote = string.IsNullOrEmpty(policy.TuiGaiRule) ? null : policy.TuiGaiRule; //退改签规则 qunarPolicy.beforeValidDay = policy.EarliestIssueDays.ToString(); //提前预定天数 qunarPolicy.cabin = string.Join(",", policy.Seat.Split(new char[] { '/' }, StringSplitOptions.RemoveEmptyEntries).ToArray()).ToUpper(); //舱位 qunarPolicy.cabinnote = policy.Comment == "" ? "无" : policy.Comment; //舱位说明 qunarPolicy.cardType = defaultUploadConfig.CardType.ToString(); //证件类型,默认支持所有 qunarPolicy.daycondition = policy.FlightCycle.Replace("/", ""); qunarPolicy.discountType = "指定票面价"; //折扣类型?? qunarPolicy.discountValue = "0"; //折扣信息?? qunarPolicy.dpt = policy.DptCity.Substring(0, 3).Replace("/", ",").ToUpper(); //出发机场?? qunarPolicy.enddate = policy.FlightExpireDate.EnsureDateRight(); //旅行结束日期 qunarPolicy.enfdata_ticket = policy.SaleExpireDate.EnsureDateRight(); //销售结束日期 qunarPolicy.flightcode = policy.AirlineCode.ToUpper(); //航空公司二字码 if (policy.FlightIn == "" && policy.FlightOut == "") { qunarPolicy.flightcondition = ""; //航班限制所有 qunarPolicy.flightNumLimit = "所有"; // } else if (policy.FlightIn != "") { List <string> lstFlightIn = policy.FlightIn.Replace("/", ",").Split(',').ToList(); ArrayList arrFlightIn = new ArrayList(); int n = 0; lstFlightIn.ForEach(x => { if (n < 25) { arrFlightIn.Add(qunarPolicy.flightcode + x); } n++; }); qunarPolicy.flightcondition = arrFlightIn.Count <= 0 ? "" : string.Join(",", arrFlightIn.ToArray()); qunarPolicy.flightNumLimit = "适用";// } else if (policy.FlightOut != "") { List <string> lstFlightOut = policy.FlightOut.Replace("/", ",").Split(',').ToList(); ArrayList arrFlightOut = new ArrayList(); int m = 0; lstFlightOut.ForEach(x => { if (m < 25) { arrFlightOut.Add(qunarPolicy.flightcode + x); } m++; }); qunarPolicy.flightcondition = arrFlightOut.Count <= 0 ? "" : string.Join(",", arrFlightOut.ToArray()); qunarPolicy.flightNumLimit = "不适用"; // } qunarPolicy.flyerpoints = policy.IsProviderScore == 0 ? "否" : "是"; //是否提供常旅客积分 qunarPolicy.policyCode = policy.PartnerPolicyId.ToString(); qunarPolicy.returnpoint = Convert.ToDouble(policy.CommisionPoint).ToString("0.00"); // Convert.ToDouble(policy.CommisionPoint).ToString("0.00");//返点 qunarPolicy.returnprice = decimal.Floor(policy.CommisionMoney).ToString(); //decimal.Floor(policy.CommisionMoney).ToString();//留钱 qunarPolicy.officeno = policy.OfficeNo.ToString(); //授权officeNo qunarPolicy.stop = defaultUploadConfig.IsStopFlight; //qunarPolicy.cpaPutInPriceType = "下浮比例"; //qunarPolicy.cpaPutInNormalPrice = qunarPolicy.cpcReturnPoint = defaultUploadConfig.CPCReturnPoint; //返点 qunarPolicy.cpcReturnPrice = decimal.Floor(Convert.ToDecimal(defaultUploadConfig.CPCReturnPrice)).ToString(); //留钱 qunarPolicy.sharedNew = defaultUploadConfig.IsShareFlight; qunarPolicy.startdate = policy.FlightEffectDate.ToString("yyyy-MM-dd"); qunarPolicy.startdate_ticket = policy.SaleEffectDate.EnsureDateRight(); //销售开始日期 qunarPolicy.xcd = policy.InvoiceType.ToString(); //是否提供行程单 return(qunarPolicy); }