示例#1
0
        /// <summary>
        /// SUMMARY
        /// </summary>
        /// <param name=""></param>
        /// <param name=""></param>
        /// <param name="connection">The connection to use. If not specified (or null) then a connection will be picked automatically.</param>
        /// <returns></returns>
        public static bool GetSubscriptionData(int habboId, string subscriptionType, out int totalBought, out int skippedLength, out int pausedStart, WrappedMySqlConnection connection = null)
        {
            Dictionary<string, object> parameters = new Dictionary<string, object>();
            parameters.Add("@habbo_id", habboId);
            parameters.Add("@subscription_type", subscriptionType);

            using (connection = connection ?? CoreManager.ServerCore.MySqlConnectionProvider.GetConnection())
            {
                using (MySqlDataReader reader = connection.GetCachedCommand("SELECT `total_bought`, `skipped_length`, `paused_start` FROM `subscriptions` WHERE `habbo_id` = @habbo_id AND `subscription_type` = @subscription_type LIMIT 1").ExecuteReader(parameters))
                {
                    if (!reader.HasRows)
                    {
                        totalBought = 0;
                        skippedLength = 0;
                        pausedStart = 0;
                        return false;
                    }

                    reader.Read();
                    totalBought = (int)reader["total_bought"];
                    skippedLength = (int)reader["skipped_length"];
                    pausedStart = (int)reader["paused_start"];
                    return true;
                }
            }
        }
示例#2
0
        /// <summary>
        ///   
        /// </summary>
        /// <param name="connection">The connection to use. If not specified (or null) then a connection will be picked automatically.</param>
        /// <returns></returns>
        public static string GetRoomNameFromRoomId(int roomId, WrappedMySqlConnection connection = null)
        {
            Dictionary<string, object> parameters = new Dictionary<string, object>();
            parameters["@room_id"] = roomId;

            return CoreManager.ServerCore.MySqlConnectionProvider.HelperGetAction<string>("SELECT `name` FROM `rooms` WHERE `room_id` = @room_id", parameters, connection);
        }
示例#3
0
        /// <summary>
        /// Retrieves the figure details of the Habbo matching the specified Habbo ID.
        /// </summary>
        /// <param name=""></param>
        /// <param name=""></param>
        /// <param name=""></param>
        /// <param name="connection">The connection to use. If not specified (or null) then a connection will be picked automatically.</param>
        /// <returns></returns>
        public static bool GetFigureFromHabboId(int habboId, out string figureString, out bool gender, WrappedMySqlConnection connection = null)
        {
            Dictionary<string, object> parameters = new Dictionary<string, object>();
            parameters["@habbo_id"] = habboId;

            using (connection = connection ?? CoreManager.ServerCore.MySqlConnectionProvider.GetConnection())
            {
                using (MySqlDataReader reader = connection.GetCommand("SELECT `figure`, `gender` FROM `habbos` WHERE `habbo_id` = @habbo_id").ExecuteReader(parameters))
                {
                    if (reader.HasRows)
                    {
                        while (reader.Read())
                        {
                            figureString = (string)reader["figure"];
                            gender = (bool)reader["gender"];
                            return true;
                        }
                    }
                }
            }

            figureString = "";
            gender = true;
            return false;
        }
示例#4
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name=""></param>
        /// <param name="connection">The connection to use. If not specified (or null) then a connection will be picked automatically.</param>
        /// <returns></returns>
        public static int GetCreditsFromHabboId(int habboId, WrappedMySqlConnection connection = null)
        {
            Dictionary<string, object> parameters = new Dictionary<string, object>();
            parameters["@habbo_id"] = habboId;

            return CoreManager.ServerCore.MySqlConnectionProvider.HelperGetAction<int>("SELECT `credits` FROM `habbos` WHERE `habbo_id` = @habbo_id", parameters, connection);
        }
示例#5
0
        /// <summary>
        /// Retrieves the figure details of the Habbo matching the specified Habbo ID.
        /// </summary>
        /// <param name=""></param>
        /// <param name=""></param>
        /// <param name=""></param>
        /// <param name="connection">The connection to use. If not specified (or null) then a connection will be picked automatically.</param>
        /// <returns></returns>
        public static bool GetFigureFromHabboId(int habboId, out string figureString, out bool gender, WrappedMySqlConnection connection = null)
        {
            Dictionary<string, object> parameters = new Dictionary<string, object>();
            parameters.Add("@habbo_id", habboId);

            using (connection = connection ?? CoreManager.ServerCore.MySqlConnectionProvider.GetConnection())
            {
                using (MySqlDataReader reader = connection.GetCachedCommand("SELECT `figure`, `gender` FROM `habbos` WHERE `habbo_id` = @habbo_id").ExecuteReader(parameters))
                {
                    if (!reader.HasRows)
                    {
                        figureString = "";
                        gender = true;
                        return false;
                    }

                    while (reader.Read())
                    {
                        figureString = reader["figure"] as string;
                        gender = (bool)reader["gender"];
                        return true;
                    }
                }
            }

            // Should never even be reached... but it is needed...
            figureString = "";
            gender = true;
            return false;
        }
示例#6
0
        private IDictionary <string, PermissionState> GetHabboPermissions(int habboId)
        {
            IDictionary <string, PermissionState> permissions = new Dictionary <string, PermissionState>();

            using (WrappedMySqlConnection connection = CoreManager.ServerCore.MySqlConnectionProvider.GetConnection())
            {
                foreach (KeyValuePair <string, PermissionState> permission in PermissionActions.GetHabboPermissionsFromHabboId(habboId, connection))
                {
                    permissions.Add(permission);
                }
                foreach (string groupName in PermissionActions.GetHabboPermissionGroupsFromHabboId(habboId, connection))
                {
                    if (!_permissionGroupCache.ContainsKey(groupName))
                    {
                        CoreManager.ServerCore.ConsoleManager.Warning("Permissions", CoreManager.ServerCore.StringLocale.GetString("CORE:ERROR_PERMISSIONS_UNDEFINED_GROUP", groupName, habboId));
                        continue;
                    }
                    foreach (KeyValuePair <string, PermissionState> permission in _permissionGroupCache[groupName])
                    {
                        if (permissions.ContainsKey(permission.Key))
                        {
                            continue;                                          // Individual permissions get priority over PermissionGroup permissions.
                        }
                        permissions.Add(permission);
                    }
                }
            }

            return(permissions);
        }
示例#7
0
        /// <summary>
        ///   
        /// </summary>
        /// <param name="connection">The connection to use. If not specified (or null) then a connection will be picked automatically.</param>
        /// <returns></returns>
        public static bool DoesRoomIdExist(int roomId, WrappedMySqlConnection connection = null)
        {
            Dictionary<string, object> parameters = new Dictionary<string, object>();
            parameters["@room_id"] = roomId;

            return CoreManager.ServerCore.MySqlConnectionProvider.HelperExistsAction("SELECT 1 FROM `rooms` WHERE `room_id` = @room_id", parameters, connection);
        }
