예제 #1
0
        public void test()
        {
            string        Name       = "2017011540";
            string        strReceive = null;
            string        sendMess   = "logout" + Name;
            ServerConnect tempsev    = new ServerConnect();

            strReceive = tempsev.ServerQuery(sendMess);

            string        Name2       = "2017011565";
            string        strReceive2 = null;
            string        sendMess2   = "logout" + Name2;
            ServerConnect tempsev2    = new ServerConnect();

            strReceive2 = tempsev2.ServerQuery(sendMess2);

            string        Name3       = "2016011889";
            string        strReceive3 = null;
            string        sendMess3   = "logout" + Name3;
            ServerConnect tempsev3    = new ServerConnect();

            strReceive3 = tempsev3.ServerQuery(sendMess3);

            string        Name4       = "2017011574";
            string        strReceive4 = null;
            string        sendMess4   = "logout" + Name4;
            ServerConnect tempsev4    = new ServerConnect();

            strReceive4 = tempsev4.ServerQuery(sendMess4);
        }
예제 #2
0
            static void Main(string[] args)
            {
                //string strReceive = null;
                //string sendReceive = "2017011540_net2019";//logout2017011540/q2017011565
                //ServerConnect tempsev = new ServerConnect();
                //strReceive = tempsev.ServerQuery(sendReceive);
                //Console.WriteLine(strReceive);
                //string strReceive2 = null;
                //string sendReceive2 = "2017011565_net2019";//logout2017011540/q2017011565
                //ServerConnect tempsev2 = new ServerConnect();
                //strReceive2 = tempsev2.ServerQuery(sendReceive2);
                //Console.WriteLine(strReceive2);
                string        strReceive  = null;
                string        sendReceive = "q2017011565";//logout2017011540/q2017011565
                ServerConnect tempsev     = new ServerConnect();

                strReceive = tempsev.ServerQuery(sendReceive);
                Console.WriteLine(strReceive);

                string mystr = "hello!";

                byte[]     mybytes = Encoding.UTF8.GetBytes(mystr);
                string     myIP1   = "183.172.90.134";
                P2PProcess a1      = new P2PProcess(myIP1, 52176);

                a1.P2PSendMess(IPAddress.Parse(strReceive), mybytes, 52177);
                string     myIP2 = "183.172.90.134";
                P2PProcess a2    = new P2PProcess(myIP2, 52177);

                a2.P2PListen();
            }
예제 #3
0
        static void Main(string[] args)
        {
            string        strReceive  = null;
            string        sendReceive = "2017011565_net2019";//logout2017011540
            ServerConnect tempsev     = new ServerConnect();

            strReceive = tempsev.ServerQuery(sendReceive);
            Console.WriteLine(strReceive);
        }
예제 #4
0
        private void LoginButton_Click(object sender, RoutedEventArgs e) //登录按钮
        {
            string tempName = this.NameTextBox.GetLineText(0);           //当前输入的用户名和密码
            string tempPasw = this.PasswordsBox.Password;

            if (!string.IsNullOrEmpty(tempName) && !string.IsNullOrEmpty(tempPasw))//判断是否为空
            {
                //数据库加载
                string           dbFilename = "myQQdb.db";
                SQLiteConnection dbCore     = new SQLiteConnection("data source=" + dbFilename);
                dbCore.Open();
                string           commandText  = "select * from users;";
                SQLiteCommand    cmd          = new SQLiteCommand(commandText, dbCore);
                int              result       = cmd.ExecuteNonQuery();
                SQLiteDataReader reader       = cmd.ExecuteReader();
                bool             signforlogin = false;
                while (reader.Read())
                {
                    //检查账号密码是否正确
                    string checkID       = (string)reader["ID"];
                    string checkPassword = (string)reader["PASSWORD"];
                    if (checkID == tempName && checkPassword == tempPasw)
                    {
                        signforlogin = true;
                    }
                }
                if (signforlogin == true)
                {
                    string        strRe  = null;
                    string        sendMe = "q" + tempName;
                    ServerConnect tempSC = new ServerConnect();
                    strRe = tempSC.ServerQuery(sendMe);
                    Console.WriteLine(strRe);
                    if (strRe == "n")
                    {
                        //登录,告知服务器上线信息
                        string        strReceive = null;
                        string        sendMess   = tempName + "_net2019";
                        ServerConnect tempsev    = new ServerConnect();
                        strReceive = tempsev.ServerQuery(sendMess);
                        if (strReceive == "lol")
                        {
                            MainWindow a = new MainWindow(tempName);
                            a.Show();
                            this.Close();
                        }
                        else
                        {
                            //错误提示
                            messegebox warning = new messegebox("登录失败:未知错误");
                            warning.WindowStartupLocation = WindowStartupLocation.CenterScreen;
                            warning.Show();
                        }
                    }
                    else
                    {
                        //错误提示
                        messegebox warning = new messegebox("账号已在线,无法登陆");
                        warning.WindowStartupLocation = WindowStartupLocation.CenterScreen;
                        warning.Show();
                    }
                }
                else
                {
                    //错误提示
                    messegebox warning = new messegebox("用户名或密码错误");
                    warning.WindowStartupLocation = WindowStartupLocation.CenterScreen;
                    warning.Show();
                }
            }
            else
            {
                //错误提示
                messegebox warning = new messegebox("用户名或密码为空");
                warning.WindowStartupLocation = WindowStartupLocation.CenterScreen;
                warning.Show();
            }
        }