Example #1
0
        /// <summary>
        /// JetermClient调用示例
        /// </summary>
        private static void dome()
        {
            //EtermClient对象
            EtermClient client = new EtermClient();
            //订单请求对象
            Command <JetermEntity.Request.Booking> cmd = new Command <JetermEntity.Request.Booking>();

            //应用程序标识
            cmd.AppId = 124345345;
            //应用缓存
            cmd.CacheTime = EtermCommand.CacheTime.min5;
            //要请求的订单对象及属性赋值
            cmd.request                 = new JetermEntity.Request.Booking();
            cmd.request.FlightList      = new List <Flight>();
            cmd.request.OfficeNo        = "SHA327";
            cmd.request.PassengerList   = new List <Passenger>();
            cmd.request.RMKOfficeNoList = new List <string>();
            cmd.TimeOut                 = new TimeSpan(0, 0, 0, 50);
            //开始调用Invoke处理业务
            CommandResult <JetermEntity.Response.Booking> result =                                               //对应的请求结果
                                                                   client.Invoke <JetermEntity.Request.Booking,  //泛型请求类定义
                                                                                  JetermEntity.Response.Booking> //泛型应答类定义
                                                                       (cmd);                                    //请求参数
            //---------------------------------------------
            //业务处理
        }
        // 返回结果:{"state":true,"error":null,"config":"TFP007","OfficeNo":"tt","result":{"PassengerList":[{"name":"赵南","idtype":-1,"cardno":"","PassType":-1,"Ename":"","BabyBirthday":"\/Date(-62135596800000+0800)\/","ChildBirthday":"\/Date(-62135596800000+0800)\/","TicketNo":"7842180572716"}],"FlightList":[{"FlightNo":"CZ3476","Airline":"CZ","Cabin":"T","SubCabin":"","SCity":"KWE","ECity":"CGO","DepTerminal":"T2","ArrTerminal":"","DepDate":"\/Date(1435638000000+0800)\/","ArrDate":"\/Date(-62135596800000+0800)\/","PNRState":null}],"Price":{"FacePrice":330.00,"Tax":50.00,"Fuel":0.0,"TotalPrice":380.00},"TicketStatus":1},"reqtime":"\/Date(1433226034274+0800)\/","SaveTime":1800}
        public static void HttpPostDemo_TicketByBigPnr()
        {
            // 设置URL:
            // url如:http://120.132.136.91:18082/format=json&language=CSharp&method=TicketByBigPnr
            string url = string.Format("{0}&language=CSharp&method={1}", ConfigurationManager.AppSettings["EtermHttpPostURL"], "TicketByBigPnr");                
            
            // 设置请求参数:
            JetermEntity.Request.TicketByBigPnr request = new JetermEntity.Request.TicketByBigPnr();     
            request.BigPnr = "PWF62P";
            request.FlightNo = "CZ3476";
            request.SCity = "KWE";
            request.ECity = "CGO";
            string strParams = JsonConvert.SerializeObject(request);

            EtermClient client = new EtermClient();        
            string str = string.Empty;
            try
            {
                str = client.Invoke(-1, url, strParams, EtermCommand.ServerSource.EtermServer, TimeSpan.FromSeconds(5));
            }
            catch (Exception ex)
            {
                throw new Exception(string.Format("JEtermClient抛出异常,异常信息为:{0}", ex.Message));
            }

            Console.WriteLine("解析结果:" + Environment.NewLine + str);

            CommandResult<TicketByBigPnr> result = JsonConvert.DeserializeObject<CommandResult<TicketByBigPnr>>(str);

            Console.ReadLine();
        }
Example #3
0
        // 传属于非平台的Office号时,如何调大系统的Demo:
        public static void BigSystemDemo_SeekPNR2()
        {
            // SeekPNR请求对象
            Command <JetermEntity.Request.SeekPNR> cmd = new Command <JetermEntity.Request.SeekPNR>();

            // 设置应用程序编号
            cmd.AppId = 100203;

            // 根据各自的业务需求,设置缓存返回结果时长
            cmd.CacheTime = EtermCommand.CacheTime.none;

            // 设置SeekPNR请求参数
            cmd.request = new JetermEntity.Request.SeekPNR();
            // 返回结果:
            // 此记录第1段航班信息的编号为“HX”状态不是有效记录编号,请检查您的PNR记录编号
            cmd.officeNo        = "CAN378";
            cmd.request.Pnr     = "HFQB18";
            cmd.request.Airline = "CZ";

            // 返回结果:指令返回为空
            //cmd.officeNo = "CAN378";
            //cmd.request.Pnr = "HFQB18";

            // 定义EtermClient对象
            EtermClient client = new EtermClient();
            // 调用大系统以处理业务
            CommandResult <JetermEntity.Response.SeekPNR> result = client.Invoke <JetermEntity.Request.SeekPNR, JetermEntity.Response.SeekPNR>(cmd);

            if (result == null)
            {
                result       = new CommandResult <JetermEntity.Response.SeekPNR>();
                result.error = new Error(EtermCommand.ERROR.SYSTEM_FAULT);
            }
            if (!result.state)
            {
                string cmdResultBag = result.error.CmdResultBag;
                Console.WriteLine(string.Format("返回有错误,错误信息为:{0}{1}。{2}", Environment.NewLine, result.error.InnerDetailedErrorMessage, string.IsNullOrWhiteSpace(cmdResultBag) ? string.Empty : string.Format("{0}RTPAT指令返回结果为:{1}{2}", Environment.NewLine, Environment.NewLine, cmdResultBag)));
                Console.ReadLine();
                return;
            }

            if (result.result == null)
            {
                Console.WriteLine("没有返回结果");
                Console.ReadLine();
                return;
            }
            string parseResult = Newtonsoft.Json.JsonConvert.SerializeObject(result.result);

            Console.WriteLine("解析结果:" + Environment.NewLine + parseResult);

            Console.ReadLine();
        }
