From efd90b56b761219af6425b1c7a2cdd3b6ffb4de2 Mon Sep 17 00:00:00 2001 From: lbsa71 Date: Thu, 27 Dec 2007 21:41:48 +0000 Subject: * Optimized usings * shortened references * Removed redundant 'this' * Normalized EOF --- OpenSim/Framework/Data.MySQL/MySQLGridData.cs | 49 +++++++++++++-------------- 1 file changed, 23 insertions(+), 26 deletions(-) (limited to 'OpenSim/Framework/Data.MySQL/MySQLGridData.cs') diff --git a/OpenSim/Framework/Data.MySQL/MySQLGridData.cs b/OpenSim/Framework/Data.MySQL/MySQLGridData.cs index 7843562..7cfac12 100644 --- a/OpenSim/Framework/Data.MySQL/MySQLGridData.cs +++ b/OpenSim/Framework/Data.MySQL/MySQLGridData.cs @@ -31,6 +31,7 @@ using System.Collections.Generic; using System.Data; using System.Security.Cryptography; using System.Text; +using System.Text.RegularExpressions; using libsecondlife; using OpenSim.Framework.Console; @@ -62,7 +63,7 @@ namespace OpenSim.Framework.Data.MySQL database = new MySQLManager(settingHostname, settingDatabase, settingUsername, settingPassword, settingPooling, settingPort); - + TestTables(); } @@ -80,7 +81,7 @@ namespace OpenSim.Framework.Data.MySQL UpgradeRegionsTable(tableList["regions"]); } - + /// /// Create or upgrade the table if necessary /// @@ -94,10 +95,10 @@ namespace OpenSim.Framework.Data.MySQL database.ExecuteResourceSql("CreateRegionsTable.sql"); return; } - } - + } + #endregion - + /// /// Shuts down the grid interface /// @@ -203,42 +204,41 @@ namespace OpenSim.Framework.Data.MySQL return null; } } + /// /// // Returns a list of avatar and UUIDs that match the query /// - public List GeneratePickerResults(LLUUID queryID, string query) { List returnlist = new List(); - System.Text.RegularExpressions.Regex objAlphaNumericPattern = new System.Text.RegularExpressions.Regex("[^a-zA-Z0-9]"); + Regex objAlphaNumericPattern = new Regex("[^a-zA-Z0-9]"); string[] querysplit; querysplit = query.Split(' '); if (querysplit.Length == 2) { Dictionary param = new Dictionary(); - param["?first"] = objAlphaNumericPattern.Replace(querysplit[0],"") + "%"; + param["?first"] = objAlphaNumericPattern.Replace(querysplit[0], "") + "%"; param["?second"] = objAlphaNumericPattern.Replace(querysplit[1], "") + "%"; try { lock (database) { - - IDbCommand result = - database.Query("SELECT UUID,username,surname FROM users WHERE username like ?first AND lastname like ?second LIMIT 100", param); + database.Query( + "SELECT UUID,username,surname FROM users WHERE username like ?first AND lastname like ?second LIMIT 100", + param); IDataReader reader = result.ExecuteReader(); while (reader.Read()) { AvatarPickerAvatar user = new AvatarPickerAvatar(); - user.AvatarID = new LLUUID((string)reader["UUID"]); - user.firstName = (string)reader["username"]; - user.lastName = (string)reader["surname"]; + user.AvatarID = new LLUUID((string) reader["UUID"]); + user.firstName = (string) reader["username"]; + user.lastName = (string) reader["surname"]; returnlist.Add(user); - } reader.Close(); result.Dispose(); @@ -250,33 +250,30 @@ namespace OpenSim.Framework.Data.MySQL MainLog.Instance.Error(e.ToString()); return returnlist; } - - - } else if (querysplit.Length == 1) { - try { lock (database) { Dictionary param = new Dictionary(); - param["?first"] = objAlphaNumericPattern.Replace(querysplit[0],"") + "%"; + param["?first"] = objAlphaNumericPattern.Replace(querysplit[0], "") + "%"; IDbCommand result = - database.Query("SELECT UUID,username,surname FROM users WHERE username like ?first OR lastname like ?second", param); + database.Query( + "SELECT UUID,username,surname FROM users WHERE username like ?first OR lastname like ?second", + param); IDataReader reader = result.ExecuteReader(); while (reader.Read()) { AvatarPickerAvatar user = new AvatarPickerAvatar(); - user.AvatarID = new LLUUID((string)reader["UUID"]); - user.firstName = (string)reader["username"]; - user.lastName = (string)reader["surname"]; + user.AvatarID = new LLUUID((string) reader["UUID"]); + user.firstName = (string) reader["username"]; + user.lastName = (string) reader["surname"]; returnlist.Add(user); - } reader.Close(); result.Dispose(); @@ -413,4 +410,4 @@ namespace OpenSim.Framework.Data.MySQL } } } -} +} \ No newline at end of file -- cgit v1.1