From 9f7639fd6d2d7fd37587223259303377ee15bab4 Mon Sep 17 00:00:00 2001 From: Jeff Ames Date: Tue, 18 Mar 2008 03:41:05 +0000 Subject: Formatting cleanup. --- OpenSim/Framework/Data.MySQL/MySQLManager.cs | 31 +++++++++--------- OpenSim/Framework/Data.MySQL/MySQLUserData.cs | 46 +++++++++------------------ 2 files changed, 30 insertions(+), 47 deletions(-) (limited to 'OpenSim/Framework/Data.MySQL') diff --git a/OpenSim/Framework/Data.MySQL/MySQLManager.cs b/OpenSim/Framework/Data.MySQL/MySQLManager.cs index 46fd1bc..d422687 100644 --- a/OpenSim/Framework/Data.MySQL/MySQLManager.cs +++ b/OpenSim/Framework/Data.MySQL/MySQLManager.cs @@ -138,13 +138,11 @@ namespace OpenSim.Framework.Data.MySQL string dllName = module.Assembly.ManifestModule.Name; Version dllVersion = module.Assembly.GetName().Version; - return string.Format("{0}.{1}.{2}.{3}", dllVersion.Major, dllVersion.Minor, dllVersion.Build, dllVersion.Revision); } - /// /// Extract a named string resource from the embedded resources /// @@ -156,7 +154,9 @@ namespace OpenSim.Framework.Data.MySQL string[] names = assem.GetManifestResourceNames(); foreach (string s in names) + { if (s.EndsWith(name)) + { using (Stream resource = assem.GetManifestResourceStream(s)) { using (StreamReader resourceReader = new StreamReader(resource)) @@ -165,6 +165,8 @@ namespace OpenSim.Framework.Data.MySQL return resourceString; } } + } + } throw new Exception(string.Format("Resource '{0}' was not found", name)); } @@ -214,8 +216,7 @@ namespace OpenSim.Framework.Data.MySQL } } - - // at some time this code should be cleaned up + // TODO: at some time this code should be cleaned up /// /// Runs a query with protection against SQL Injection by using parameterised input. @@ -249,7 +250,7 @@ namespace OpenSim.Framework.Data.MySQL { } - // Try reopen it + // Try to reopen it try { dbcon = new MySqlConnection(connectionString); @@ -368,7 +369,7 @@ namespace OpenSim.Framework.Data.MySQL retval.reservationMinY = Convert.ToInt32(reader["resYMin"].ToString()); retval.reservationName = (string) reader["resName"]; retval.status = Convert.ToInt32(reader["status"].ToString()) == 1; - LLUUID.TryParse((string) reader["userUUID"], out retval.userUUID); + LLUUID.TryParse((string) reader["userUUID"], out retval.userUUID); } else { @@ -458,22 +459,22 @@ namespace OpenSim.Framework.Data.MySQL else retval.profileAboutText = (string) reader["profileAboutText"]; - if (reader.IsDBNull( reader.GetOrdinal( "profileFirstText" ) ) ) + if (reader.IsDBNull(reader.GetOrdinal("profileFirstText"))) retval.profileFirstText = ""; else retval.profileFirstText = (string)reader["profileFirstText"]; - if (reader.IsDBNull( reader.GetOrdinal( "profileImage" ) ) ) + if (reader.IsDBNull(reader.GetOrdinal("profileImage"))) retval.profileImage = LLUUID.Zero; else LLUUID.TryParse((string)reader["profileImage"], out retval.profileImage); - if (reader.IsDBNull( reader.GetOrdinal( "profileFirstImage" ) ) ) + if (reader.IsDBNull(reader.GetOrdinal("profileFirstImage"))) retval.profileFirstImage = LLUUID.Zero; else LLUUID.TryParse((string)reader["profileFirstImage"], out retval.profileFirstImage); - if( reader.IsDBNull( reader.GetOrdinal( "webLoginKey" ) ) ) + if(reader.IsDBNull(reader.GetOrdinal("webLoginKey"))) { retval.webLoginKey = LLUUID.Zero; } @@ -489,7 +490,6 @@ namespace OpenSim.Framework.Data.MySQL return retval; } - /// /// Inserts a new row into the log database /// @@ -534,7 +534,6 @@ namespace OpenSim.Framework.Data.MySQL return returnval; } - /// /// Creates a new user and inserts it into the database /// @@ -630,7 +629,7 @@ namespace OpenSim.Framework.Data.MySQL return returnval; } - /// + /// /// Creates a new user and inserts it into the database /// /// User ID @@ -823,6 +822,7 @@ namespace OpenSim.Framework.Data.MySQL return returnval; } + /// /// Delete a region from the database /// @@ -833,14 +833,13 @@ namespace OpenSim.Framework.Data.MySQL { bool returnval = false; - string sql = - "DELETE FROM regions WHERE uuid = ?uuid;"; + string sql = "DELETE FROM regions WHERE uuid = ?uuid;"; Dictionary parameters = new Dictionary(); try { - parameters["?uuid"] = uuid; + parameters["?uuid"] = uuid; IDbCommand result = Query(sql, parameters); diff --git a/OpenSim/Framework/Data.MySQL/MySQLUserData.cs b/OpenSim/Framework/Data.MySQL/MySQLUserData.cs index 4c76461..1370b1b 100644 --- a/OpenSim/Framework/Data.MySQL/MySQLUserData.cs +++ b/OpenSim/Framework/Data.MySQL/MySQLUserData.cs @@ -108,7 +108,6 @@ namespace OpenSim.Framework.Data.MySQL UpgradeAgentsTable(tableList[m_agentsTableName]); UpgradeUsersTable(tableList[m_usersTableName]); UpgradeFriendsTable(tableList[m_userFriendsTableName]); - } /// @@ -227,7 +226,6 @@ namespace OpenSim.Framework.Data.MySQL "(?friendID,?ownerID,?friendPerms,?datetimestamp)", param); adder.ExecuteNonQuery(); - } } catch (Exception e) @@ -244,23 +242,21 @@ namespace OpenSim.Framework.Data.MySQL param["?ownerID"] = friendlistowner.UUID.ToString(); param["?friendID"] = friend.UUID.ToString(); - try { lock (database) { IDbCommand updater = database.Query( - "delete from " + m_userFriendsTableName + " where ownerID = ?ownerID and friendID = ?friendID", + "delete from " + m_userFriendsTableName + " where ownerID = ?ownerID and friendID = ?friendID", param); updater.ExecuteNonQuery(); updater = database.Query( - "delete from " + m_userFriendsTableName + " where ownerID = ?friendID and friendID = ?ownerID", + "delete from " + m_userFriendsTableName + " where ownerID = ?friendID and friendID = ?ownerID", param); updater.ExecuteNonQuery(); - } } catch (Exception e) @@ -270,13 +266,13 @@ namespace OpenSim.Framework.Data.MySQL return; } } + public void UpdateUserFriendPerms(LLUUID friendlistowner, LLUUID friend, uint perms) { Dictionary param = new Dictionary(); param["?ownerID"] = friendlistowner.UUID.ToString(); param["?friendID"] = friend.UUID.ToString(); param["?friendPerms"] = perms.ToString(); - try { @@ -284,12 +280,11 @@ namespace OpenSim.Framework.Data.MySQL { IDbCommand updater = database.Query( - "update " + m_userFriendsTableName + - " SET friendPerms = ?friendPerms " + - "where ownerID = ?ownerID and friendID = ?friendID", + "update " + m_userFriendsTableName + + " SET friendPerms = ?friendPerms " + + "where ownerID = ?ownerID and friendID = ?friendID", param); updater.ExecuteNonQuery(); - } } catch (Exception e) @@ -300,7 +295,6 @@ namespace OpenSim.Framework.Data.MySQL } } - public List GetUserFriendList(LLUUID friendlistowner) { List Lfli = new List(); @@ -315,12 +309,11 @@ namespace OpenSim.Framework.Data.MySQL //Left Join userfriends to itself IDbCommand result = database.Query( - "select a.ownerID,a.friendID,a.friendPerms,b.friendPerms as ownerperms from " + m_userFriendsTableName + " as a, " + m_userFriendsTableName + " as b" + - " where a.ownerID = ?ownerID and b.ownerID = a.friendID and b.friendID = a.ownerID", + "select a.ownerID,a.friendID,a.friendPerms,b.friendPerms as ownerperms from " + m_userFriendsTableName + " as a, " + m_userFriendsTableName + " as b" + + " where a.ownerID = ?ownerID and b.ownerID = a.friendID and b.friendID = a.ownerID", param); IDataReader reader = result.ExecuteReader(); - while (reader.Read()) { FriendListItem fli = new FriendListItem(); @@ -354,7 +347,6 @@ namespace OpenSim.Framework.Data.MySQL m_log.Info("[USER]: Stub UpdateUserCUrrentRegion called"); } - public List GeneratePickerResults(LLUUID queryID, string query) { List returnlist = new List(); @@ -378,7 +370,6 @@ namespace OpenSim.Framework.Data.MySQL param); IDataReader reader = result.ExecuteReader(); - while (reader.Read()) { Framework.AvatarPickerAvatar user = new Framework.AvatarPickerAvatar(); @@ -413,7 +404,6 @@ namespace OpenSim.Framework.Data.MySQL param); IDataReader reader = result.ExecuteReader(); - while (reader.Read()) { Framework.AvatarPickerAvatar user = new Framework.AvatarPickerAvatar(); @@ -489,7 +479,6 @@ namespace OpenSim.Framework.Data.MySQL public void StoreWebLoginKey(LLUUID AgentID, LLUUID WebLoginKey) { - Dictionary param = new Dictionary(); param["?UUID"] = AgentID.UUID.ToString(); param["?webLoginKey"] = WebLoginKey.UUID.ToString(); @@ -500,11 +489,10 @@ namespace OpenSim.Framework.Data.MySQL { IDbCommand updater = database.Query( - "update " + m_usersTableName + " SET webLoginKey = ?webLoginKey " + - "where UUID = ?UUID", + "update " + m_usersTableName + " SET webLoginKey = ?webLoginKey " + + "where UUID = ?UUID", param); updater.ExecuteNonQuery(); - } } catch (Exception e) @@ -513,10 +501,6 @@ namespace OpenSim.Framework.Data.MySQL m_log.Error(e.ToString()); return; } - - - - } /// @@ -605,11 +589,11 @@ namespace OpenSim.Framework.Data.MySQL /// The profile data to use to update the DB public bool UpdateUserProfile(UserProfileData user) { - database.updateUserRow(user.UUID, user.username, user.surname, user.passwordHash, user.passwordSalt - , user.homeRegion, user.homeLocation.X, user.homeLocation.Y, user.homeLocation.Z, user.homeLookAt.X - , user.homeLookAt.Y, user.homeLookAt.Z, user.created, user.lastLogin, user.userInventoryURI - , user.userAssetURI, user.profileCanDoMask, user.profileWantDoMask, user.profileAboutText - , user.profileFirstText, user.profileImage, user.profileFirstImage, user.webLoginKey); + database.updateUserRow(user.UUID, user.username, user.surname, user.passwordHash, user.passwordSalt, + user.homeRegion, user.homeLocation.X, user.homeLocation.Y, user.homeLocation.Z, user.homeLookAt.X, + user.homeLookAt.Y, user.homeLookAt.Z, user.created, user.lastLogin, user.userInventoryURI, + user.userAssetURI, user.profileCanDoMask, user.profileWantDoMask, user.profileAboutText, + user.profileFirstText, user.profileImage, user.profileFirstImage, user.webLoginKey); return true; } -- cgit v1.1