Пример #1
0
        public User getUser(string user)
        {
            lock (typeof(Database))
            {
                try
                {
                    connection.Open();
                    MySqlCommand comm = new MySqlCommand("SELECT phpbb_users.user_avatar, pulse_user.totalscore, pulse_user.playcount, phpbb_users.username,pulse_user.accuracy," +
                        "pulse_user.accounttype, pulse_user.level FROM `pulse_user` " +
                        "INNER JOIN `phpbb_users` on pulse_user.user_id=phpbb_users.user_id where lower(phpbb_users.username)=lower(@username);", connection);
                    MySqlParameter param = new MySqlParameter("@username", user);
                    comm.Parameters.Add(param);

                    MySqlDataReader read = comm.ExecuteReader();
                    if (!read.HasRows)
                    {
                        connection.Close();
                        return null;
                    }
                    User u = new User();
                    read.Read();
                    u.Name = user.ToLower();
                    u.RealName = read.GetString("username");
                    u.Level = read.GetInt16("level");
                    u.AccountType = read.GetInt32("accounttype");
                    u.Avatar = read.GetString("user_avatar");
                    u.Accuracy = read.GetFloat("accuracy");
                    u.TotalScore = read.GetInt32("totalscore");
                    u.Playcount = read.GetInt32("playcount");
                    u.Mode = User.PlayMode.IDLE;
                    return u;

                }
                catch (Exception e)
                {
                    Console.WriteLine(e);
                }
                finally
                {
                    connection.Close();
                }
                return null;
            }
        }
Пример #2
0
 public static void sendUserInfo(ClientHandler ch, User u, string usr)
 {
     try
     {
         BinaryWriter Bw = ch.Bw;
         if (ch != null && Bw != null)
         {
             Bw.Write((short)SendHeaders.USER_REQUEST_INFO);
             //Console.WriteLine(u.Name);
             //online bool, name,realname,,avatar,playcount,totalscore,mode,currentsong,currentchart, accuracy, level
             if (u == null)
             {
                 Bw.Write(false);
                 Bw.Write(usr);
             }
             else
             {
                 Bw.Write(true);
                 Bw.Write(u.Name);
                 Bw.Write(u.RealName);
                 Bw.Write(u.Avatar);
                 Bw.Write(u.Playcount);
                 Bw.Write(u.TotalScore);
                 Bw.Write((int)u.Mode);
                 Bw.Write(u.CurrentSong);
                 Bw.Write(u.CurrentChart);
                 Bw.Write(u.Accuracy);
                 Bw.Write(u.Level);
             }
         }
         else
         {
             ch.abort();
         }
     }
     catch (Exception e)
     {
         ch.abort(e);
     }
 }