예제 #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;
        }
예제 #2
0
파일: Form1.cs 프로젝트: jsgydjq/train
        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;
     }
 }
예제 #4
0
 private void Log(Account account, string message)
 {
     Trace.WriteLine(account + "," + System.DateTime.Now.ToString("hh:mm:ss:") + message);
 }
예제 #5
0
 public TicketBuyer(TicketSetting ticketSetting)
 {
     TicketSetting = ticketSetting;
     account = new Account(ticketSetting.Username, ticketSetting.Password, ticketSetting.Proxy);
 }
예제 #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());
        }
예제 #7
0
파일: Form1.cs 프로젝트: jsgydjq/train
 /// <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, "登陆成功");
     }
 }
예제 #8
0
파일: Form1.cs 프로젝트: jsgydjq/train
 private void Log(Account account, Exception ex)
 {
     Log(account, ex.Message + "\r\n\t" + ex.StackTrace);
 }
예제 #9
0
파일: Form1.cs 프로젝트: jsgydjq/train
        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());
        }
예제 #10
0
파일: Form1.cs 프로젝트: jsgydjq/train
 private void CheckState(Account account)
 {
     if (Stop) return;
     while (!Stop && account.CheckState() == State.Maintenance)
     {
         Log(account, "服务器维护中,10s重新检测");
         Thread.Sleep(10000);
     }
 }