Пример #1
0
 /// <summary>
 /// 发送验证码回调函数
 /// </summary>
 /// <param name="state"></param>
 /// <param name="data"></param>
 private void ButtonVerify_Callback(bool state, byte[] data)
 {
     ClassStatic.Result resultData = ClassStatic.GetResult(data);
     this.Invoke(new Action(() => {
         if (resultData != null)
         {
             if (resultData.ret == "true")
             {
                 buttonVerify.ForeColor = Color.Black;
                 buttonVerify.BackColor = Color.WhiteSmoke;
                 buttonVerify.Cursor    = Cursors.No;
                 buttonVerify.Text      = timeVerify.ToString();
                 timerVerify.Start();
             }
             else
             {
                 LabelTipShow(resultData.msg);
             }
         }
         else
         {
             LabelTipShow("发送验证码失败");
         }
     }));
 }
Пример #2
0
        /// <summary>
        /// 修改密码按钮
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void buttonSubmit_Click(object sender, EventArgs e)
        {
            if (!ClassStatic.tcpClient.IsConnected)
            {
                return;
            }
            string account  = inputAccount.Text;
            string verify   = inputVerify.Text;
            string password = inputPassword.Text;

            if (!ClassStatic.IsPhone(account))
            {
                LabelTipShow("请输入正确的手机号");
                return;
            }
            if (verify.Length != 6)
            {
                LabelTipShow("请输入正确的验证码");
                return;
            }
            if (!ClassStatic.IsComplexPass(password))
            {
                LabelTipShow("请输入8位以上的复杂密码");
                return;
            }

            ClassStatic.ClientData clientData = new ClassStatic.ClientData(account, password, verify);
            Action <bool, byte[]>  action     = new Action <bool, byte[]>(ButtonSubmit_Callback);

            ClassStatic.tcpClient.Send(107, ClassStatic.SetClientDataByte(clientData), action);
        }
        private void labelLogin_Click(object sender, EventArgs e)
        {
            labelLogin.Focus();
            if (!ClassStatic.tcpClient.IsConnected)
            {
                return;
            }

            string account  = inputAccount.Text;
            string password = inputPassword.Text;

            if (!ClassStatic.IsPhone(account))
            {
                FormLogin.formLogin.LabelTipShow("请输入正确的手机号再登录");
                return;
            }
            if (password.Length == 0)
            {
                FormLogin.formLogin.LabelTipShow("请输入密码后再登录");
                return;
            }

            ClassStatic.ClientData clientData = new ClassStatic.ClientData(account, password);
            Action <bool, byte[]>  action     = new Action <bool, byte[]>(LabelLogin_Callback);

            ClassStatic.tcpClient.Send(101, ClassStatic.SetClientDataByte(clientData), action);
        }
        public void InitializeControl()
        {
            ForeColor          = Color.Black;
            inputAccount.Tips  = "请输入手机号";
            inputPassword.Tips = "请输入至少8位的密码";

            // 账号
            string account = ClassStatic.GetConfig("account");
            // 头像
            string portrait = ClassStatic.GetConfig("portrait");
            // 密码
            string password = ClassStatic.GetConfig("password");
            // 记住密码
            string remember = ClassStatic.GetConfig("remember");

            ClassStatic.portraitPid     = (portrait == "") ? 0 : Convert.ToInt32(portrait);
            controlPortraitBox.Portrait = ClassStatic.portraitPid;

            if (ClassStatic.IsPhone(account))
            {
                inputAccount.Text = account;
                if (ClassStatic.IsComplexPass(password))
                {
                    inputPassword.Text = password;
                    if (remember == "true")
                    {
                        checkBoxRemember.Checked = true;
                    }
                }
            }
        }
 /// <summary>
 /// 登录回调函数
 /// </summary>
 /// <param name="state"></param>
 /// <param name="data"></param>
 private void LabelLogin_Callback(bool state, byte[] data)
 {
     ClassStatic.Result resultData = ClassStatic.GetResult(data);
     if (state && resultData != null)
     {
         if (resultData.ret == "true")
         {
             this.Invoke(new Action(() => {
                 string remember = checkBoxRemember.Checked ? "true" : "false";
                 ClassStatic.SetConfig("account", inputAccount.Text);
                 ClassStatic.SetConfig("password", inputPassword.Text);
                 ClassStatic.SetConfig("remember", remember);
                 FormLogin.formLogin.LoginSuccess(inputAccount.Text);
             }));
         }
         else
         {
             FormLogin.formLogin.LabelTipShow(resultData.msg);
         }
     }
     else
     {
         FormLogin.formLogin.LabelTipShow("登录失败,请检查网络");
     }
 }
        private void TimerQrcode_Callback(bool state, byte[] data)
        {
            ClassStatic.Result resultData = ClassStatic.GetResult(data);
            System.Diagnostics.Debug.WriteLine(resultData.ret);
            if (state && resultData != null)
            {
                switch (resultData.ret)
                {
                case "0":
                    //登录成功
                    this.Invoke(new Action(() => {
                        FormLogin.formLogin.LoginSuccess(resultData.data);
                        pictureQRcode.Image.Dispose();
                        pictureQRcode.Image = Properties.Resources.qrcodeInvalid;
                        labelTip.Text       = "二维码已失效";
                        timerQrcode.Stop();
                    }));
                    break;

                case "1":
                    //二维码未失效
                    break;

                case "2":
                    this.Invoke(new Action(() => {
                        labelTip.Text = "扫码成功,等待用户确定";
                    }));
                    break;

                case "4":
                    this.Invoke(new Action(() => {
                        pictureQRcode.Image.Dispose();
                        pictureQRcode.Image = Properties.Resources.qrcodeInvalid;
                        labelTip.Text       = "没有绑定手机号,请先注册";
                        timerQrcode.Stop();
                    }));
                    break;

                default:
                    //二维码已失效
                    this.Invoke(new Action(() => {
                        pictureQRcode.Image.Dispose();
                        pictureQRcode.Image = Properties.Resources.qrcodeInvalid;
                        labelTip.Text       = "二维码已失效";
                        timerQrcode.Stop();
                    }));
                    break;
                }
            }
            else
            {
                this.Invoke(new Action(() => {
                    pictureQRcode.Image.Dispose();
                    pictureQRcode.Image = Properties.Resources.qrcodeInvalid;
                    labelTip.Text       = "获取二维码失败";
                    timerQrcode.Stop();
                }));
            }
        }