示例#8
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name=""></param>
        /// <param name="connection">The connection to use. If not specified (or null) then a connection will be picked automatically.</param>
        /// <returns></returns>
        public static bool AddHabboPermissionGroups(int habboId, string groupName, WrappedMySqlConnection connection = null)
        {
            Dictionary<string, object> parameters = new Dictionary<string, object>();
            parameters["@habbo_id"] = habboId;
            parameters["@group_name"] = groupName;

            return CoreManager.ServerCore.MySqlConnectionProvider.HelperSetAction("INSERT INTO `permission_habbo_groups` SET `habbo_id` = @habbo_id, `group_name` = @group_name", parameters, connection);
        }
示例#9
0
        /// <summary>
        /// Retrieves the last access date of the Habbo matching the specified Habbo ID.
        /// </summary>
        /// <param name=""></param>
        /// <param name="connection">The connection to use. If not specified (or null) then a connection will be picked automatically.</param>
        /// <returns></returns>
        public static DateTime GetLastAccessDateFromHabboId(int habboId, WrappedMySqlConnection connection = null)
        {
            Dictionary <string, object> parameters = new Dictionary <string, object>();

            parameters["@habbo_id"] = habboId;

            return(CoreManager.ServerCore.MySqlConnectionProvider.HelperGetAction <DateTime>("SELECT `last_access` FROM `habbos` WHERE `habbo_id` = @habbo_id", parameters, connection));
        }
示例#10
0
        /// <summary>
        ///   Retrieves the username of the Habbo matching the specified Habbo ID.
        /// </summary>
        /// <param name="habboId">The Habbo ID to match.</param>
        /// <param name="connection">The connection to use. If not specified (or null) then a connection will be picked automatically.</param>
        /// <returns>The username of the Habbo.</returns>
        public static string GetHabboUsernameFromHabboId(int habboId, WrappedMySqlConnection connection = null)
        {
            Dictionary <string, object> parameters = new Dictionary <string, object>();

            parameters["@habbo_id"] = habboId;

            return(CoreManager.ServerCore.MySqlConnectionProvider.HelperGetAction <string>("SELECT `username` FROM `habbos` WHERE `habbo_id` = @habbo_id", parameters, connection));
        }
示例#11
0
        /// <summary>
        ///   Retrieves the ID of the Habbo matching the specified username.
        /// </summary>
        /// <param name="username">The Habbo username to match.</param>
        /// <param name="connection">The connection to use. If not specified (or null) then a connection will be picked automatically.</param>
        /// <returns>The ID of the Habbo.</returns>
        public static int GetHabboIdFromHabboUsername(string username, WrappedMySqlConnection connection = null)
        {
            Dictionary <string, object> parameters = new Dictionary <string, object>();

            parameters["@username"] = username;

            return(CoreManager.ServerCore.MySqlConnectionProvider.HelperGetAction <int>("SELECT `habbo_id` FROM `habbos` WHERE `username` = @username", parameters, connection));
        }
示例#12
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="connection">The connection to use. If not specified (or null) then a connection will be picked automatically.</param>
        /// <returns></returns>
        public static string GetRoomNameFromRoomId(int roomId, WrappedMySqlConnection connection = null)
        {
            Dictionary <string, object> parameters = new Dictionary <string, object>();

            parameters["@room_id"] = roomId;

            return(CoreManager.ServerCore.MySqlConnectionProvider.HelperGetAction <string>("SELECT `name` FROM `rooms` WHERE `room_id` = @room_id", parameters, connection));
        }
示例#13
0
        /// <summary>
        ///   Retrieves the ID of the Habbo matching the specified SSO Ticket.
        ///   If no match is made, -1 is returned.
        /// </summary>
        /// <param name="ssoTicket">The SSO Ticket to match.</param>
        /// <param name="connection">The connection to use. If not specified (or null) then a connection will be picked automatically.</param>
        /// <returns>The ID of the Habbo, or -1 if no Habbo has the specified SSO Ticket.</returns>
        public static int GetHabboIdFromSSOTicket(string ssoTicket, WrappedMySqlConnection connection = null)
        {
            Dictionary <string, object> parameters = new Dictionary <string, object>();

            parameters["@sso_ticket"] = ssoTicket;

            return(CoreManager.ServerCore.MySqlConnectionProvider.HelperGetAction <int>("SELECT `habbo_id` FROM `habbos` WHERE `sso_ticket` = @sso_ticket", parameters, connection));
        }
示例#14
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="connection">The connection to use. If not specified (or null) then a connection will be picked automatically.</param>
        /// <returns></returns>
        public static bool DoesRoomIdExist(int roomId, WrappedMySqlConnection connection = null)
        {
            Dictionary <string, object> parameters = new Dictionary <string, object>();

            parameters["@room_id"] = roomId;

            return(CoreManager.ServerCore.MySqlConnectionProvider.HelperExistsAction("SELECT 1 FROM `rooms` WHERE `room_id` = @room_id", parameters, connection));
        }
示例#15
0
        /// <summary>
        ///
        /// </summary>
        /// <param name=""></param>
        /// <param name="connection">The connection to use. If not specified (or null) then a connection will be picked automatically.</param>
        /// <returns></returns>
        public static bool SetMottoFromHabboId(int habboId, string motto, WrappedMySqlConnection connection = null)
        {
            Dictionary <string, object> parameters = new Dictionary <string, object>();

            parameters["@habbo_id"] = habboId;
            parameters["@motto"]    = motto;

            return(CoreManager.ServerCore.MySqlConnectionProvider.HelperSetAction("UPDATE `habbos` SET `motto` = @motto WHERE `habbo_id` = @habbo_id", parameters, connection));
        }
示例#16
0
        /// <summary>
        ///
        /// </summary>
        /// <param name=""></param>
        /// <param name="connection">The connection to use. If not specified (or null) then a connection will be picked automatically.</param>
        /// <returns></returns>
        public static bool SetRoomNameFromRoomId(int roomId, string name, WrappedMySqlConnection connection = null)
        {
            Dictionary <string, object> parameters = new Dictionary <string, object>();

            parameters["@room_id"] = roomId;
            parameters["@name"]    = name;

            return(CoreManager.ServerCore.MySqlConnectionProvider.HelperSetAction("UPDATE `rooms` SET `name` = @name WHERE `room_id` = @room_id", parameters, connection));
        }
示例#17
0
        /// <summary>
        ///
        /// </summary>
        /// <param name=""></param>
        /// <param name="connection">The connection to use. If not specified (or null) then a connection will be picked automatically.</param>
        /// <returns></returns>
        public static bool AddHabboPermissionGroups(int habboId, string groupName, WrappedMySqlConnection connection = null)
        {
            Dictionary <string, object> parameters = new Dictionary <string, object>();

            parameters["@habbo_id"]   = habboId;
            parameters["@group_name"] = groupName;

            return(CoreManager.ServerCore.MySqlConnectionProvider.HelperSetAction("INSERT INTO `permission_habbo_groups` SET `habbo_id` = @habbo_id, `group_name` = @group_name", parameters, connection));
        }
