示例#1
0
        //------------------------------[Button]------------------------------

        /// <summary>Starts a Login Request</summary>
        private void LoginButton_Click(object sender, System.EventArgs e)
        {
            Enabled = false;
            Form    = new ServerContactForm("Logging in to the server", "Please wait...");

            try { Connection = new LBLConnection(IPBox.Text, int.Parse(PortBox.Text)); }
            catch (System.Exception) { MessageBox.Show("Unable to parse " + PortBox.Text + " to an integer", "LBL", MessageBoxButtons.OK, MessageBoxIcon.Error); return; }

            Username = UsernameTXB.Text;
            Password = PasswordTXB.Text;
            Form.Show();
            LoginBW.RunWorkerAsync();
        }
示例#2
0
        private void Logingiwifiuser()// ##测试数据
        {
            //如果网卡是正在连接的情况   D//////////////////////////////////////////////////////////////////////////////////////////////////////////
            if (client.Interfaces[0].NetworkInterface.OperationalStatus == OperationalStatus.Testing)
            {
                MessageBox.Show("flag");
            }
            //timeOut(2000);
            while (client.Interfaces[0].NetworkInterface.OperationalStatus == OperationalStatus.Down)
            {
                Application.DoEvents();
            }
            try
            {
                long i = long.Parse(LoginInternet.loginUser);
                if (LoginInternet.loginUser.Length != 11)
                {
                    skinComboBox1.Text = "关闭循环检测";
                    SkinButton3_Click(null, null);
                    MessageBox.Show("检测到用户名位数不正确", "登录组件", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    skinComboBox1.Text = "关闭循环检测";
                    SkinButton3_Click(null, null);
                    return;
                }
                if (LoginInternet.UserPassword.Length == 0)
                {
                    skinComboBox1.Text = "关闭循环检测";
                    SkinButton3_Click(null, null);
                    MessageBox.Show("密码不可以为0位", "登录组件", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    skinComboBox1.Text = "关闭循环检测";
                    SkinButton3_Click(null, null);
                    return;
                }
            }
            catch (Exception)
            {
                MessageBox.Show("检测到登录名非法");
                return;
            }
            LoginBW.Navigate(new Uri("http://login.gwifi.com.cn/cmps/admin.php/api/login"), false);
            LoginBW.Refresh();

            while (LoginBW.ReadyState != WebBrowserReadyState.Complete) // 最新检查是否加载完毕替代延时
            {
                System.Windows.Forms.Application.DoEvents();
            }

            HtmlElement username = LoginBW.Document.GetElementById("first_name");
            HtmlElement password = LoginBW.Document.GetElementById("first_password");
            HtmlElement login    = LoginBW.Document.GetElementById("first_button");

            if (username != null && password != null && login != null)
            {
                username.SetAttribute("value", LoginInternet.loginUser);
                password.SetAttribute("value", LoginInternet.UserPassword);
                // login.InvokeMember("click");



                login.InvokeMember("click");
            }
            else
            {
                LoginBW.Navigate(new Uri("http://login.gwifi.com.cn/cmps/admin.php/api/login"), false);
                LoginBW.Refresh();
                while (LoginBW.ReadyState != WebBrowserReadyState.Complete) // 最新检查是否加载完毕替代延时
                {
                    System.Windows.Forms.Application.DoEvents();
                }
                username = LoginBW.Document.GetElementById("first_name");
                password = LoginBW.Document.GetElementById("first_password");
                login    = LoginBW.Document.GetElementById("first_button");

                if (username != null && password != null && login != null)
                {
                    username.SetAttribute("value", LoginInternet.loginUser);
                    password.SetAttribute("value", LoginInternet.UserPassword);
                    login.InvokeMember("click");
                    return;
                }

                MessageBox.Show("系统检测到程序可能不在giwifi环境之下,或开启代理", "有几率是误报情况");
                InternetLight();
            }
        }