Example #4
0
        // 返回结果:{"PassengerList":[{"name":"孙伟哲","idtype":0,"cardno":"NI150105198605034390","PassType":0,"Ename":"","BabyBirthday":"\/Date(-62135596800000+0800)\/","ChildBirthday":"\/Date(-62135596800000+0800)\/","TicketNo":""}],"PNR":"HSB9K6","FlightList":[{"FlightNo":"CZ3723","Airline":"","Cabin":"Y","SCity":"CAN","ECity":"XMN","DepTerminal":null,"ArrTerminal":null,"DepDate":"\/Date(1436828400000+0800)\/","ArrDate":"\/Date(1436832600000+0800)\/"}],"ShareFlight":false,"FlightType":0,"RMKOfficeNoList":["SHA111"],"BigPNR":"MGMP4Z","Mobile":"18101810679","OfficeNo":"SHA243","AdultPnr":null,"PriceList":[{"FacePrice":950.00,"Tax":50.00,"Fuel":0.0,"TotalPrice":1000.00}],"ResultBag":" 1.孙伟哲 HSB9K6                                                                  \r 2.  CZ3723 Y   TU14JUL  CANXMN HK1   0700 0810          E                     \r 3.SHA/T SHA/T021-36412780/SHANGHAI FENGRUI INDUSTRY CO.LTD/ZHAO YAN ZHONG     \r     ABCDEFG                                                                   \r 4.TL/1224/04MAY/KHN117                                                        \r 5.SSR FOID CZ HK1 NI150105198605034390/P1                                     \r 6.SSR ADTK 1E BY SHA14MAY15/1124 OR CXL CZ BOOKING                            \r 7.OSI CZ CTCT18101810679                                                      \r 8.RMK TJ AUTH SHA111                                                          \r 9.RMK CA/MGMP4Z                                                               \r10.SHA243                                                                      \r\r\n\r\n>PAT:A                                                                         \r01 Y FARE:CNY950.00 TAX:CNY50.00 YQ:TEXEMPTYQ  TOTAL:1000.00                   \r?SFC:01   ?SFN:01                                                              \r"}
        public static void EtermServerDemo_SeekPNR()
        {
            // 定义请求对象
            Command <JetermEntity.Request.SeekPNR> cmd = new Command <JetermEntity.Request.SeekPNR>();

            // 设置应用程序编号
            cmd.AppId = 100001;

            // 设置Office号
            // 可以设置,也可以不设置。根据业务需要来决定是否设置。
            cmd.officeNo = "SHA243";

            // 根据各自的业务需求,设置缓存返回结果时长
            cmd.CacheTime = EtermCommand.CacheTime.min30;

            // 设置请求参数
            cmd.request               = new JetermEntity.Request.SeekPNR();
            cmd.request.Pnr           = "HSB9K6";
            cmd.request.PassengerType = EtermCommand.PassengerType.Adult;
            cmd.request.GetPrice      = true;

            // 定义EtermClient对象
            EtermClient client = new EtermClient();

            // 调用Invoke以处理业务
            CommandResult <JetermEntity.Response.SeekPNR> result = client.Invoke <JetermEntity.Request.SeekPNR, JetermEntity.Response.SeekPNR>(cmd);

            if (result == null)
            {
                result       = new CommandResult <JetermEntity.Response.SeekPNR>();
                result.error = new Error(EtermCommand.ERROR.SYSTEM_FAULT);
            }
            if (!result.state)
            {
                string cmdResultBag = result.error.CmdResultBag;
                Console.WriteLine(string.Format("返回有错误,错误信息为:{0}{1}。{2}", Environment.NewLine, result.error.InnerDetailedErrorMessage, string.IsNullOrWhiteSpace(cmdResultBag) ? string.Empty : string.Format("{0}RT指令返回结果为:{1}{2}", Environment.NewLine, Environment.NewLine, cmdResultBag)));
                Console.ReadLine();
                return;
            }

            if (result.result == null)
            {
                Console.WriteLine("没有返回结果");
                Console.ReadLine();
                return;
            }
            string parseResult = Newtonsoft.Json.JsonConvert.SerializeObject(result.result);

            Console.WriteLine("解析结果:" + Environment.NewLine + parseResult);

            Console.ReadLine();
        }
Example #5
0
        // 返回结果:{"PassengerList":[{"name":"邹丽媛","idtype":-1,"cardno":"","PassType":-1,"Ename":"","BabyBirthday":"\/Date(-62135596800000+0800)\/","ChildBirthday":"\/Date(-62135596800000+0800)\/","TicketNo":"7812192001934"}],"FlightList":[{"FlightNo":"MU5522","Airline":"MU","Cabin":"R","SCity":"MDG","ECity":"TAO","DepTerminal":null,"ArrTerminal":null,"DepDate":"\/Date(1444377600000+0800)\/","ArrDate":"\/Date(-62135596800000+0800)\/","PNRState":null}],"Price":{"FacePrice":1220.00,"Tax":100.00,"Fuel":0.0,"TotalPrice":1320.00},"TicketStatus":1}
        public static void EtermServerDemo_TicketByBigPnr()
        {
            // 定义请求对象
            Command <JetermEntity.Request.TicketByBigPnr> cmd = new Command <JetermEntity.Request.TicketByBigPnr>();

            // 设置应用程序编号
            cmd.AppId = 100001;

            // 根据各自的业务需求,设置缓存返回结果时长
            cmd.CacheTime = EtermCommand.CacheTime.min30;

            cmd.request = new JetermEntity.Request.TicketByBigPnr();

            // 设置请求参数
            cmd.request.BigPnr   = "PG5ZRE";
            cmd.request.FlightNo = "MU5522";
            cmd.request.SCity    = "MDG";
            cmd.request.ECity    = "TAO";

            // 定义EtermClient对象
            EtermClient client = new EtermClient();

            // 调用Invoke以处理业务
            CommandResult <JetermEntity.Response.TicketByBigPnr> result = client.Invoke <JetermEntity.Request.TicketByBigPnr, JetermEntity.Response.TicketByBigPnr>(cmd);

            if (result == null)
            {
                result       = new CommandResult <JetermEntity.Response.TicketByBigPnr>();
                result.error = new Error(EtermCommand.ERROR.SYSTEM_FAULT);
            }
            if (!result.state)
            {
                string cmdResult2 = result.error.CmdResultBag;
                Console.WriteLine(string.Format("返回有错误,错误信息为:{0}{1}。{2}", Environment.NewLine, result.error.InnerDetailedErrorMessage, string.IsNullOrWhiteSpace(cmdResult2) ? string.Empty : string.Format("{0}TicketByBigPnr指令返回结果为:{1}{2}", Environment.NewLine, Environment.NewLine, cmdResult2)));
                Console.ReadLine();
                return;
            }

            if (result.result == null)
            {
                Console.WriteLine("没有返回结果");
                Console.ReadLine();
                return;
            }
            string parseResult = Newtonsoft.Json.JsonConvert.SerializeObject(result.result);

            Console.WriteLine("解析结果:" + Environment.NewLine + parseResult);

            Console.ReadLine();
        }