示例#18
0
        /// <summary>
        /// Retrieves a persistent value.
        /// </summary>
        /// <param name=""></param>
        /// <param name=""></param>
        /// <param name=""></param>
        /// <param name=""></param>
        /// <param name="connection">The connection to use. If not specified (or null) then a connection will be picked automatically.</param>
        /// <returns></returns>
        public static byte[] GetPersistentValue(string typeName, long instanceId, string variableName, WrappedMySqlConnection connection = null)
        {
            Dictionary<string, object> parameters = new Dictionary<string, object>();
            parameters["@type_name"] = variableName;
            parameters["@instance_id"] = variableName;
            parameters["@variable_name"] = variableName;

            return CoreManager.ServerCore.MySqlConnectionProvider.HelperGetAction<byte[]>("SELECT `value` FROM `persistent_storage` WHERE `type_name` = @type_name AND `instance_id` = @instance_id AND `variable_name` LIMIT 1", parameters, connection);
        }
示例#19
0
        /// <summary>
        ///
        /// </summary>
        /// <param name=""></param>
        /// <param name="connection">The connection to use. If not specified (or null) then a connection will be picked automatically.</param>
        /// <returns></returns>
        public static bool SetCreditsFromHabboId(int habboId, int credits, WrappedMySqlConnection connection = null)
        {
            Dictionary <string, object> parameters = new Dictionary <string, object>();

            parameters["@habbo_id"] = habboId;
            parameters["@credits"]  = credits;

            return(CoreManager.ServerCore.MySqlConnectionProvider.HelperSetAction("UPDATE `habbos` SET `credits` = @credits WHERE `habbo_id` = @habbo_id", parameters, connection));
        }
示例#20
0
        /// <summary>
        /// Updates the SSO ticket of the Habbo matching the specified Habbo ID.
        /// </summary>
        /// <param name=""></param>
        /// <param name=""></param>
        /// <param name="connection">The connection to use. If not specified (or null) then a connection will be picked automatically.</param>
        /// <returns></returns>
        public static bool SetSSOTicketFromHabboId(int habboId, string ssoTicket, WrappedMySqlConnection connection = null)
        {
            Dictionary <string, object> parameters = new Dictionary <string, object>();

            parameters["@habbo_id"]   = habboId;
            parameters["@sso_ticket"] = ssoTicket;

            return(CoreManager.ServerCore.MySqlConnectionProvider.HelperSetAction("UPDATE `habbos` SET `sso_ticket` = @sso_ticket WHERE `habbo_id` = @habbo_id", parameters, connection));
        }
示例#21
0
        /// <summary>
        ///   
        /// </summary>
        /// <param name="connection">The connection to use. If not specified (or null) then a connection will be picked automatically.</param>
        /// <returns></returns>
        public static bool DoesHabboIdExist(int habboId, WrappedMySqlConnection connection = null)
        {
            Dictionary<string, object> parameters = new Dictionary<string, object>();
            parameters.Add("@habbo_id", habboId);

            using (connection = connection ?? CoreManager.ServerCore.MySqlConnectionProvider.GetConnection())
            {
                return connection.GetCachedCommand("SELECT 1 FROM `habbos` WHERE `habbo_id` = @habbo_id").ExecuteScalar(parameters) != null;
            }
        }
示例#22
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name=""></param>
        /// <param name="connection">The connection to use. If not specified (or null) then a connection will be picked automatically.</param>
        /// <returns></returns>
        public static bool AddHabboPermissionGroups(int habboId, string groupName, WrappedMySqlConnection connection = null)
        {
            Dictionary<string, object> parameters = new Dictionary<string, object>();
            parameters.Add("@habbo_id", habboId);
            parameters.Add("@group_name", groupName);

            using (connection = connection ?? CoreManager.ServerCore.MySqlConnectionProvider.GetConnection())
            {
                return connection.GetCachedCommand("INSERT INTO `permission_habbo_groups` SET `habbo_id` = @habbo_id, `group_name` = @group_name").ExecuteNonQuery(parameters) > 0;
            }
        }
示例#23
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="connection">The connection to use. If not specified (or null) then a connection will be picked automatically.</param>
        /// <returns></returns>
        public static bool DoesHabboIdExist(int habboId, WrappedMySqlConnection connection = null)
        {
            Dictionary <string, object> parameters = new Dictionary <string, object>();

            parameters.Add("@habbo_id", habboId);

            using (connection = connection ?? CoreManager.ServerCore.MySqlConnectionProvider.GetConnection())
            {
                return(connection.GetCachedCommand("SELECT 1 FROM `habbos` WHERE `habbo_id` = @habbo_id").ExecuteScalar(parameters) != null);
            }
        }
示例#24
0
        /// <summary>
        ///
        /// </summary>
        /// <param name=""></param>
        /// <param name="connection">The connection to use. If not specified (or null) then a connection will be picked automatically.</param>
        /// <returns></returns>
        public static bool AddHabboPermissionGroups(int habboId, string groupName, WrappedMySqlConnection connection = null)
        {
            Dictionary <string, object> parameters = new Dictionary <string, object>();

            parameters.Add("@habbo_id", habboId);
            parameters.Add("@group_name", groupName);

            using (connection = connection ?? CoreManager.ServerCore.MySqlConnectionProvider.GetConnection())
            {
                return(connection.GetCachedCommand("INSERT INTO `permission_habbo_groups` SET `habbo_id` = @habbo_id, `group_name` = @group_name").ExecuteNonQuery(parameters) > 0);
            }
        }
示例#25
0
        /// <summary>
        /// Updates the SSO ticket of the Habbo matching the specified Habbo ID.
        /// </summary>
        /// <param name=""></param>
        /// <param name=""></param>
        /// <param name="connection">The connection to use. If not specified (or null) then a connection will be picked automatically.</param>
        /// <returns></returns>
        public static bool SetSSOTicketFromHabboId(int habboId, string ssoTicket, WrappedMySqlConnection connection = null)
        {
            Dictionary <string, object> parameters = new Dictionary <string, object>();

            parameters.Add("@habbo_id", habboId);
            parameters.Add("@sso_ticket", ssoTicket);

            using (connection = connection ?? CoreManager.ServerCore.MySqlConnectionProvider.GetConnection())
            {
                return(connection.GetCachedCommand("UPDATE `habbos` SET `sso_ticket` = @sso_ticket WHERE `habbo_id` = @habbo_id").ExecuteNonQuery(parameters) > 0);
            }
        }
