Beispiel #1
0
        /// <summary>
        /// ����һ�����˺�
        /// </summary>
        /// <returns></returns>
        public static Account CreateNewAccount()
        {
            string name = "NewAccount" + _accountList.Count + 1;
            AccountInfo accountInfo = new AccountInfo() {Username = name};
            Config.BuyTicketConfig.Instance.AccountInfos.Add(accountInfo);
            Config.BuyTicketConfig.Save();
            Account account = new Account(accountInfo);
            _accountList.Add(account);

            return account;
        }
Beispiel #2
0
        public void Log(Account account, string message)
        {
            if (lbPassengers.InvokeRequired)
            {
                lbPassengers.Invoke(new Action(() =>
                    {
                        var l = lbPassengers.Text.Length - 10000;
                        lbPassengers.Text = lbPassengers.Text.Substring(l > 0 ? l : 0) + account + "," + System.DateTime.Now.ToString("hh:mm:ss:") + message + "\r\n";
                        lbPassengers.SelectionStart = lbPassengers.TextLength;
                        lbPassengers.ScrollToCaret();

                    }));
            }
            else
            {
                var l = lbPassengers.Text.Length - 10000;
                lbPassengers.Text = lbPassengers.Text.Substring(l > 0 ? l : 0) + account + "," + System.DateTime.Now.ToString("hh:mm:ss:") + message + "\r\n";
                lbPassengers.SelectionStart = lbPassengers.TextLength;
                lbPassengers.ScrollToCaret();
            }
        }
 /// <summary>
 /// ���˺��������ip�仯ʱ�ᴴ���µ��˺ţ���������ԭ�����˺�
 /// </summary>
 /// <param name="userName"></param>
 /// <param name="password"></param>
 /// <param name="proxyIp"></param>
 /// <returns></returns>
 public static Account GetAccount(string userName,string password,string proxyIp)
 {
     string key = string.Format("{0},{1},{2}", userName, password, proxyIp).ToLower();
     if(accounts.ContainsKey(key))
     {
         return accounts[key];
     }
     else
     {
         Account account=new Account(userName,password,proxyIp);
         accounts.Add(key,account);
         return account;
     }
 }
Beispiel #4
0
 private void Log(Account account, string message)
 {
     Trace.WriteLine(account + "," + System.DateTime.Now.ToString("hh:mm:ss:") + message);
 }
Beispiel #5
0
 public TicketBuyer(TicketSetting ticketSetting)
 {
     TicketSetting = ticketSetting;
     account = new Account(ticketSetting.Username, ticketSetting.Password, ticketSetting.Proxy);
 }
Beispiel #6
0
        private void DisplayTrainInfos(List<TrainItemInfo> list, Account account)
        {
            StringBuilder sb = new StringBuilder();
            sb.AppendLine("======��ѯ���г���Ϣ====");
            sb.Append("����\t��ʱ\t������\t�ص���\tһ����\t������\t�߼���\t����\tӲ��\t����\tӲ��\t����\t����\r\n");

            foreach (TrainItemInfo trainItemInfo in list)
            {
                if (TicketSetting.ShowRealLeftTicketNum)
                {
                    trainItemInfo.ParseYpDetail();
                }
                sb.Append(trainItemInfo.ToStringWithNoStation());
                sb.AppendLine();
            }
            Log(account, sb.ToString());
        }
Beispiel #7
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, "登陆成功");
     }
 }
Beispiel #8
0
 private void Log(Account account, Exception ex)
 {
     Log(account, ex.Message + "\r\n\t" + ex.StackTrace);
 }
Beispiel #9
0
        private void DisplayTrainInfos(List<TrainItemInfo> list, Account account)
        {
            StringBuilder sb = new StringBuilder();
            sb.AppendLine("======查询到列车信息====");
            sb.Append("车次\t历时\t商务座\t特等座\t一等座\t二等座\t高级软\t软卧\t硬卧\t软座\t硬座\t无座\t其他\r\n");

            foreach (TrainItemInfo trainItemInfo in list)
            {
                if (cbShowRealYp.Checked)
                {
                    trainItemInfo.ParseYpDetail();
                }
                sb.Append(trainItemInfo.ToStringWithNoStation());
                sb.AppendLine();
            }
            Log(account, sb.ToString());
        }
Beispiel #10
0
 private void CheckState(Account account)
 {
     if (Stop) return;
     while (!Stop && account.CheckState() == State.Maintenance)
     {
         Log(account, "服务器维护中,10s重新检测");
         Thread.Sleep(10000);
     }
 }