Example #6
0
        public static void Main1(string[] args)
        //public static void Main(string[] args)
        {
            EtermClient client = new EtermClient();
            string      str    = string.Empty;

            try
            {
                client.Invoke(100001, "http://114.80.79.158:8084/HelloWorld.rem", "RTR/JQF0B7", EtermCommand.ServerSource.EtermRemote, TimeSpan.FromSeconds(5));
            }
            catch (Exception e)
            {
                throw new Exception(e.Message);
            }
            CommandResult <JetermEntity.Response.SeekPNR> response = new JetermEntity.Parser.SeekPNR().ParseCmdResult(str);

            Console.ReadLine();
        }
        // 返回结果:{"PassengerList":[{"name":"干园","idtype":0,"cardno":"NI650121199412242866","PassType":0,"Ename":"","BirthDayString":"","ChildBirthDayDate":"\/Date(-62135596800000+0800)\/","TicketNo":""},{"name":"张杰","idtype":0,"cardno":"NI140525198401186312","PassType":0,"Ename":"","BirthDayString":"","ChildBirthDayDate":"\/Date(-62135596800000+0800)\/","TicketNo":""}],"PNR":"HS8LF7","FlightList":[{"FlightNo":"MU5623","Airline":"","Cabin":"R","SCity":"PVG","ECity":"DLC","DepTerminal":"T1","ArrTerminal":"","DepDate":"\/Date(1432169100000+0800)\/","ArrDate":"\/Date(1432175400000+0800)\/"}],"ShareFlight":false,"FlightType":0,"RMKOfficeNoList":[],"BigPNR":"PKEVW0","Mobile":"13472634765","OfficeNo":"SHA243","AdultPnr":null,"PriceList":[{"FacePrice":570.00,"Tax":50.00,"Fuel":0.0,"TotalPrice":620.00}],"ResultBag":" 1.干园 2.张杰 HS8LF7   \r 3.  MU5623 R   TH21MAY  PVGDLC HK2   0845 1030          E T1-- \r     -CA-PKEVW0 \r 4.SHA/T SHA/T021-36412780/SHANGHAI FENGRUI INDUSTRY CO.LTD/ZHAO YAN ZHONG  \r     ABCDEFG\r 5.TL/1818/29APR/SHA888 \r 6.SSR FOID MU HK1 NI140525198401186312/P2  \r 7.SSR FOID MU HK1 NI650121199412242866/P1  \r 8.SSR FQTV MU HK1 PVGDLC 5623 R21MAY MU600287397934/P2 \r 9.SSR ADTK 1E BY SHA01MAY15/1718 OR CXL MU5623 R21MAY  \r10.OSI MU CTCT13472634765   \r11.RMK CA/PKEVW0                                                               +\r\n\u001e12.SHA243                                                                      -\r\n\u001e[price]>PAT:A  \r01 R FARE:CNY570.00 TAX:CNY50.00 YQ:TEXEMPTYQ  TOTAL:620.00 \r\u001eSFC:01   \u001eSFN:01   \r\u001e[eTerm:o72fe231]"}
        public static void EtermRemoteDemo_SeekPNR()
        {
            EtermClient client = new EtermClient();
            //string str = client.Invoke(100001, "http://114.80.79.158:8084/HelloWorld.rem", "RTR/JQF0B7", EtermCommand.ServerSource.EtermRemote, TimeSpan.FromSeconds(5));
            string str = string.Empty;

            try
            {
                str = client.Invoke(100001, "http://114.80.79.158:8084/HelloWorld.rem", "RTR/HS8LF7", EtermCommand.ServerSource.EtermRemote, TimeSpan.FromSeconds(5));
            }
            catch (Exception ex)
            {
                throw new Exception(string.Format("JEtermClient抛出异常,异常信息为:{0}", ex.Message));
            }

            JetermEntity.Parser.SeekPNR seekPNRParser            = new JetermEntity.Parser.SeekPNR();
            CommandResult <JetermEntity.Response.SeekPNR> result = seekPNRParser.ParseCmdResult(str);

            if (result == null)
            {
                result       = new CommandResult <JetermEntity.Response.SeekPNR>();
                result.error = new Error(EtermCommand.ERROR.SYSTEM_FAULT);
            }
            if (!result.state)
            {
                string cmdResultBag = result.error.CmdResultBag;
                Console.WriteLine(string.Format("返回有错误,错误信息为:{0}{1}。{2}", Environment.NewLine, result.error.ErrorMessage, string.IsNullOrWhiteSpace(cmdResultBag) ? string.Empty : string.Format("{0}RT指令返回结果为:{1}{2}", Environment.NewLine, Environment.NewLine, cmdResultBag)));
                Console.ReadLine();
                return;
            }

            if (result.result == null)
            {
                Console.WriteLine("没有返回结果");
                Console.ReadLine();
                return;
            }
            string parseResult = Newtonsoft.Json.JsonConvert.SerializeObject(result.result);

            Console.WriteLine("解析结果:" + Environment.NewLine + parseResult);

            Console.ReadLine();
        }
Example #8
0
        public void Test_ChildrenBookingInvoke2()
        {
            // 订位请求对象
            Command <JetermEntity.Request.Booking> cmd = new Command <JetermEntity.Request.Booking>();

            // 设置应用程序编号
            cmd.AppId = 100630;

            // 根据各自的业务需求,设置缓存时长
            cmd.CacheTime = EtermCommand.CacheTime.min30;

            cmd.request = new JetermEntity.Request.Booking();

            #region 订位请求参数

            JetermEntity.Flight flight = new JetermEntity.Flight();
            //flight.FlightNo = "CA1893";
            //flight.Cabin = "G";
            //flight.DepDate = Convert.ToDateTime("2015-04-24");
            //flight.SCity = "PVG";
            //flight.ECity = "SZX";
            //cmd.request.FlightList.Add(flight);

            //flight = new JetermEntity.Flight();
            //flight.FlightNo = "CA919";
            //flight.Cabin = "Q";
            //flight.DepDate = Convert.ToDateTime("2015-04-29");
            //flight.SCity = "SZX";
            //flight.ECity = "PVG";
            //cmd.request.FlightList.Add(flight);

            flight.FlightNo = "MU5137";
            flight.Cabin    = "H";
            //flight.SDate = "18MAR";
            flight.DepDate = Convert.ToDateTime("2015-04-27");
            flight.SCity   = "SHA";
            flight.ECity   = "PEK";
            cmd.request.FlightList.Add(flight);

            flight          = new JetermEntity.Flight();
            flight.FlightNo = "MU5156";
            flight.Cabin    = "B";
            //flight.SDate = "18MAR";
            flight.DepDate = Convert.ToDateTime("2015-04-30");
            flight.SCity   = "PEK";
            flight.ECity   = "SHA";
            cmd.request.FlightList.Add(flight);

            JetermEntity.Passenger passenger = new JetermEntity.Passenger();
            passenger.name              = "林秀CHD";
            passenger.idtype            = JetermEntity.EtermCommand.IDtype.Other;
            passenger.cardno            = "20110201";
            passenger.PassType          = EtermCommand.PassengerType.Children;
            passenger.ChildBirthDayDate = Convert.ToDateTime("2011-02-01");
            cmd.request.PassengerList.Add(passenger);

            passenger                   = new JetermEntity.Passenger();
            passenger.name              = "徐莹莹CHD";
            passenger.idtype            = JetermEntity.EtermCommand.IDtype.Other;
            passenger.cardno            = "612732198903210342";
            passenger.PassType          = EtermCommand.PassengerType.Children;
            passenger.ChildBirthDayDate = Convert.ToDateTime("2012-07-10");
            cmd.request.PassengerList.Add(passenger);

            //cmd.request.OfficeNo = "KHN117";
            cmd.request.OfficeNo = "SHA888";
            //cmd.request.OfficeNo = "BJS579";

            cmd.request.Mobile = "13472634765";

            //cmd.request.RMKOfficeNoList.Add("KHN117");
            //cmd.request.RMKOfficeNoList.Add("SHA777");
            //cmd.request.RMKOfficeNoList.Add("PEK513");
            //cmd.request.RMKOfficeNoList.Add("PEK277");
            //cmd.request.RMKOfficeNoList.Add("CKG234");
            //cmd.request.RMKOfficeNoList.Add("CKG24");
            //cmd.request.RMKOfficeNoList.Add("PEK112");
            //cmd.request.RMKOfficeNoList.Add("SHA123");
            //cmd.request.RMKOfficeNoList.Add("PEK530");

            //cmd.request.RMKRemark = "test";

            //cmd.request.Pnr = "JNL22B";
            //cmd.request.Pnr = "HF4X80";
            cmd.request.Pnr = "JMME8S";

            #endregion

            #region 调用Invoke以处理业务

            EtermClient client = new EtermClient();

            CommandResult <JetermEntity.Response.Booking> result = client.Invoke <JetermEntity.Request.Booking, JetermEntity.Response.Booking>(cmd);

            #endregion

            #region 业务处理

            if (result == null)
            {
                Console.WriteLine("没有返回结果");
                //Console.ReadLine();
                return;
            }
            if (!result.state)
            {
                string cmdResult2 = result.error.CmdResultBag;
                Console.WriteLine(string.Format("返回有错误,错误信息为:{0}{1}。{2}", Environment.NewLine, result.error.ErrorMessage, string.IsNullOrWhiteSpace(cmdResult2) ? string.Empty : string.Format("{0}订位指令返回结果为:{1}{2}", Environment.NewLine, Environment.NewLine, cmdResult2)));
                //Console.ReadLine();
                return;
            }
            if (result.result == null)
            {
                Console.WriteLine("没有返回结果");
                //Console.ReadLine();
                return;
            }

            string parseResult = Newtonsoft.Json.JsonConvert.SerializeObject(result.result);
            Console.WriteLine("解析结果:" + Environment.NewLine + parseResult);

            //Console.ReadLine();

            #endregion
        }