示例#26
0
        /// <summary>
        /// Sets a persistent value.
        /// </summary>
        /// <param name=""></param>
        /// <param name=""></param>
        /// <param name=""></param>
        /// <param name=""></param>
        /// <param name="connection">The connection to use. If not specified (or null) then a connection will be picked automatically.</param>
        /// <returns></returns>
        public static bool SetPersistentValue(string typeName, long instanceId, string variableName, byte[] value, WrappedMySqlConnection connection = null)
        {
            Dictionary<string, object> parameters = new Dictionary<string, object>();
            parameters["@type_name"] = variableName;
            parameters["@instance_id"] = variableName;
            parameters["@variable_name"] = variableName;
            parameters["@value"] = value;

            if (value != null)
                return CoreManager.ServerCore.MySqlConnectionProvider.HelperSetAction("INSERT INTO `persistent_storage` (`type_name`, `instance_id`, `variable_name`, `value`) VALUES (@type_name, @instance_id, @variable_name, @value) ON DUPLICATE KEY UPDATE `value` = @value", parameters, connection);
            return CoreManager.ServerCore.MySqlConnectionProvider.HelperSetAction("DELETE FROM `persistent_storage` WHERE `type_name` = @type_name AND `instance_id` = @instance_id AND `variable_name` = @variable_name", parameters, connection);
        }
示例#27
0
        /// <summary>
        ///
        /// </summary>
        /// <param name=""></param>
        /// <param name="connection">The connection to use. If not specified (or null) then a connection will be picked automatically.</param>
        /// <returns></returns>
        public static bool SetRoomNameFromRoomId(int roomId, string name, WrappedMySqlConnection connection = null)
        {
            Dictionary <string, object> parameters = new Dictionary <string, object>();

            parameters.Add("@room_id", roomId);
            parameters.Add("@name", name);

            using (connection = connection ?? CoreManager.ServerCore.MySqlConnectionProvider.GetConnection())
            {
                // Get the value from the database and return it.
                return(connection.GetCachedCommand("UPDATE `rooms` SET `name` = @name WHERE `room_id` = @room_id").ExecuteNonQuery(parameters) > 0);
            }
        }
示例#28
0
        /// <summary>
        ///
        /// </summary>
        /// <param name=""></param>
        /// <param name="connection">The connection to use. If not specified (or null) then a connection will be picked automatically.</param>
        /// <returns></returns>
        public static bool SetMottoFromHabboId(int habboId, string motto, WrappedMySqlConnection connection = null)
        {
            Dictionary <string, object> parameters = new Dictionary <string, object>();

            parameters.Add("@habbo_id", habboId);
            parameters.Add("@motto", motto);

            using (connection = connection ?? CoreManager.ServerCore.MySqlConnectionProvider.GetConnection())
            {
                // Get the value from the database and return it.
                return(connection.GetCachedCommand("UPDATE `habbos` SET `motto` = @motto WHERE `habbo_id` = @habbo_id").ExecuteNonQuery(parameters) > 0);
            }
        }
示例#29
0
        /// <summary>
        /// SUMMARY
        /// </summary>
        /// <param name=""></param>
        /// <param name=""></param>
        /// <param name="connection">The connection to use. If not specified (or null) then a connection will be picked automatically.</param>
        /// <returns></returns>
        public static bool SetSubscriptionData(int habboId, string subscriptionType, int totalBought, int skippedLength, int pausedStart, WrappedMySqlConnection connection = null)
        {
            Dictionary<string, object> parameters = new Dictionary<string, object>();
            parameters.Add("@habbo_id", habboId);
            parameters.Add("@subscription_type", subscriptionType);
            parameters.Add("@total_bought", totalBought);
            parameters.Add("@skipped_length", skippedLength);
            parameters.Add("@paused_start", pausedStart);

            using (connection = connection ?? CoreManager.ServerCore.MySqlConnectionProvider.GetConnection())
            {
                return connection.GetCachedCommand("INSERT INTO `subscriptions` (`habbo_id`, `subscription_type`, `total_bought`, `skipped_length`, `paused_start`) VALUES (@habbo_id, @subscription_type, @total_bought, @skipped_length, @paused_start) ON DUPLICATE KEY UPDATE `total_bought` = @total_bought, `skipped_length` = @skipped_length, `paused_start` = @paused_start").ExecuteNonQuery(parameters) >= 1;
            }
        }
示例#30
0
        /// <summary>
        ///   
        /// </summary>
        /// <param name="connection">The connection to use. If not specified (or null) then a connection will be picked automatically.</param>
        /// <returns></returns>
        public static string GetRoomModelFromRoomId(int roomId, WrappedMySqlConnection connection = null)
        {
            Dictionary<string, object> parameters = new Dictionary<string, object>();
            parameters.Add("@room_id", roomId);

            string returnValue;
            using (connection = connection ?? CoreManager.ServerCore.MySqlConnectionProvider.GetConnection())
            {
                returnValue = connection.GetCachedCommand("SELECT `model` FROM `rooms` WHERE `room_id` = @room_id").ExecuteScalar(parameters) as string;
            }

            if (returnValue != null)
                return returnValue;
            throw new NoResultsException();
        }
示例#31
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name=""></param>
        /// <param name="connection">The connection to use. If not specified (or null) then a connection will be picked automatically.</param>
        /// <returns></returns>
        public static int GetCreditsFromHabboId(int habboId, WrappedMySqlConnection connection = null)
        {
            Dictionary<string, object> parameters = new Dictionary<string, object>();
            parameters.Add("@habbo_id", habboId);

            object returnValue;
            using (connection = connection ?? CoreManager.ServerCore.MySqlConnectionProvider.GetConnection())
            {
                // Get the value from the database.
                returnValue = connection.GetCachedCommand("SELECT `last_access` FROM `habbos` WHERE `habbo_id` = @habbo_id").ExecuteScalar(parameters);
            }

            if (returnValue != null)
                return (int)returnValue;
            throw new NoResultsException();
        }
示例#32
0
        /// <summary>
        ///	
        /// </summary>
        /// <param name=""></param>
        /// <param name=""></param>
        /// <param name="connection">The connection to use. If not specified (or null) then a connection will be picked automatically.</param>
        /// <returns></returns>
        public static ICollection<PermissionsGroupPermissionData> GetAllPermissionGroupPermissions(WrappedMySqlConnection connection = null)
        {
            List<PermissionsGroupPermissionData> groupPermissions = new List<PermissionsGroupPermissionData>();

            using (connection = connection ?? CoreManager.ServerCore.MySqlConnectionProvider.GetConnection())
            {
                using (MySqlDataReader reader = connection.GetCommand("SELECT `group_name`, `permission_name`, `permission_state` FROM `permission_group_permissions`").ExecuteReader())
                {
                    while (reader.Read())
                    {
                        groupPermissions.Add(new PermissionsGroupPermissionData((string)reader["group_name"], (string)reader["permission_name"], (PermissionState)reader["permission_state"])); // TODO: Test if a direct cast to PermissionState is possible.
                    }

                    return groupPermissions;
                }
            }
        }
