Exemplo n.º 1
0
        //工作
        private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
        {
            PP m = e.Argument as PP;

            if (m != null)
            {
                ParamInfo   PI = m.ll[0];
                ParamObject PM = new ParamObject();
                PM.ServerIP   = PI.IP;
                PM.ServerPort = int.Parse(PI.Port);
                PM.Office     = PI.Office;
                PnrAnalysis.FormatPNR format = new FormatPNR();
                int i = 1;
                foreach (string item in m.ticketList)
                {
                    if (item.Replace("-", "").Trim() != "")
                    {
                        //发送指令
                        PM.code = "detr:TN" + item.Replace("-", "").Trim();
                        string RecvData     = SendNewPID.SendCommand(PM);
                        string TicketStatus = format.GetTicketStatus(RecvData);
                        if (TicketStatus.ToUpper().Contains("OPEN FOR USE"))
                        {
                            m.resultList.Add(item);
                            LogWrite(item + "\r\n", path);
                        }
                        backgroundWorker1.ReportProgress((i * 100) / m.ticketList.Count, "发送:" + PM.code + "结果:" + RecvData);
                        Thread.Sleep(m.ScanJJ * 1000);
                    }

                    i++;
                }
                e.Result = m;
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// 生成编码
        /// </summary>
        /// <param name="CarryCode">航空公司二字码</param>
        /// <param name="Office">预订编码Office</param>
        /// <param name="AdultPnr">儿童订单中儿童编码备注的成人编码</param>
        /// <param name="IsChdETDZAudltTK">是否儿童出成人票</param>
        /// <param name="pList">乘机人列表</param>
        /// <param name="skywaylist">航段列表</param>
        /// <returns></returns>
        public RePnrObj GetPnrInfo(string CarryCode, List <Tb_Ticket_Passenger> pList, List <Tb_Ticket_SkyWay> skywaylist, out string ErrMsg)
        {
            ErrMsg = "";
            List <IPassenger> pasList  = new List <IPassenger>();
            List <ISkyLeg>    skyList  = new List <ISkyLeg>();
            SendNewPID        pid      = new SendNewPID();
            PnrParamObj       PnrParam = new PnrParamObj();

            //必填项 是否开启新版PID发送指令
            PnrParam.UsePIDChannel     = userInfo.FQP.KongZhiXiTong != null && userInfo.FQP.KongZhiXiTong.Contains("|48|") ? 2 : 0; //2;
            PnrParam.ServerIP          = userInfo.Configparam.WhiteScreenIP;
            PnrParam.ServerPort        = int.Parse(string.IsNullOrEmpty(userInfo.Configparam.WhiteScreenPort) ? "0" : userInfo.Configparam.WhiteScreenPort);
            PnrParam.Office            = userInfo.Configparam.Office.Split('^')[0];
            PnrParam.CarryCode         = CarryCode;
            PnrParam.PasList           = pasList;
            PnrParam.SkyList           = skyList;
            PnrParam.IsGetSpecialPrice = 1;//为获取特价
            //是否儿童出成人票
            PnrParam.ChildIsAdultEtdz = "0";
            //可选项
            PnrParam.UserName = userInfo.User != null ? userInfo.User.LoginName : "";

            //输入的手机号码 预订编码CT项电话
            PnrParam.CTTel     = "028-55555555";
            PnrParam.CTCTPhone = "15928636274";


            PnrParam.PID   = userInfo.Configparam.Pid;
            PnrParam.KeyNo = userInfo.Configparam.KeyNo;
            //乘机人
            foreach (Tb_Ticket_Passenger pas in pList)
            {
                IPassenger p1 = new IPassenger();
                pasList.Add(p1);
                p1.PassengerName = pas.PassengerName;
                p1.PassengerType = pas.PassengerType;
                p1.PasSsrCardID  = pas.Cid;
            }
            //航段
            foreach (Tb_Ticket_SkyWay skyway in skywaylist)
            {
                ISkyLeg leg1 = new ISkyLeg();
                skyList.Add(leg1);
                leg1.CarryCode    = skyway.CarryCode;
                leg1.FlightCode   = skyway.FlightCode;
                leg1.FlyStartTime = skyway.FromDate.ToString("HHmm");
                leg1.FlyEndTime   = skyway.ToDate.ToString("HHmm");
                leg1.FlyStartDate = skyway.FromDate.ToString("yyyy-MM-dd");
                leg1.fromCode     = skyway.FromCityCode;
                leg1.toCode       = skyway.ToCityCode;
                leg1.Space        = skyway.Space;
                leg1.Discount     = skyway.Discount;
            }
            RePnrObj pObj = pid.ISendIns(PnrParam);

            //记录指令
            SaveInsInfo(pObj, userInfo.User, userInfo.Company);
            return(pObj);
        }
Exemplo n.º 3
0
        /// <summary>
        /// 指令记录到数据库
        /// </summary>
        /// <param name="PM"></param>
        /// <param name="TicketLP"></param>
        /// <returns></returns>
        public string WriteLogDB(ParamObject PM, ListParam TicketLP)
        {
            string         Recvdata = "";
            Tb_SendInsData sendins  = new Tb_SendInsData();

            try
            {
                sendins.SendTime = System.DateTime.Now;
                Recvdata         = SendNewPID.SendCommand(PM);
                sendins.RecvTime = System.DateTime.Now;
            }
            catch (Exception ex)
            {
            }
            finally
            {
                try
                {
                    //指令记入数据库
                    sendins.SendIns         = PM.code;
                    sendins.RecvData        = Recvdata;
                    sendins.SendInsType     = 18;
                    sendins.Office          = PM.Office;
                    sendins.ServerIPAndPort = PM.ServerIP + ":" + PM.ServerPort;
                    sendins.UserAccount     = "BSP";
                    sendins.CpyNo           = TicketLP.CpyNo;
                    //插入数据库
                    Manage.ExecuteNonQuerySQLInfo(PbProject.Dal.Mapping.MappingHelper <Tb_SendInsData> .CreateInsertModelSql(sendins, new List <string>()
                    {
                        "id"
                    }));
                }
                catch (Exception)
                {
                }
            }
            return(Recvdata);
        }
Exemplo n.º 4
0
    /// <summary>
    /// 获取指令数据
    /// </summary>
    /// <param name="SendIns"></param>
    /// <param name="Office"></param>
    /// <param name="cpyNo">公司编号</param>
    /// <returns></returns>
    public string GetData(string SendIns, string Office, string cpyNo, string Other)
    {
        string recvData = string.Empty;

        try
        {
            ConfigParam CP = null;
            if (!string.IsNullOrEmpty(Other))
            {
                string[] strArr            = Other.Split(new string[] { "@@@@" }, StringSplitOptions.None);
                string   strHeiPingCanShu  = strHeiPingCanShu = strArr[0];
                string   strDaPeiZhiCanShu = strArr[1];
                CP = GetConfigParam(strHeiPingCanShu, strHeiPingCanShu);
            }
            if (string.IsNullOrEmpty(SendIns))
            {
                recvData = "发送指令为空";
                return(recvData);
            }
            if (CP == null)
            {
                recvData = "参数错误";
                return(recvData);
            }
            IHashObject         param       = new HashObject();
            string              sqlWhere    = string.Format("UninCode='{0}' and  RoleType in(2,3) ", cpyNo);
            User_Company        m_Company   = null;
            List <User_Company> CompanyList = baseDataManage.CallMethod("User_Company", "GetList", null, new object[] { sqlWhere }) as List <User_Company>;
            if (CompanyList != null && CompanyList.Count > 0)
            {
                //该公司实体
                m_Company = CompanyList[0];
                //该公司参数表信息
                List <Bd_Base_Parameters> db_param = baseDataManage.CallMethod("Bd_Base_Parameters", "GetList", null, new object[] { "CpyNo='" + cpyNo + "'" }) as List <Bd_Base_Parameters>;

                string Mark = BaseParams.getParams(db_param).KongZhiXiTong;

                string bigIP = "127.0.0.1", bigPort = "391", BigOffice = "";
                string IP = "127.0.0.1", Port = "391";


                Tb_SendInsData sendins = new Tb_SendInsData();
                sendins.SendInsType = 11;  //标识为控台系统发送的指令
                sendins.UserAccount = mUser != null ? mUser.LoginName : "控台管理员";
                sendins.CpyNo       = mUser != null ? mUser.CpyNo : "控台管理员";

                //查找白屏预订Pid的IP地址
                IP = CP.WhiteScreenIP;
                //查找白屏预订Pid的端口
                Port = CP.WhiteScreenPort;
                //查找大配置IP
                bigIP = CP.BigCfgIP;
                //查找大配置Port
                bigPort = CP.BigCfgPort;
                //查找大配置Office
                BigOffice = CP.BigCfgOffice;

                //使用的IP 端口 Office
                string ServerIP   = "";
                int    ServerPort = 0;
                //是否开启大配置
                bool IsUseBigConfig = Mark.Contains("|39|");
                //是有使用新的PID
                bool IsUseNewPid = Mark.Contains("|48|");

                if (IsUseBigConfig)
                {
                    //大配置
                    int _Port = 451;
                    int.TryParse(bigPort, out _Port);
                    ServerIP   = bigIP;
                    ServerPort = _Port;
                    //大配置Office
                    Office = BigOffice;
                }
                else
                {
                    int.TryParse(Port, out ServerPort);
                    ServerIP = IP;
                }
                string[] OfficeNum  = null;
                string   tempOffice = CP.Office;//GetValue("office", db_param);
                if (Office == "")
                {
                    //空台设置的Office
                    OfficeNum = tempOffice.Split(new string[] { "|", " ", "/", ",", ",", "\\", "#", "^" }, StringSplitOptions.RemoveEmptyEntries);
                }
                else
                {
                    //空台设置的Office
                    OfficeNum = Office.Split(new string[] { "|", " ", "/", ",", ",", "\\", "#", "^" }, StringSplitOptions.RemoveEmptyEntries);
                }
                ///使用新的PID
                if (IsUseNewPid)
                {
                    //DataModel.A2 = "新的PID";
                    // WebManage.ServerIp = ServerIP;
                    // WebManage.ServerPort = ServerPort;
                    ParamObject Pm = new ParamObject();
                    Pm.ServerIP   = ServerIP;
                    Pm.ServerPort = ServerPort;


                    bool   IsPn       = false;//是否PN
                    string patternPnr = @"\s*(?<=rt|\(eas\)rt|rtx/|\(eas\)rtx/)(?=\w{6})\s*";
                    Match  mch        = Regex.Match(SendIns, patternPnr, RegexOptions.Compiled | RegexOptions.Multiline | RegexOptions.IgnoreCase);
                    if (mch.Success)
                    {
                        IsPn = true;
                    }
                    SendIns = SendIns.ToLower().StartsWith("ig|") ? SendIns.Trim().Substring(2) : SendIns;
                    if (Office != "" && Office.IndexOf("|") == -1)
                    {
                        //发送指令数据
                        SendIns = SendIns.Replace("\n", "").Replace("\r", "^");
                        //去掉ig
                        SendIns                 = SendIns.ToLower().StartsWith("ig|") ? SendIns.Trim().Substring(3).ToLower() : SendIns.ToLower();
                        sendins.SendIns         = SendIns;
                        sendins.Office          = Office;
                        sendins.ServerIPAndPort = ServerIP + ":" + ServerPort;
                        sendins.SendTime        = System.DateTime.Now;

                        Pm.code   = SendIns;
                        Pm.IsPn   = IsPn;
                        Pm.Office = Office;
                        recvData  = SendNewPID.SendCommand(Pm);

                        //recvData = WebManage.SendCommand(SendIns, Office, IsPn, false, ServerIP, ServerPort);

                        sendins.RecvTime = System.DateTime.Now;
                        if (recvData == null)
                        {
                            recvData = "";
                        }
                        recvData         = recvData.Replace("^", "\r");
                        sendins.RecvData = recvData;
                        //添加日志
                        AddLog(sendins);
                    }
                    if (recvData.Contains("授权") || Office == "")
                    {
                        foreach (string _Office in OfficeNum)
                        {
                            if (_Office.ToLower() != Office.ToLower())
                            {
                                Office = _Office.ToLower();
                                //发送指令数据
                                SendIns = SendIns.Replace("\n", "").Replace("\r", "^");
                                //去掉ig
                                SendIns                 = SendIns.ToLower().StartsWith("ig|") ? SendIns.Trim().Substring(3).ToLower() : SendIns.ToLower();
                                sendins.SendIns         = SendIns;
                                sendins.Office          = Office;
                                sendins.ServerIPAndPort = ServerIP + ":" + ServerPort;
                                sendins.SendTime        = System.DateTime.Now;

                                Pm.code   = SendIns;
                                Pm.IsPn   = IsPn;
                                Pm.Office = Office;
                                recvData  = SendNewPID.SendCommand(Pm);

                                //recvData = WebManage.SendCommand(SendIns, _Office, IsPn, false, ServerIP, ServerPort);

                                sendins.RecvTime = System.DateTime.Now;
                                if (recvData == null)
                                {
                                    recvData = "";
                                }
                                recvData         = recvData.Replace("^", "\r");
                                sendins.RecvData = recvData;
                                //添加日志
                                AddLog(sendins);
                            }
                            if (!recvData.Contains("授权"))
                            {
                                break;
                            }
                        }
                    }
                }
                else
                {
                    Office = (Office == "" ? "" : "&" + Office.TrimEnd('$').Trim() + "$") + "#1";
                    ECParam ecParam = new ECParam();
                    ecParam.ECIP   = ServerIP;
                    ecParam.ECPort = ServerPort.ToString();
                    //ecParam.PID = supModel.PId;
                    //ecParam.KeyNo = supModel.KeyNo;

                    ecParam.UserName = mUser == null ? "控台管理员" : mUser.UserName;
                    SendEC sendec = new SendEC(ecParam);
                    if (Office != "")
                    {
                        //发送指令数据
                        //logPnr.SSContent = "[EC:" + ServerIP + ":" + ServerPort + "|" + Office + "]" + SendIns + Office;
                        sendins.Office          = Office;
                        sendins.ServerIPAndPort = ServerIP + ":" + ServerPort;
                        sendins.SendTime        = System.DateTime.Now;
                        sendins.SendIns         = SendIns + Office;
                        recvData         = sendec.SendData(SendIns + Office, out recvData);
                        sendins.RecvData = recvData;
                        sendins.RecvTime = System.DateTime.Now;
                        // logPnr.ResultContent = recvData;
                        //添加日志
                        AddLog(sendins);
                    }
                    if (recvData.Contains("授权") || Office == "" || Office == "#1")
                    {
                        tempOffice = "";
                        foreach (string _Office in OfficeNum)
                        {
                            if (_Office.ToLower() != Office.ToLower())
                            {
                                tempOffice = (_Office == "" ? "" : "&" + _Office.TrimEnd('$').Trim() + "$") + "#1";
                                //logPnr.SSContent = "[EC:" + ServerIP + ":" + ServerPort + "|" + Office + "]" + SendIns + Office;
                                //发送指令数据
                                sendins.SendIns         = SendIns + Office;
                                sendins.Office          = _Office;
                                sendins.ServerIPAndPort = ServerIP + ":" + ServerPort;
                                sendins.SendTime        = System.DateTime.Now;
                                recvData         = sendec.SendData(SendIns + tempOffice, out recvData);
                                sendins.RecvData = recvData;
                                sendins.RecvTime = System.DateTime.Now;
                                //  logPnr.ResultContent = recvData;
                                //添加日志
                                AddLog(sendins);
                            }
                            if (!recvData.Contains("授权"))
                            {
                                break;
                            }
                        }
                    }
                }
            }
            else
            {
                recvData = "该供应商不存在";
                return(recvData);
            }
        }
        catch (Exception ex)
        {
            recvData = System.DateTime.Now + ":" + ex.Message + "|" + ex.StackTrace.ToString();
        }
        return(escape(recvData));
    }
Exemplo n.º 5
0
        /// <summary>
        /// 创建PNR时 生成一个没有政策的订单信息
        /// </summary>
        /// <param name="writer"></param>
        /// <param name="parames"></param>
        public override void Create(ResponseWriter writer, System.Collections.Specialized.NameValueCollection parames)
        {
            List <Tb_Ticket_Passenger> pList      = new List <Tb_Ticket_Passenger>();
            List <Tb_Ticket_SkyWay>    skywaylist = new List <Tb_Ticket_SkyWay>();

            #region 取提交的参数信息

            string adultPnr      = parames["adultPnr"];                         //只是儿童时需要备注的成人编码
            string pListStr      = parames["pList"];                            //乘机人信息 名称,类型,证件ID,儿童生日/名称,类型,证件ID,儿童生日
            string skywaylistStr = parames["skywaylist"];                       //航段信息 承运人,航班号,起飞日期,到达日期,起飞三字码,到达三字码,起飞城市,到达城市,舱位,折扣/航段信息 承运人,航班号,起飞日期,到达日期,起飞三字码,到达三字码,起飞城市,到达城市,舱位,折扣
            allowChangePNRFlag         = parames["allowChangePNRFlag"] == "1";  //是否允许换编码出票
            isAsAdultOrder             = parames["isAsAdultOrder"] == "1";      //是否关联成人订单号
            cHDAssociationAdultOrderId = parames["cHDAssociationAdultOrderId"]; //关联成人定单号
            isCHDToAudltTK             = parames["isCHDToAudltTK"] == "1";      //儿童票出成人票
            linkMan      = parames["linkMan"];                                  //联系人
            linkManPhone = parames["linkManPhone"];                             //联系人电话
            travelType   = parames["travelType"];                               //航班类型  1=单程,2=往返,3=中转联程 4=多程
            foreach (var pStr in pListStr.Split('/'))
            {
                var ps = pStr.Split(',');
                if (ps[1] == "2" && ps.Count() == 4)
                {
                    pList.Add(new Tb_Ticket_Passenger()
                    {
                        PassengerName = ps[0],
                        PassengerType = int.Parse(ps[1]),
                        Cid           = ps[2],
                        A7            = ps[3]
                    });
                }
                else if (ps[1] != "2")
                {
                    pList.Add(new Tb_Ticket_Passenger()
                    {
                        PassengerName = ps[0],
                        PassengerType = int.Parse(ps[1]),
                        Cid           = ps[2]
                    });
                }

                else
                {
                    writer.WriteEx(550, "passenger format error", "乘机人格式有误");
                }
            }
            foreach (var kStr in skywaylistStr.Split('/'))
            {
                var ks = kStr.Split(',');
                if (ks.Count() == 10)
                {
                    skywaylist.Add(new Tb_Ticket_SkyWay()
                    {
                        CarryCode    = ks[0],
                        FlightCode   = ks[1],
                        FromDate     = DateTime.Parse(ks[2]),
                        ToDate       = DateTime.Parse(ks[3]),
                        FromCityCode = ks[4],
                        ToCityCode   = ks[5],
                        FromCityName = ks[6],
                        ToCityName   = ks[7],
                        Space        = ks[8],
                        Discount     = ks[9]
                    });
                }
                else
                {
                    writer.WriteEx(550, "skyway format error", "航段格式有误");
                }
            }
            #endregion

            UserLoginInfo     userLogin = AuthLogin.GetUserInfo(Username);
            List <IPassenger> pasList   = new List <IPassenger>();
            List <ISkyLeg>    skyList   = new List <ISkyLeg>();
            SendNewPID        pid       = new SendNewPID();
            PnrParamObj       PnrParam  = new PnrParamObj();
            //必填项 是否开启新版PID发送指令
            PnrParam.UsePIDChannel = userLogin.FQP.KongZhiXiTong != null && userLogin.FQP.KongZhiXiTong.Contains("|48|") ? 2 : 0;  //2;
            PnrParam.ServerIP      = userLogin.Configparam.WhiteScreenIP;
            PnrParam.ServerPort    = int.Parse(string.IsNullOrEmpty(userLogin.Configparam.WhiteScreenPort) ? "0" : userLogin.Configparam.WhiteScreenPort);
            PnrParam.Office        = userLogin.Configparam.Office;
            PnrParam.CarryCode     = skywaylist[0].CarryCode;
            PnrParam.PasList       = pasList;
            PnrParam.SkyList       = skyList;
            //只是儿童时需要备注的成人编码
            PnrParam.AdultPnr = adultPnr;
            //是否儿童出成人票
            PnrParam.ChildIsAdultEtdz = isCHDToAudltTK ? "1" : "0";;
            //可选项
            PnrParam.UserName = Username;



            //输入的手机号码 预订编码CT项电话
            if (userLogin.FQP.KongZhiXiTong == null || !userLogin.FQP.KongZhiXiTong.Contains("|19|"))
            {
                PnrParam.CTTel     = userLogin.User != null ? userLogin.User.Tel : "";
                PnrParam.CTCTPhone = linkManPhone != "" ? linkManPhone : (userLogin.Company != null && userLogin.Company.ContactTel.Trim() != "" ? userLogin.Company.ContactTel.Trim() : "");
            }
            else
            {
                PnrParam.CTTel     = userLogin.mSupCompany.Tel != null ? userLogin.mSupCompany.Tel : "";
                PnrParam.CTCTPhone = linkManPhone != "" ? linkManPhone : (userLogin.mSupCompany != null && userLogin.mSupCompany.ContactTel.Trim() != "" ? userLogin.mSupCompany.ContactTel.Trim() : "");
            }

            //关闭生成订单联系人默认值   生成订单时,联系人不需要默认值,让用户自己填写
            if (userLogin.FQP.KongZhiXiTong != null && userLogin.FQP.KongZhiXiTong.Contains("|55|"))
            {
                PnrParam.CTTel     = userLogin.User != null ? userLogin.User.Tel : "";
                PnrParam.CTCTPhone = linkManPhone;
            }


            PnrParam.PID   = userLogin.Configparam.Pid;
            PnrParam.KeyNo = userLogin.Configparam.KeyNo;
            //乘机人
            foreach (Tb_Ticket_Passenger pas in pList)
            {
                IPassenger p1 = new IPassenger();
                pasList.Add(p1);
                p1.PassengerName = pas.PassengerName;
                p1.PassengerType = pas.PassengerType;
                p1.PasSsrCardID  = pas.Cid;
                p1.ChdBirthday   = pas.A7;
            }
            //航段
            foreach (Tb_Ticket_SkyWay skyway in skywaylist)
            {
                ISkyLeg leg1 = new ISkyLeg();
                skyList.Add(leg1);
                leg1.CarryCode    = skyway.CarryCode;
                leg1.FlightCode   = skyway.FlightCode;
                leg1.FlyStartTime = skyway.FromDate.ToString("HHmm");
                leg1.FlyEndTime   = skyway.ToDate.ToString("HHmm");
                leg1.FlyStartDate = skyway.FromDate.ToString("yyyy-MM-dd");
                leg1.fromCode     = skyway.FromCityCode;
                leg1.toCode       = skyway.ToCityCode;
                leg1.Space        = skyway.Space;
                leg1.Discount     = skyway.Discount;
            }
            RePnrObj pObj = pid.ISendIns(PnrParam);
            string   msg  = "";
            if (GenerationOrder(userLogin, skywaylist, pList, pObj, out msg))
            {
                writer.Write(new { pnr = pObj, orderID = msg });
            }
            else
            {
                writer.WriteEx(565, "create order error", "创建空白定单失败:" + msg);
            }
        }
Exemplo n.º 6
0
        //自动取消处理线程
        public static void XEPNRProcess()
        {
            string SendIns  = string.Empty;
            string RecvData = string.Empty;
            string Office   = string.Empty;
            string ErrMsg   = string.Empty;
            string Pnr      = string.Empty;
            string OrderId  = string.Empty;

            PnrAnalysis.FormatPNR pnrFormat = new FormatPNR();
            while (true)
            {
                try
                {
                    SendIns  = string.Empty;
                    RecvData = string.Empty;
                    Office   = string.Empty;
                    ErrMsg   = string.Empty;
                    Pnr      = string.Empty;
                    OrderId  = string.Empty;

                    //组织订单过滤条件
                    //订单来源:白屏预订PNR
                    string tmpSQL = " OrderSourceType=1 " +
                                    //订单状态:新订单,等待支付
                                    "and OrderStatusCode=1 " +
                                    //支付状态:未付
                                    "and PayStatus=0 " +
                                    //预订公司编号(归属的落地运营商编号范围)
                                    "and left(OwnerCpyNo,12) in (" + string.Join(",", m_XePNRInfo.CompanyNoList.ToArray()) + ") " +
                                    //预定时间超过设置取消时间值
                                    " and DateDiff(minute,CreateTime,getdate())>" + m_XePNRInfo.XEMinutes.ToString() +
                                    //3天内的预定订单
                                    " and DateDiff(day,CreateTime,getdate())<" + XePNR.m_XePNRInfo.day.ToString();

                    //取消订单表
                    List <Tb_Ticket_Order> list = Manage.CallMethod("Tb_Ticket_Order", "GetList", null, new object[] { tmpSQL }) as List <Tb_Ticket_Order>;
                    //滤过的PNR
                    List <string> tempPntList = new List <string>();
                    for (int i = 0; i < list.Count; i++)
                    {
                        //停止服务,则退出处理
                        if (m_XePNRInfo.EndFlag || XeLog == null)
                        {
                            return;
                        }
                        Tb_Ticket_Order tmpTicketOrder = list[i];
                        ///控制权限
                        string KonZhiXT = GetGYParameters(tmpTicketOrder.OwnerCpyNo);
                        //是否关闭后台自动取消编码功能
                        if (KonZhiXT != null && KonZhiXT.Contains("|98|"))
                        {
                            continue;
                        }
                        #region 过滤掉已经处理的PNR
                        if (tempPntList.Contains("'" + tmpTicketOrder.PNR + "'"))
                        {
                            continue;
                        }
                        #endregion

                        #region 检查同一编码、同一预订公司下是否存在已付款的订单
                        //包括收银
                        string tmpSQL3 = "  PNR='" + tmpTicketOrder.PNR + "'"
                                         + " and CreateTime>='" + tmpTicketOrder.CreateTime.ToString("yyyy-MM-dd") + "' and ( (OrderStatusCode in(3,4) and  PayStatus=0)  or   PayStatus=1 or OrderStatusCode=4 )";
                        bool flag1 = (bool)Manage.CallMethod("Tb_Ticket_Order", "IsExist", null, new object[] { tmpSQL3 });
                        if (flag1)
                        {
                            if (tmpTicketOrder.PNR != "")
                            {
                                tempPntList.Add("'" + tmpTicketOrder.PNR + "'");
                            }
                            //存在已经支付的订单,略过
                            //记录日志
                            Log.Record("XePnr.log", "订单号:" + tmpTicketOrder.OrderId + ",PNR编号:" + tmpTicketOrder.PNR + "存在已经付款订单,略过该PNR...");
                            continue;
                        }
                        #endregion 检查同一编码、同一预订公司下是否存在已付款的订单

                        #region 提取并检查PNR是否已经出票或RR状态,如果是则略过
                        string GYCpyNo = tmpTicketOrder.OwnerCpyNo;
                        if (GYCpyNo.Length >= 12)
                        {
                            GYCpyNo = GYCpyNo.Substring(0, 12);
                        }
                        List <Bd_Base_Parameters> baseParamList = Manage.CallMethod("Bd_Base_Parameters", "GetList", null, new Object[] { "CpyNo='" + GYCpyNo + "'" }) as List <Bd_Base_Parameters>;
                        ConfigParam config = Bd_Base_ParametersBLL.GetConfigParam(baseParamList);
                        if (config == null)
                        {
                            XeLog(1, string.Format("订单号{0},落地运营商未设置使用配置信息,请设置!", tmpTicketOrder.OrderId));
                            //移除该落地运营商 该落地运营商未设置配置参数
                            if (m_XePNRInfo.CompanyNoList.Contains("'" + GYCpyNo + "'"))
                            {
                                m_XePNRInfo.CompanyNoList.Remove("'" + GYCpyNo + "'");
                            }
                            continue;
                        }
                        OrderId = tmpTicketOrder.OrderId;
                        Office  = string.IsNullOrEmpty(tmpTicketOrder.Office) ? config.Office.Split('^')[0] : tmpTicketOrder.Office;
                        if (string.IsNullOrEmpty(Office))
                        {
                            XeLog(1, string.Format("订单号{0}中没有Office或者落地运营商没有设置Office,请检查!", OrderId));
                            //移除该落地运营商 该落地运营商未设置配置参数
                            if (m_XePNRInfo.CompanyNoList.Contains("'" + GYCpyNo + "'"))
                            {
                                m_XePNRInfo.CompanyNoList.Remove("'" + GYCpyNo + "'");
                            }
                            continue;
                        }
                        Pnr = tmpTicketOrder.PNR;
                        if (string.IsNullOrEmpty(tmpTicketOrder.PNR) || (tmpTicketOrder.PNR.Trim() == ""))
                        {
                            XeLog(1, string.Format("订单号{0}中没有PNR,更改为已取消订单!", OrderId));

                            //更改订单状态为已经取消订单
                            string tempSql = "update Tb_Ticket_Order set OrderStatusCode=2,TicketStatus=6  where id='" + tmpTicketOrder.id + "'";
                            Manage.ExecuteNonQuerySQLInfo(tempSql);
                            continue;
                        }

                        Tb_SendInsData SendModel = new Tb_SendInsData();
                        ParamObject    PM        = new ParamObject();
                        PM.ServerIP   = config.WhiteScreenIP;
                        PM.ServerPort = int.Parse(config.WhiteScreenPort);
                        PM.Office     = Office;
                        //发送指令
                        SendIns = "RT" + Pnr;
                        PM.code = SendIns;
                        PM.IsPn = true;

                        SendModel.SendIns         = SendIns;             //发送指令
                        SendModel.SendInsType     = 13;                  //扫描程序发送的指令
                        SendModel.SendTime        = System.DateTime.Now; //发送时间
                        SendModel.Office          = Office;
                        SendModel.ServerIPAndPort = PM.ServerIP + ":" + PM.ServerPort;
                        SendModel.UserAccount     = "扫描程序";
                        SendModel.CpyNo           = GYCpyNo;
                        //返回数据
                        RecvData           = SendNewPID.SendCommand(PM);
                        SendModel.RecvData = RecvData;
                        SendModel.RecvTime = System.DateTime.Now;
                        //记录指令到数据库
                        LogData(SendModel);

                        //指令日志
                        XeLog(1, string.Format("\r\n【编码:{0}】发送指令>{1}\r\n接收数据:\r\n{2}\r\n订单号:{3}\r\n", Pnr, SendIns, RecvData, tmpTicketOrder.OrderId));
                        if (RecvData.Contains("授权"))
                        {
                            //更改订单状态为已经取消订单
                            string tempSql = "update Tb_Ticket_Order set OrderStatusCode=2,TicketStatus=6  where id='" + tmpTicketOrder.id + "'";
                            Manage.ExecuteNonQuerySQLInfo(tempSql);
                            if (tmpTicketOrder.PNR != "")
                            {
                                tempPntList.Add("'" + tmpTicketOrder.PNR + "'");
                            }
                            XeLog(1, string.Format("订单号{0}中{1} {2},只取消订单不取消编码!", OrderId, Pnr, RecvData));
                            continue;
                        }
                        string PnrStatus = pnrFormat.GetPnrStatus(RecvData, out ErrMsg);
                        if (!PnrStatus.ToUpper().Contains("HK") && !PnrStatus.ToUpper().Contains("HL") && !PnrStatus.ToUpper().Contains("NO"))//(PnrStatus.Contains("RR") || PnrStatus.Contains("XX"))
                        {
                            if (tmpTicketOrder.PNR != "")
                            {
                                tempPntList.Add("'" + tmpTicketOrder.PNR + "'");
                            }
                            XeLog(1, string.Format("订单号{0}中{1}状态为{2},只取消订单,不处理PNR!", OrderId, Pnr, PnrStatus));

                            //更改订单状态为已经取消订单
                            string tempSql = "update Tb_Ticket_Order set OrderStatusCode=2,TicketStatus=6  where id='" + tmpTicketOrder.id + "'";
                            Manage.ExecuteNonQuerySQLInfo(tempSql);
                            continue;
                        }
                        #endregion 提取并检查PNR是否已经出票或RR状态,如果是则略过

                        #region 发送取消PNR指令并检查结果

                        if (PnrStatus.ToUpper().Contains("HK") || PnrStatus.ToUpper().Contains("HL") || PnrStatus.ToUpper().Contains("NO"))
                        {
                            //取消编码
                            SendIns = "RT" + Pnr + "|XEPNR@" + Pnr;
                            PM.code = SendIns;
                            PM.IsPn = false;

                            SendModel                 = new Tb_SendInsData();
                            SendModel.SendIns         = SendIns;             //发送指令
                            SendModel.SendInsType     = 13;                  //扫描程序发送的指令
                            SendModel.SendTime        = System.DateTime.Now; //发送时间
                            SendModel.Office          = Office;
                            SendModel.ServerIPAndPort = PM.ServerIP + ":" + PM.ServerPort;
                            SendModel.UserAccount     = "扫描程序";
                            SendModel.CpyNo           = GYCpyNo;
                            //返回数据
                            RecvData           = SendNewPID.SendCommand(PM);
                            SendModel.RecvData = RecvData;
                            SendModel.RecvTime = System.DateTime.Now;
                            //记录指令到数据库
                            LogData(SendModel);

                            //指令日志
                            XeLog(1, string.Format("\r\n【订单号{0}】发送指令>{1}\r\n接收数据:\r\n{2}\r\n", OrderId, SendIns, RecvData));

                            if (RecvData.ToUpper().Contains("CANCELLED"))
                            {
                                //加入不需要取消的列表
                                tempPntList.Add("'" + tmpTicketOrder.PNR + "'");
                                //取消编码成功后 取消订单
                                List <string> ListSQL = new List <string>();
                                //修改订单数据
                                string tempSql = "update Tb_Ticket_Order set OrderStatusCode=2,TicketStatus=6  where id='" + tmpTicketOrder.id + "'";
                                ListSQL.Add(tempSql);//
                                //修改乘客数据
                                tempSql = "update Tb_Ticket_Passenger set TicketStatus=6  where OrderId='" + OrderId + "'";
                                ListSQL.Add(tempSql);//1.添加订单日志

                                //取消编码 订单日志
                                Log_Tb_AirOrder OrderLog = new Log_Tb_AirOrder();
                                OrderLog.id            = Guid.NewGuid();
                                OrderLog.OperContent   = "订单超过" + m_XePNRInfo.XEMinutes.ToString() + "分钟未能成功支付,系统于" + System.DateTime.Now + "订单自动取消";;
                                OrderLog.OperLoginName = "管理员";
                                OrderLog.OperTime      = DateTime.Now;
                                OrderLog.OperType      = "修改";
                                OrderLog.OperUserName  = "******";
                                OrderLog.OrderId       = OrderId;
                                OrderLog.WatchType     = 1;
                                //订单出票公司信息
                                ListParam TicketLP = LPList.Find(delegate(ListParam _tempLP)
                                {
                                    return(tmpTicketOrder.OwnerCpyNo.Contains(_tempLP.CpyNo));
                                });
                                if (TicketLP != null)
                                {
                                    OrderLog.CpyName = TicketLP.UninAllName;
                                    OrderLog.CpyNo   = TicketLP.CpyNo;
                                    OrderLog.CpyType = 1;
                                }
                                else
                                {
                                    OrderLog.CpyName = tmpTicketOrder.OwnerCpyName;
                                    OrderLog.CpyNo   = tmpTicketOrder.OwnerCpyNo;
                                    OrderLog.CpyType = 1;
                                }
                                tempSql = PbProject.Dal.Mapping.MappingHelper <Log_Tb_AirOrder> .CreateInsertModelSql(OrderLog);

                                ListSQL.Add(tempSql);
                                //取消订单
                                if (Manage.ExecuteSqlTran(ListSQL, out ErrMsg))
                                {
                                    XeLog(1, System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + " 订单号:" + OrderId + " 订单已取消");
                                }
                            }
                        }
                        #endregion 发送取消PNR指令并检查结果
                    }

                    #region //修改滤过的PNR状态
                    if (tempPntList.Count > 0)
                    {
                        string sqlWhere = " update Log_Pnr set  Flag=1 where   Pnr in(" + string.Join(",", tempPntList.ToArray()) + ")";
                        Manage.ExecuteNonQuerySQLInfo(sqlWhere);
                    }

                    #endregion

                    #region    //生成了编码 没有生成订单的编码
                    string tmpSQL2 = " left(CpyNo,12) in (" + string.Join(",", m_XePNRInfo.CompanyNoList.ToArray()) + ") and DateDiff(minute,OperTime,getdate())>" + m_XePNRInfo.XEMinutes.ToString() + " and OrderFlag=0 and Flag=0 and RetryCount<" + m_XePNRInfo.ReTryCount;
                    //过滤掉没有连接成功的PNR
                    List <string> lstRepeat = new List <string>();
                    //取消PNR表 没有写入订单的数据
                    List <Log_Pnr> list2 = Manage.CallMethod("Log_Pnr", "GetList", null, new object[] { tmpSQL2 }) as List <Log_Pnr>;
                    for (int j = 0; j < list2.Count; j++)
                    {
                        //停止服务,则退出处理
                        if (m_XePNRInfo.EndFlag)
                        {
                            return;
                        }
                        Log_Pnr tmpLogPnr = list2[j];
                        ///控制权限
                        string KonZhiXT = GetGYParameters(tmpLogPnr.CpyNo);
                        //是否关闭后台自动取消编码功能
                        if (KonZhiXT != null && KonZhiXT.Contains("|98|"))
                        {
                            continue;
                        }
                        string GYCpyNo = tmpLogPnr.CpyNo.Length >= 12 ? tmpLogPnr.CpyNo.Substring(0, 12) : tmpLogPnr.CpyNo;
                        //勾选了该落地运营商的才取消编码
                        if (!m_XePNRInfo.CompanyNoList.Contains("'" + GYCpyNo + "'"))
                        {
                            continue;
                        }
                        //不取消滤过的PNR
                        if (tmpLogPnr.PNR != "" && tempPntList.Contains("'" + tmpLogPnr.PNR + "'"))
                        {
                            tmpLogPnr.Flag = true;
                            string tempSql = PbProject.Dal.Mapping.MappingHelper <Log_Pnr> .CreateUpdateModelSql(tmpLogPnr, "id");

                            Manage.ExecuteNonQuerySQLInfo(tempSql);
                            continue;
                        }

                        #region 取消PNR
                        string pnr = tmpLogPnr.PNR;
                        //pnr为空不处理  //Office为空不处理
                        if (string.IsNullOrEmpty(pnr) || string.IsNullOrEmpty(tmpLogPnr.OfficeCode))
                        {
                            tmpLogPnr.Flag = true;
                            string tempSql = PbProject.Dal.Mapping.MappingHelper <Log_Pnr> .CreateUpdateModelSql(tmpLogPnr, "id");

                            Manage.ExecuteNonQuerySQLInfo(tempSql);
                            continue;
                        }
                        ////IP端口为空不处理
                        string[] strIPPort = tmpLogPnr.A7.Split('|');
                        if (strIPPort.Length == 2)
                        {
                            if (pnr.Trim() == "")
                            {
                                tmpLogPnr.Flag = true;
                                string tempSql = PbProject.Dal.Mapping.MappingHelper <Log_Pnr> .CreateUpdateModelSql(tmpLogPnr, "id");

                                Manage.ExecuteNonQuerySQLInfo(tempSql);
                                continue;
                            }


                            string ip   = strIPPort[0];
                            int    Port = 0;
                            int.TryParse(strIPPort[1], out Port);

                            Tb_SendInsData SendModel = new Tb_SendInsData();
                            ParamObject    PM        = new ParamObject();
                            PM.ServerIP   = ip;
                            PM.ServerPort = Port;
                            PM.Office     = tmpLogPnr.OfficeCode;

                            //发送指令
                            SendIns = "RT" + pnr;
                            PM.code = SendIns;

                            SendModel.SendIns         = SendIns;             //发送指令
                            SendModel.SendInsType     = 13;                  //扫描程序发送的指令
                            SendModel.SendTime        = System.DateTime.Now; //发送时间
                            SendModel.Office          = Office;
                            SendModel.ServerIPAndPort = PM.ServerIP + ":" + PM.ServerPort;
                            SendModel.UserAccount     = "扫描程序";
                            SendModel.CpyNo           = GYCpyNo;
                            //过滤连接不通的IP端口
                            if (lstRepeat.Contains(SendModel.ServerIPAndPort))
                            {
                                continue;
                            }
                            //返回数据
                            RecvData           = SendNewPID.SendCommand(PM);
                            SendModel.RecvData = RecvData;
                            SendModel.RecvTime = System.DateTime.Now;
                            //记录指令到数据库
                            LogData(SendModel);
                            //过滤连接不通的IP端口
                            if (RecvData.Contains("由于连接方在一段时间后没有正确答复或连接的主机没有反应") || RecvData.Contains("不知道这样的主机"))
                            {
                                lstRepeat.Add(SendModel.ServerIPAndPort);
                            }
                            //指令日志
                            XeLog(1, string.Format("\r\n【编码:{0}】发送指令>{1}\r\n接收数据:\r\n{2}\r\n", Pnr, SendIns, RecvData));
                            string PnrStatus = pnrFormat.GetPnrStatus(RecvData, out ErrMsg);
                            if (!PnrStatus.Contains("RR") && !PnrStatus.Contains("XX") && PnrStatus != "")
                            {
                                if (PnrStatus.ToUpper().Contains("HK") || PnrStatus.ToUpper().Contains("HL") || PnrStatus.ToUpper().Contains("NO"))
                                {
                                    //发送指令
                                    SendIns = "RT" + pnr + "|XePNR@" + pnr;
                                    PM.code = SendIns;

                                    SendModel                 = new Tb_SendInsData();
                                    SendModel.SendIns         = SendIns;             //发送指令
                                    SendModel.SendInsType     = 13;                  //扫描程序发送的指令
                                    SendModel.SendTime        = System.DateTime.Now; //发送时间
                                    SendModel.Office          = Office;
                                    SendModel.ServerIPAndPort = PM.ServerIP + ":" + PM.ServerPort;
                                    SendModel.UserAccount     = "扫描程序";
                                    SendModel.CpyNo           = GYCpyNo;
                                    //返回数据
                                    RecvData           = SendNewPID.SendCommand(PM);
                                    SendModel.RecvData = RecvData;
                                    SendModel.RecvTime = System.DateTime.Now;
                                    //记录指令到数据库
                                    LogData(SendModel);

                                    //指令日志
                                    XeLog(1, string.Format("\r\n【编码:{0}】发送指令>{1}\r\n接收数据:\r\n{2}\r\n", pnr, SendIns, RecvData));
                                    if (RecvData.ToUpper().Contains("CANCELLED"))
                                    {
                                        //取消成功
                                        tmpLogPnr.Flag = true;
                                    }
                                    else
                                    {
                                        //取消失败
                                        tmpLogPnr.Flag = false;
                                        tmpLogPnr.RetryCount++;
                                    }
                                    string tempSql = PbProject.Dal.Mapping.MappingHelper <Log_Pnr> .CreateUpdateModelSql(tmpLogPnr, "id");

                                    Manage.ExecuteNonQuerySQLInfo(tempSql);
                                }
                            }
                            else
                            {
                                tmpLogPnr.Flag = true;
                                string tempSql = PbProject.Dal.Mapping.MappingHelper <Log_Pnr> .CreateUpdateModelSql(tmpLogPnr, "id");

                                Manage.ExecuteNonQuerySQLInfo(tempSql);
                            }
                        }
                        #endregion
                    }
                    //更新数据库
                    //if (UpdateSQL.Count > 0)
                    //{
                    //    Manage.ExecuteSqlTran(UpdateSQL, out ErrMsg);
                    //}
                    #endregion
                }
                catch (Exception ex)
                {
                    //记录错误日志
                    Log.Record("XePnrError.log", ex, "XEPNRProcess:自动取消PNR处理过程出错!");
                }
                //遍历时间间隔
                Thread.Sleep(m_XePNRInfo.InterMinutes * 1000);//分钟
            }
        }