Esempio n. 1
0
        public static string ExtractWarnMsg(CefFrame frame)
        {
            string warnMsg = "";

            if (frame != null)
            {
                warnMsg = CefFrameHelper.GetMsgByJs(frame, "mydoc.getElementsByClassName('warnMsg')[0].innerHTML");
            }
            LogManager.WriteLog("warnMsg:" + warnMsg);
            return(warnMsg);
        }
Esempio n. 2
0
        private void tbV3_Init_reg()
        {
            if (IsInit_tbV3_loaded)
            {
                return;
            }
            IsInit_tbV3_loaded = true;

            Operation fill_mobile = new Operation(MainCefFrame)
            {
                CurrentUrl     = "http://reg.taobao.com/member/reg/fill_mobile.htm",
                index          = 1.1,
                PerviousStatus = BusinessStatus.Tb_reg_v3_member_reg_fill_mobile_before,
                NextStatus     = BusinessStatus.Tb_reg_v3_member_reg_fill_mobile,
            };

            fill_mobile.OperationHandler += (s, e) => {
                string js2run = "document.getElementsByClassName('f12')[1].getElementsByTagName('a')[0].click()";
                CefFrameHelper.ExcuteJs(MainCefFrame, js2run);
            };


            //填会员信息
            Operation new_register = new Operation(MainCefFrame)
            {
                CurrentUrl     = "http://reg.taobao.com/member/reg/fill_email.htm",
                index          = 1.2,
                PerviousStatus = BusinessStatus.Tb_reg_v3_member_reg_fill_mobile,
                NextStatus     = BusinessStatus.Tb_reg_v3_member_reg_fill_email,
                Deadline       = ConfigHelper.GetIntValue("TBV3注册第一步耗时") * 1000 * 60,
            };

            new_register.OperationHandler += (s, e) => {
                #region ==========填会员信息&过手机验证==========

                //获取ID=J_CheckCode 的data-imgurl属性的值url
                //识别url中的图片

                string js3run = "document.getElementById('J_CheckCodeInput').focus();";

                CefFrameHelper.ExcuteJs(MainCefFrame, js3run);
                new Thread(() => {
                    Thread.Sleep(ConfigHelper.GetIntValue("等待验证码时间(秒)") * 1000);
                    var isVCodeOk = false;
                    for (int j = 0; !isVCodeOk && j < 3; j++)
                    {
                        bool vcodeFrom51 = false;
                        string srcs      = "";
                        for (int i = 0; i < 3; i++)
                        {
                            //srcs = CefFrameHelper.GetUrlListByHapId(MainCefFrame, "J_CheckCodeContainer", "div", "data-imgurl").FirstOrDefault();


                            srcs = CefFrameHelper.GetUrlListByHapId(MainCefFrame, "J_CheckCodeImg1", "img", "src").FirstOrDefault();
                            srcs = srcs.Replace("&amp;", "&");
                            if (!string.IsNullOrEmpty(srcs))
                            {
                                break;
                            }
                        }
                        if (string.IsNullOrEmpty(srcs))
                        {
                            LogManager.WriteLog("重复3次后仍然无法获取图片。");
                            return;
                        }

                        string returnMess;
                        vcodeFrom51 = Vcode.GetVcodeFormImageUrl(srcs, out returnMess);
                        if (!vcodeFrom51)
                        {
                            continue;
                        }

                        string js2run = "document.getElementById('J_Email').value='{0}';".With(currentHaoZi.zfbEmail) +
                                        "document.getElementById('J_CheckCodeInput').value='{0}';".With(returnMess) +
                                        "document.getElementById('J_BtnEmailForm').click();";

                        CefFrameHelper.ExcuteJs(MainCefFrame, js2run);

                        #region    ==================过验证码====================



                        new Thread(() => {
                            Thread.Sleep(3000);
                            var res = "";

                            for (int i = 0; i < 3; i++)
                            {
                                res = CefFrameHelper.GetMsgByJs(MainCefFrame, "document.getElementById('J_MobileCheck').getAttribute('style')");
                                if (!string.IsNullOrEmpty(res))
                                {
                                    break;
                                }
                                Thread.Sleep(1000);
                            }
                            if (res.Contains("block"))
                            {
                                isVCodeOk = true;
                            }
                            checkVcodeOkEvent.Set();
                        }).Start();
                        checkVcodeOkEvent.Reset();
                        checkVcodeOkEvent.WaitOne(9000);
                        #endregion

                        if (isVCodeOk)
                        {
                            break;
                        }
                    }

                    //手机验证

                    new Thread(() => {
                        try {
                            phoneVailed(state);
                        } catch (Exception e2) {
                            LogManager.WriteLog(e2.StackTrace + e2.ToString());
                        }
                    }).Start();
                    //
                }).Start();
                #endregion
            };

            //账户注册-1.设置登录名-接收邮件
            Operation email_sent = new Operation(MainCefFrame)
            {
                PerviousStatus = BusinessStatus.Tb_reg_v3_member_reg_fill_email,
                NextStatus     = BusinessStatus.Tb_reg_v3_member_reg_email_sent,
                CurrentUrl     = "http://reg.taobao.com/member/reg/email_sent.htm",
                index          = 2,
                note           = "账户注册-1.设置登录名-接收邮件"
            };
            email_sent.OperationHandler += (s, e) => {
                //  BeginInvoke(new Action(() => {
                Thread.Sleep(5000);
                var url = EmailCheck("新用户确认通知信", "request_dispatcher.htm");
                MainCefFrame.LoadUrl(url);
                //   }));
            };

            Operation fill_user_info = new Operation(MainCefFrame)
            {
                PerviousStatus = BusinessStatus.Tb_reg_v3_member_reg_email_sent,
                NextStatus     = BusinessStatus.Tb_reg_v3_Member_reg_fill_user_info,
                CurrentUrl     = "http://reg.taobao.com/member/reg/fill_user_info.htm",
                index          = 3,
                note           = "账户注册-2.填写账户信息"
            };
            fill_user_info.OperationHandler += (s, e) => {
                string js2runS1 =
                    "document.getElementById('J_Password').value='{0}';".With(currentHaoZi.tbPwd) +
                    "document.getElementById('J_RePassword').value='{0}';".With(currentHaoZi.tbPwd) +
                    "document.getElementById('J_Nick').value='{0}';".With(currentHaoZi.tbName) +
                    "document.getElementById('J_BtnInfoForm').click();";
                CefFrameHelper.ExcuteJs(MainCefFrame, js2runS1);
            };


            Operation login_unusual = new Operation(MainCefFrame)
            {
                PerviousStatus = BusinessStatus.Tb_reg_v3_Member_reg_fill_user_info,
                NextStatus     = BusinessStatus.Tb_reg_v3_member_reg_reg_success,
                CurrentUrl     = "http://login.taobao.com/member/login_unusual.htm",
                //http://login.taobao.com/member/login_unusual.htm
                index = 4.1,
                note  = "登录身份验证 ",
            };
            login_unusual.OperationHandler += (s, e) => {
                toolStripMenuItem20_Click(this, new EventArgs());//过登录验证
            };


            Operation member_reg_reg_success = new Operation(MainCefFrame)
            {
                PerviousStatus = BusinessStatus.Tb_reg_v3_Member_reg_fill_user_info,
                NextStatus     = BusinessStatus.Tb_reg_v3_member_reg_reg_success,
                CurrentUrl     = "http://reg.taobao.com/member/reg/reg_success.htm",
                index          = 4.2,
                note           = "淘宝注册成功 填写收货地址",
            };
            member_reg_reg_success.OperationHandler += (s, e) => {
                //var url = "http://member1.taobao.com/member/fresh/account_management.htm";

                var url = "http://member1.taobao.com/member/fresh/deliver_address.htm";
                MainCefFrame.LoadUrl(url);
            };


            Operation deliver_address = new Operation(MainCefFrame)
            {
                PerviousStatus = BusinessStatus.Tb_reg_v3_member_reg_reg_success,
                NextStatus     = BusinessStatus.Tb_reg_v3_deliver_address,
                CurrentUrl     = "http://member1.taobao.com/member/fresh/deliver_address.htm",
                index          = 33,
                note           = "添加收货地址 判断是否激活支付宝  ",
            };
            deliver_address.OperationHandler += (s, e) => {
                var js2run = RandomAddressPlace();
                CefFrameHelper.ExcuteJs(MainCefFrame, js2run);
                new Thread(() => {
                    Application.DoEvents();
                    Thread.Sleep(3000);

                    bool activeZFB = ConfigHelper.GetBoolValue("是否激活支付宝");
                    if (activeZFB)
                    {
                        var url = "http://member1.taobao.com/member/fresh/account_management.htm";
                        MainCefFrame.LoadUrl(url);
                    }
                    else
                    {
                        FinishOneResgister();
                    }
                }).Start();
            };


            Operation member_fresh_account_management = new Operation(MainCefFrame)
            {
                PerviousStatus = BusinessStatus.Tb_reg_v3_deliver_address,
                NextStatus     = BusinessStatus.Tb_reg_v3_member_fresh_account_management,
                CurrentUrl     = "http://member1.taobao.com/member/fresh/account_management.htm",
                index          = 5,
                note           = "找到 包含 立即补全 的链接  前往"
            };

            member_fresh_account_management.OperationHandler += (s, e) => {
                string js2runS1 = "document.getElementsByClassName('kv_item')[2].getElementsByTagName('a')[0].click();";
                CefFrameHelper.ExcuteJs(MainCefFrame, js2runS1);
            };


            Operation account_reg_complete_complete = new Operation(MainCefFrame)
            {
                PerviousStatus = BusinessStatus.Tb_reg_v3_member_fresh_account_management,
                NextStatus     = BusinessStatus.Tb_reg_v3_account_reg_complete_complete,
                CurrentUrl     = "https://memberprod.alipay.com/account/reg/complete/complete.htm",
                index          = 6,
                note           = "开通支付宝 填支付密码"
            };
            account_reg_complete_complete.OperationHandler += (s, e) => {
                string js2runS1 =
                    "         document.getElementById('queryPwd').value='{0}';".With(currentHaoZi.zfbPwd) +
                    "document.getElementById('queryPwdConfirm').value='{0}';".With(currentHaoZi.zfbPwd) +
                    "document.getElementById('payPwd').value='{0}';".With(currentHaoZi.zfbPayPwd) +
                    "document.getElementById('payPwdConfirm').value='{0}';".With(currentHaoZi.zfbPayPwd) +
                    "document.getElementById('realName').value='{0}';".With(currentHaoZi.realname) +
                    "document.getElementById('IDCardNo').value='{0}';".With(currentHaoZi.zfbSFZ) +
                    "document.getElementById('J-complete-form').submit();";
                CefFrameHelper.ExcuteJs(MainCefFrame, js2runS1);
            };


            Operation asset_paymethod_paymethod = new Operation(MainCefFrame)
            {
                PerviousStatus = BusinessStatus.Tb_reg_v3_account_reg_complete_complete,
                NextStatus     = BusinessStatus.Tb_reg_v3_asset_paymethod_paymethod,
                CurrentUrl     = "https://zht.alipay.com/asset/paymethod/paymethod.htm",
                index          = 7
            };

            asset_paymethod_paymethod.OperationHandler += (s, e) => {
                MainCefFrame.LoadUrl("https://benefitprod.alipay.com/asset/paymethod/bindassetcard.htm");
            };


            Operation account_reg_success = new Operation(MainCefFrame)
            {
                PerviousStatus = BusinessStatus.Tb_reg_v3_asset_paymethod_paymethod,
                NextStatus     = BusinessStatus.Tb_reg_v3_account_reg_success,
                CurrentUrl     = "https://memberprod.alipay.com/account/reg/success.htm",
                index          = 8,
                note           = "开通支付宝成功"
            };

            account_reg_success.OperationHandler += (s, e) => {
                // new Thread(() => {

                FinishOneResgister();
                //  }).Start();
            };



            this.opsList.Add(fill_mobile);
            this.opsList.Add(new_register);
            this.opsList.Add(email_sent);
            this.opsList.Add(login_unusual);

            this.opsList.Add(fill_user_info);
            this.opsList.Add(member_reg_reg_success);
            this.opsList.Add(deliver_address);
            this.opsList.Add(member_fresh_account_management);
            this.opsList.Add(account_reg_complete_complete);
            this.opsList.Add(asset_paymethod_paymethod);
            this.opsList.Add(account_reg_success);
        }