示例#33
0
        /// <summary>
        ///   Retrieves the ID of the Habbo matching the specified username.
        /// </summary>
        /// <param name="username">The Habbo username to match.</param>
        /// <param name="connection">The connection to use. If not specified (or null) then a connection will be picked automatically.</param>
        /// <returns>The ID of the Habbo.</returns>
        public static int GetHabboIdFromHabboUsername(string username, WrappedMySqlConnection connection = null)
        {
            Dictionary <string, object> parameters = new Dictionary <string, object>();

            parameters.Add("@username", username);

            object returnValue;

            using (connection = connection ?? CoreManager.ServerCore.MySqlConnectionProvider.GetConnection())
            {
                returnValue = connection.GetCachedCommand("SELECT `habbo_id` FROM `habbos` WHERE `username` = @username").ExecuteScalar(parameters);
            }

            if (returnValue != null)
            {
                return((int)returnValue);
            }
            throw new NoResultsException();
        }
示例#34
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="connection">The connection to use. If not specified (or null) then a connection will be picked automatically.</param>
        /// <returns></returns>
        public static string GetRoomModelFromRoomId(int roomId, WrappedMySqlConnection connection = null)
        {
            Dictionary <string, object> parameters = new Dictionary <string, object>();

            parameters.Add("@room_id", roomId);

            string returnValue;

            using (connection = connection ?? CoreManager.ServerCore.MySqlConnectionProvider.GetConnection())
            {
                returnValue = connection.GetCachedCommand("SELECT `model` FROM `rooms` WHERE `room_id` = @room_id").ExecuteScalar(parameters) as string;
            }

            if (returnValue != null)
            {
                return(returnValue);
            }
            throw new NoResultsException();
        }
示例#35
0
        /// <summary>
        ///   Retrieves the username of the Habbo matching the specified Habbo ID.
        /// </summary>
        /// <param name="habboId">The Habbo ID to match.</param>
        /// <param name="connection">The connection to use. If not specified (or null) then a connection will be picked automatically.</param>
        /// <returns>The username of the Habbo.</returns>
        public static string GetHabboUsernameFromHabboId(int habboId, WrappedMySqlConnection connection = null)
        {
            Dictionary <string, object> parameters = new Dictionary <string, object>();

            parameters.Add("@habbo_id", habboId);

            string returnValue;

            using (connection = connection ?? CoreManager.ServerCore.MySqlConnectionProvider.GetConnection())
            {
                returnValue = connection.GetCachedCommand("SELECT `username` FROM `habbos` WHERE `habbo_id` = @habbo_id").ExecuteScalar(parameters) as string;
            }

            if (returnValue != null)
            {
                return(returnValue);
            }
            throw new NoResultsException();
        }
示例#36
0
        /// <summary>
        ///	
        /// </summary>
        /// <param name=""></param>
        /// <param name=""></param>
        /// <param name="connection">The connection to use. If not specified (or null) then a connection will be picked automatically.</param>
        /// <returns></returns>
        public static IEnumerable<string> GetHabboPermissionGroupsFromHabboId(int habboId, WrappedMySqlConnection connection = null)
        {
            Dictionary<string, object> parameters = new Dictionary<string, object>();
            parameters.Add("@habbo_id", habboId);

            List<string> groupNames = new List<string>();

            using (connection = connection ?? CoreManager.ServerCore.MySqlConnectionProvider.GetConnection())
            {
                using (MySqlDataReader reader = connection.GetCommand("SELECT `group_name` FROM `permission_habbo_groups` WHERE `habbo_id` = @habbo_id").ExecuteReader(parameters))
                {
                    while (reader.Read())
                    {
                        groupNames.Add((string)reader["group_name"]);
                    }

                    return groupNames;
                }
            }
        }
示例#37
0
        /// <summary>
        ///
        /// </summary>
        /// <param name=""></param>
        /// <param name="connection">The connection to use. If not specified (or null) then a connection will be picked automatically.</param>
        /// <returns></returns>
        public static string GetMottoFromHabboId(int habboId, WrappedMySqlConnection connection = null)
        {
            Dictionary <string, object> parameters = new Dictionary <string, object>();

            parameters.Add("@habbo_id", habboId);

            object returnValue;

            using (connection = connection ?? CoreManager.ServerCore.MySqlConnectionProvider.GetConnection())
            {
                // Get the value from the database.
                returnValue = connection.GetCachedCommand("SELECT `motto` FROM `habbos` WHERE `habbo_id` = @habbo_id").ExecuteScalar(parameters);
            }

            if (returnValue != null)
            {
                return((string)returnValue);
            }
            throw new NoResultsException();
        }
示例#38
0
        /// <summary>
        ///   Retrieves the IDs of the Rooms owned by owner ID.
        /// </summary>
        /// <param name="ownerId">The owner ID to search with.</param>
        /// <param name="connection">The connection to use. If not specified (or null) then a connection will be picked automatically.</param>
        public static IEnumerable<int> GetRoomIdsFromRoomOwner(string ownerId, WrappedMySqlConnection connection = null)
        {
            Dictionary<string, object> parameters = new Dictionary<string, object>();
            parameters.Add("@owner_id", ownerId);

            List<int> roomIds = new List<int>();

            using (connection = connection ?? CoreManager.ServerCore.MySqlConnectionProvider.GetConnection())
            {
                using (MySqlDataReader reader = connection.GetCommand("SELECT `room_id` FROM `rooms` WHERE `owner_id` = @owner_id").ExecuteReader(parameters))
                {
                    while (reader.Read())
                    {
                        roomIds.Add((int)reader["room_id"]);
                    }

                    return roomIds;
                }
            }
        }
示例#39
0
        /// <summary>
        ///   Retrieves the IDs of the Rooms owned by owner ID.
        /// </summary>
        /// <param name="ownerId">The owner ID to search with.</param>
        /// <param name="connection">The connection to use. If not specified (or null) then a connection will be picked automatically.</param>
        public static IEnumerable <int> GetRoomIdsFromRoomOwner(string ownerId, WrappedMySqlConnection connection = null)
        {
            Dictionary <string, object> parameters = new Dictionary <string, object>();

            parameters.Add("@owner_id", ownerId);

            List <int> roomIds = new List <int>();

            using (connection = connection ?? CoreManager.ServerCore.MySqlConnectionProvider.GetConnection())
            {
                using (MySqlDataReader reader = connection.GetCommand("SELECT `room_id` FROM `rooms` WHERE `owner_id` = @owner_id").ExecuteReader(parameters))
                {
                    while (reader.Read())
                    {
                        roomIds.Add((int)reader["room_id"]);
                    }

                    return(roomIds);
                }
            }
        }
