aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/Data.MySQL/MySQLManager.cs
diff options
context:
space:
mode:
authorlbsa712007-10-30 09:05:31 +0000
committerlbsa712007-10-30 09:05:31 +0000
commit67e12b95ea7b68f4904a7484d77ecfd787d16d0c (patch)
tree20b00d24c8a7617017960432ec044852e3ad5fa9 /OpenSim/Framework/Data.MySQL/MySQLManager.cs
parent* Deleted .user file (diff)
downloadopensim-SC-67e12b95ea7b68f4904a7484d77ecfd787d16d0c.zip
opensim-SC-67e12b95ea7b68f4904a7484d77ecfd787d16d0c.tar.gz
opensim-SC-67e12b95ea7b68f4904a7484d77ecfd787d16d0c.tar.bz2
opensim-SC-67e12b95ea7b68f4904a7484d77ecfd787d16d0c.tar.xz
* Optimized usings
* Shortened type references * Removed redundant 'this' qualifier
Diffstat (limited to 'OpenSim/Framework/Data.MySQL/MySQLManager.cs')
-rw-r--r--OpenSim/Framework/Data.MySQL/MySQLManager.cs329
1 files changed, 174 insertions, 155 deletions
diff --git a/OpenSim/Framework/Data.MySQL/MySQLManager.cs b/OpenSim/Framework/Data.MySQL/MySQLManager.cs
index 8fcf68b..778da06 100644
--- a/OpenSim/Framework/Data.MySQL/MySQLManager.cs
+++ b/OpenSim/Framework/Data.MySQL/MySQLManager.cs
@@ -25,16 +25,14 @@
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26* 26*
27*/ 27*/
28
28using System; 29using System;
29using System.IO; 30using System.Collections.Generic;
30using System.Data; 31using System.Data;
32using System.IO;
31using System.Reflection; 33using System.Reflection;
32using System.Collections.Generic;
33using libsecondlife; 34using libsecondlife;
34
35using MySql.Data.MySqlClient; 35using MySql.Data.MySqlClient;
36
37using OpenSim.Framework;
38using OpenSim.Framework.Console; 36using OpenSim.Framework.Console;
39 37
40namespace OpenSim.Framework.Data.MySQL 38namespace OpenSim.Framework.Data.MySQL
@@ -42,16 +40,17 @@ namespace OpenSim.Framework.Data.MySQL
42 /// <summary> 40 /// <summary>
43 /// A MySQL Database manager 41 /// A MySQL Database manager
44 /// </summary> 42 /// </summary>
45 class MySQLManager 43 internal class MySQLManager
46 { 44 {
47 /// <summary> 45 /// <summary>
48 /// The database connection object 46 /// The database connection object
49 /// </summary> 47 /// </summary>
50 MySqlConnection dbcon; 48 private MySqlConnection dbcon;
49
51 /// <summary> 50 /// <summary>
52 /// Connection string for ADO.net 51 /// Connection string for ADO.net
53 /// </summary> 52 /// </summary>
54 string connectionString; 53 private string connectionString;
55 54
56 /// <summary> 55 /// <summary>
57 /// Initialises and creates a new MySQL connection and maintains it. 56 /// Initialises and creates a new MySQL connection and maintains it.
@@ -61,11 +60,13 @@ namespace OpenSim.Framework.Data.MySQL
61 /// <param name="username">The username logging into the database</param> 60 /// <param name="username">The username logging into the database</param>
62 /// <param name="password">The password for the user logging in</param> 61 /// <param name="password">The password for the user logging in</param>
63 /// <param name="cpooling">Whether to use connection pooling or not, can be one of the following: 'yes', 'true', 'no' or 'false', if unsure use 'false'.</param> 62 /// <param name="cpooling">Whether to use connection pooling or not, can be one of the following: 'yes', 'true', 'no' or 'false', if unsure use 'false'.</param>
64 public MySQLManager(string hostname, string database, string username, string password, string cpooling, string port) 63 public MySQLManager(string hostname, string database, string username, string password, string cpooling,
64 string port)
65 { 65 {
66 try 66 try
67 { 67 {
68 connectionString = "Server=" + hostname + ";Port=" + port + ";Database=" + database + ";User ID=" + username + ";Password=" + password + ";Pooling=" + cpooling + ";"; 68 connectionString = "Server=" + hostname + ";Port=" + port + ";Database=" + database + ";User ID=" +
69 username + ";Password=" + password + ";Pooling=" + cpooling + ";";
69 dbcon = new MySqlConnection(connectionString); 70 dbcon = new MySqlConnection(connectionString);
70 71
71 dbcon.Open(); 72 dbcon.Open();
@@ -123,15 +124,17 @@ namespace OpenSim.Framework.Data.MySQL
123 /// <returns>A string containing the DB provider</returns> 124 /// <returns>A string containing the DB provider</returns>
124 public string getVersion() 125 public string getVersion()
125 { 126 {
126 System.Reflection.Module module = this.GetType().Module; 127 Module module = GetType().Module;
127 string dllName = module.Assembly.ManifestModule.Name; 128 string dllName = module.Assembly.ManifestModule.Name;
128 Version dllVersion = module.Assembly.GetName().Version; 129 Version dllVersion = module.Assembly.GetName().Version;
129 130
130 131
131 return string.Format("{0}.{1}.{2}.{3}", dllVersion.Major, dllVersion.Minor, dllVersion.Build, dllVersion.Revision); 132 return
133 string.Format("{0}.{1}.{2}.{3}", dllVersion.Major, dllVersion.Minor, dllVersion.Build,
134 dllVersion.Revision);
132 } 135 }
133 136
134 137
135 /// <summary> 138 /// <summary>
136 /// Extract a named string resource from the embedded resources 139 /// Extract a named string resource from the embedded resources
137 /// </summary> 140 /// </summary>
@@ -139,7 +142,7 @@ namespace OpenSim.Framework.Data.MySQL
139 /// <returns>string contained within the embedded resource</returns> 142 /// <returns>string contained within the embedded resource</returns>
140 private string getResourceString(string name) 143 private string getResourceString(string name)
141 { 144 {
142 Assembly assem = this.GetType().Assembly; 145 Assembly assem = GetType().Assembly;
143 string[] names = assem.GetManifestResourceNames(); 146 string[] names = assem.GetManifestResourceNames();
144 147
145 foreach (string s in names) 148 foreach (string s in names)
@@ -173,7 +176,10 @@ namespace OpenSim.Framework.Data.MySQL
173 { 176 {
174 lock (dbcon) 177 lock (dbcon)
175 { 178 {
176 MySqlCommand tablesCmd = new MySqlCommand("SELECT TABLE_NAME, TABLE_COMMENT FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA=?dbname", dbcon); 179 MySqlCommand tablesCmd =
180 new MySqlCommand(
181 "SELECT TABLE_NAME, TABLE_COMMENT FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA=?dbname",
182 dbcon);
177 tablesCmd.Parameters.AddWithValue("?dbname", dbcon.Database); 183 tablesCmd.Parameters.AddWithValue("?dbname", dbcon.Database);
178 using (MySqlDataReader tables = tablesCmd.ExecuteReader()) 184 using (MySqlDataReader tables = tablesCmd.ExecuteReader())
179 { 185 {
@@ -181,9 +187,9 @@ namespace OpenSim.Framework.Data.MySQL
181 { 187 {
182 try 188 try
183 { 189 {
184 string tableName = (string)tables["TABLE_NAME"]; 190 string tableName = (string) tables["TABLE_NAME"];
185 string comment = (string)tables["TABLE_COMMENT"]; 191 string comment = (string) tables["TABLE_COMMENT"];
186 if(tableList.ContainsKey(tableName)) 192 if (tableList.ContainsKey(tableName))
187 tableList[tableName] = comment; 193 tableList[tableName] = comment;
188 } 194 }
189 catch (Exception e) 195 catch (Exception e)
@@ -198,7 +204,7 @@ namespace OpenSim.Framework.Data.MySQL
198 204
199 205
200 // at some time this code should be cleaned up 206 // at some time this code should be cleaned up
201 207
202 /// <summary> 208 /// <summary>
203 /// Runs a query with protection against SQL Injection by using parameterised input. 209 /// Runs a query with protection against SQL Injection by using parameterised input.
204 /// </summary> 210 /// </summary>
@@ -209,14 +215,14 @@ namespace OpenSim.Framework.Data.MySQL
209 { 215 {
210 try 216 try
211 { 217 {
212 MySqlCommand dbcommand = (MySqlCommand)dbcon.CreateCommand(); 218 MySqlCommand dbcommand = (MySqlCommand) dbcon.CreateCommand();
213 dbcommand.CommandText = sql; 219 dbcommand.CommandText = sql;
214 foreach (KeyValuePair<string, string> param in parameters) 220 foreach (KeyValuePair<string, string> param in parameters)
215 { 221 {
216 dbcommand.Parameters.AddWithValue(param.Key, param.Value); 222 dbcommand.Parameters.AddWithValue(param.Key, param.Value);
217 } 223 }
218 224
219 return (IDbCommand)dbcommand; 225 return (IDbCommand) dbcommand;
220 } 226 }
221 catch 227 catch
222 { 228 {
@@ -227,7 +233,9 @@ namespace OpenSim.Framework.Data.MySQL
227 { 233 {
228 dbcon.Close(); 234 dbcon.Close();
229 } 235 }
230 catch { } 236 catch
237 {
238 }
231 239
232 // Try reopen it 240 // Try reopen it
233 try 241 try
@@ -243,14 +251,14 @@ namespace OpenSim.Framework.Data.MySQL
243 // Run the query again 251 // Run the query again
244 try 252 try
245 { 253 {
246 MySqlCommand dbcommand = (MySqlCommand)dbcon.CreateCommand(); 254 MySqlCommand dbcommand = (MySqlCommand) dbcon.CreateCommand();
247 dbcommand.CommandText = sql; 255 dbcommand.CommandText = sql;
248 foreach (KeyValuePair<string, string> param in parameters) 256 foreach (KeyValuePair<string, string> param in parameters)
249 { 257 {
250 dbcommand.Parameters.AddWithValue(param.Key, param.Value); 258 dbcommand.Parameters.AddWithValue(param.Key, param.Value);
251 } 259 }
252 260
253 return (IDbCommand)dbcommand; 261 return (IDbCommand) dbcommand;
254 } 262 }
255 catch (Exception e) 263 catch (Exception e)
256 { 264 {
@@ -275,20 +283,20 @@ namespace OpenSim.Framework.Data.MySQL
275 { 283 {
276 // Region Main 284 // Region Main
277 retval.regionHandle = Convert.ToUInt64(reader["regionHandle"].ToString()); 285 retval.regionHandle = Convert.ToUInt64(reader["regionHandle"].ToString());
278 retval.regionName = (string)reader["regionName"]; 286 retval.regionName = (string) reader["regionName"];
279 retval.UUID = new LLUUID((string)reader["uuid"]); 287 retval.UUID = new LLUUID((string) reader["uuid"]);
280 288
281 // Secrets 289 // Secrets
282 retval.regionRecvKey = (string)reader["regionRecvKey"]; 290 retval.regionRecvKey = (string) reader["regionRecvKey"];
283 retval.regionSecret = (string)reader["regionSecret"]; 291 retval.regionSecret = (string) reader["regionSecret"];
284 retval.regionSendKey = (string)reader["regionSendKey"]; 292 retval.regionSendKey = (string) reader["regionSendKey"];
285 293
286 // Region Server 294 // Region Server
287 retval.regionDataURI = (string)reader["regionDataURI"]; 295 retval.regionDataURI = (string) reader["regionDataURI"];
288 retval.regionOnline = false; // Needs to be pinged before this can be set. 296 retval.regionOnline = false; // Needs to be pinged before this can be set.
289 retval.serverIP = (string)reader["serverIP"]; 297 retval.serverIP = (string) reader["serverIP"];
290 retval.serverPort = (uint)reader["serverPort"]; 298 retval.serverPort = (uint) reader["serverPort"];
291 retval.serverURI = (string)reader["serverURI"]; 299 retval.serverURI = (string) reader["serverURI"];
292 retval.httpPort = Convert.ToUInt32(reader["serverHttpPort"].ToString()); 300 retval.httpPort = Convert.ToUInt32(reader["serverHttpPort"].ToString());
293 retval.remotingPort = Convert.ToUInt32(reader["serverRemotingPort"].ToString()); 301 retval.remotingPort = Convert.ToUInt32(reader["serverRemotingPort"].ToString());
294 302
@@ -304,14 +312,14 @@ namespace OpenSim.Framework.Data.MySQL
304 retval.regionNorthOverrideHandle = Convert.ToUInt64(reader["northOverrideHandle"].ToString()); 312 retval.regionNorthOverrideHandle = Convert.ToUInt64(reader["northOverrideHandle"].ToString());
305 313
306 // Assets 314 // Assets
307 retval.regionAssetURI = (string)reader["regionAssetURI"]; 315 retval.regionAssetURI = (string) reader["regionAssetURI"];
308 retval.regionAssetRecvKey = (string)reader["regionAssetRecvKey"]; 316 retval.regionAssetRecvKey = (string) reader["regionAssetRecvKey"];
309 retval.regionAssetSendKey = (string)reader["regionAssetSendKey"]; 317 retval.regionAssetSendKey = (string) reader["regionAssetSendKey"];
310 318
311 // Userserver 319 // Userserver
312 retval.regionUserURI = (string)reader["regionUserURI"]; 320 retval.regionUserURI = (string) reader["regionUserURI"];
313 retval.regionUserRecvKey = (string)reader["regionUserRecvKey"]; 321 retval.regionUserRecvKey = (string) reader["regionUserRecvKey"];
314 retval.regionUserSendKey = (string)reader["regionUserSendKey"]; 322 retval.regionUserSendKey = (string) reader["regionUserSendKey"];
315 323
316 // World Map Addition 324 // World Map Addition
317 string tempRegionMap = reader["regionMapTexture"].ToString(); 325 string tempRegionMap = reader["regionMapTexture"].ToString();
@@ -341,17 +349,16 @@ namespace OpenSim.Framework.Data.MySQL
341 ReservationData retval = new ReservationData(); 349 ReservationData retval = new ReservationData();
342 if (reader.Read()) 350 if (reader.Read())
343 { 351 {
344 retval.gridRecvKey = (string)reader["gridRecvKey"]; 352 retval.gridRecvKey = (string) reader["gridRecvKey"];
345 retval.gridSendKey = (string)reader["gridSendKey"]; 353 retval.gridSendKey = (string) reader["gridSendKey"];
346 retval.reservationCompany = (string)reader["resCompany"]; 354 retval.reservationCompany = (string) reader["resCompany"];
347 retval.reservationMaxX = Convert.ToInt32(reader["resXMax"].ToString()); 355 retval.reservationMaxX = Convert.ToInt32(reader["resXMax"].ToString());
348 retval.reservationMaxY = Convert.ToInt32(reader["resYMax"].ToString()); 356 retval.reservationMaxY = Convert.ToInt32(reader["resYMax"].ToString());
349 retval.reservationMinX = Convert.ToInt32(reader["resXMin"].ToString()); 357 retval.reservationMinX = Convert.ToInt32(reader["resXMin"].ToString());
350 retval.reservationMinY = Convert.ToInt32(reader["resYMin"].ToString()); 358 retval.reservationMinY = Convert.ToInt32(reader["resYMin"].ToString());
351 retval.reservationName = (string)reader["resName"]; 359 retval.reservationName = (string) reader["resName"];
352 retval.status = Convert.ToInt32(reader["status"].ToString()) == 1; 360 retval.status = Convert.ToInt32(reader["status"].ToString()) == 1;
353 retval.userUUID = new LLUUID((string)reader["userUUID"]); 361 retval.userUUID = new LLUUID((string) reader["userUUID"]);
354
355 } 362 }
356 else 363 else
357 { 364 {
@@ -359,6 +366,7 @@ namespace OpenSim.Framework.Data.MySQL
359 } 366 }
360 return retval; 367 return retval;
361 } 368 }
369
362 /// <summary> 370 /// <summary>
363 /// Reads an agent row from a database reader 371 /// Reads an agent row from a database reader
364 /// </summary> 372 /// </summary>
@@ -371,12 +379,12 @@ namespace OpenSim.Framework.Data.MySQL
371 if (reader.Read()) 379 if (reader.Read())
372 { 380 {
373 // Agent IDs 381 // Agent IDs
374 retval.UUID = new LLUUID((string)reader["UUID"]); 382 retval.UUID = new LLUUID((string) reader["UUID"]);
375 retval.sessionID = new LLUUID((string)reader["sessionID"]); 383 retval.sessionID = new LLUUID((string) reader["sessionID"]);
376 retval.secureSessionID = new LLUUID((string)reader["secureSessionID"]); 384 retval.secureSessionID = new LLUUID((string) reader["secureSessionID"]);
377 385
378 // Agent Who? 386 // Agent Who?
379 retval.agentIP = (string)reader["agentIP"]; 387 retval.agentIP = (string) reader["agentIP"];
380 retval.agentPort = Convert.ToUInt32(reader["agentPort"].ToString()); 388 retval.agentPort = Convert.ToUInt32(reader["agentPort"].ToString());
381 retval.agentOnline = Convert.ToBoolean(reader["agentOnline"].ToString()); 389 retval.agentOnline = Convert.ToBoolean(reader["agentOnline"].ToString());
382 390
@@ -385,9 +393,9 @@ namespace OpenSim.Framework.Data.MySQL
385 retval.logoutTime = Convert.ToInt32(reader["logoutTime"].ToString()); 393 retval.logoutTime = Convert.ToInt32(reader["logoutTime"].ToString());
386 394
387 // Current position 395 // Current position
388 retval.currentRegion = (string)reader["currentRegion"]; 396 retval.currentRegion = (string) reader["currentRegion"];
389 retval.currentHandle = Convert.ToUInt64(reader["currentHandle"].ToString()); 397 retval.currentHandle = Convert.ToUInt64(reader["currentHandle"].ToString());
390 LLVector3.TryParse((string)reader["currentPos"], out retval.currentPos); 398 LLVector3.TryParse((string) reader["currentPos"], out retval.currentPos);
391 } 399 }
392 else 400 else
393 { 401 {
@@ -407,12 +415,12 @@ namespace OpenSim.Framework.Data.MySQL
407 415
408 if (reader.Read()) 416 if (reader.Read())
409 { 417 {
410 retval.UUID = new LLUUID((string)reader["UUID"]); 418 retval.UUID = new LLUUID((string) reader["UUID"]);
411 retval.username = (string)reader["username"]; 419 retval.username = (string) reader["username"];
412 retval.surname = (string)reader["lastname"]; 420 retval.surname = (string) reader["lastname"];
413 421
414 retval.passwordHash = (string)reader["passwordHash"]; 422 retval.passwordHash = (string) reader["passwordHash"];
415 retval.passwordSalt = (string)reader["passwordSalt"]; 423 retval.passwordSalt = (string) reader["passwordSalt"];
416 424
417 retval.homeRegion = Convert.ToUInt64(reader["homeRegion"].ToString()); 425 retval.homeRegion = Convert.ToUInt64(reader["homeRegion"].ToString());
418 retval.homeLocation = new LLVector3( 426 retval.homeLocation = new LLVector3(
@@ -427,18 +435,17 @@ namespace OpenSim.Framework.Data.MySQL
427 retval.created = Convert.ToInt32(reader["created"].ToString()); 435 retval.created = Convert.ToInt32(reader["created"].ToString());
428 retval.lastLogin = Convert.ToInt32(reader["lastLogin"].ToString()); 436 retval.lastLogin = Convert.ToInt32(reader["lastLogin"].ToString());
429 437
430 retval.userInventoryURI = (string)reader["userInventoryURI"]; 438 retval.userInventoryURI = (string) reader["userInventoryURI"];
431 retval.userAssetURI = (string)reader["userAssetURI"]; 439 retval.userAssetURI = (string) reader["userAssetURI"];
432 440
433 retval.profileCanDoMask = Convert.ToUInt32(reader["profileCanDoMask"].ToString()); 441 retval.profileCanDoMask = Convert.ToUInt32(reader["profileCanDoMask"].ToString());
434 retval.profileWantDoMask = Convert.ToUInt32(reader["profileWantDoMask"].ToString()); 442 retval.profileWantDoMask = Convert.ToUInt32(reader["profileWantDoMask"].ToString());
435 443
436 retval.profileAboutText = (string)reader["profileAboutText"]; 444 retval.profileAboutText = (string) reader["profileAboutText"];
437 retval.profileFirstText = (string)reader["profileFirstText"]; 445 retval.profileFirstText = (string) reader["profileFirstText"];
438
439 retval.profileImage = new LLUUID((string)reader["profileImage"]);
440 retval.profileFirstImage = new LLUUID((string)reader["profileFirstImage"]);
441 446
447 retval.profileImage = new LLUUID((string) reader["profileImage"]);
448 retval.profileFirstImage = new LLUUID((string) reader["profileFirstImage"]);
442 } 449 }
443 else 450 else
444 { 451 {
@@ -448,7 +455,6 @@ namespace OpenSim.Framework.Data.MySQL
448 } 455 }
449 456
450 457
451
452 /// <summary> 458 /// <summary>
453 /// Inserts a new row into the log database 459 /// Inserts a new row into the log database
454 /// </summary> 460 /// </summary>
@@ -459,7 +465,8 @@ namespace OpenSim.Framework.Data.MySQL
459 /// <param name="priority">How critical is this?</param> 465 /// <param name="priority">How critical is this?</param>
460 /// <param name="logMessage">Extra message info</param> 466 /// <param name="logMessage">Extra message info</param>
461 /// <returns>Saved successfully?</returns> 467 /// <returns>Saved successfully?</returns>
462 public bool insertLogRow(string serverDaemon, string target, string methodCall, string arguments, int priority, string logMessage) 468 public bool insertLogRow(string serverDaemon, string target, string methodCall, string arguments, int priority,
469 string logMessage)
463 { 470 {
464 string sql = "INSERT INTO logs (`target`, `server`, `method`, `arguments`, `priority`, `message`) VALUES "; 471 string sql = "INSERT INTO logs (`target`, `server`, `method`, `arguments`, `priority`, `message`) VALUES ";
465 sql += "(?target, ?server, ?method, ?arguments, ?priority, ?message)"; 472 sql += "(?target, ?server, ?method, ?arguments, ?priority, ?message)";
@@ -493,89 +500,97 @@ namespace OpenSim.Framework.Data.MySQL
493 } 500 }
494 501
495 502
496 /// <summary> 503 /// <summary>
497 /// Creates a new user and inserts it into the database 504 /// Creates a new user and inserts it into the database
498 /// </summary> 505 /// </summary>
499 /// <param name="uuid">User ID</param> 506 /// <param name="uuid">User ID</param>
500 /// <param name="username">First part of the login</param> 507 /// <param name="username">First part of the login</param>
501 /// <param name="lastname">Second part of the login</param> 508 /// <param name="lastname">Second part of the login</param>
502 /// <param name="passwordHash">A salted hash of the users password</param> 509 /// <param name="passwordHash">A salted hash of the users password</param>
503 /// <param name="passwordSalt">The salt used for the password hash</param> 510 /// <param name="passwordSalt">The salt used for the password hash</param>
504 /// <param name="homeRegion">A regionHandle of the users home region</param> 511 /// <param name="homeRegion">A regionHandle of the users home region</param>
505 /// <param name="homeLocX">Home region position vector</param> 512 /// <param name="homeLocX">Home region position vector</param>
506 /// <param name="homeLocY">Home region position vector</param> 513 /// <param name="homeLocY">Home region position vector</param>
507 /// <param name="homeLocZ">Home region position vector</param> 514 /// <param name="homeLocZ">Home region position vector</param>
508 /// <param name="homeLookAtX">Home region 'look at' vector</param> 515 /// <param name="homeLookAtX">Home region 'look at' vector</param>
509 /// <param name="homeLookAtY">Home region 'look at' vector</param> 516 /// <param name="homeLookAtY">Home region 'look at' vector</param>
510 /// <param name="homeLookAtZ">Home region 'look at' vector</param> 517 /// <param name="homeLookAtZ">Home region 'look at' vector</param>
511 /// <param name="created">Account created (unix timestamp)</param> 518 /// <param name="created">Account created (unix timestamp)</param>
512 /// <param name="lastlogin">Last login (unix timestamp)</param> 519 /// <param name="lastlogin">Last login (unix timestamp)</param>
513 /// <param name="inventoryURI">Users inventory URI</param> 520 /// <param name="inventoryURI">Users inventory URI</param>
514 /// <param name="assetURI">Users asset URI</param> 521 /// <param name="assetURI">Users asset URI</param>
515 /// <param name="canDoMask">I can do mask</param> 522 /// <param name="canDoMask">I can do mask</param>
516 /// <param name="wantDoMask">I want to do mask</param> 523 /// <param name="wantDoMask">I want to do mask</param>
517 /// <param name="aboutText">Profile text</param> 524 /// <param name="aboutText">Profile text</param>
518 /// <param name="firstText">Firstlife text</param> 525 /// <param name="firstText">Firstlife text</param>
519 /// <param name="profileImage">UUID for profile image</param> 526 /// <param name="profileImage">UUID for profile image</param>
520 /// <param name="firstImage">UUID for firstlife image</param> 527 /// <param name="firstImage">UUID for firstlife image</param>
521 /// <returns>Success?</returns> 528 /// <returns>Success?</returns>
522 public bool insertUserRow(libsecondlife.LLUUID uuid, string username, string lastname, string passwordHash, string passwordSalt, UInt64 homeRegion, float homeLocX, float homeLocY, float homeLocZ, 529 public bool insertUserRow(LLUUID uuid, string username, string lastname, string passwordHash,
523 float homeLookAtX, float homeLookAtY, float homeLookAtZ, int created, int lastlogin, string inventoryURI, string assetURI, uint canDoMask, uint wantDoMask, string aboutText, string firstText, 530 string passwordSalt, UInt64 homeRegion, float homeLocX, float homeLocY, float homeLocZ,
524 libsecondlife.LLUUID profileImage, libsecondlife.LLUUID firstImage) 531 float homeLookAtX, float homeLookAtY, float homeLookAtZ, int created, int lastlogin,
525 { 532 string inventoryURI, string assetURI, uint canDoMask, uint wantDoMask,
526 string sql = "INSERT INTO users (`UUID`, `username`, `lastname`, `passwordHash`, `passwordSalt`, `homeRegion`, "; 533 string aboutText, string firstText,
527 sql += "`homeLocationX`, `homeLocationY`, `homeLocationZ`, `homeLookAtX`, `homeLookAtY`, `homeLookAtZ`, `created`, "; 534 LLUUID profileImage, LLUUID firstImage)
528 sql += "`lastLogin`, `userInventoryURI`, `userAssetURI`, `profileCanDoMask`, `profileWantDoMask`, `profileAboutText`, "; 535 {
529 sql += "`profileFirstText`, `profileImage`, `profileFirstImage`) VALUES "; 536 string sql =
530 537 "INSERT INTO users (`UUID`, `username`, `lastname`, `passwordHash`, `passwordSalt`, `homeRegion`, ";
531 sql += "(?UUID, ?username, ?lastname, ?passwordHash, ?passwordSalt, ?homeRegion, "; 538 sql +=
532 sql += "?homeLocationX, ?homeLocationY, ?homeLocationZ, ?homeLookAtX, ?homeLookAtY, ?homeLookAtZ, ?created, "; 539 "`homeLocationX`, `homeLocationY`, `homeLocationZ`, `homeLookAtX`, `homeLookAtY`, `homeLookAtZ`, `created`, ";
533 sql += "?lastLogin, ?userInventoryURI, ?userAssetURI, ?profileCanDoMask, ?profileWantDoMask, ?profileAboutText, "; 540 sql +=
534 sql += "?profileFirstText, ?profileImage, ?profileFirstImage)"; 541 "`lastLogin`, `userInventoryURI`, `userAssetURI`, `profileCanDoMask`, `profileWantDoMask`, `profileAboutText`, ";
535 542 sql += "`profileFirstText`, `profileImage`, `profileFirstImage`) VALUES ";
536 Dictionary<string, string> parameters = new Dictionary<string, string>(); 543
537 parameters["?UUID"] = uuid.ToStringHyphenated(); 544 sql += "(?UUID, ?username, ?lastname, ?passwordHash, ?passwordSalt, ?homeRegion, ";
538 parameters["?username"] = username.ToString(); 545 sql +=
539 parameters["?lastname"] = lastname.ToString(); 546 "?homeLocationX, ?homeLocationY, ?homeLocationZ, ?homeLookAtX, ?homeLookAtY, ?homeLookAtZ, ?created, ";
540 parameters["?passwordHash"] = passwordHash.ToString(); 547 sql +=
541 parameters["?passwordSalt"] = passwordSalt.ToString(); 548 "?lastLogin, ?userInventoryURI, ?userAssetURI, ?profileCanDoMask, ?profileWantDoMask, ?profileAboutText, ";
542 parameters["?homeRegion"] = homeRegion.ToString(); 549 sql += "?profileFirstText, ?profileImage, ?profileFirstImage)";
543 parameters["?homeLocationX"] = homeLocX.ToString(); 550
544 parameters["?homeLocationY"] = homeLocY.ToString(); 551 Dictionary<string, string> parameters = new Dictionary<string, string>();
545 parameters["?homeLocationZ"] = homeLocZ.ToString(); 552 parameters["?UUID"] = uuid.ToStringHyphenated();
546 parameters["?homeLookAtX"] = homeLookAtX.ToString(); 553 parameters["?username"] = username.ToString();
547 parameters["?homeLookAtY"] = homeLookAtY.ToString(); 554 parameters["?lastname"] = lastname.ToString();
548 parameters["?homeLookAtZ"] = homeLookAtZ.ToString(); 555 parameters["?passwordHash"] = passwordHash.ToString();
549 parameters["?created"] = created.ToString(); 556 parameters["?passwordSalt"] = passwordSalt.ToString();
550 parameters["?lastLogin"] = lastlogin.ToString(); 557 parameters["?homeRegion"] = homeRegion.ToString();
551 parameters["?userInventoryURI"] = ""; 558 parameters["?homeLocationX"] = homeLocX.ToString();
552 parameters["?userAssetURI"] = ""; 559 parameters["?homeLocationY"] = homeLocY.ToString();
553 parameters["?profileCanDoMask"] = "0"; 560 parameters["?homeLocationZ"] = homeLocZ.ToString();
554 parameters["?profileWantDoMask"] = "0"; 561 parameters["?homeLookAtX"] = homeLookAtX.ToString();
555 parameters["?profileAboutText"] = ""; 562 parameters["?homeLookAtY"] = homeLookAtY.ToString();
556 parameters["?profileFirstText"] = ""; 563 parameters["?homeLookAtZ"] = homeLookAtZ.ToString();
557 parameters["?profileImage"] = libsecondlife.LLUUID.Zero.ToStringHyphenated(); 564 parameters["?created"] = created.ToString();
558 parameters["?profileFirstImage"] = libsecondlife.LLUUID.Zero.ToStringHyphenated(); 565 parameters["?lastLogin"] = lastlogin.ToString();
559 566 parameters["?userInventoryURI"] = "";
560 bool returnval = false; 567 parameters["?userAssetURI"] = "";
561 568 parameters["?profileCanDoMask"] = "0";
562 try 569 parameters["?profileWantDoMask"] = "0";
563 { 570 parameters["?profileAboutText"] = "";
564 IDbCommand result = Query(sql, parameters); 571 parameters["?profileFirstText"] = "";
565 572 parameters["?profileImage"] = LLUUID.Zero.ToStringHyphenated();
566 if (result.ExecuteNonQuery() == 1) 573 parameters["?profileFirstImage"] = LLUUID.Zero.ToStringHyphenated();
567 returnval = true; 574
568 575 bool returnval = false;
569 result.Dispose(); 576
570 } 577 try
571 catch (Exception e) 578 {
572 { 579 IDbCommand result = Query(sql, parameters);
573 MainLog.Instance.Error(e.ToString()); 580
574 return false; 581 if (result.ExecuteNonQuery() == 1)
575 } 582 returnval = true;
576 583
577 return returnval; 584 result.Dispose();
578 } 585 }
586 catch (Exception e)
587 {
588 MainLog.Instance.Error(e.ToString());
589 return false;
590 }
591
592 return returnval;
593 }
579 594
580 595
581 /// <summary> 596 /// <summary>
@@ -585,13 +600,18 @@ namespace OpenSim.Framework.Data.MySQL
585 /// <returns>Success?</returns> 600 /// <returns>Success?</returns>
586 public bool insertRegion(RegionProfileData regiondata) 601 public bool insertRegion(RegionProfileData regiondata)
587 { 602 {
588 string sql = "REPLACE INTO regions (regionHandle, regionName, uuid, regionRecvKey, regionSecret, regionSendKey, regionDataURI, "; 603 string sql =
589 sql += "serverIP, serverPort, serverURI, locX, locY, locZ, eastOverrideHandle, westOverrideHandle, southOverrideHandle, northOverrideHandle, regionAssetURI, regionAssetRecvKey, "; 604 "REPLACE INTO regions (regionHandle, regionName, uuid, regionRecvKey, regionSecret, regionSendKey, regionDataURI, ";
590 sql += "regionAssetSendKey, regionUserURI, regionUserRecvKey, regionUserSendKey, regionMapTexture, serverHttpPort, serverRemotingPort) VALUES "; 605 sql +=
606 "serverIP, serverPort, serverURI, locX, locY, locZ, eastOverrideHandle, westOverrideHandle, southOverrideHandle, northOverrideHandle, regionAssetURI, regionAssetRecvKey, ";
607 sql +=
608 "regionAssetSendKey, regionUserURI, regionUserRecvKey, regionUserSendKey, regionMapTexture, serverHttpPort, serverRemotingPort) VALUES ";
591 609
592 sql += "(?regionHandle, ?regionName, ?uuid, ?regionRecvKey, ?regionSecret, ?regionSendKey, ?regionDataURI, "; 610 sql += "(?regionHandle, ?regionName, ?uuid, ?regionRecvKey, ?regionSecret, ?regionSendKey, ?regionDataURI, ";
593 sql += "?serverIP, ?serverPort, ?serverURI, ?locX, ?locY, ?locZ, ?eastOverrideHandle, ?westOverrideHandle, ?southOverrideHandle, ?northOverrideHandle, ?regionAssetURI, ?regionAssetRecvKey, "; 611 sql +=
594 sql += "?regionAssetSendKey, ?regionUserURI, ?regionUserRecvKey, ?regionUserSendKey, ?regionMapTexture, ?serverHttpPort, ?serverRemotingPort);"; 612 "?serverIP, ?serverPort, ?serverURI, ?locX, ?locY, ?locZ, ?eastOverrideHandle, ?westOverrideHandle, ?southOverrideHandle, ?northOverrideHandle, ?regionAssetURI, ?regionAssetRecvKey, ";
613 sql +=
614 "?regionAssetSendKey, ?regionUserURI, ?regionUserRecvKey, ?regionUserSendKey, ?regionMapTexture, ?serverHttpPort, ?serverRemotingPort);";
595 615
596 Dictionary<string, string> parameters = new Dictionary<string, string>(); 616 Dictionary<string, string> parameters = new Dictionary<string, string>();
597 617
@@ -626,7 +646,6 @@ namespace OpenSim.Framework.Data.MySQL
626 646
627 try 647 try
628 { 648 {
629
630 IDbCommand result = Query(sql, parameters); 649 IDbCommand result = Query(sql, parameters);
631 650
632 //Console.WriteLine(result.CommandText); 651 //Console.WriteLine(result.CommandText);
@@ -646,4 +665,4 @@ namespace OpenSim.Framework.Data.MySQL
646 return returnval; 665 return returnval;
647 } 666 }
648 } 667 }
649} 668} \ No newline at end of file