Exemplo n.º 1
0
        private void client_CheckUserCompleted(object sender, CheckUserCompletedEventArgs args)
        {
            string       ip     = GetIp();
            BoolResponse result = args.Result;

            if (result.Result)
            {
                if (this.checkBox1.Checked)
                {
                    Beauty.Common.Helper.RegisterKey("Userinfo", this.textBox1.Text.Trim() + "|" + this.textBox2.Text.Trim() + "|1");
                }
                else
                {
                    Beauty.Common.Helper.RegisterKey("Userinfo", this.textBox1.Text.Trim() + "|" + this.textBox2.Text.Trim() + "|0");
                }

                Beauty.App.BeautyService.WebUser user = client.GetUser(this.textBox1.Text.Trim());

                if (!user.IsLogin)
                {
                    //client.LoginActive(this.textBox1.Text.Trim(), ip);

                    if (user != null)
                    {
                        Main mainform = new Main(this.textBox1.Text.Trim(), user.ID.ToString());
                        //Form1 mainform = new Form1();
                        this.Hide();
                        mainform.ShowDialog();
                    }
                    else
                    {
                        MsgSet("用户名密码错误");
                    }
                }
                else
                {
                    if (!string.IsNullOrEmpty(user.Ip) && !string.IsNullOrEmpty(ip) && ip.Trim() != user.Ip.Replace("\n", "").Trim())
                    {
                        //writelog("clientip:" + ip + ",userip:" + user.Ip);
                        //ButtonReset();

                        MsgSet("该帐号正在登录");
                    }
                    else
                    {
                        //client.LoginActive(this.textBox1.Text.Trim(), ip);

                        if (user != null)
                        {
                            Main mainform = new Main(this.textBox1.Text.Trim(), user.ID.ToString());
                            this.Hide();
                            mainform.ShowDialog();
                        }
                        else
                        {
                            MsgSet("用户名密码错误");
                        }
                    }
                }
            }
            else
            {
                MsgSet("用户名密码错误");
            }

            ButtonReset();
        }
Exemplo n.º 2
0
        public int BeautyLogin(string username, string password, out string userid)
        {
            userid = string.Empty;
            if (client.State == System.ServiceModel.CommunicationState.Closed)
            {
                client.Open();
            }
            BoolResponse result = client.CheckUser(this.textBox1.Text.Trim(), this.textBox2.Text.Trim());
            string       ip     = GetIp();

            if (result.Result)
            {
                if (this.checkBox1.Checked)
                {
                    Beauty.Common.Helper.RegisterKey("Userinfo", this.textBox1.Text.Trim() + "|" + this.textBox2.Text.Trim() + "|1");
                }
                else
                {
                    Beauty.Common.Helper.RegisterKey("Userinfo", this.textBox1.Text.Trim() + "|" + this.textBox2.Text.Trim() + "|0");
                }

                Beauty.App.BeautyService.WebUser user = client.GetUser(this.textBox1.Text.Trim());
                if (!user.IsLogin)
                {
                    //client.LoginActive(this.textBox1.Text.Trim(), ip);

                    if (user != null)
                    {
                        //Main mainform = new Main(this.textBox1.Text.Trim(), user.ID.ToString());
                        ////Form1 mainform = new Form1();
                        //this.Hide();
                        //mainform.ShowDialog();
                        userid = user.ID.ToString();
                        return(0);
                    }
                    else
                    {
                        ButtonReset();
                        return(1);
                    }
                }
                else
                {
                    if (!string.IsNullOrEmpty(user.Ip) && !string.IsNullOrEmpty(ip) && ip.Trim() != user.Ip.Trim())
                    {
                        writelog("clientip:" + ip + ",userip:" + user.Ip);
                        ButtonReset();

                        return(2);
                    }
                    else
                    {
                        //client.LoginActive(this.textBox1.Text.Trim(), ip);

                        if (user != null)
                        {
                            //Main mainform = new Main(this.textBox1.Text.Trim(), user.ID.ToString());
                            //this.Hide();
                            //mainform.ShowDialog();
                            userid = user.ID.ToString();
                            return(0);
                        }
                        else
                        {
                            ButtonReset();
                            return(1);
                        }
                    }
                }
                //Environment.Exit(-1);
            }
            else
            {
                ButtonReset();
                return(1);
            }
        }