示例#40
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name=""></param>
        /// <param name="connection">The connection to use. If not specified (or null) then a connection will be picked automatically.</param>
        /// <returns></returns>
        public static bool SetMottoFromHabboId(int habboId, string motto, WrappedMySqlConnection connection = null)
        {
            Dictionary<string, object> parameters = new Dictionary<string, object>();
            parameters.Add("@habbo_id", habboId);
            parameters.Add("@motto", motto);

            using (connection = connection ?? CoreManager.ServerCore.MySqlConnectionProvider.GetConnection())
            {
                // Get the value from the database and return it.
                return connection.GetCachedCommand("UPDATE `habbos` SET `motto` = @motto WHERE `habbo_id` = @habbo_id").ExecuteNonQuery(parameters) > 0;
            }
        }
示例#41
0
        /// <summary>
        /// Updates the SSO ticket of the Habbo matching the specified Habbo ID.
        /// </summary>
        /// <param name=""></param>
        /// <param name=""></param>
        /// <param name="connection">The connection to use. If not specified (or null) then a connection will be picked automatically.</param>
        /// <returns></returns>
        public static bool SetSSOTicketFromHabboId(int habboId, string ssoTicket, WrappedMySqlConnection connection = null)
        {
            Dictionary<string, object> parameters = new Dictionary<string, object>();
            parameters.Add("@habbo_id", habboId);
            parameters.Add("@sso_ticket", ssoTicket);

            using (connection = connection ?? CoreManager.ServerCore.MySqlConnectionProvider.GetConnection())
            {
                return connection.GetCachedCommand("UPDATE `habbos` SET `sso_ticket` = @sso_ticket WHERE `habbo_id` = @habbo_id").ExecuteNonQuery(parameters) > 0;
            }
        }
示例#42
0
        /// <summary>
        /// Retrieves the SSO ticket of the Habbo matching the specified Habbo ID.
        /// </summary>
        /// <param name=""></param>
        /// <param name="connection">The connection to use. If not specified (or null) then a connection will be picked automatically.</param>
        /// <returns></returns>
        public static string GetSSOTicketFromHabboId(int habboId, WrappedMySqlConnection connection = null)
        {
            Dictionary<string, object> parameters = new Dictionary<string, object>();
            parameters.Add("@habbo_id", habboId);

            string returnValue;
            using (connection = connection ?? CoreManager.ServerCore.MySqlConnectionProvider.GetConnection())
            {
                // Get the value from the database and return it.
                returnValue = connection.GetCachedCommand("SELECT `sso_ticket` FROM `habbos` WHERE `habbo_id` = @habbo_id").ExecuteScalar(parameters) as string;
            }

            if (returnValue != null)
                return returnValue;
            throw new NoResultsException();
        }
示例#43
0
        /// <summary>
        /// Updates the last access date of the Habbo matching the specified Habbo ID.
        /// </summary>
        /// <param name=""></param>
        /// <param name="connection">The connection to use. If not specified (or null) then a connection will be picked automatically.</param>
        /// <returns></returns>
        public static bool SetLastAccessDateFromHabboId(int habboId, DateTime lastAccessDate, WrappedMySqlConnection connection = null)
        {
            Dictionary<string, object> parameters = new Dictionary<string, object>();
            parameters.Add("@habbo_id", habboId);
            parameters.Add("@last_access", lastAccessDate);

            using (connection = connection ?? CoreManager.ServerCore.MySqlConnectionProvider.GetConnection())
            {
                // Get the value from the database and return it.
                return connection.GetCachedCommand("UPDATE `habbos` SET `last_access` = @last_access WHERE `habbo_id` = @habbo_id").ExecuteNonQuery(parameters) > 0;
            }
        }
示例#44
0
        /// <summary>
        ///   Retrieves the ID of the Habbo matching the specified SSO Ticket.
        ///   If no match is made, -1 is returned.
        /// </summary>
        /// <param name="ssoTicket">The SSO Ticket to match.</param>
        /// <param name="connection">The connection to use. If not specified (or null) then a connection will be picked automatically.</param>
        /// <returns>The ID of the Habbo, or -1 if no Habbo has the specified SSO Ticket.</returns>
        public static int GetHabboIdFromSSOTicket(string ssoTicket, WrappedMySqlConnection connection = null)
        {
            Dictionary<string, object> parameters = new Dictionary<string, object>();
            parameters.Add("@sso_ticket", ssoTicket);

            object returnValue;
            using (connection = connection ?? CoreManager.ServerCore.MySqlConnectionProvider.GetConnection())
            {
                returnValue = connection.GetCachedCommand("SELECT `habbo_id` FROM `habbos` WHERE `sso_ticket` = @sso_ticket").ExecuteScalar(parameters);
            }

            if (returnValue != null)
                return (int)returnValue;
            throw new NoResultsException();
        }
示例#45
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name=""></param>
        /// <param name="connection">The connection to use. If not specified (or null) then a connection will be picked automatically.</param>
        /// <returns></returns>
        public static bool SetRoomNameFromRoomId(int roomId, string name, WrappedMySqlConnection connection = null)
        {
            Dictionary<string, object> parameters = new Dictionary<string, object>();
            parameters.Add("@room_id", roomId);
            parameters.Add("@name", name);

            using (connection = connection ?? CoreManager.ServerCore.MySqlConnectionProvider.GetConnection())
            {
                // Get the value from the database and return it.
                return connection.GetCachedCommand("UPDATE `rooms` SET `name` = @name WHERE `room_id` = @room_id").ExecuteNonQuery(parameters) > 0;
            }
        }
示例#46
0
        /// <summary>
        /// Updates the last access date of the Habbo matching the specified Habbo ID.
        /// </summary>
        /// <param name=""></param>
        /// <param name="connection">The connection to use. If not specified (or null) then a connection will be picked automatically.</param>
        /// <returns></returns>
        public static bool SetLastAccessDateFromHabboId(int habboId, DateTime lastAccessDate, WrappedMySqlConnection connection = null)
        {
            Dictionary <string, object> parameters = new Dictionary <string, object>();

            parameters.Add("@habbo_id", habboId);
            parameters.Add("@last_access", lastAccessDate);

            using (connection = connection ?? CoreManager.ServerCore.MySqlConnectionProvider.GetConnection())
            {
                // Get the value from the database and return it.
                return(connection.GetCachedCommand("UPDATE `habbos` SET `last_access` = @last_access WHERE `habbo_id` = @habbo_id").ExecuteNonQuery(parameters) > 0);
            }
        }
示例#47
0
        /// <summary>
        /// Retrieves the figure details of the Habbo matching the specified Habbo ID.
        /// </summary>
        /// <param name=""></param>
        /// <param name=""></param>
        /// <param name=""></param>
        /// <param name="connection">The connection to use. If not specified (or null) then a connection will be picked automatically.</param>
        /// <returns></returns>
        public static bool GetFigureFromHabboId(int habboId, out string figureString, out bool gender, WrappedMySqlConnection connection = null)
        {
            Dictionary <string, object> parameters = new Dictionary <string, object>();

            parameters.Add("@habbo_id", habboId);

            using (connection = connection ?? CoreManager.ServerCore.MySqlConnectionProvider.GetConnection())
            {
                using (MySqlDataReader reader = connection.GetCachedCommand("SELECT `figure`, `gender` FROM `habbos` WHERE `habbo_id` = @habbo_id").ExecuteReader(parameters))
                {
                    if (!reader.HasRows)
                    {
                        figureString = "";
                        gender       = true;
                        return(false);
                    }

                    while (reader.Read())
                    {
                        figureString = reader["figure"] as string;
                        gender       = (bool)reader["gender"];
                        return(true);
                    }
                }
            }

            // Should never even be reached... but it is needed...
            figureString = "";
            gender       = true;
            return(false);
        }
