Beispiel #1
0
        static void Main(string[] args)
        {
            System.Net.ServicePointManager.ServerCertificateValidationCallback =(sender, certificate, chain, errors) => true;

            //IPAddress[] ipAddresses = System.Net.Dns.GetHostAddresses("dynamic.12306.cn");

            OrderRequest orderRequest = new OrderRequest()
                                            {
                                                FromStationTelecode = "BJP",
                                                //FromStationTelecodeName="北京",
                                                ToStationTelecode = "NCG",
                                                //ToStationTelecodeName = "南昌",
                                                IncludeStudent = "00",
                                                StartTimeStr = "00:00--24:00",
                                                TrainClass = "QB#D#Z#T#K#QT#",
                                                TrainDate = DateTime.Parse("2012-10-11"),
                                                TrainPassType = "QB"
                                            };
            BuyTicketConfig.Instance.OrderRequest = orderRequest;
            var Passengers=new Passenger[]
                                       {
                                           new Passenger(){Name="林利",CardNo = "362201198409101614",Checked=true,MobileNo="15910675179"},
                                           new Passenger(){Name="林艳",CardNo = "362201198305131667",Checked=true,MobileNo="18610037900"},
                                       };
            Account account = new Account("mydobit", "03265791", null);
            bool auto = false;
            account.Login(ref auto);
            Console.WriteLine(account.IsLogin);
            var list = account.QueryTrainInfos(new List<TrainItemInfo>());
            //string ret = account.OrderTicket(list[0], Passengers);
            //if(string.IsNullOrEmpty(ret))
            //{
            //  Console.WriteLine("OrderId="+account.GetOderId());
            //}
            //else
            //{
            //    Console.WriteLine(ret);
            //}
            Console.ReadLine();
        }
Beispiel #2
0
 /// <summary>
 /// 登录
 /// </summary>
 /// <param name="account"></param>
 /// <returns></returns>
 private void Login(Account account)
 {
     if (Stop) return;
     if (account.IsLogin)
     {
         Log(account, "已经登陆,不需要登录");
     }
     else
     {
         Log(account, "开始登陆");
         while (!Stop && !account.IsLogin)
         {
             try
             {
                 account.Login(ref autoVcode);
             }
             catch (Exception exception)
             {
                 Log(account, exception);
             }
             Thread.Sleep(100); //休息0.1秒
         }
         if (account.IsLogin)
             Log(account, "登陆成功");
     }
 }