Example #9
0
        public void Test_AdultBookingInvoke2()
        {
            // 订位请求对象
            Command <JetermEntity.Request.Booking> cmd = new Command <JetermEntity.Request.Booking>();

            // 设置应用程序编号
            cmd.AppId = 100630;

            // 根据各自的业务需求,设置缓存时长
            cmd.CacheTime = EtermCommand.CacheTime.min30;

            cmd.request = new JetermEntity.Request.Booking();

            #region 订位请求参数

            JetermEntity.Flight flight = new JetermEntity.Flight();

            flight = new JetermEntity.Flight();
            //flight.FlightNo = "CA1884";
            //flight.Cabin = "B";
            ////flight.SDate = "18MAR";
            //flight.DepDate = Convert.ToDateTime("2015-05-30");
            //flight.SCity = "SHA";
            //flight.ECity = "PEK";
            //flight.FlightNo = "MU5110";
            //flight.Cabin = "Y";
            ////flight.SDate = "18MAR";
            //flight.DepDate = Convert.ToDateTime("2015-07-25");
            //flight.SCity = "PEK";
            //flight.ECity = "SHA";

            //flight.FlightNo = "CA1893";
            //flight.Cabin = "G";
            ////flight.SDate = "18MAR";
            //flight.DepDate = Convert.ToDateTime("2015-04-24");
            //flight.SCity = "PVG";
            //flight.ECity = "SZX";
            //cmd.request.FlightList.Add(flight);

            //flight = new JetermEntity.Flight();
            //flight.FlightNo = "CA919";
            //flight.Cabin = "Q";
            ////flight.SDate = "18MAR";
            //flight.DepDate = Convert.ToDateTime("2015-04-29");
            //flight.SCity = "SZX";
            //flight.ECity = "PVG";
            //cmd.request.FlightList.Add(flight);

            flight.FlightNo = "MU5137";
            flight.Cabin    = "H";
            //flight.SDate = "18MAR";
            flight.DepDate = Convert.ToDateTime("2015-04-27");
            flight.SCity   = "SHA";
            flight.ECity   = "PEK";
            cmd.request.FlightList.Add(flight);

            flight          = new JetermEntity.Flight();
            flight.FlightNo = "MU5156";
            flight.Cabin    = "B";
            //flight.SDate = "18MAR";
            flight.DepDate = Convert.ToDateTime("2015-04-30");
            flight.SCity   = "PEK";
            flight.ECity   = "SHA";
            cmd.request.FlightList.Add(flight);

            JetermEntity.Passenger passenger = new JetermEntity.Passenger();
            //passenger.name = "朱伟坚";
            //passenger.idtype = JetermEntity.EtermCommand.IDtype.IDcard;
            //passenger.cardno = "440106196510042095";
            //passenger.PassType = EtermCommand.PassengerType.Adult;
            //passenger.Ename = "zhuweijian";
            //cmd.request.PassengerList.Add(passenger);

            //passenger = new JetermEntity.Passenger();
            //passenger.name = "张路";
            //passenger.idtype = JetermEntity.EtermCommand.IDtype.IDcard;
            //passenger.cardno = "341281198703102834";
            //passenger.PassType = EtermCommand.PassengerType.Adult;
            ////passenger.Ename = "zhuweijian";

            passenger.name     = "干园";
            passenger.idtype   = JetermEntity.EtermCommand.IDtype.IDcard;
            passenger.cardno   = "650121199412242866";
            passenger.PassType = EtermCommand.PassengerType.Adult;
            //passenger.Ename = "zhuweijian";
            cmd.request.PassengerList.Add(passenger);

            //passenger.name = "李刚";
            //passenger.idtype = JetermEntity.EtermCommand.IDtype.IDcard;
            //passenger.cardno = "110101198810018696";
            //passenger.PassType = EtermCommand.PassengerType.Adult;
            ////passenger.Ename = "zhuweijian";

            //passenger.name = "张路";
            //passenger.idtype = JetermEntity.EtermCommand.IDtype.IDcard;
            //passenger.cardno = "341281198703102834";
            //passenger.PassType = EtermCommand.PassengerType.Adult;
            ////passenger.Ename = "zhuweijian";

            //passenger.name = "徐大莹CHD";
            //passenger.Ename = "XuXiaoYIng";
            //passenger.idtype = JetermEntity.EtermCommand.IDtype.IDcard;
            //passenger.cardno = "612732198903210342";
            //passenger.PassType = EtermCommand.PassengerType.Children;
            ////passenger.Ename = "zhuweijian";

            passenger      = new JetermEntity.Passenger();
            passenger.name = "张杰";
            //passenger.Ename = "XuXiaoYIng";
            passenger.idtype   = JetermEntity.EtermCommand.IDtype.IDcard;
            passenger.cardno   = "140525198401186312";
            passenger.PassType = EtermCommand.PassengerType.Adult;
            //passenger.Ename = "zhuweijian";
            cmd.request.PassengerList.Add(passenger);

            //passenger.name = "沈璐";
            ////passenger.Ename = "XuXiaoYIng";
            //passenger.idtype = JetermEntity.EtermCommand.IDtype.IDcard;
            //passenger.cardno = "12312";
            //passenger.PassType = EtermCommand.PassengerType.Adult;
            ////passenger.Ename = "zhuweijian";

            //cmd.request.PassengerList.Add(passenger);

            //JetermEntity.Passenger passenger = new JetermEntity.Passenger();
            //passenger.name = "张业华";
            //passenger.idtype = JetermEntity.EtermCommand.IDtype.IDcard;
            //passenger.cardno = "310107198812044435";
            //passenger.PassType = EtermCommand.PassengerType.Adult;
            //passenger.Ename = "zhangyehua";
            //cmd.request.PassengerList.Add(passenger);

            //passenger = new JetermEntity.Passenger();
            //passenger.name = "杜俊强";
            //passenger.idtype = JetermEntity.EtermCommand.IDtype.IDcard;
            //passenger.cardno = "310107198312044435";
            //passenger.PassType = EtermCommand.PassengerType.Adult;
            //passenger.Ename = "dujunqiang";
            //cmd.request.PassengerList.Add(passenger);

            //cmd.request.OfficeNo = "KHN117";
            cmd.request.OfficeNo = "SHA888";
            //cmd.request.OfficeNo = "BJS579";

            cmd.request.Mobile = "13472634765";

            //cmd.request.RMKOfficeNoList.Add("KHN117");
            //cmd.request.RMKOfficeNoList.Add("SHA777");
            //cmd.request.RMKOfficeNoList.Add("PEK513");
            //cmd.request.RMKOfficeNoList.Add("PEK277");
            //cmd.request.RMKOfficeNoList.Add("CKG234");
            //cmd.request.RMKOfficeNoList.Add("CKG24");
            //cmd.request.RMKOfficeNoList.Add("PEK112");
            //cmd.request.RMKOfficeNoList.Add("SHA123");
            //cmd.request.RMKOfficeNoList.Add("PEK530");

            //cmd.request.RMKRemark = "test";

            #endregion

            #region 调用Invoke以处理业务

            EtermClient client = new EtermClient();

            CommandResult <JetermEntity.Response.Booking> result = client.Invoke <JetermEntity.Request.Booking, JetermEntity.Response.Booking>(cmd);

            #endregion

            #region 业务处理

            if (result == null)
            {
                Console.WriteLine("没有返回结果");
                //Console.ReadLine();
                return;
            }
            if (!result.state)
            {
                string cmdResult2 = result.error.CmdResultBag;
                Console.WriteLine(string.Format("返回有错误,错误信息为:{0}{1}。{2}", Environment.NewLine, result.error.ErrorMessage, string.IsNullOrWhiteSpace(cmdResult2) ? string.Empty : string.Format("{0}订位指令返回结果为:{1}{2}", Environment.NewLine, Environment.NewLine, cmdResult2)));
                //Console.ReadLine();
                return;
            }
            if (result.result == null)
            {
                Console.WriteLine("没有返回结果");
                //Console.ReadLine();
                return;
            }

            string parseResult = Newtonsoft.Json.JsonConvert.SerializeObject(result.result);
            Console.WriteLine("解析结果:" + Environment.NewLine + parseResult);

            //Console.ReadLine();

            #endregion
        }