示例#48
0
        /// <summary>
        /// SUMMARY
        /// </summary>
        /// <param name=""></param>
        /// <param name=""></param>
        /// <param name="connection">The connection to use. If not specified (or null) then a connection will be picked automatically.</param>
        /// <returns></returns>
        public static bool GetSubscriptionData(int habboId, string subscriptionType, out int totalBought, out int skippedLength, out int pausedStart, WrappedMySqlConnection connection = null)
        {
            Dictionary <string, object> parameters = new Dictionary <string, object>();

            parameters.Add("@habbo_id", habboId);
            parameters.Add("@subscription_type", subscriptionType);

            using (connection = connection ?? CoreManager.ServerCore.MySqlConnectionProvider.GetConnection())
            {
                using (MySqlDataReader reader = connection.GetCachedCommand("SELECT `total_bought`, `skipped_length`, `paused_start` FROM `subscriptions` WHERE `habbo_id` = @habbo_id AND `subscription_type` = @subscription_type LIMIT 1").ExecuteReader(parameters))
                {
                    if (!reader.HasRows)
                    {
                        totalBought   = 0;
                        skippedLength = 0;
                        pausedStart   = 0;
                        return(false);
                    }

                    reader.Read();
                    totalBought   = (int)reader["total_bought"];
                    skippedLength = (int)reader["skipped_length"];
                    pausedStart   = (int)reader["paused_start"];
                    return(true);
                }
            }
        }
示例#49
0
        /// <summary>
        /// Retrieves a persistent value.
        /// </summary>
        /// <param name=""></param>
        /// <param name=""></param>
        /// <param name=""></param>
        /// <param name=""></param>
        /// <param name="connection">The connection to use. If not specified (or null) then a connection will be picked automatically.</param>
        /// <returns></returns>
        public static byte[] GetPersistentValue(string typeName, long instanceId, string variableName, WrappedMySqlConnection connection = null)
        {
            Dictionary <string, object> parameters = new Dictionary <string, object>();

            parameters["@type_name"]     = variableName;
            parameters["@instance_id"]   = variableName;
            parameters["@variable_name"] = variableName;

            return(CoreManager.ServerCore.MySqlConnectionProvider.HelperGetAction <byte[]>("SELECT `value` FROM `persistent_storage` WHERE `type_name` = @type_name AND `instance_id` = @instance_id AND `variable_name` LIMIT 1", parameters, connection));
        }
示例#50
0
        /// <summary>
        ///
        /// </summary>
        /// <param name=""></param>
        /// <param name="connection">The connection to use. If not specified (or null) then a connection will be picked automatically.</param>
        /// <returns></returns>
        public static bool SetRoomDescriptionFromRoomId(int roomId, string description, WrappedMySqlConnection connection = null)
        {
            Dictionary <string, object> parameters = new Dictionary <string, object>();

            parameters["@room_id"]     = roomId;
            parameters["@description"] = description;

            return(CoreManager.ServerCore.MySqlConnectionProvider.HelperSetAction("UPDATE `rooms` SET `description` = @description WHERE `room_id` = @room_id", parameters, connection));
        }
示例#51
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name=""></param>
        /// <param name="connection">The connection to use. If not specified (or null) then a connection will be picked automatically.</param>
        /// <returns></returns>
        public static bool SetRoomDescriptionFromRoomId(int roomId, string description, WrappedMySqlConnection connection = null)
        {
            Dictionary<string, object> parameters = new Dictionary<string, object>();
            parameters["@room_id"] = roomId;
            parameters["@description"] = description;

            return CoreManager.ServerCore.MySqlConnectionProvider.HelperSetAction("UPDATE `rooms` SET `description` = @description WHERE `room_id` = @room_id", parameters, connection);
        }
示例#52
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name=""></param>
        /// <param name="connection">The connection to use. If not specified (or null) then a connection will be picked automatically.</param>
        /// <returns></returns>
        public static bool RemoveHabboPermissionGroups(int habboId, string groupName, WrappedMySqlConnection connection = null)
        {
            Dictionary<string, object> parameters = new Dictionary<string, object>();
            parameters["@habbo_id"] = habboId;
            parameters["@group_name"] = groupName;

            return CoreManager.ServerCore.MySqlConnectionProvider.HelperSetAction("DELETE FROM `permission_habbo_groups` WHERE `habbo_id` = @habbo_id AND `group_name` = @group_name", parameters, connection);
        }
示例#53
0
        /// <summary>
        ///   Retrieves the ID of the Habbo matching the specified username.
        /// </summary>
        /// <param name="username">The Habbo username to match.</param>
        /// <param name="connection">The connection to use. If not specified (or null) then a connection will be picked automatically.</param>
        /// <returns>The ID of the Habbo.</returns>
        public static int GetHabboIdFromHabboUsername(string username, WrappedMySqlConnection connection = null)
        {
            Dictionary<string, object> parameters = new Dictionary<string, object>();
            parameters["@username"] = username;

            return CoreManager.ServerCore.MySqlConnectionProvider.HelperGetAction<int>("SELECT `habbo_id` FROM `habbos` WHERE `username` = @username", parameters, connection);
        }
示例#54
0
        /// <summary>
        /// Sets a persistent value.
        /// </summary>
        /// <param name=""></param>
        /// <param name=""></param>
        /// <param name=""></param>
        /// <param name=""></param>
        /// <param name="connection">The connection to use. If not specified (or null) then a connection will be picked automatically.</param>
        /// <returns></returns>
        public static bool SetPersistentValue(string typeName, long instanceId, string variableName, byte[] value, WrappedMySqlConnection connection = null)
        {
            Dictionary <string, object> parameters = new Dictionary <string, object>();

            parameters.Add("@type_name", typeName);
            parameters.Add("@instance_id", instanceId);
            parameters.Add("@variable_name", variableName);
            parameters.Add("@value", value);

            using (connection = connection ?? CoreManager.ServerCore.MySqlConnectionProvider.GetConnection())
            {
                if (value != null)
                {
                    return(connection.GetCachedCommand("INSERT INTO `persistent_storage` (`type_name`, `instance_id`, `variable_name`, `value`) VALUES (@type_name, @instance_id, @variable_name, @value) ON DUPLICATE KEY UPDATE `value` = @value").ExecuteNonQuery(parameters) > 0);
                }
                return(connection.GetCachedCommand("DELETE FROM `persistent_storage` WHERE `type_name` = @type_name AND `instance_id` = @instance_id AND `variable_name` = @variable_name").ExecuteNonQuery(parameters) > 0);
            }
        }