Пример #7
0
        /// <summary>
        /// 发送验证码点击事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void buttonVerify_Click(object sender, EventArgs e)
        {
            if (!ClassStatic.tcpClient.IsConnected || buttonVerify.Cursor == Cursors.No)
            {
                return;
            }

            string account = inputAccount.Text;

            if (!ClassStatic.IsPhone(account))
            {
                LabelTipShow("请输入正确的手机号再试");
                return;
            }

            Action <bool, byte[]> action = new Action <bool, byte[]>(ButtonVerify_Callback);

            ClassStatic.tcpClient.Send(106, System.Text.Encoding.UTF8.GetBytes(account), action);
        }
Пример #8
0
        static void Main(string[] args)
        {
            unchecked
            {
                int readedValue = int.MaxValue / 300;

                if (args.Length == 0 || string.IsNullOrEmpty(args[0]) || args[0].Equals("Class"))
                {
                    GC.Collect(GC.MaxGeneration);
                    GC.WaitForFullGCComplete();


                    Console.WriteLine(ClassStatic.SampleClass(readedValue, 30));
                }
                if (args.Length == 0 || string.IsNullOrEmpty(args[0]) || args[0].Equals("Struct"))
                {
                    // Console.ReadKey();
                    GC.Collect(GC.MaxGeneration);
                    GC.WaitForFullGCComplete();

                    Console.WriteLine(StructStatic.SampleStruct(readedValue, 30));
                }

                if (args.Length == 0 || string.IsNullOrEmpty(args[0]) || args[0].Equals("ClassLarge"))
                {
                    GC.Collect(GC.MaxGeneration);
                    GC.WaitForFullGCComplete();


                    Console.WriteLine(ClassLargeStatic.SampleClass(readedValue, 30));
                }
                if (args.Length == 0 || string.IsNullOrEmpty(args[0]) || args[0].Equals("StructLarge"))
                {
                    // Console.ReadKey();
                    GC.Collect(GC.MaxGeneration);
                    GC.WaitForFullGCComplete();

                    Console.WriteLine(StructLargeStatic.SampleStruct(readedValue, 30));
                }
            }
        }
        /// <summary>
        /// 找回密码按钮提交回调函数
        /// </summary>
        /// <param name="state"></param>
        /// <param name="data"></param>
        private void ButtonSubmit_Callback(bool state, byte[] data)
        {
            ClassStatic.Result resultData = ClassStatic.GetResult(data);

            if (resultData != null)
            {
                if (resultData.ret == "true")
                {
                    FormLogin.formLogin.LabelTipShow("修改密码成功,正在跳转...", false);
                    this.Invoke(new Action(() => {
                        labelBackLogin_Click(labelBackLogin, null);
                    }));
                }
                else
                {
                    FormLogin.formLogin.LabelTipShow(resultData.msg);
                }
            }
            else
            {
                FormLogin.formLogin.LabelTipShow("修改密码失败");
            }
        }