Example #10
0
        static void Main(string[] args)
        {
            ParserTest.Main1();
            return;

            EtermClient client = new EtermClient();
            string      str    = client.Invoke(123, "http://114.80.69.227:5555/RT123456", "", EtermCommand.ServerSource.EtermServer, TimeSpan.FromSeconds(5));

            string.Format(JMetricsHelper.JetermCount, "TEST").MeterMark("次");//计数
            //MetricsManager.MeterMark(string.Format(JMetricsHelper.JetermCount, "Common"), "次");



            Command <JetermEntity.Request.Booking> book = new Command <JetermEntity.Request.Booking>();

            book.AppId              = 1232423;
            book.request            = new JetermEntity.Request.Booking();
            book.request.FlightList = new List <Flight>();
            book.request.FlightList.Add(new Flight()
            {
                Cabin = "C", ECity = "PEK", SCity = "SHA", FlightNo = "CA2232"
            });
            book.request.PassengerList = new List <Passenger>();
            book.request.PassengerList.Add(new Passenger()
            {
                cardno = "2343543", BirthDayString = "23423543"
            });
            CommandResult <JetermEntity.Response.Booking> r1 = client.Invoke <JetermEntity.Request.Booking, JetermEntity.Response.Booking>(book);

            string.Format(JMetricsHelper.JetermCount, "Common").MeterMark("次");//计数
            Console.ReadLine();

            /*
             * // string tes="{\"state\":false,\"error\":{\"ErrorCode\":4,\"ErrorMessage\":\"没有传必须传的请求参数值\"},\"config\":\"CS002\",\"OfficeNo\":\"KHN117\",\"result\":{\"Pnr\":null,\"OfficeNo\":\"KHN117\",\"PnrState\":false,\"Command\":null,\"ResultBag\":null},\"reqtime\":\"\\/Date(1427093175480+0800)\\/\",\"SaveTime\":1800}";
             * // CommandResult<JetermEntity.Response.Booking> r=JsonConvert.DeserializeObject<CommandResult<JetermEntity.Response.Booking>>(tes);
             * Console.WriteLine(string.Format("开始 {0}", DateTime.Now.ToString("HH:mm:ss.fff")));
             * string s = "{\"FlightNo\":\"MU5137\",\"Cabin\":\"B\",\"SCity\":\"\",\"ECity\":\"PEK\",\"DepDate\":\"\\/Date(1427731200000+0800)\\/\",\"ArrDate\":\"\\/Date(-62135596800000+0800)\\/\"}";
             *
             * string sss =  JetermClient.Utility.HttpService.HttpPost("192.168.5.165:15252", "Booking", s, 500, 500);
             * //dome();
             * Console.WriteLine(sss);
             *
             * Console.WriteLine(string.Format("结束 {0}", DateTime.Now.ToString("HH:mm:ss.fff")));
             *
             * Console.ReadLine();
             *
             *
             *
             * Flight f= JsonConvert.DeserializeObject<Flight>(s);
             */

            /*
             * string commandBag = string.Format("{0}{1}{2}", "rtCmd", Environment.NewLine, "rtCmdResult");
             * commandBag += string.Format("{0}{1}{2}{3}{4}", Environment.NewLine, Environment.NewLine, "priceCmd", Environment.NewLine, "priceCmdResult");
             * return;
             */

            /*
             * string error = "[ERROR]abc";
             * //string error = "a[ERROR]bc";
             * //error = "abc";
             * error = error.Substring(7);
             * int i = error.IndexOf("[ERROR]");
             * return;
             */

            /*
             * try
             * {
             *  //ERROR errorValue = (ERROR)Enum.Parse(typeof(ERROR), "NO_FIND_CONFIG");
             *  ERROR errorValue = (ERROR)Enum.Parse(typeof(ERROR), "NO_FIND_CONFIG1,");
             *  if (Enum.IsDefined(typeof(ERROR), errorValue) | errorValue.ToString().Contains(","))
             *  {
             *      Console.WriteLine("Converted '{0}' to {1}.", "NO_FIND_CONFIG", errorValue.ToString());
             *  }
             *  else
             *  {
             *      Console.WriteLine("{0} is not an underlying value of the ERROR enumeration.", "NO_FIND_CONFIG1,");
             *  }
             * }
             * catch (ArgumentException)
             * {
             *  Console.WriteLine("'{0}' is not a member of the ERROR enumeration.", "NO_FIND_CONFIG1,");
             * }
             * return;
             */

            //CommandResult<JetermEntity.Response.TicketInfo> re=new CommandResult<JetermEntity.Response.TicketInfo>();
            //JetermEntity.EtermCommand.TicketStatus ts= EtermCommand.TicketStatus.NotSet;
            //EtermProxy.Common.CommonBll<JetermEntity.Response.TicketInfo>.GetTicketStatusAndSaveTime("USED", re, out ts);

            //#region 邮件测试
            //JetermUntility.Communication com = new JetermUntility.Communication();
            //com.SendMail("*****@*****.**", "bkbjwhsh","smtp.qq.com","测试","test",new string[]{"*****@*****.**"});
            //#endregion

            //#region 配置管理测试
            //JetermEntity.EtermConfig config = new JetermEntity.EtermConfig();
            //config.UserName = "******";
            //EtermClient client = new EtermClient();
            //bool bret = client.ConfigManage(EtermCommand.OperatMethod.add, config);
            //#endregion

            //#region Eterm代理测试
            ////string s = "http://localhost:15252/format=json&method=SeekPNR&param0=SFE234&param1=Adult&param2=True";
            ////string s = "http://192.168.5.165:15252/format=json&language=CSharp&method=TicketInfo&param0=675-8911180438";
            //string s = "http://192.168.2.224:15252/format=json&language=CSharp&method=Booking";
            //string post = "{\"FlightList\":[{\"FlightNo\":\"MU5109\",\"Cabin\":\"Y\",\"SCity\":\"SHA\",\"ECity\":\"PEK\",\"DepDate\":\"\\/Date(1428422400000+0800)\\/\",\"ArrDate\":\"\\/Date(-62135596800000+0800)\\/\"}],\"PassengerList\":[{\"name\":\"朱伟坚\",\"idtype\":0,\"cardno\":\"440106196510042095\",\"PassType\":0,\"Ename\":\"zhuweijian\",\"BirthDayString\":\"\",\"TicketNo\":\"\"}],\"OfficeNo\":\"KHN117\",\"Mobile\":\"13647125256\",\"RMKOfficeNoList\":[\"KHN117\"],\"RMKRemark\":\"test\",\"Pnr\":\"JNL22B\"}";
            //EtermProxy.Proxy proxy = new EtermProxy.Proxy();
            //IntPtr ptr = IntPtr.Zero;
            //string str = proxy.InvokeEterm(ptr, ptr, "CS003", "", s, post);
            ////object o = JsonConvert.DeserializeObject(str);
            //return;
            //#endregion

            #region EtermClient测试
            //EtermClient clinet = new EtermClient();

            //Command<JetermEntity.Request.Booking> book = new Command<JetermEntity.Request.Booking>();
            //book.AppId = "1232423";
            //book.request = new JetermEntity.Request.Booking();
            //book.request.FlightList = new List<Flight>();
            //book.request.FlightList.Add(new Flight() { Cabin = "C", ECity = "PEK", SCity = "SHA", FlightNo = "CA2232" });
            //book.request.PassengerList = new List<Passenger>();
            //book.request.PassengerList.Add(new Passenger() { name="李小波", cardno = "2343543", BirthDayString = "23423543" });
            //CommandResult<JetermEntity.Response.Booking> r1 = clinet.Invoke<JetermEntity.Request.Booking, JetermEntity.Response.Booking>(book);

            //string sret = JsonConvert.SerializeObject(r1);

            //Console.Write(sret);
            //Console.ReadKey();


            // 大编码获取票号请求对象
            //Command<JetermEntity.Request.TicketByBigPnr> cmd = new Command<JetermEntity.Request.TicketByBigPnr>();
            // 订位请求对象
            Command <JetermEntity.Request.Booking> cmd = new Command <JetermEntity.Request.Booking>();

            // 设置应用程序编号
            cmd.AppId = 100630;

            // 根据各自的业务需求,设置缓存时长
            cmd.CacheTime = EtermCommand.CacheTime.min30;

            //cmd.request = new JetermEntity.Request.TicketByBigPnr();
            cmd.request = new JetermEntity.Request.Booking();

            #region 大编码号请求参数

            //cmd.request.BigPnr = "PCZ0SX";
            //cmd.request.FlightNo = "8L9801";
            //string flightCode = "KMGLJG";
            //if (!string.IsNullOrEmpty(flightCode))
            //{
            //    if (flightCode.Length > 3)
            //    {
            //        cmd.request.SCity = flightCode.Substring(0, 3);
            //    }

            //    if (flightCode.Length > 5)
            //    {
            //        cmd.request.ECity = flightCode.Substring(3, 3);
            //    }
            //}

            #endregion

            #region 订位请求参数

            JetermEntity.Flight flight = new JetermEntity.Flight();
            //flight.FlightNo = "CA4309";
            //flight.Cabin = "E";
            //flight.SDate = "28JAN";
            //flight.SCity = "CTU";
            //flight.ECity = "CAN";

            //flight.FlightNo = "MU5138";
            //flight.Cabin = "V";
            ////flight.SDate = "18MAR";
            //flight.DepDate = Convert.ToDateTime("2015-03-10");
            //flight.SCity = "PEK";
            //flight.ECity = "SHA";

            //flight.FlightNo = "MU5183";
            //flight.Cabin = "Y";
            ////flight.SDate = "18MAR";
            //flight.DepDate = Convert.ToDateTime("2015-04-06");
            //flight.SCity = "PEK";
            //flight.ECity = "SHA";

            //flight.FlightNo = "MU5109";
            //flight.Cabin = "Y";
            ////flight.SDate = "18MAR";
            //flight.DepDate = Convert.ToDateTime("2015-04-08");
            //flight.SCity = "SHA";
            //flight.ECity = "PEK";

            //flight.FlightNo = "MU5137";
            //flight.Cabin = "P";
            ////flight.SDate = "18MAR";
            //flight.DepDate = Convert.ToDateTime("2015-03-31");
            //flight.SCity = "SHA";
            //flight.ECity = "PEK";

            //flight.FlightNo = "MU5137";
            //flight.Cabin = "B";
            ////flight.SDate = "18MAR";
            //flight.DepDate = Convert.ToDateTime("2015-03-27");
            //flight.SCity = "SHA";
            //flight.ECity = "PEK";

            //flight.FlightNo = "MU5137";
            //flight.Cabin = "B";
            ////flight.SDate = "18MAR";
            //flight.DepDate = Convert.ToDateTime("2015-03-31");
            //flight.SCity = "SHA";
            //flight.ECity = "PEK";

            //flight.FlightNo = "MU5183";
            //flight.Cabin = "L";
            ////flight.SDate = "18MAR";
            //flight.DepDate = Convert.ToDateTime("2015-03-21");
            //flight.SCity = "PEK";
            //flight.ECity = "SHA";
            //cmd.request.FlightList.Add(flight);

            //flight = new JetermEntity.Flight();
            //flight.FlightNo = "MU5127";
            //flight.Cabin = "M";
            ////flight.SDate = "18MAR";
            //flight.DepDate = Convert.ToDateTime("2015-03-23");
            //flight.SCity = "SHA";
            //flight.ECity = "PEK";
            //cmd.request.FlightList.Add(flight);

            //flight.FlightNo = "CZ6412";
            //flight.Cabin = "Y";
            ////flight.SDate = "18MAR";
            //flight.DepDate = Convert.ToDateTime("2015-05-01");
            //flight.SCity = "PEK";
            //flight.ECity = "SHA";
            //cmd.request.FlightList.Add(flight);

            //flight = new JetermEntity.Flight();
            //flight.FlightNo = "CZ3908";
            //flight.Cabin = "Y";
            ////flight.SDate = "18MAR";
            //flight.DepDate = Convert.ToDateTime("2015-05-04");
            //flight.SCity = "SHA";
            //flight.ECity = "PEK";
            //cmd.request.FlightList.Add(flight);

            //flight.FlightNo = "CA1606";
            //flight.Cabin = "B";
            ////flight.SDate = "18MAR";
            //flight.DepDate = Convert.ToDateTime("2015-06-17");
            //flight.SCity = "DLC";
            //flight.ECity = "PEK";
            //cmd.request.FlightList.Add(flight);

            //flight.FlightNo = "CA1831";
            //flight.Cabin = "K";
            ////flight.SDate = "18MAR";
            //flight.DepDate = Convert.ToDateTime("2015-05-29");
            //flight.SCity = "PEK";
            //flight.ECity = "SHA";
            //cmd.request.FlightList.Add(flight);

            flight = new JetermEntity.Flight();
            //flight.FlightNo = "CA1884";
            //flight.Cabin = "B";
            ////flight.SDate = "18MAR";
            //flight.DepDate = Convert.ToDateTime("2015-05-30");
            //flight.SCity = "SHA";
            //flight.ECity = "PEK";
            //flight.FlightNo = "MU5110";
            //flight.Cabin = "Y";
            ////flight.SDate = "18MAR";
            //flight.DepDate = Convert.ToDateTime("2015-07-25");
            //flight.SCity = "PEK";
            //flight.ECity = "SHA";

            flight.FlightNo = "MU5102";
            flight.Cabin    = "M";
            //flight.SDate = "18MAR";
            flight.DepDate = Convert.ToDateTime("2015-04-16");
            flight.SCity   = "PEK";
            flight.ECity   = "SHA";
            cmd.request.FlightList.Add(flight);

            flight          = new JetermEntity.Flight();
            flight.FlightNo = "MU5153";
            flight.Cabin    = "L";
            //flight.SDate = "18MAR";
            flight.DepDate = Convert.ToDateTime("2015-04-18");
            flight.SCity   = "SHA";
            flight.ECity   = "PEK";
            cmd.request.FlightList.Add(flight);

            JetermEntity.Passenger passenger = new JetermEntity.Passenger();
            //passenger.name = "朱伟坚";
            //passenger.idtype = JetermEntity.EtermCommand.IDtype.IDcard;
            //passenger.cardno = "440106196510042095";
            //passenger.PassType = EtermCommand.PassengerType.Adult;
            //passenger.Ename = "zhuweijian";

            passenger.name     = "张路";
            passenger.idtype   = JetermEntity.EtermCommand.IDtype.IDcard;
            passenger.cardno   = "341281198703102834";
            passenger.PassType = EtermCommand.PassengerType.Adult;
            //passenger.Ename = "zhuweijian";

            //passenger.name = "干园";
            //passenger.idtype = JetermEntity.EtermCommand.IDtype.IDcard;
            //passenger.cardno = "650121199412242866";
            //passenger.PassType = EtermCommand.PassengerType.Adult;
            ////passenger.Ename = "zhuweijian";

            //passenger.name = "李刚";
            //passenger.idtype = JetermEntity.EtermCommand.IDtype.IDcard;
            //passenger.cardno = "110101198810018696";
            //passenger.PassType = EtermCommand.PassengerType.Adult;
            ////passenger.Ename = "zhuweijian";

            //passenger.name = "张路";
            //passenger.idtype = JetermEntity.EtermCommand.IDtype.IDcard;
            //passenger.cardno = "341281198703102834";
            //passenger.PassType = EtermCommand.PassengerType.Adult;
            ////passenger.Ename = "zhuweijian";

            //passenger.name = "徐大莹CHD";
            //passenger.Ename = "XuXiaoYIng";
            //passenger.idtype = JetermEntity.EtermCommand.IDtype.IDcard;
            //passenger.cardno = "612732198903210342";
            //passenger.PassType = EtermCommand.PassengerType.Children;
            ////passenger.Ename = "zhuweijian";

            //passenger.name = "张杰";
            ////passenger.Ename = "XuXiaoYIng";
            //passenger.idtype = JetermEntity.EtermCommand.IDtype.IDcard;
            //passenger.cardno = "140525198401186312";
            //passenger.PassType = EtermCommand.PassengerType.Adult;
            ////passenger.Ename = "zhuweijian";

            //passenger.name = "沈璐";
            ////passenger.Ename = "XuXiaoYIng";
            //passenger.idtype = JetermEntity.EtermCommand.IDtype.IDcard;
            //passenger.cardno = "12312";
            //passenger.PassType = EtermCommand.PassengerType.Adult;
            ////passenger.Ename = "zhuweijian";

            cmd.request.PassengerList.Add(passenger);

            //JetermEntity.Passenger passenger = new JetermEntity.Passenger();
            //passenger.name = "张业华";
            //passenger.idtype = JetermEntity.EtermCommand.IDtype.IDcard;
            //passenger.cardno = "310107198812044435";
            //passenger.PassType = EtermCommand.PassengerType.Adult;
            //passenger.Ename = "zhangyehua";
            //cmd.request.PassengerList.Add(passenger);

            //passenger = new JetermEntity.Passenger();
            //passenger.name = "杜俊强";
            //passenger.idtype = JetermEntity.EtermCommand.IDtype.IDcard;
            //passenger.cardno = "310107198312044435";
            //passenger.PassType = EtermCommand.PassengerType.Adult;
            //passenger.Ename = "dujunqiang";
            //cmd.request.PassengerList.Add(passenger);

            //cmd.request.OfficeNo = "KHN117";
            cmd.request.OfficeNo = "SHA888";
            //cmd.request.OfficeNo = "BJS579";

            //cmd.request.Mobile = "13647125256";
            //cmd.request.Mobile = "15021977488";
            //cmd.request.Mobile = "15192781928";
            //cmd.request.Mobile = "15692182199";
            //cmd.request.Mobile = "15821988525";
            cmd.request.Mobile = "13472634765";

            //cmd.request.RMKOfficeNoList.Add("KHN117");
            //cmd.request.RMKOfficeNoList.Add("SHA777");
            //cmd.request.RMKOfficeNoList.Add("PEK513");
            //cmd.request.RMKOfficeNoList.Add("PEK277");
            //cmd.request.RMKOfficeNoList.Add("CKG234");
            //cmd.request.RMKOfficeNoList.Add("CKG24");
            //cmd.request.RMKOfficeNoList.Add("PEK112");
            //cmd.request.RMKOfficeNoList.Add("SHA123");
            cmd.request.RMKOfficeNoList.Add("PEK530");

            //cmd.request.RMKRemark = "test";

            //cmd.request.Pnr = "JNL22B";
            //cmd.request.Pnr = "HF4X80";

            #endregion

            #endregion

            // EtermClient对象
            //EtermClient client = new EtermClient();

            //Command<JetermEntity.Request.Booking> book = new Command<JetermEntity.Request.Booking>();
            //book.AppId = "1232423";
            //book.request = new JetermEntity.Request.Booking();
            //book.request.FlightList = new List<Flight>();
            //book.request.FlightList.Add(new Flight() { Cabin="C", ECity="PEK",SCity="SHA", FlightNo="CA2232" });
            //book.request.PassengerList = new List<Passenger>();
            //book.request.PassengerList.Add(new Passenger() { cardno="2343543", BirthDayString="23423543" });
            //CommandResult<JetermEntity.Response.Booking> r1 = clinet.Invoke<JetermEntity.Request.Booking, JetermEntity.Response.Booking>(book);

            #region 调用Invoke以处理业务

            //CommandResult<JetermEntity.Response.TicketByBigPnr> result = client.Invoke<JetermEntity.Request.TicketByBigPnr, JetermEntity.Response.TicketByBigPnr>(cmd);
            CommandResult <JetermEntity.Response.Booking> result = client.Invoke <JetermEntity.Request.Booking, JetermEntity.Response.Booking>(cmd);

            #endregion

            #region 业务处理

            if (result == null)
            {
                Console.WriteLine("没有返回结果");
                Console.ReadLine();
                return;
            }
            if (!result.state)
            {
                Console.WriteLine(string.Format("返回有错误,错误信息为{0}", result.error.ErrorMessage));
                Console.ReadLine();
                return;
            }
            if (result.result == null)
            {
                Console.WriteLine("没有返回结果");
                Console.ReadLine();
                return;
            }

            Console.WriteLine("运行结果:" + Newtonsoft.Json.JsonConvert.SerializeObject(result.result));

            Console.ReadLine();

            #endregion
        }
