Example #1
0
        /// <summary>
        /// 登陆验证码刷新
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void llLoginVcode_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            textBoxVcode1.Text = "";

            if (string.IsNullOrEmpty(BaiduLogin.m_codeString))
            {
                pictureBoxVcode1.ImageLocation = "";
            }
            else
            {
                pictureBoxVcode1.ImageLocation = Vcode.GetLoginVcodeUrl(BaiduLogin.m_codeString);
                llLoginVcode.Visible           = true;
            }
        }
Example #2
0
        /// <summary>
        /// 百度登陆判断
        /// </summary>
        private void Login()
        {
            this.BeginInvoke(labledelegate, new object[] { labelWarning, "正在登陆百度账号..." });

            BaiduLogin baiduLogin = new BaiduLogin();

            //登陆
            string content = baiduLogin.Login(m_loginName, m_passWord);

            if (BaiduLogin.m_isLogin)
            {
                BaiduLogin.m_codeString = string.Empty;

                BaiduLogin.m_verifyCode = string.Empty;

                this.BeginInvoke(labledelegate, new object[] { labelWarning, "百度账号登陆成功!" });

                m_replyNum = 0;
            }
            else
            {
                int errNo = Convert.ToInt32(Regex.Match(content, m_loginErrNo).ToString());

                //验证码错误
                if (errNo == TieBaError.ErrNo257 || errNo == TieBaError.ErrNo6)
                {
                    BaiduLogin.m_codeString = Regex.Match(content, m_loginVcodeRegex).ToString();

                    pictureBoxVcode1.ImageLocation = Vcode.GetLoginVcodeUrl(BaiduLogin.m_codeString);

                    this.BeginInvoke(labledelegate, new object[] { labelWarning, "请输入登陆验证码!" });

                    if (thread != null)
                    {
                        thread.Abort();
                    }
                }
                //ip地址被禁
                else if (errNo == TieBaError.ErrNo13)
                {
                    this.BeginInvoke(labledelegate, new object[] { labelWarning, "IP地址被禁。" });

                    if (thread != null)
                    {
                        thread.Abort();
                    }
                }
                //重新登陆
                else if (errNo == TieBaError.ErrNo2101 || errNo == TieBaError.ErrNo260005)
                {
                    this.BeginInvoke(labledelegate, new object[] { labelWarning, "登陆异常,正在重新登陆..." });

                    //重新登陆,必须回帖数等于账号可回最大回帖数
                    m_replyNum = m_replyMaxNum;

                    ChangeBaiduLogin();
                }
                else if (errNo == TieBaError.ErrNo100023)
                {
                    this.BeginInvoke(labledelegate, new object[] { labelWarning, "回帖异常,请结束回帖" });

                    LogManager.Instance.WriteLog(LogFileEnum.error, "异常:" + content);

                    if (thread != null)
                    {
                        thread.Abort();
                    }
                }
                //异常
                else
                {
                    this.BeginInvoke(labledelegate, new object[] { labelWarning, "百度账号异常,正在更换百度账号..." });

                    //更新账号异常
                    //ClientPost.UpdateAccountAbnormal(m_loginName, errNo);

                    LogManager.Instance.WriteLog(LogFileEnum.error, "异常:" + content);

                    //重新登陆,必须回帖数等于账号可回最大回帖数
                    m_replyNum = m_replyMaxNum;

                    ChangeBaiduLogin();
                }
            }
        }