示例#55
0
        /// <summary>
        /// Updates the SSO ticket of the Habbo matching the specified Habbo ID.
        /// </summary>
        /// <param name=""></param>
        /// <param name=""></param>
        /// <param name="connection">The connection to use. If not specified (or null) then a connection will be picked automatically.</param>
        /// <returns></returns>
        public static bool SetSSOTicketFromHabboId(int habboId, string ssoTicket, WrappedMySqlConnection connection = null)
        {
            Dictionary<string, object> parameters = new Dictionary<string, object>();
            parameters["@habbo_id"] = habboId;
            parameters["@sso_ticket"] = ssoTicket;

            return CoreManager.ServerCore.MySqlConnectionProvider.HelperSetAction("UPDATE `habbos` SET `sso_ticket` = @sso_ticket WHERE `habbo_id` = @habbo_id", parameters, connection);
        }
示例#56
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name=""></param>
        /// <param name="connection">The connection to use. If not specified (or null) then a connection will be picked automatically.</param>
        /// <returns></returns>
        public static bool SetHabboPermissionsFromId(int habboId, string permissionName, PermissionState permissionState, WrappedMySqlConnection connection = null)
        {
            Dictionary<string, object> parameters = new Dictionary<string, object>();
            parameters.Add("@habbo_id", habboId);
            parameters.Add("@permission_name", permissionName);

            if (permissionState == PermissionState.Undefined)
            {
                using (connection = connection ?? CoreManager.ServerCore.MySqlConnectionProvider.GetConnection())
                {
                    return connection.GetCommand("DELETE FROM `permission_habbo_permissions` WHERE `habbo_id` = @habbo_id AND `permission_name`= @permission_name").ExecuteNonQuery(parameters) > 0;
                }
            }

            parameters.Add("@permission_state", (int)permissionState);
            using (connection = connection ?? CoreManager.ServerCore.MySqlConnectionProvider.GetConnection())
            {
                return connection.GetCommand("INSERT INTO `permission_habbo_permissions` SET `habbo_id` = @habbo_id, `permission_name` = @permission_name, `permission_state` = @permission_state ON DUPLICATE KEY UPDATE `permission_state` = @permission_state").ExecuteNonQuery(parameters) > 0;
            }
        }
示例#57
0
        /// <summary>
        /// SUMMARY
        /// </summary>
        /// <param name=""></param>
        /// <param name=""></param>
        /// <param name="connection">The connection to use. If not specified (or null) then a connection will be picked automatically.</param>
        /// <returns></returns>
        public static bool SetSubscriptionData(int habboId, string subscriptionType, int totalBought, int skippedLength, int pausedStart, WrappedMySqlConnection connection = null)
        {
            Dictionary <string, object> parameters = new Dictionary <string, object>();

            parameters.Add("@habbo_id", habboId);
            parameters.Add("@subscription_type", subscriptionType);
            parameters.Add("@total_bought", totalBought);
            parameters.Add("@skipped_length", skippedLength);
            parameters.Add("@paused_start", pausedStart);

            using (connection = connection ?? CoreManager.ServerCore.MySqlConnectionProvider.GetConnection())
            {
                return(connection.GetCachedCommand("INSERT INTO `subscriptions` (`habbo_id`, `subscription_type`, `total_bought`, `skipped_length`, `paused_start`) VALUES (@habbo_id, @subscription_type, @total_bought, @skipped_length, @paused_start) ON DUPLICATE KEY UPDATE `total_bought` = @total_bought, `skipped_length` = @skipped_length, `paused_start` = @paused_start").ExecuteNonQuery(parameters) >= 1);
            }
        }
示例#58
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name=""></param>
        /// <param name="connection">The connection to use. If not specified (or null) then a connection will be picked automatically.</param>
        /// <returns></returns>
        public static bool SetRoomNameFromRoomId(int roomId, string name, WrappedMySqlConnection connection = null)
        {
            Dictionary<string, object> parameters = new Dictionary<string, object>();
            parameters["@room_id"] = roomId;
            parameters["@name"] = name;

            return CoreManager.ServerCore.MySqlConnectionProvider.HelperSetAction("UPDATE `rooms` SET `name` = @name WHERE `room_id` = @room_id", parameters, connection);
        }
示例#59
0
        /// <summary>
        /// Sets a persistent value.
        /// </summary>
        /// <param name=""></param>
        /// <param name=""></param>
        /// <param name=""></param>
        /// <param name=""></param>
        /// <param name="connection">The connection to use. If not specified (or null) then a connection will be picked automatically.</param>
        /// <returns></returns>
        public static bool SetPersistentValue(string typeName, long instanceId, string variableName, byte[] value, WrappedMySqlConnection connection = null)
        {
            Dictionary <string, object> parameters = new Dictionary <string, object>();

            parameters["@type_name"]     = variableName;
            parameters["@instance_id"]   = variableName;
            parameters["@variable_name"] = variableName;
            parameters["@value"]         = value;

            if (value != null)
            {
                return(CoreManager.ServerCore.MySqlConnectionProvider.HelperSetAction("INSERT INTO `persistent_storage` (`type_name`, `instance_id`, `variable_name`, `value`) VALUES (@type_name, @instance_id, @variable_name, @value) ON DUPLICATE KEY UPDATE `value` = @value", parameters, connection));
            }
            return(CoreManager.ServerCore.MySqlConnectionProvider.HelperSetAction("DELETE FROM `persistent_storage` WHERE `type_name` = @type_name AND `instance_id` = @instance_id AND `variable_name` = @variable_name", parameters, connection));
        }
示例#60
0
        /// <summary>
        ///	
        /// </summary>
        /// <param name=""></param>
        /// <param name=""></param>
        /// <param name="connection">The connection to use. If not specified (or null) then a connection will be picked automatically.</param>
        /// <returns></returns>
        public static Dictionary<string, PermissionState> GetHabboPermissionsFromHabboId(int habboId, WrappedMySqlConnection connection = null)
        {
            Dictionary<string, PermissionState> permissions = new Dictionary<string, PermissionState>();

            Dictionary<string, object> parameters = new Dictionary<string, object>();
            parameters.Add("@habbo_id", habboId);

            using (connection = connection ?? CoreManager.ServerCore.MySqlConnectionProvider.GetConnection())
            {
                using (MySqlDataReader reader = connection.GetCommand("SELECT `permission_name`, `permission_state` FROM `permission_habbo_permissions` WHERE `habbo_id` = @habbo_id").ExecuteReader(parameters))
                {
                    while (reader.Read())
                    {
                        if((sbyte)reader["permission_state"] == 1)
                            permissions.Add((string)reader["permission_name"], PermissionState.Allow);
                        else
                            permissions.Add((string)reader["permission_name"], PermissionState.Deny);
                    }

                    return permissions;
                }
            }
            ;
        }