Пример #10
0
        /// <summary>
        /// 注册账号按钮提交回调函数
        /// </summary>
        /// <param name="state"></param>
        /// <param name="data"></param>
        private void ButtonRegister_Callback(bool state, byte[] data)
        {
            ClassStatic.Result resultData = ClassStatic.GetResult(data);

            if (resultData != null)
            {
                if (resultData.ret == "true")
                {
                    FormLogin.formLogin.LabelTipShow("注册成功,正在跳转", false);
                    this.Invoke(new Action(() => {
                        label5_Click(label5, null);
                    }));
                }
                else
                {
                    FormLogin.formLogin.LabelTipShow(resultData.msg);
                }
            }
            else
            {
                FormLogin.formLogin.LabelTipShow("注册失败");
            }
        }
Пример #11
0
        /// <summary>
        /// 找回密码按钮提交回调函数
        /// </summary>
        /// <param name="state"></param>
        /// <param name="data"></param>
        private void ButtonSubmit_Callback(bool state, byte[] data)
        {
            ClassStatic.Result resultData = ClassStatic.GetResult(data);

            this.Invoke(new Action(() => {
                if (resultData != null)
                {
                    if (resultData.ret == "true")
                    {
                        buttonVerify.Enabled = false;
                        buttonSubmit.Enabled = false;
                        LabelTipShow("修改密码成功", false, false);
                    }
                    else
                    {
                        LabelTipShow(resultData.msg);
                    }
                }
                else
                {
                    LabelTipShow("修改密码失败");
                }
            }));
        }
Пример #12
0
        private void TimerQrcode_Callback(bool state, byte[] data)
        {
            ClassStatic.Result resultData = ClassStatic.GetResult(data);
            if (state && resultData != null)
            {
                switch (resultData.ret)
                {
                case "0":
                    //扫码成功
                    this.Invoke(new Action(() => {
                        labelTip.Text    = "解绑成功";
                        ClassStatic.bind = "";
                        timerQrcode.Stop();
                    }));
                    break;

                case "1":
                    //二维码未失效
                    break;

                case "2":
                    this.Invoke(new Action(() => {
                        labelTip.Text = "扫码成功,等待用户确定";
                    }));
                    break;

                case "4":
                    this.Invoke(new Action(() => {
                        pictureQRcode.Image.Dispose();
                        pictureQRcode.Image = Properties.Resources.qrcodeInvalid;
                        labelTip.Text       = "未绑定到手机号";
                        timerQrcode.Stop();
                    }));
                    break;

                case "5":
                    this.Invoke(new Action(() => {
                        pictureQRcode.Image.Dispose();
                        pictureQRcode.Image = Properties.Resources.qrcodeInvalid;
                        labelTip.Text       = "解绑失败";
                        timerQrcode.Stop();
                    }));
                    break;

                default:
                    //二维码已失效
                    this.Invoke(new Action(() => {
                        pictureQRcode.Image.Dispose();
                        pictureQRcode.Image = Properties.Resources.qrcodeInvalid;
                        labelTip.Text       = "二维码已失效";
                        timerQrcode.Stop();
                    }));
                    break;
                }
            }
            else
            {
                this.Invoke(new Action(() => {
                    pictureQRcode.Image.Dispose();
                    pictureQRcode.Image = Properties.Resources.qrcodeInvalid;
                    labelTip.Text       = "获取二维码失败";
                    timerQrcode.Stop();
                }));
            }
        }