Esempio n. 3
0
        //zfb 过验证
        private void mobilephoeOfzfb2()
        {
            //1.login
            GlobalVar.sms = IMySmsFactory.Build(ConfigHelper.GetValue("smsConfigzfb"));
            GlobalVar.sms.GetConfigOfSms();//SmsConfigHelper.GetConfigOfSms();
            //if (!SmsApi.logined) {
            //    LogManager.WriteLog("登录失败");
            //    return;
            //}
            //2.
            string phoneNum = "";

            Application.DoEvents();
            //  lock (changeTel1) {
            bool getPhoneOK = false;
            bool isVcodeOk  = false;

            int TryPhoneNum          = int.Parse(ConfigHelper.GetValue("TryPhoneNum"));
            int TryPhoneNumInterTime = int.Parse(ConfigHelper.GetValue("TryPhoneNumInterTime"));

            for (int i = 0; i < TryPhoneNum; i++)
            {
                Thread.Sleep(2000);
                //2.1
                if (MainForm.state != BusinessStatus.emailCheck)
                {
                    LogManager.WriteLog("当前不是获取手机号码 的页面了.");
                    break;
                }

                //2.2 获取手机

                //GetPhone(ref string phoneNum,string serverid) {

                //支付宝注册
                getPhoneOK = GetPhone(ref phoneNum, SmsServer.zfb_reg_vcode);
                if (!getPhoneOK)
                {
                    continue;
                }

                //2.3 填充手机
                string js2run = "var mydoc=window.frames[2].document;";
                js2run +=
                    "mydoc.getElementById('J-secure-mobile').value = '{0}';".With(phoneNum) +
                    "mydoc.getElementById('J-getCheckcodeBtn').click();";
                CefFrameHelper.ExcuteJs(MainCefFrame, js2run);
                LogManager.WriteLog("{0} is fill ".With(phoneNum));
                #region MyRegion

                // 2.4 检测手机是否可用
                LogManager.WriteLog("check valueOfStyle");
                string valueOfStyle       = "";
                bool   is_valueOfStyle_ok = false;
                for (int j = 0; j < 3; j++)
                {
                    // valueOfStyle = CefFrameHelper.GetUrlListByHapId(MainCefFrame, "J-resend-check-code", "div", "class").FirstOrDefault();
                    valueOfStyle = CefFrameHelper.GetMsgByJs(MainCefFrame, "mydoc.getElementById('J-resend-check-code').getAttribute('class')");
                    //.GetUrlListByHapId(MainCefFrame, "J-resend-check-code", "div", "class").FirstOrDefault();

                    //
                    LogManager.WriteLog("valueOfStyle:" + valueOfStyle);
                    is_valueOfStyle_ok = (valueOfStyle != null && !valueOfStyle.Contains("fn-hide"));
                    if (is_valueOfStyle_ok)
                    {
                        break;
                    }

                    Application.DoEvents();
                    Thread.Sleep(2000);
                }
                if (!is_valueOfStyle_ok)
                {
                    LogManager.WriteLog("手机号码 {1} 不可用.重新获取,{0}".With(7 - i, phoneNum));
                    //释放单个手机
                    //   SmsApi.ReleasePhone(phoneNum, "1365");
                    continue;
                }

                #endregion

                //2.5 手机可用则接收短信

                LogManager.WriteLog("检查通过,手机号码 {0} 可用.".With(phoneNum));
                string vcodeNum = "";
                //  isVcodeOk = SmsConfigHelper.GetSmsOfPhone(phoneNum, ref vcodeNum,SmsServer.zfb_reg_vcode);
                //    isVcodeOk = SmsConfigHelper.GetSmsOfPhone(phoneNum, ref vcodeNum, SmsServer.zfb_reg_vcode);
                isVcodeOk = SmsConfigHelper.GetSmsOfPhone(phoneNum, ref vcodeNum, SmsServer.zfb_reg_vcode);

                if (!isVcodeOk)
                {
                    LogManager.WriteLog("没有收到验证码,返回重新接收");

                    //页面上点击 返回修改手机号码
                    //string jsOfChangePhoneNum = "document.getElementById('J_RewritePhone').click()';";
                    //CefFrameHelper.ExcuteJs(MainCefFrame, jsOfChangePhoneNum);
                    continue;
                }
                //2.6 接收到短信则提交
                //                document.getElementById('J_PhoneCheckCode').value='295768';
                //document.getElementsByClassName('btn-s')[0].click();

                string jsOfSubmitVcode = "var mydoc=window.frames[2].document;";
                jsOfSubmitVcode += "mydoc.getElementById('J-checkcode').value='{0}';".With(vcodeNum) +
                                   "mydoc.getElementById('J-submit-btn').click();";
                CefFrameHelper.ExcuteJs(MainCefFrame, jsOfSubmitVcode);//提交验证码
                LogManager.WriteLog("tel {0} ".With(phoneNum));
                GlobalVar.phoneNum = phoneNum;

                break;
            }
            //     }).Start();
            //   };
        }