예제 #1
0
 /// <summary>
 ///     单个程序是单例
 /// </summary>
 /// <returns></returns>
 public static BatchOpenAccount GetBatchOpenAccount(Action <int> action)
 {
     if (instanceBatchOpenAccount == null)
     {
         Action1 = action;
         instanceBatchOpenAccount = new BatchOpenAccount();
     }
     return(instanceBatchOpenAccount);
 }
예제 #2
0
        /// <summary>
        ///     批量开户
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void toolStripButton1_Click(object sender, EventArgs e)
        {
            BatchOpenAccount batchOpenAccount = BatchOpenAccount.GetBatchOpenAccount(async nums => await Task.Run(() =>
            {
                this.lbl_showOpen.Text        = "正在批量开户,请耐心等待.......";
                this.btn_opne.Enabled         = false;
                this.toolStripButton1.Enabled = false;
                for (int i = 0; i < nums; i++)
                {
                    this.isFlagByOpenAccount     = false;
                    this.secondsOpenAccount      = 0;
                    Tuple <string, string> infos = AutoCreateAnyCode.GetUserName1();
                    AccountUsers user            = new AccountUsers
                    {
                        CellPhone    = infos.Item2,
                        Pwd          = "111111",
                        RealName     = infos.Item1,
                        BankCardNo   = AutoCreateAnyCode.GetBankCardNo(),
                        CredentialNo = AutoCreateAnyCode.GetCredentialNo(),
                        UserMac      = AutoCreateAnyCode.GetMacAddressByNetworkInformation(),
                        CgCellPhone  = AutoCreateAnyCode.GetCellPhone(),
                        RigisterTime = DateTime.Now.ToString("yyyyMMdd HH:mm:ss")
                    };
                    if (!this.jymService.CheckCellPhone(user.CellPhone).Result)
                    {
                        continue;
                    }
                    this.btn_opne.Enabled = false;
                    user.RealName         = user.RealName == "" ? AutoCreateAnyCode.GetUserName() : user.RealName;
                    user.InviteBy         = user.InviteBy == "" ? "22222" : user.InviteBy;
                    user.CgCellPhone      = user.CgCellPhone == "" ? AutoCreateAnyCode.GetCellPhone() : user.CgCellPhone;
                    //注册认证
                    int i1 = i + 1;
                    AccountUsers successAccountUsers = this.Register(user).Result;
                    if (successAccountUsers != null)
                    {
                        //存管开户
                        bool result = this.bankPageCommon.OpenBankAccount(successAccountUsers, this.webBrowser_OpenAccount, () =>
                        {
                            this.lbl_showOpen.Text   = $"正在批量开户,请耐心等待.......   已经开户数量{i1}";
                            this.isFlagByOpenAccount = true;
                        }).Result;
                    }
                    else
                    {
                        this.lbl_showOpen.Text = $"第{i1}个用户开户失败";
                    }
                    while (!this.isFlagByOpenAccount)
                    {
                        Thread.Sleep(2000);
                        this.secondsOpenAccount += 2000;
                        if (this.secondsOpenAccount >= 35000)
                        {
                            this.lbl_showOpen.Text = $"第{i1}个用户开户失败";
                            break;
                        }
                    }
                }
                this.lbl_showOpen.Text        = "批量开户结束";
                this.btn_opne.Enabled         = true;
                this.toolStripButton1.Enabled = true;
            }));

            batchOpenAccount.ShowDialog();
        }