Beispiel #1
0
        /// <summary>
        /// 获取登录用户信息对象
        /// </summary>
        /// <param name="userTableArray">用户信息表</param>
        /// <returns>返回用户信息对象</returns>
        private UserLoginInfo GetLoginUserInfo(DataTable[] userTableArray)
        {
            //当前登录用户信息
            User_Employees user = MappingHelper <User_Employees> .FillModel(userTableArray[0].Rows[0]);

            //当前登录公司信息
            User_Company company = MappingHelper <User_Company> .FillModel(userTableArray[1].Rows[0]);

            //当前登录用户公司参数信息
            List <Bd_Base_Parameters> baseParametersList = MappingHelper <Bd_Base_Parameters> .FillModelList(userTableArray[2]);

            var mSupCompany = MappingHelper <User_Company> .FillModel(userTableArray[3].Rows[0]);

            var supParameters = MappingHelper <Bd_Base_Parameters> .FillModelList(userTableArray[4]);

            var configparam = Bd_Base_ParametersBLL.GetConfigParam(supParameters);
            var FQP         = PbProject.WebCommon.Utility.BaseParams.getParams(supParameters);
            //用户信息对象
            UserLoginInfo userInfo = new UserLoginInfo()
            {
                User               = user,
                Company            = company,
                BaseParametersList = baseParametersList,
                mSupCompany        = mSupCompany,
                Configparam        = configparam,
                SupParameters      = supParameters,
                FQP = FQP
            };

            return(userInfo);
        }