Example #11
0
        //public static void Main(string[] args)
        public static void Main33(string[] args)
        {
            // url如:http://120.132.136.91:18082/format=json&language=CSharp&method=TicketByBigPnr
            string url       = string.Format("{0}&language=CSharp&method={1}", ConfigurationManager.AppSettings["HttpPostURL"], "TicketByBigPnr");
            string strParams = "{\"BigPnr\":\"MJK958\",\"FlightNo\":\"JD5357\",\"SCity\":\"PEK\",\"ECity\":\"ERL\"}";

            //string strParams = "{\"BigPnr\":\"NVZSHM\",\"FlightNo\":\"MU5844\",\"SCity\":\"CTU\",\"ECity\":\"KMG\"}";
            url       = "http://114.80.69.243:9999/format=json&language=CSharp&method=SeekPNR";
            strParams = "{\"Pnr\":\"HYEHSM\",\"PassengerType\":0,\"GetPrice\":true}";

            EtermClient client = new EtermClient();

            try
            {
                client.Invoke(123, "format=json&method=SeekPNR&officeno=SHA243", "system(\"RT KZ9EZN\");\r\nreturn DATA;", new TimeSpan(0, 0, 50));
                //client.Invoke(123, "format=json&method=SeekPNR&officeno=SHA244", "system(\"RT KZ9EZN\");\r\nreturn DATA;", new TimeSpan(0, 0, 50));
                //client.Invoke(123, "format=json&method=SeekPNR&officeno=SHA243", "system(\"RT KZ9EZN\");\r\nreturn DATAss;", new TimeSpan(0, 0, 50));
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
            return;


            CommandResult <JetermEntity.Response.SeekPNR> sk = client.Invoke <JetermEntity.Request.SeekPNR, JetermEntity.Response.SeekPNR>(new JetermEntity.Request.Command <JetermEntity.Request.SeekPNR>()
            {
                AppId = 0, officeNo = "SHA243", request = new JetermEntity.Request.SeekPNR()
                {
                    Pnr = "HYEHSM", PassengerType = EtermCommand.PassengerType.Adult, GetPrice = true
                }
            });
            string str = string.Empty;

            try
            {
                str = client.Invoke(-1, url, strParams, EtermCommand.ServerSource.EtermServer, TimeSpan.FromSeconds(5));
            }
            catch (Exception ex)
            {
                throw new Exception(ex.ToString());
            }

            CommandResult <JetermEntity.Response.TicketByBigPnr> result = JsonConvert.DeserializeObject <CommandResult <JetermEntity.Response.TicketByBigPnr> >(str);

            if (result == null)
            {
                result       = new CommandResult <JetermEntity.Response.TicketByBigPnr>();
                result.error = new Error(EtermCommand.ERROR.SYSTEM_FAULT);
            }
            if (!result.state)
            {
                string cmdResultBag = result.error.CmdResultBag;
                Console.WriteLine(string.Format("返回有错误,错误信息为:{0}{1}。{2}", Environment.NewLine, result.error.ErrorMessage, string.IsNullOrWhiteSpace(cmdResultBag) ? string.Empty : string.Format("{0}TicketByBigPnr指令返回结果为:{1}{2}", Environment.NewLine, Environment.NewLine, cmdResultBag)));
                Console.ReadLine();
                return;
            }
            if (result.result == null)
            {
                Console.WriteLine("没有返回结果");
                Console.ReadLine();
                return;
            }

            Console.WriteLine("解析结果:" + Environment.NewLine + str);

            Console.ReadLine();
        }