diff options
author | lbsa71 | 2007-12-27 21:41:48 +0000 |
---|---|---|
committer | lbsa71 | 2007-12-27 21:41:48 +0000 |
commit | efd90b56b761219af6425b1c7a2cdd3b6ffb4de2 (patch) | |
tree | bf5b897e1e3c13211e3e2fc61d30508b94c928c0 /OpenSim/Framework/Data.MySQL/MySQLGridData.cs | |
parent | * removed always true if (diff) | |
download | opensim-SC-efd90b56b761219af6425b1c7a2cdd3b6ffb4de2.zip opensim-SC-efd90b56b761219af6425b1c7a2cdd3b6ffb4de2.tar.gz opensim-SC-efd90b56b761219af6425b1c7a2cdd3b6ffb4de2.tar.bz2 opensim-SC-efd90b56b761219af6425b1c7a2cdd3b6ffb4de2.tar.xz |
* Optimized usings
* shortened references
* Removed redundant 'this'
* Normalized EOF
Diffstat (limited to 'OpenSim/Framework/Data.MySQL/MySQLGridData.cs')
-rw-r--r-- | OpenSim/Framework/Data.MySQL/MySQLGridData.cs | 49 |
1 files changed, 23 insertions, 26 deletions
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; | |||
31 | using System.Data; | 31 | using System.Data; |
32 | using System.Security.Cryptography; | 32 | using System.Security.Cryptography; |
33 | using System.Text; | 33 | using System.Text; |
34 | using System.Text.RegularExpressions; | ||
34 | using libsecondlife; | 35 | using libsecondlife; |
35 | using OpenSim.Framework.Console; | 36 | using OpenSim.Framework.Console; |
36 | 37 | ||
@@ -62,7 +63,7 @@ namespace OpenSim.Framework.Data.MySQL | |||
62 | database = | 63 | database = |
63 | new MySQLManager(settingHostname, settingDatabase, settingUsername, settingPassword, settingPooling, | 64 | new MySQLManager(settingHostname, settingDatabase, settingUsername, settingPassword, settingPooling, |
64 | settingPort); | 65 | settingPort); |
65 | 66 | ||
66 | TestTables(); | 67 | TestTables(); |
67 | } | 68 | } |
68 | 69 | ||
@@ -80,7 +81,7 @@ namespace OpenSim.Framework.Data.MySQL | |||
80 | 81 | ||
81 | UpgradeRegionsTable(tableList["regions"]); | 82 | UpgradeRegionsTable(tableList["regions"]); |
82 | } | 83 | } |
83 | 84 | ||
84 | /// <summary> | 85 | /// <summary> |
85 | /// Create or upgrade the table if necessary | 86 | /// Create or upgrade the table if necessary |
86 | /// </summary> | 87 | /// </summary> |
@@ -94,10 +95,10 @@ namespace OpenSim.Framework.Data.MySQL | |||
94 | database.ExecuteResourceSql("CreateRegionsTable.sql"); | 95 | database.ExecuteResourceSql("CreateRegionsTable.sql"); |
95 | return; | 96 | return; |
96 | } | 97 | } |
97 | } | 98 | } |
98 | 99 | ||
99 | #endregion | 100 | #endregion |
100 | 101 | ||
101 | /// <summary> | 102 | /// <summary> |
102 | /// Shuts down the grid interface | 103 | /// Shuts down the grid interface |
103 | /// </summary> | 104 | /// </summary> |
@@ -203,42 +204,41 @@ namespace OpenSim.Framework.Data.MySQL | |||
203 | return null; | 204 | return null; |
204 | } | 205 | } |
205 | } | 206 | } |
207 | |||
206 | /// <summary> | 208 | /// <summary> |
207 | /// // Returns a list of avatar and UUIDs that match the query | 209 | /// // Returns a list of avatar and UUIDs that match the query |
208 | /// </summary> | 210 | /// </summary> |
209 | |||
210 | public List<AvatarPickerAvatar> GeneratePickerResults(LLUUID queryID, string query) | 211 | public List<AvatarPickerAvatar> GeneratePickerResults(LLUUID queryID, string query) |
211 | { | 212 | { |
212 | List<AvatarPickerAvatar> returnlist = new List<AvatarPickerAvatar>(); | 213 | List<AvatarPickerAvatar> returnlist = new List<AvatarPickerAvatar>(); |
213 | 214 | ||
214 | System.Text.RegularExpressions.Regex objAlphaNumericPattern = new System.Text.RegularExpressions.Regex("[^a-zA-Z0-9]"); | 215 | Regex objAlphaNumericPattern = new Regex("[^a-zA-Z0-9]"); |
215 | 216 | ||
216 | string[] querysplit; | 217 | string[] querysplit; |
217 | querysplit = query.Split(' '); | 218 | querysplit = query.Split(' '); |
218 | if (querysplit.Length == 2) | 219 | if (querysplit.Length == 2) |
219 | { | 220 | { |
220 | Dictionary<string, string> param = new Dictionary<string, string>(); | 221 | Dictionary<string, string> param = new Dictionary<string, string>(); |
221 | param["?first"] = objAlphaNumericPattern.Replace(querysplit[0],"") + "%"; | 222 | param["?first"] = objAlphaNumericPattern.Replace(querysplit[0], "") + "%"; |
222 | param["?second"] = objAlphaNumericPattern.Replace(querysplit[1], "") + "%"; | 223 | param["?second"] = objAlphaNumericPattern.Replace(querysplit[1], "") + "%"; |
223 | try | 224 | try |
224 | { | 225 | { |
225 | lock (database) | 226 | lock (database) |
226 | { | 227 | { |
227 | |||
228 | |||
229 | IDbCommand result = | 228 | IDbCommand result = |
230 | database.Query("SELECT UUID,username,surname FROM users WHERE username like ?first AND lastname like ?second LIMIT 100", param); | 229 | database.Query( |
230 | "SELECT UUID,username,surname FROM users WHERE username like ?first AND lastname like ?second LIMIT 100", | ||
231 | param); | ||
231 | IDataReader reader = result.ExecuteReader(); | 232 | IDataReader reader = result.ExecuteReader(); |
232 | 233 | ||
233 | 234 | ||
234 | while (reader.Read()) | 235 | while (reader.Read()) |
235 | { | 236 | { |
236 | AvatarPickerAvatar user = new AvatarPickerAvatar(); | 237 | AvatarPickerAvatar user = new AvatarPickerAvatar(); |
237 | user.AvatarID = new LLUUID((string)reader["UUID"]); | 238 | user.AvatarID = new LLUUID((string) reader["UUID"]); |
238 | user.firstName = (string)reader["username"]; | 239 | user.firstName = (string) reader["username"]; |
239 | user.lastName = (string)reader["surname"]; | 240 | user.lastName = (string) reader["surname"]; |
240 | returnlist.Add(user); | 241 | returnlist.Add(user); |
241 | |||
242 | } | 242 | } |
243 | reader.Close(); | 243 | reader.Close(); |
244 | result.Dispose(); | 244 | result.Dispose(); |
@@ -250,33 +250,30 @@ namespace OpenSim.Framework.Data.MySQL | |||
250 | MainLog.Instance.Error(e.ToString()); | 250 | MainLog.Instance.Error(e.ToString()); |
251 | return returnlist; | 251 | return returnlist; |
252 | } | 252 | } |
253 | |||
254 | |||
255 | |||
256 | } | 253 | } |
257 | else if (querysplit.Length == 1) | 254 | else if (querysplit.Length == 1) |
258 | { | 255 | { |
259 | |||
260 | try | 256 | try |
261 | { | 257 | { |
262 | lock (database) | 258 | lock (database) |
263 | { | 259 | { |
264 | Dictionary<string, string> param = new Dictionary<string, string>(); | 260 | Dictionary<string, string> param = new Dictionary<string, string>(); |
265 | param["?first"] = objAlphaNumericPattern.Replace(querysplit[0],"") + "%"; | 261 | param["?first"] = objAlphaNumericPattern.Replace(querysplit[0], "") + "%"; |
266 | 262 | ||
267 | IDbCommand result = | 263 | IDbCommand result = |
268 | database.Query("SELECT UUID,username,surname FROM users WHERE username like ?first OR lastname like ?second", param); | 264 | database.Query( |
265 | "SELECT UUID,username,surname FROM users WHERE username like ?first OR lastname like ?second", | ||
266 | param); | ||
269 | IDataReader reader = result.ExecuteReader(); | 267 | IDataReader reader = result.ExecuteReader(); |
270 | 268 | ||
271 | 269 | ||
272 | while (reader.Read()) | 270 | while (reader.Read()) |
273 | { | 271 | { |
274 | AvatarPickerAvatar user = new AvatarPickerAvatar(); | 272 | AvatarPickerAvatar user = new AvatarPickerAvatar(); |
275 | user.AvatarID = new LLUUID((string)reader["UUID"]); | 273 | user.AvatarID = new LLUUID((string) reader["UUID"]); |
276 | user.firstName = (string)reader["username"]; | 274 | user.firstName = (string) reader["username"]; |
277 | user.lastName = (string)reader["surname"]; | 275 | user.lastName = (string) reader["surname"]; |
278 | returnlist.Add(user); | 276 | returnlist.Add(user); |
279 | |||
280 | } | 277 | } |
281 | reader.Close(); | 278 | reader.Close(); |
282 | result.Dispose(); | 279 | result.Dispose(); |
@@ -413,4 +410,4 @@ namespace OpenSim.Framework.Data.MySQL | |||
413 | } | 410 | } |
414 | } | 411 | } |
415 | } | 412 | } |
416 | } | 413 | } \ No newline at end of file |