Esempio n. 1
0
 static void RegistrationReaply(string textMsg)
 {
     Message_Sr.Registration_Sr reaply = new Message_Sr.Registration_Sr();
     reaply.reg = false;
     reaply.msg = textMsg;
     temp.Send(Networking_msgType_Sr.Registration, reaply);
 }
Esempio n. 2
0
    public static void CreatNewAccount(NetworkMessage netmsg)
    {
        Message_Sr.Registration_Sr reg = netmsg.ReadMessage <Message_Sr.Registration_Sr> ();
        log  = reg.log;
        pas  = reg.pass;
        mail = reg.mail;
        temp = netmsg.conn;


        if (log.Length >= minLogSymbol)
        {
            if (pas.Length >= minPassSymbol)
            {
                if (mail.IndexOf(m) != -1 && mail.IndexOf(t) != -1)
                {
                    Linq.CommandText = "SELECT Mail FROM accountlist WHERE Mail = '" + mail + "'";
                    MySqlDataReader Reader = Linq.ExecuteReader();
                    try {
                        if (Reader.Read())
                        {
                            RegistrationReaply(mailNotAvaileble);
                            Reader.Close();
                        }
                        else
                        {
                            Reader.Close();

                            Linq.CommandText = "SELECT AccountName FROM accountlist WHERE AccountName = '" + log + "'";
                            MySqlDataReader Reader2 = Linq.ExecuteReader();
                            try {
                                if (Reader2.Read())
                                {
                                    RegistrationReaply(LoginNotAvaileble);
                                    Reader2.Close();
                                }
                                else
                                {
                                    Reader2.Close();
                                    try {
                                        Linq.CommandText = "INSERT INTO accountlist (AccountName, PasswordAc, Mail) VALUES ('" + log + "','" + pas + "','" + mail + "')";
                                        int row = Linq.ExecuteNonQuery();
                                        Debug.Log("Succsess create new account '" + log + "' " + row + ".");

                                        RegistrationReaply(Succsess);
                                    } catch (MySqlException e) {
                                        Debug.Log(e.Number);
                                    }
                                }
                            } catch (MySqlException ex) {
                                Reader2.Close();
                                Debug.Log(ex.Number);
                            }
                        }
                    } catch (MySqlException ex) {
                        Reader.Close();
                        Debug.Log(ex.Number);
                    }
                }
                else
                {
                    RegistrationReaply(mailNotCorrect);
                }
            }
            else
            {
                RegistrationReaply(minPass);
            }
        }
        else
        {
            RegistrationReaply(minLog);
        }
    }