Beispiel #2
0
        /// <summary>
        /// 登录用户信息转化
        /// </summary>
        /// <param name="LoginIn"></param>
        /// <returns></returns>
        public SessionContent GetLoginUserModel(DataSet LoginIn)
        {
            //当前登录用户信息
            User_Employees m_User = null;
            //当前登录公司信息
            User_Company mCompany = null;
            //供应商和落地运营商公司信息
            User_Company mSupCompany = null;
            //当前登录用户参数信息
            List <Bd_Base_Parameters> baseParametersList = null;
            //落地运营商和供应商公司参数信息
            List <Bd_Base_Parameters> SupParameters = null;
            //配置信息
            ConfigParam configparam = null;
            //保存用户信息
            SessionContent sessionContent = new SessionContent();

            if (LoginIn.Tables.Count == 5)
            {
                m_User = MappingHelper <User_Employees> .FillModel(LoginIn.Tables[0].Rows[0]);

                mCompany = MappingHelper <User_Company> .FillModel(LoginIn.Tables[1].Rows[0]);

                baseParametersList = MappingHelper <Bd_Base_Parameters> .FillModelList(LoginIn.Tables[2]);

                mSupCompany = MappingHelper <User_Company> .FillModel(LoginIn.Tables[3].Rows[0]);

                SupParameters = MappingHelper <Bd_Base_Parameters> .FillModelList(LoginIn.Tables[4]);

                configparam = Bd_Base_ParametersBLL.GetConfigParam(SupParameters);
            }
            else if (LoginIn.Tables.Count == 3)
            {
                //管理员
                m_User = MappingHelper <User_Employees> .FillModel(LoginIn.Tables[0].Rows[0]);

                mCompany = MappingHelper <User_Company> .FillModel(LoginIn.Tables[1].Rows[0]);

                baseParametersList = MappingHelper <Bd_Base_Parameters> .FillModelList(LoginIn.Tables[2]);
            }
            sessionContent.USER              = m_User;             // 用户信息
            sessionContent.COMPANY           = mCompany;           // 公司信息
            sessionContent.SUPCOMPANY        = mSupCompany;        //供应商和落地运营商公司信息
            sessionContent.BASEPARAMETERS    = baseParametersList; //公司参数信息
            sessionContent.SupBASEPARAMETERS = SupParameters;      //落地运营商和供应商公司参数信息
            sessionContent.CONFIGPARAM       = configparam;        //配置信息
            //设置到全局变量中
            Program.UserModel = sessionContent;
            return(sessionContent);
        }
        /* BSP常见错误信息
         * MRT:HT0LYJ IGNORED
         * INCOMPLETE PNR/FN
         * PLEASE CHECK TKT ELEMENT
         * CHECK BLINK CODE
         * ELE NBR
         */
        /// <summary>
        /// BSP订单处理
        /// </summary>
        /// <param name="Order"></param>
        private void BspHandle(Tb_Ticket_Order Order, List <ListParam> LPList, BSPShowLog Log)
        {  //订单日志
            StringBuilder sbLog = new StringBuilder();

            if (Order != null)
            {
                //订单出票公司信息
                ListParam TicketLP = LPList.Find(delegate(ListParam _tempLP)
                {
                    return(Order.OwnerCpyNo.Contains(_tempLP.CpyNo));
                });

                //编码解析类
                PnrAnalysis.FormatPNR pnrFormat = new PnrAnalysis.FormatPNR();
                //判断标识
                List <string> NumTickList          = new List <string>();
                List <string> PTList               = null;
                List <Tb_Ticket_Passenger> PasList = null;
                try
                {
                    Log(0, System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "订单号:" + Order.OrderId + "=======================start=====================\r\n");
                    string GYCpyNo = Order.OwnerCpyNo;
                    if (GYCpyNo.Length >= 12)
                    {
                        GYCpyNo = GYCpyNo.Substring(0, 12);
                    }
                    string CarrayCode = Order.CarryCode.Split('/')[0];
                    Tb_Ticket_PrintOffice PrintOffice = GetPrintOffice(GYCpyNo, CarrayCode);
                    if (PrintOffice == null || PrintOffice.PrintCode == "")
                    {
                        Log(0, string.Format("{0}未设置打票机号,请手动出票!", CarrayCode));
                        sbLog.Append(string.Format("{0}未设置打票机号,请手动出票!", CarrayCode));
                        return;
                    }
                    //出票Office
                    string pOffice   = string.IsNullOrEmpty(PrintOffice.OfficeCode) ? Order.PrintOffice : PrintOffice.OfficeCode;
                    string PrintCode = PrintOffice.PrintCode;
                    string Pnr       = Order.PNR;//Pnr编码
                    if (pOffice == "")
                    {
                        Log(0, string.Format("{0}出票Office不能为空!", CarrayCode));
                        sbLog.Append(string.Format("{0}出票Office不能为空!", CarrayCode));
                        return;
                    }
                    //获取乘客
                    string sqlWhere           = string.Format(" OrderId='{0}' order by PassengerType", Order.OrderId);
                    Tb_Ticket_Passenger pMode = null;
                    PasList = Manage.CallMethod("Tb_Ticket_Passenger", "GetList", null, new object[] { sqlWhere }) as List <Tb_Ticket_Passenger>;
                    if (PasList == null || PasList.Count == 0)
                    {
                        Log(0, string.Format("订单号:{0}没有找到对应的乘客信息!", Order.OrderId));
                        sbLog.Append(string.Format("订单号:{0}没有找到对应的乘客信息!", Order.OrderId));
                        return;
                    }
                    else
                    {
                        pMode = PasList[0];
                    }
                    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);
                    //指令管理类
                    //SendInsManage SendManage = new SendInsManage(Order.OwnerCpyNo, GYCpyNo, config);
                    if (config == null)
                    {
                        Log(0, string.Format("订单号{0},公司{1}未设置使用配置信息,请设置!", Order.OrderId, CarrayCode));
                        sbLog.Append(string.Format("订单号{0},公司{1}未设置使用配置信息,请设置!", Order.OrderId, CarrayCode));
                        return;
                    }
                    if (string.IsNullOrEmpty(Order.PNR))
                    {
                        Log(0, string.Format("订单号{0}中没有PNR,请检查!", Order.OrderId));
                        sbLog.Append(string.Format("订单号{0}中没有PNR,请检查!", Order.OrderId));
                        return;
                    }

                    ParamObject PM = new ParamObject();
                    PM.ServerIP   = config.WhiteScreenIP;
                    PM.ServerPort = int.Parse(config.WhiteScreenPort);
                    PM.Office     = pOffice;

                    //发送指令
                    string SendIns = "RT" + Pnr;
                    //返回数据
                    string Recvdata = string.Empty;
                    PM.code = SendIns;
                    PM.IsPn = true;
                    //  Recvdata = SendNewPID.SendCommand(PM);
                    Recvdata = WriteLogDB(PM, TicketLP);
                    //指令日志
                    Log(0, string.Format("\r\n【订单号{0}】发送指令>{1}\r\n接收数据:\r\n{2}\r\n", Order.OrderId, SendIns, Recvdata));
                    //授权检查
                    if (Recvdata.ToUpper().Contains("授权"))
                    {
                        Log(0, string.Format("订单号{0},编码{1} 出票Office{2},发送指令需要授权!", Order.OrderId, Pnr, pOffice));
                        sbLog.Append(string.Format("订单号{0},编码{1} 出票Office{2},发送指令需要授权!", Order.OrderId, Pnr, pOffice));
                        return;
                    }
                    else if (Recvdata.ToUpper().Contains("CANCELLED"))
                    {
                        Log(0, string.Format("订单号{0},编码{1} 出票Office{2},编码已取消,出票失败!", Order.OrderId, Pnr, pOffice));
                        sbLog.Append(string.Format("订单号{0},编码{1} 出票Office{2},编码已取消,出票失败!", Order.OrderId, Pnr, pOffice));
                        return;
                    }
                    string Msg = "";
                    string Xe = "", RR = "";
                    string PnrStatus = pnrFormat.GetPnrStatus(Recvdata, out Msg);
                    if (PnrStatus.Contains("NO"))
                    {
                        Log(0, string.Format("订单号{0},编码{1} 出票Office{2},编码状态为{3},不能自动出票!!", Order.OrderId, Pnr, pOffice, PnrStatus));
                        sbLog.Append(string.Format("订单号{0},编码{1} 出票Office{2},编码状态为{3},不能自动出票!!", Order.OrderId, Pnr, pOffice, PnrStatus));
                        return;
                    }
                    //存在的票号
                    PTList = GetTicketNum(Pnr, Recvdata.ToUpper(), pnrFormat);
                    List <string> RRList = null;
                    List <string> XEList = null;
                    if (PTList.Count == 0)
                    {
Start:
                        {
                            //进行出票
                            HashObject hash = GetNumList(Recvdata);
                            XEList = hash["XEList"] as List <string>;
                            RRList = hash["RRList"] as List <string>;
                            List <string> StartXeList = hash["StartXeList"] as List <string>;
                            //XE项
                            if (StartXeList.Count > 0)
                            {
                                for (int i = 0; i < StartXeList.Count; i++)
                                {
                                    string XeStr = StartXeList[i];
                                    if (XeStr != "")
                                    {
                                        //发送指令
                                        SendIns = "RT" + Pnr + "|XE" + XeStr + "|@";
                                        PM.code = SendIns;
                                        PM.IsPn = false;
                                        //Recvdata = SendNewPID.SendCommand(PM);//MRT:JG61M2 IGNORED
                                        Recvdata = WriteLogDB(PM, TicketLP);
                                        //指令日志
                                        Log(0, string.Format("\r\n【订单号{0}】发送指令>{1}\r\n接收数据:\r\n{2}\r\n", Order.OrderId, SendIns, Recvdata));

                                        //判断是否XE成功
                                        if (pnrFormat.INFMarkIsOK(Recvdata, out Msg))
                                        {
                                            /*  3U8881  E TU30APR  CTUPEK HK1   0730 1005
                                             * JG61M2 -  航空公司使用自动出票时限, 请检查PNR
                                             *** 预订酒店指令HC, 详情  HC:HELP   ***
                                             */
                                            //发送指令
                                            SendIns = "RT" + Pnr;
                                            PM.code = SendIns;
                                            PM.IsPn = true;
                                            //Recvdata = SendNewPID.SendCommand(PM);
                                            Recvdata = WriteLogDB(PM, TicketLP);
                                            //指令日志
                                            Log(0, string.Format("\r\n【订单号{0}】发送指令>{1}\r\n接收数据:\r\n{2}\r\n", Order.OrderId, SendIns, Recvdata));
                                            goto Start;
                                        }
                                    }
                                }
                            }
                        }



                        string patPrice = "pat:a";
                        if (!Order.IsChdFlag)
                        {
                            //成人
                            patPrice = "pat:a";
                        }
                        else
                        {
                            //儿童
                            patPrice = "pat:a*ch";
                        }
                        //发送指令
                        SendIns = "RT" + Pnr + "|" + patPrice;
                        PM.code = SendIns;
                        PM.IsPn = false;
                        //Recvdata = SendNewPID.SendCommand(PM);
                        Recvdata = WriteLogDB(PM, TicketLP);
                        //指令日志
                        Log(0, string.Format("\r\n【订单号{0}】发送指令>{1}\r\n接收数据:\r\n{2}\r\n", Order.OrderId, SendIns, Recvdata));
                        if (Recvdata.IndexOf("PAT") == -1)
                        {
                            //发送指令
                            Log(0, string.Format("订单号{0},编码{1} 出票Office{2},编码已取消,未能PAT出票价,出票失败!", Order.OrderId, Pnr, pOffice));
                            sbLog.Append(string.Format("订单号{0},编码{1} 出票Office{2},编码已取消,未能PAT出票价,出票失败!", Order.OrderId, Pnr, pOffice));
                            return;
                        }

                        //比较
                        string  xuhao = "", Seat = "", Err = "";
                        decimal _xsFare          = 0m;
                        bool    IsExistParice    = false;
                        PnrAnalysis.PatModel PAT = pnrFormat.GetPATInfo(Recvdata.Replace("\r", ""), out Err);
                        foreach (PatInfo pat in PAT.UninuePatList)
                        {
                            decimal.TryParse(pat.Fare, out _xsFare);
                            //存在此价格
                            if (_xsFare == pMode.PMFee)
                            {
                                IsExistParice = true;
                                xuhao         = pat.SerialNum;
                                Seat          = pat.SeatGroup;
                                break;
                            }
                        }
                        if (!IsExistParice)
                        {
                            Log(0, string.Format("订单号{0},编码{1} 出票Office{2},舱位价{3}与Pat价格{4}不一致,出票失败!", Order.OrderId, Pnr, pOffice, pMode.PMFee, _xsFare));
                            sbLog.Append(string.Format("订单号{0},编码{1} 出票Office{2},舱位价{3}与Pat价格{4}不一致,出票失败!", Order.OrderId, Pnr, pOffice, pMode.PMFee, _xsFare));
                            return;
                        }

                        //做价格进去
                        SendIns = "RT" + Pnr + "|" + patPrice + "|SFC:" + xuhao + "|@";
                        PM.code = SendIns;
                        PM.IsPn = false;
                        //Recvdata = SendNewPID.SendCommand(PM);
                        Recvdata = WriteLogDB(PM, TicketLP);
                        //指令日志
                        Log(0, string.Format("\r\n【订单号{0}】发送指令>{1}\r\n接收数据:\r\n{2}\r\n", Order.OrderId, SendIns, Recvdata));
                        if (Recvdata.Contains("超时") || Recvdata.Contains("NO PNR"))
                        {
                            //Recvdata = SendNewPID.SendCommand(PM);
                            Recvdata = WriteLogDB(PM, TicketLP);
                            //指令日志
                            Log(0, string.Format("\r\n【订单号{0}】发送指令>{1}\r\n接收数据:\r\n{2}\r\n", Order.OrderId, SendIns, Recvdata));
                        }

                        //做备注
                        decimal _Discount = 0m;
                        if (decimal.TryParse(Order.Discount, out _Discount) && Order.Space.IndexOf("Y") == -1 && Order.Space.IndexOf("C") == -1 && Order.Space.IndexOf("F") == -1 && _Discount < 100)
                        {
                            //做价格进去
                            SendIns = "RT" + Pnr + "|EI:不得签转|@";
                            PM.code = SendIns;
                            PM.IsPn = false;
                            //Recvdata = SendNewPID.SendCommand(PM);
                            Recvdata = WriteLogDB(PM, TicketLP);
                            //指令日志
                            Log(0, string.Format("\r\n【订单号{0}】发送指令>{1}\r\n接收数据:\r\n{2}\r\n", Order.OrderId, SendIns, Recvdata));
                            if (Recvdata != "" && Recvdata.Contains("超时"))
                            {
                                //Recvdata = SendNewPID.SendCommand(PM);
                                Recvdata = WriteLogDB(PM, TicketLP);
                                //指令日志
                                Log(0, string.Format("\r\n【订单号{0}】发送指令>{1}\r\n接收数据:\r\n{2}\r\n", Order.OrderId, SendIns, Recvdata));
                            }
                        }



                        foreach (string item in XEList)
                        {
                            if (item != "")
                            {
                                Xe += "XE" + item + "|";
                            }
                        }
                        foreach (string item in RRList)
                        {
                            if (item != "")
                            {
                                RR += item + "RR" + "|";
                            }
                        }
                        if (Xe.Trim(new char[] { '|' }) == "")
                        {
                            Xe = "";
                        }
                        else
                        {
                            Xe = "|" + Xe.Trim('|') + "|";
                        }
                        if (RR.Trim(new char[] { '|' }) == "")
                        {
                            RR = "";
                        }
                        else
                        {
                            RR = "|" + RR.Trim('|') + "|";
                        }
                        if (RR == "")
                        {
                            RR = "|";
                        }
                        if (XEList == null || XEList.Count == 0 || Xe == "")
                        {
                            Log(0, string.Format("订单号{0},编码{1} 出票Office{2},编码状态为{3},未能取出出票时限!!", Order.OrderId, Pnr, pOffice, PnrStatus));
                            sbLog.Append(string.Format("订单号{0},编码{1} 出票Office{2},编码状态为{3},未能取出出票时限!!", Order.OrderId, Pnr, pOffice, PnrStatus));
                            return;
                        }

                        //组合打票指令
                        string etdz = "rt" + Pnr + Xe + RR.TrimEnd('|') + "|ETDZ " + PrintCode;
                        etdz = etdz.Replace("||", "|");

                        //出票
                        SendIns = etdz;
                        PM.code = SendIns;
                        PM.IsPn = false;
                        // Recvdata = SendNewPID.SendCommand(PM);
                        Recvdata = WriteLogDB(PM, TicketLP);
                        //指令日志
                        Log(0, string.Format("\r\n【订单号{0}】发送指令>{1}\r\n接收数据:\r\n{2}\r\n", Order.OrderId, SendIns, Recvdata));


                        if (Recvdata.Contains("超时") || Recvdata.Contains("NO PNR"))
                        {
                            //Recvdata = SendNewPID.SendCommand(PM);
                            Recvdata = WriteLogDB(PM, TicketLP);
                            //指令日志
                            Log(0, string.Format("\r\n【订单号{0}】发送指令>{1}\r\n接收数据:\r\n{2}\r\n", Order.OrderId, SendIns, Recvdata));
                        }
                        if (Recvdata.Contains("请输入证件信息"))
                        {
                            Log(0, string.Format("订单号{0},编码{1} 出票Office{2},编码状态为{3},编码中没有证件号,请输入证件信息,否则不能出票!", Order.OrderId, Pnr, pOffice, PnrStatus));
                            sbLog.Append(string.Format("订单号{0},编码{1} 出票Office{2},编码状态为{3},编码中没有证件号,请输入证件信息,否则不能出票!", Order.OrderId, Pnr, pOffice, PnrStatus));
                            return;
                        }
                        if (Recvdata.ToUpper().Contains("STOCK"))
                        {
                            Log(0, string.Format("订单号{0},编码{1} 出票Office{2},编码状态为{3}," + Recvdata + "没有票号了!", Order.OrderId, Pnr, pOffice, PnrStatus));
                            sbLog.Append(string.Format("订单号{0},编码{1} 出票Office{2},编码状态为{3}," + Recvdata + "没有票号了!", Order.OrderId, Pnr, pOffice, PnrStatus));
                            return;
                        }
                        //出票成功
                        if (Recvdata.Contains("CNY") && Recvdata.ToUpper().Contains(Pnr.ToUpper()))
                        {
                            /*CNY2730.00      HF9550
                             * 876-3250823439         876-3250823441  */

                            SendIns = "RT" + Pnr;
                            PM.code = SendIns;
                            PM.IsPn = true;
                            //Recvdata = SendNewPID.SendCommand(PM);
                            Recvdata = WriteLogDB(PM, TicketLP);
                            //指令日志
                            Log(0, string.Format("\r\n【订单号{0}】发送指令>{1}\r\n接收数据:\r\n{2}\r\n", Order.OrderId, SendIns, Recvdata));
                            //存在的票号
                            PTList = GetTicketNum(Pnr, Recvdata.ToUpper(), pnrFormat);
                        }
                        else
                        {
                            //出票失败 重试
                            if (!Recvdata.ToUpper().Contains("**ELECTRONIC TICKET PNR**") &&
                                Recvdata.ToUpper().Contains("SSR TKNE") &&
                                Recvdata.ToUpper().Contains("/DPN") &&
                                Recvdata.ToUpper().Contains("RMK " + CarrayCode + "/"))
                            {
                                //"ETRY:"   重试指令
                                SendIns = "RT" + Pnr + "|ETRY:";
                                PM.code = SendIns;
                                PM.IsPn = false;
                                //Recvdata = SendNewPID.SendCommand(PM);
                                Recvdata = WriteLogDB(PM, TicketLP);
                                //指令日志
                                Log(0, string.Format("\r\n【订单号{0}】发送指令>{1}\r\n接收数据:\r\n{2}\r\n", Order.OrderId, SendIns, Recvdata));
                            }
                            else
                            {
                                Log(0, string.Format("订单号{0},编码{1} 出票Office{2},编码状态为{3}," + "出票失败,{4}", Order.OrderId, Pnr, pOffice, PnrStatus, Recvdata));
                                sbLog.Append(string.Format("订单号{0},编码{1} 出票Office{2},编码状态为{3}," + "出票失败,{4}", Order.OrderId, Pnr, pOffice, PnrStatus, Recvdata));
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    Log(0, string.Format("订单号{0},出票异常:{1}", Order.OrderId, ex.Message + ex.Source + ex.StackTrace.ToString()));
                    sbLog.Append(string.Format("订单号{0},出票异常:{1}", Order.OrderId, ex.Message + ex.Source + ex.StackTrace.ToString()));
                }
                finally
                {
                    string          TicketMsg = "";
                    Log_Tb_AirOrder OrderLog  = new Log_Tb_AirOrder();
                    //执行SQl语句
                    List <string> sqlList = new List <string>();
                    //修改订单数据列表
                    List <string> OrderList = new List <string>();
                    if (TicketLP != null)
                    {
                        //解锁
                        OrderList.Add(" LockCpyNo='' ");
                        OrderList.Add(" LockLoginName='' ");
                        OrderList.Add(" LockTime='1900-01-01' ");

                        OrderList.Add(" CPTime=getdate() ");
                        OrderList.Add(" CPName='管理员' ");
                        OrderList.Add(string.Format(" CPCpyNo='{0}' ", TicketLP.CpyNo));
                        OrderList.Add(" CPRemark='BSP自动出票' ");
                        OrderList.Add(string.Format(" CPCpyName='{0}' ", TicketLP.UninAllName));

                        //日志
                        OrderLog.id            = Guid.NewGuid();
                        OrderLog.OrderId       = Order.OrderId;
                        OrderLog.OperType      = "出票";
                        OrderLog.OperTime      = DateTime.Now;
                        OrderLog.OperLoginName = "管理员";
                        OrderLog.OperUserName  = "******";
                        OrderLog.CpyNo         = TicketLP.CpyNo;
                        OrderLog.CpyType       = 1;
                        OrderLog.CpyName       = TicketLP.UninAllName;
                    }

                    if (PTList != null && PTList.Count > 0 && PasList != null && PasList.Count > 0)
                    {
                        string PasName = "", TicketNumber = "";
                        for (int i = 0; i < PTList.Count; i++)
                        {
                            if (PTList[i].Split('|').Length == 2)
                            {
                                TicketNumber = PTList[i].Split('|')[0];
                                PasName      = PTList[i].Split('|')[1];
                                Tb_Ticket_Passenger Passenger = PasList.Find(delegate(Tb_Ticket_Passenger _tempPassenger)
                                {
                                    return(PTList[i].ToUpper().Trim().Contains(_tempPassenger.PassengerName.ToUpper().Trim()));
                                });
                                if (Passenger != null)
                                {
                                    sqlList.Add(string.Format(" update Tb_Ticket_Passenger set TicketNumber='{0}',TicketStatus=2 where id='{1}' and PassengerName='{2}' ", TicketNumber, Passenger.id.ToString(), Passenger.PassengerName));
                                }
                            }
                        }
                        //修改订单数据
                        OrderList.Add(" TicketStatus=2 ");
                        OrderList.Add(" OrderStatusCode=4 ");
                        if (OrderList.Count > 0)
                        {
                            sqlList.Add(string.Format(" update Tb_Ticket_Order set {0} where id='{1}' ", string.Join(",", OrderList.ToArray()), Order.id.ToString()));
                        }

                        //出票成功
                        TicketMsg          = "出票成功";
                        OrderLog.WatchType = 5;
                        //日志
                        OrderLog.OperContent = "订单号:" + Order.OrderId + " BSP自动出票成功," + string.Format(",", PasList.ToArray());
                        //修改数据库状态
                    }
                    else
                    {
                        //出票失败
                        TicketMsg = "出票失败";
                        //修改订单自动出票尝试次数
                        if (Order.AutoPrintTimes > 3)//尝试次数大于3改为手动出票
                        {
                            sqlList.Add(string.Format(" update Tb_Ticket_Order set AutoPrintFlag=0,AutoPrintTimes=CAST(AutoPrintTimes as int)+1  where id='{0}' ", Order.id.ToString()));
                        }
                        else
                        {
                            sqlList.Add(string.Format(" update Tb_Ticket_Order set AutoPrintTimes=CAST(AutoPrintTimes as int)+1  where id='{0}' ", Order.id.ToString()));
                        }
                        OrderLog.WatchType = 2;
                        //日志
                        OrderLog.OperContent = "BSP自动出票失败," + sbLog.ToString();
                    }
                    //日志
                    string tempSql = Dal.Mapping.MappingHelper <Log_Tb_AirOrder> .CreateInsertModelSql(OrderLog);

                    sqlList.Add(tempSql);

                    string Msg = "";
                    //修改数据库
                    if (!Manage.ExecuteSqlTran(sqlList, out Msg))
                    {
                        Log(0, string.Format("订单号{0},修改数据库失败:{1}", Order.OrderId, Msg));
                    }
                    Log(0, System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "订单号:" + Order.OrderId + "  " + TicketMsg + "=======================end=====================\r\n");
                }
            }
        }
Beispiel #4
0
    /// <summary>
    /// 原先设计用的是Session现在改为Application,但是方法名称未改变,避免过多改动引发系统不稳定.YYY 2013-6-17
    /// </summary>
    public void LoadSession()
    {
        try
        {
            SessionContent sessionContent = new SessionContent();
            string         currentuserid  = System.Web.HttpContext.Current.Request["currentuserid"] ?? string.Empty;

            if (!string.IsNullOrEmpty(currentuserid))
            {
                //if (Session[currentuserid] == null)
                if (Application[currentuserid] == null)
                //if (HttpContext.Current.Application[currentuserid] == null)
                {
                    FormsAuthentication.RedirectToLoginPage();
                }
                else
                {
                    //sessionContent = Session[currentuserid] as SessionContent;
                    //sessionContent = HttpContext.Current.Application[currentuserid] as SessionContent;
                    sessionContent = Application[currentuserid] as SessionContent;
                    mUser          = sessionContent.USER;
                    mCompany       = sessionContent.COMPANY;

                    //mSupCompany = sessionContent.SUPCOMPANY;

                    //如果保存的落地运营商的<公司信息>全局变量为空,则重新读取一次数据库
                    if (Application[sessionContent.parentCpyno + "Company"] == null)
                    {
                        string strwhere = "1=1 and unincode='" + sessionContent.parentCpyno + "'";
                        List <User_Company> listUser_Company = baseDataManage.CallMethod("User_Company", "GetList", null, new Object[] { strwhere }) as List <User_Company>;
                        if (listUser_Company != null && listUser_Company.Count > 0)
                        {
                            Application[sessionContent.parentCpyno + "Company"] = listUser_Company[0];
                        }
                    }
                    mSupCompany        = Application[sessionContent.parentCpyno + "Company"] as User_Company;
                    baseParametersList = sessionContent.BASEPARAMETERS;
                    //如果保存落地运营商的全局变量为空,则重新读取一次数据库
                    if (Application[sessionContent.parentCpyno + "Parameters"] == null)
                    {
                        string strwhere = "1=1 and cpyno='" + sessionContent.parentCpyno + "'";
                        List <Bd_Base_Parameters> listParameters = baseDataManage.CallMethod("Bd_Base_Parameters", "GetList", null, new Object[] { strwhere }) as List <Bd_Base_Parameters>;
                        if (listParameters != null)
                        {
                            Application[sessionContent.parentCpyno + "Parameters"] = listParameters;
                        }
                    }
                    supBaseParametersList = Application[sessionContent.parentCpyno + "Parameters"] as List <Bd_Base_Parameters>;//落地运营商和供应商公司参数信息
                    //supBaseParametersList = sessionContent.SupBASEPARAMETERS;//落地运营商和供应商公司参数信息
                    configparam = Bd_Base_ParametersBLL.GetConfigParam(supBaseParametersList);

                    //configparam = sessionContent.CONFIGPARAM;


                    //当前登录用户权限
                    m_UserPermissions = sessionContent.M_USERPERMISSIONS;
                    // Limits();
                }
            }
            else
            {
                FormsAuthentication.RedirectToLoginPage();
            }

            /*
             * if (Session[sessionContent.USERLOGIN] == null)
             * {
             *  FormsAuthentication.RedirectToLoginPage();
             * }
             * else
             * {
             *  sessionContent = Session[sessionContent.USERLOGIN] as SessionContent;
             *  mUser = sessionContent.USER;
             *  mCompany = sessionContent.COMPANY;
             *  mSupCompany = sessionContent.SUPCOMPANY;
             *  baseParametersList = sessionContent.BASEPARAMETERS;
             *  supBaseParametersList = sessionContent.SupBASEPARAMETERS;//落地运营商和供应商公司参数信息
             *  configparam = sessionContent.CONFIGPARAM;
             *  //当前登录用户权限
             *  m_UserPermissions = sessionContent.M_USERPERMISSIONS;
             *  //权限验证
             *  Limits();
             * }*/
            //}
        }
        catch
        {
            //  跳转登陆页
        }
    }
Beispiel #5
0
    /// <summary>
    /// 获取打印数据
    /// </summary>
    /// <returns></returns>
    public PnrAnalysis.Model.TripPrintData GetPrintData()
    {
        PnrAnalysis.Model.TripPrintData model = null;
        if (Request["OrderId"] != null && Request["OrderId"].ToString() != "" && Request["PasId"] != null && Request["PasId"].ToString() != "")
        {
            model = new PnrAnalysis.Model.TripPrintData();
            model.m_strOrderId     = Request["OrderId"].ToString();
            model.m_strPassengerId = Request["PasId"].ToString();

            OrderInputParam InputParam = new OrderInputParam();
            string          ErrMsg     = "";
            //成人订单数据显示
            InputParam = OrderBLL.GetOrder(model.m_strOrderId, InputParam, out ErrMsg);
            if (InputParam != null && InputParam.OrderParamModel.Count > 0)
            {
                OrderMustParamModel OMP       = InputParam.OrderParamModel[0];
                Tb_Ticket_Passenger Passenger = OMP.PasList.Find(delegate(Tb_Ticket_Passenger _TP)
                {
                    return(_TP.id.ToString().ToUpper() == model.m_strPassengerId.ToUpper());
                });
                Tb_TripDistribution         tb_tripdistribution = null;
                Tb_Ticket_Order             Order   = OMP.Order;
                List <Tb_Ticket_SkyWay>     skyList = OMP.SkyList;
                PbProject.Model.ConfigParam config  = this.configparam;
                if (Passenger != null && Order != null)
                {
                    if (Passenger.TravelNumber.Trim() != "")
                    {
                        string sqlWhere = string.Format(" TripNum='{0}' and UseCpyNo='{1}' ", Passenger.TravelNumber.Trim(), Order.OwnerCpyNo);
                        List <Tb_TripDistribution> TTPList = this.baseDataManage.CallMethod("Tb_TripDistribution", "GetList", null, new object[] { sqlWhere }) as List <Tb_TripDistribution>;
                        if (TTPList != null && TTPList.Count > 0)
                        {
                            tb_tripdistribution = TTPList[0];
                        }
                    }
                    //管理员
                    if (mCompany.RoleType == 1)
                    {
                        string GYCpyNo = Order.OwnerCpyNo;
                        if (Order.OwnerCpyNo.Length >= 12)
                        {
                            GYCpyNo = GYCpyNo.Substring(0, 12);
                        }
                        List <Bd_Base_Parameters> baseParamList = baseDataManage.CallMethod("Bd_Base_Parameters", "GetList", null, new Object[] { "CpyNo='" + GYCpyNo + "'" }) as List <Bd_Base_Parameters>;
                        config = Bd_Base_ParametersBLL.GetConfigParam(baseParamList);
                    }

                    #region 获取 配置号
                    if (tb_tripdistribution != null)
                    {
                        //航协号
                        model.m_strIataCode = tb_tripdistribution.IataCode;
                        //中文填开单位
                        model.m_strCNTKTConjunction = tb_tripdistribution.OwnerCpyName;
                        //office
                        model.m_strAgentOffice = tb_tripdistribution.CreateOffice;
                        //行程单号
                        model.m_strTravelNumber = tb_tripdistribution.TripNum;
                    }
                    else
                    {
                        //行程单号为空时
                        if (config != null)
                        {
                            string   PrintOffice      = GetPrintOffice(Order.OwnerCpyNo, Order.CarryCode.Split('/')[0]);
                            string[] Arroffice        = config.Office.Split('^');        //office
                            string[] ArrIataCode      = config.IataCode.Split('^');      //航协号
                            string[] ArrTicketCompany = config.TicketCompany.Split('^'); //公司名称
                            for (int i = 0; i < Arroffice.Length; i++)
                            {
                                if (Arroffice.Length == ArrIataCode.Length && Arroffice.Length == ArrTicketCompany.Length)
                                {
                                    if (PrintOffice == "")
                                    {
                                        //Office
                                        model.m_strAgentOffice = Arroffice[i];
                                        //中文填开单位
                                        model.m_strCNTKTConjunction = ArrTicketCompany[i];
                                        //航协号
                                        model.m_strIataCode = ArrIataCode[i];//航协号
                                        break;
                                    }
                                    else
                                    {
                                        if (PrintOffice.ToUpper() == Arroffice[i].ToUpper())
                                        {
                                            //Office
                                            model.m_strAgentOffice = Arroffice[i];             //Office
                                            //中文填开单位
                                            model.m_strCNTKTConjunction = ArrTicketCompany[i]; //填开单位
                                            //航协号
                                            model.m_strIataCode = ArrIataCode[i];              //航协号
                                            break;
                                        }
                                    }
                                }
                            }
                        }
                    }
                    #endregion

                    //乘客姓名
                    model.m_strPassengerName = Passenger.PassengerName;
                    //乘客证件号
                    model.m_strPassengerCardId = Passenger.Cid;
                    //签注
                    model.m_strEndorsements = ddlEndorsements.SelectedValue;
                    //小编码
                    model.m_strPnrB = Order.PNR.ToUpper();
                    //行程单号
                    model.m_strTravelNumber = Passenger.TravelNumber.Trim();
                    //舱位价
                    model.m_strSpaceFare = Passenger.PMFee.ToString("F2");
                    //基建费
                    model.m_strABFare = Passenger.ABFee.ToString("F2");
                    //燃油费
                    model.m_strFuelFare = Passenger.FuelFee.ToString("F2");
                    //总价
                    model.m_strTotalFare = (Passenger.PMFee + Passenger.ABFee + Passenger.FuelFee).ToString("F2");
                    //保险费
                    model.m_strInsuranceFare = "XXX";
                    //其他费用
                    model.m_strOtherFare = "0.00";
                    //票号
                    model.m_strTicketNumber = Passenger.TicketNumber;
                    //验证码
                    model.m_strCheckNum = Passenger.TravelNumber.Length > 4 ? (Passenger.TravelNumber.Substring(Passenger.TravelNumber.Length - 4, 4)) : txtCheckNum.Value;
                    //填开日期
                    model.m_strIssuedDate = System.DateTime.Now.ToString("yyyy-MM-dd");
                    //航段
                    if (skyList != null && skyList.Count > 0)
                    {
                        //第一段
                        model.m_strFCityName1    = skyList[0].FromCityName;    //出发城市
                        model.m_strTCityName1    = skyList[0].ToCityName;      //到达城市
                        model.m_strAirName1      = skyList[0].CarryName;       //航空公司名称
                        model.m_strAirCode1      = skyList[0].CarryCode;       //航空公司二字码
                        model.m_strFlightNum1    = skyList[0].FlightCode;      //航班号
                        model.m_strSpace1        = skyList[0].Space.ToUpper(); //舱位
                        model.m_strTicketBasis1  = skyList[0].Space.ToUpper(); //舱位等级
                        model.m_strFlyDate1      = skyList[0].FromDate.ToString("yyyy-MM-dd");
                        model.m_strFlyStartTime1 = skyList[0].FromDate.ToString("HH:mm");
                        model.m_strFlyEndTime1   = skyList[0].ToDate.ToString("HH:mm"); //到达时间
                        model.m_strTerminal1     = skyList[0].Terminal;                 //航站楼

                        //行李
                        model.m_strAllowPacket1 = "20K";
                        if (model.m_strSpace1 == "C")
                        {
                            model.m_strAllowPacket1 = "30K";
                        }
                        else if (model.m_strSpace1 == "F")
                        {
                            model.m_strAllowPacket1 = "40K";
                        }
                        //-------------------------------------------
                        //第二段
                        if (skyList.Count > 1)
                        {
                            model.m_strFCityName2    = skyList[1].FromCityName;    //出发城市
                            model.m_strTCityName2    = skyList[1].ToCityName;      //到达城市
                            model.m_strAirName2      = skyList[1].CarryName;       //航空公司名称
                            model.m_strAirCode2      = skyList[1].CarryCode;       //航空公司二字码
                            model.m_strFlightNum2    = skyList[1].FlightCode;      //航班号
                            model.m_strSpace2        = skyList[1].Space.ToUpper(); //舱位
                            model.m_strTicketBasis2  = skyList[1].Space.ToUpper(); //舱位等级
                            model.m_strFlyDate2      = skyList[1].FromDate.ToString("yyyy-MM-dd");
                            model.m_strFlyStartTime2 = skyList[1].FromDate.ToString("HH:mm");
                            model.m_strFlyEndTime2   = skyList[1].ToDate.ToString("HH:mm"); //到达时间
                            model.m_strTerminal2     = skyList[1].Terminal;                 //航站楼
                            //行李
                            model.m_strAllowPacket2 = "20K";
                            if (model.m_strSpace2 == "C")
                            {
                                model.m_strAllowPacket2 = "30K";
                            }
                            else if (model.m_strSpace2 == "F")
                            {
                                model.m_strAllowPacket2 = "40K";
                            }
                            if (model.m_strFCityName2 == model.m_strTCityName1)
                            {
                                if (model.m_strFCityName1 != model.m_strTCityName2)
                                {
                                    model.m_strTravelType = "3";//联程
                                }
                                else
                                {
                                    model.m_strTravelType = "2";//往返
                                }
                            }
                            else
                            {
                                if (skyList.Count == 2)
                                {
                                    model.m_strTravelType = "4";//缺口程
                                }
                                else
                                {
                                    model.m_strTravelType = "5";//多程
                                }
                            }
                        }
                    }
                }
            }
        }
        return(model);
    }
    /// <summary>
    /// 1PNR内容导入 0PNR导入 2pnr入库记账
    /// </summary>
    /// <param name="type"></param>
    public void Import(int type)
    {
        bool IsResponse = false;

        try
        {
            string strKongZhiXiTong = "", strGongYingKongZhiFenXiao = "";
            PbProject.Model.ConfigParam    configParam = null;
            PbProject.Model.User_Company   msupCompany = null;
            PbProject.Model.User_Company   mcompany = null;
            PbProject.Model.User_Employees muser = null;
            string strGY = Hid_GY.Value;
            string strKH = Hid_KH.Value;
            if (mCompany.RoleType == 1)
            {
                //平台
                if (!string.IsNullOrEmpty(strGY))
                {
                    //UninCode-LoginName-UninAllName-uid-cid
                    string[] strArr = strGY.Split('@');
                    msupCompany = this.baseDataManage.CallMethod("User_Company", "GetById", null, new object[] { strArr[4] }) as User_Company;
                    if (msupCompany != null)
                    {
                        List <Bd_Base_Parameters> GYParameters = baseDataManage.CallMethod("Bd_Base_Parameters", "GetList", null, new Object[] { "CpyNo='" + msupCompany.UninCode + "'" }) as List <Bd_Base_Parameters>;
                        if (GYParameters != null)
                        {
                            strKongZhiXiTong          = BaseParams.getParams(GYParameters).KongZhiXiTong;
                            strGongYingKongZhiFenXiao = BaseParams.getParams(GYParameters).GongYingKongZhiFenXiao;
                            configParam = Bd_Base_ParametersBLL.GetConfigParam(GYParameters);
                        }
                    }
                }
            }
            else
            {
                //供应
                strKongZhiXiTong          = BaseParams.getParams(supBaseParametersList).KongZhiXiTong;
                strGongYingKongZhiFenXiao = BaseParams.getParams(baseParametersList).GongYingKongZhiFenXiao;
                configParam = this.configparam;
                msupCompany = this.mSupCompany;
            }
            //选择客户
            if (!string.IsNullOrEmpty(strKH))
            {
                //UninCode-LoginName-UninAllName-uid-cid
                string[] strArr = strKH.Split('@');
                if (strArr.Length == 5)
                {
                    muser = this.baseDataManage.CallMethod("User_Employees", "GetById", null, new object[] { strArr[3] }) as User_Employees;
                    List <User_Company> uCompanyList = baseDataManage.CallMethod("User_Company", "GetList", null, new Object[] { "UninCode='" + muser.CpyNo + "'" }) as List <User_Company>;

                    if (uCompanyList != null && uCompanyList.Count > 0)
                    {
                        mcompany = uCompanyList[0];
                    }
                }
            }
            PnrImportParam Param = new PnrImportParam();
            Param.m_UserInfo     = muser;
            Param.m_CurCompany   = mcompany;
            Param.m_SupCompany   = msupCompany;
            Param.m_LoginUser    = mUser;
            Param.m_LoginCompany = mCompany;
            PnrImportManage Mange = new PnrImportManage(muser, mcompany, msupCompany, strKongZhiXiTong, strGongYingKongZhiFenXiao, configParam);
            //是否生成订单 否
            Param.IsCreateOrder = false;
            Param.Source        = 1;//后台
            Param.RoleType      = mCompany.RoleType.ToString();
            Param.OrderId       = Hid_OrderId.Value;
            if (type == 0 || type == 2)
            {
                //是否PNR入库记账
                Param.IsImportJZ = type == 2 ? 1 : 0;
                //Pnr导入 或者PNR入库记账
                Param.Pnr = (type == 2) ? txtH_PNR3.Value.Trim() : txtH_PNR.Value.Trim();
                if (Hid_IsBigCode.Value == "1")
                {
                    Param.ImportTongDao = 3;
                    Param.BigPnr        = txtH_PNR.Value.Trim();
                }
            }
            else if (type == 1)
            {
                //Pnr内容导入
                Param.ImportTongDao = 4;
                //关闭PNR导入合并
                if (KongZhiXiTong != null && KongZhiXiTong.Contains("|59|"))
                {
                    Param.IsMerge = 0;//未合并
                    Param.RTData  = pnrCon.Value.Trim().Replace("'", "");
                    Param.PATData = patCon.Value.Trim().Replace("'", "");
                }
                else
                {
                    Param.IsMerge      = 1;//合并
                    Param.RTAndPatData = txtPNRAndPata.Text.Trim().Replace("'", "");
                }
            }
            bool IsSuc = Mange.GetImportPnrInfo(Param);
            if (!IsSuc)
            {
                #region 出错提示

                Hid_OrderId.Value      = "";
                Param.SecondPM.ErrCode = "0";
                if (Param.IsNextOK == 1)
                {
                    //继续操作
                    Param.SecondPM.OpType = "1";
                }
                else
                {
                    Param.SecondPM.Msg = Param.TipMsg;
                    //提示
                    Param.SecondPM.OpType = "0";
                }
                string result = JsonHelper.ObjToJson <PnrImportParam>(Param);
                ScriptManager.RegisterStartupScript(this, GetType(), Guid.NewGuid().ToString(), "showMsg('" + escape(Param.SecondPM.Msg) + "',{t:2,type:" + type + ",code:\"" + escape(result) + "\"});ShowDiv(false);", true);

                #endregion
            }
            else
            {
                //页面间传递数据对象
                ////成功显示数据
                //ViewState["Param"] = Param;
                //将数据传入到指定页面处理
                this.PageObj = Param;
                //方案一
                //Server.Transfer("HandPnrImport.aspx", true);
                //Response.Redirect("HandPnrImport.aspx", false);
                //方案二
                System.IO.StringWriter sw = new System.IO.StringWriter();
                Server.Execute("HandPnrImport.aspx?currentuserid=" + this.currentuserid.Value, sw);
                IsResponse = true;
                Response.Clear();
                Response.Write(sw.ToString());
                Response.End();
            }
        }
        catch (Exception ex)
        {
            if (!IsResponse)
            {
                ScriptManager.RegisterStartupScript(this, GetType(), Guid.NewGuid().ToString(), "showMsg('页面异常!');ShowDiv(false);", true);
            }
        }
    }
Beispiel #7
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);//分钟
            }
        }