private string GetSignSync(PolicyServiceBy19e.syncRateRequest req) { //string sign = "GetSyncRate" + req.aircomp2c + "" + req.rateType + "" + req.psgType + "19" + "#U[jZ&6#U9#l3TZ#U0Ylj033j96j9#Yl"; string safecode = Config.SafeCode19e;// TriDES.Decrypt(ConfigurationManager.AppSettings["safeCode_19e"]); StringBuilder sbSign = new StringBuilder(); sbSign.Append("GetSyncRate"); sbSign.Append(req.aircomp2c); sbSign.Append(req.rateType); sbSign.Append(req.psgType); sbSign.Append(req.strategyId); sbSign.Append(req.updateTime); sbSign.Append(req.minDiscount); sbSign.Append(req.pageSize); sbSign.Append(req.username); sbSign.Append(req.appcode); //sbSign.Append("[66USljYj[3S#lkk3T#930Yj#93*j93&"); sbSign.Append(safecode); return(EncryptWithoutKey(sbSign.ToString(), Encoding.GetEncoding("GB2312"))); }
public void SyncForAdd() { try { PolicyServiceBy19e.syncRateRequest req = new PolicyServiceBy19e.syncRateRequest(); PolicyServiceBy19e.SyncRateServiceGHImplService c = new PolicyServiceBy19e.SyncRateServiceGHImplService(); //while (true) //{ string[] arryTimeAndId = GetLastUpTimeAndId("ND.ReceivePolicyService\\19e\\PolicyAddLog19e").Split('|'); req.aircomp2c = ""; //航空公司, 如:MU, 为空取所有 req.rateType = "3"; //政策类型[1:普通/2:特殊3:全部] req.psgType = "1"; //乘客类型[1:成人/2:儿童/3:全部] req.strategyId = arryTimeAndId[1]; req.updateTime = arryTimeAndId[0]; req.minDiscount = "0"; req.pageSize = Config.PerPageSize; req.username = Config.Username19e; //"18618001265"; req.appcode = Config.AppCode19e; // "19"; req.sign = GetSignSync(req); PolicyServiceBy19e.syncRateResponse res = new syncRateResponse(); try { // ShowMsgToForm("接收19e政策请求参数:" + JsonConvert.SerializeObject(req)); res = c.GetSyncRate(req); } catch (Exception ex) { ShowMsgToForm("接收19e政策异常:" + JsonConvert.SerializeObject(ex)); return; } if (res.code.Trim() == "F") { ShowMsgToForm("19e政策接收失败,错误信息:" + res.message); return; } else if (res.code.Trim() == "S") { ShowMsgToForm("19e政策接口连接成功,接收政策...", "19e", false, false); PolicyServiceBy19e.rate[] arry = res.rateList; if (arry == null || arry.Length == 0) { ShowMsgToForm("19e政策 - 尚无新政策", "19e", false, false); return; } List <Policies> list = new List <Policies>(); Regex regV = new Regex(@"[^\d\/]"); foreach (var item in arry) { #region 新代码 Policies policyInfo = new Policies(); // policyInfo.PolicyId = System.Guid.NewGuid().ToString(); policyInfo.AirlineCode = item.aircomp2c; //航空公司 policyInfo.DptCity = item.fromport3c; //出发城市 policyInfo.ArrCity = item.toport3c; //抵达城市 policyInfo.FlightIn = item.flightnoFit == null ? "" : item.flightnoFit == "***" ? "" : regV.Replace(item.flightnoFit, "").Trim(); //适用航班 policyInfo.FlightOut = item.flightnoNotFit == null ? "" : item.flightnoNotFit == "***" ? "" : regV.Replace(item.flightnoNotFit, "").Trim(); //不适用航班 policyInfo.Seat = item.flightclass != "" ? item.flightclass : ""; //舱位 policyInfo.SrcType = (int)item.routetype; //航程类型航程类型[1:单程/2:往返/3:单程及往返] policyInfo.SaleEffectDate = item.sdate; //政策有效期(开始时间) policyInfo.SaleExpireDate = item.edate; //政策有效期(截止时间) policyInfo.FlightEffectDate = item.sdate; policyInfo.FlightExpireDate = item.edate; policyInfo.CommisionPoint = item.backrate; //返点 policyInfo.CommisionMoney = 0; //返现 policyInfo.NeedSwitchPNR = 0; //是否需要换pnr policyInfo.TicketSpeed = item.thespeed; //出票速度 policyInfo.IssueWorkTime = item.worktime == null ? "" : item.worktime; //出票时间段 policyInfo.VtWorkTime = item.voidtime == null ? "" : item.voidtime; //废票时间段 policyInfo.PartnerId = (int)SupplierType._19E; policyInfo.PartnerName = SupplierType._19E.ToString(); policyInfo.Comment = item.chngretmemo ?? ""; //政策备注 policyInfo.FlightCycle = item.daysFit; //适用班期 policyInfo.DelDegree = 1; policyInfo.CommisionType = int.Parse(item.ratetype); //政策类型 1-普通 policyInfo.PartnerPolicyId = item.strategyId.ToString(); //政策代号 policyInfo.PolicyStatus = 1; policyInfo.CreateTime = DateTime.Now; policyInfo.PolicyType = ((PolicyType)item.strategyType).ToString(); policyInfo.PsgType = item.psgtype;//乘客类型[1:成人] //policyInfo.UserType = item.usertype;//客户类型[1:散客] policyInfo.Param1 = ""; policyInfo.Param2 = ""; policyInfo.Param3 = ""; policyInfo.Param4 = ""; list.Add(policyInfo); #endregion } ShowMsgToForm("19e政策接收成功,共接收 " + list.Count + " 条政策,更新数据库...", "19e", false); if (Config.IsSendPolicyQueue) { MessageQueueHelper helper = new MessageQueueHelper(); bool r = helper.SendMsgToQueue(Config.QueueName, list, MessagePriority.Normal, Config.QueueHost); if (r) { ShowMsgToForm("发送去哪儿更新队列成功", "19e", false); } } List <PolicySyncRec> errList = PolicyManage19e.SynchronizePolicy(list); if (errList.Count <= 0) { SaveLastUpTimeAndId(res.updateTime + "|" + arry[arry.Length - 1].strategyId, "ND.ReceivePolicyService\\19e\\PolicyAddLog19e"); ShowMsgToForm("19e政策更新数据库成功!", "19e", false); } //else // ShowMsgToForm("19e政策更新数据库失败!更新不成功的数据:" + JsonConvert.SerializeObject(errList),"19eErrAddRec"); if (res.pageCount < 1) { return; } else { ShowMsgToForm("19e政策 PageCount(" + res.pageCount + ") 大于 1 继续调用同步接口...", "19e", false); } } } catch (Exception ex) { var str = ex.Message; while (ex.InnerException != null) { ex = ex.InnerException; str += ex.ToString(); // ex.Message; } ShowMsgToForm("添加19e政策异常:" + str); } }