diff options
Diffstat (limited to 'OpenSim/Data/MSSQL/MSSQLUserData.cs')
-rw-r--r-- | OpenSim/Data/MSSQL/MSSQLUserData.cs | 518 |
1 files changed, 222 insertions, 296 deletions
diff --git a/OpenSim/Data/MSSQL/MSSQLUserData.cs b/OpenSim/Data/MSSQL/MSSQLUserData.cs index cb5ba24..20c3acd 100644 --- a/OpenSim/Data/MSSQL/MSSQLUserData.cs +++ b/OpenSim/Data/MSSQL/MSSQLUserData.cs | |||
@@ -44,7 +44,7 @@ namespace OpenSim.Data.MSSQL | |||
44 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 44 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
45 | 45 | ||
46 | /// <summary> | 46 | /// <summary> |
47 | /// Database manager for MySQL | 47 | /// Database manager for MSSQL |
48 | /// </summary> | 48 | /// </summary> |
49 | public MSSQLManager database; | 49 | public MSSQLManager database; |
50 | 50 | ||
@@ -100,36 +100,41 @@ namespace OpenSim.Data.MSSQL | |||
100 | /// <returns></returns> | 100 | /// <returns></returns> |
101 | private bool TestTables() | 101 | private bool TestTables() |
102 | { | 102 | { |
103 | IDbCommand cmd; | ||
104 | 103 | ||
105 | cmd = database.Query("select top 1 * from " + m_usersTableName, new Dictionary<string, string>()); | 104 | using (IDbCommand cmd = database.Query("select top 1 * from " + m_usersTableName, new Dictionary<string, string>())) |
106 | try | ||
107 | { | ||
108 | cmd.ExecuteNonQuery(); | ||
109 | } | ||
110 | catch | ||
111 | { | 105 | { |
112 | database.ExecuteResourceSql("Mssql-users.sql"); | 106 | try |
107 | { | ||
108 | cmd.ExecuteNonQuery(); | ||
109 | } | ||
110 | catch | ||
111 | { | ||
112 | database.ExecuteResourceSql("Mssql-users.sql"); | ||
113 | } | ||
113 | } | 114 | } |
114 | 115 | ||
115 | cmd = database.Query("select top 1 * from " + m_agentsTableName, new Dictionary<string, string>()); | 116 | using (IDbCommand cmd = database.Query("select top 1 * from " + m_agentsTableName, new Dictionary<string, string>())) |
116 | try | ||
117 | { | ||
118 | cmd.ExecuteNonQuery(); | ||
119 | } | ||
120 | catch | ||
121 | { | 117 | { |
122 | database.ExecuteResourceSql("Mssql-agents.sql"); | 118 | try |
119 | { | ||
120 | cmd.ExecuteNonQuery(); | ||
121 | } | ||
122 | catch | ||
123 | { | ||
124 | database.ExecuteResourceSql("Mssql-agents.sql"); | ||
125 | } | ||
123 | } | 126 | } |
124 | 127 | ||
125 | cmd = database.Query("select top 1 * from " + m_userFriendsTableName, new Dictionary<string, string>()); | 128 | using (IDbCommand cmd = database.Query("select top 1 * from " + m_userFriendsTableName, new Dictionary<string, string>())) |
126 | try | ||
127 | { | 129 | { |
128 | cmd.ExecuteNonQuery(); | 130 | try |
129 | } | 131 | { |
130 | catch | 132 | cmd.ExecuteNonQuery(); |
131 | { | 133 | } |
132 | database.ExecuteResourceSql("CreateUserFriendsTable.sql"); | 134 | catch |
135 | { | ||
136 | database.ExecuteResourceSql("CreateUserFriendsTable.sql"); | ||
137 | } | ||
133 | } | 138 | } |
134 | 139 | ||
135 | return true; | 140 | return true; |
@@ -145,27 +150,18 @@ namespace OpenSim.Data.MSSQL | |||
145 | { | 150 | { |
146 | try | 151 | try |
147 | { | 152 | { |
148 | lock (database) | 153 | Dictionary<string, string> param = new Dictionary<string, string>(); |
149 | { | 154 | param["first"] = user; |
150 | Dictionary<string, string> param = new Dictionary<string, string>(); | 155 | param["second"] = last; |
151 | param["first"] = user; | ||
152 | param["second"] = last; | ||
153 | |||
154 | IDbCommand result = | ||
155 | database.Query("SELECT * FROM " + m_usersTableName + " WHERE username = @first AND lastname = @second", param); | ||
156 | IDataReader reader = result.ExecuteReader(); | ||
157 | 156 | ||
158 | UserProfileData row = database.readUserRow(reader); | 157 | using (IDbCommand result = database.Query("SELECT * FROM " + m_usersTableName + " WHERE username = @first AND lastname = @second", param)) |
159 | 158 | using (IDataReader reader = result.ExecuteReader()) | |
160 | reader.Close(); | 159 | { |
161 | result.Dispose(); | 160 | return database.readUserRow(reader); |
162 | |||
163 | return row; | ||
164 | } | 161 | } |
165 | } | 162 | } |
166 | catch (Exception e) | 163 | catch (Exception e) |
167 | { | 164 | { |
168 | database.Reconnect(); | ||
169 | m_log.Error(e.ToString()); | 165 | m_log.Error(e.ToString()); |
170 | return null; | 166 | return null; |
171 | } | 167 | } |
@@ -191,32 +187,30 @@ namespace OpenSim.Data.MSSQL | |||
191 | 187 | ||
192 | try | 188 | try |
193 | { | 189 | { |
194 | lock (database) | 190 | using (IDbCommand adder = |
191 | database.Query( | ||
192 | "INSERT INTO " + m_userFriendsTableName + " " + | ||
193 | "(ownerID,friendID,friendPerms,datetimestamp) " + | ||
194 | "VALUES " + | ||
195 | "(@ownerID,@friendID,@friendPerms,@datetimestamp)", | ||
196 | param)) | ||
195 | { | 197 | { |
196 | IDbCommand adder = | ||
197 | database.Query( | ||
198 | "INSERT INTO " + m_userFriendsTableName + " " + | ||
199 | "(ownerID,friendID,friendPerms,datetimestamp) " + | ||
200 | "VALUES " + | ||
201 | "(@ownerID,@friendID,@friendPerms,@datetimestamp)", | ||
202 | param); | ||
203 | |||
204 | adder.ExecuteNonQuery(); | 198 | adder.ExecuteNonQuery(); |
205 | 199 | } | |
206 | adder = | 200 | |
207 | database.Query( | 201 | using (IDbCommand adder = |
208 | "INSERT INTO " + m_userFriendsTableName + " " + | 202 | database.Query( |
209 | "(ownerID,friendID,friendPerms,datetimestamp) " + | 203 | "INSERT INTO " + m_userFriendsTableName + " " + |
210 | "VALUES " + | 204 | "(ownerID,friendID,friendPerms,datetimestamp) " + |
211 | "(@friendID,@ownerID,@friendPerms,@datetimestamp)", | 205 | "VALUES " + |
212 | param); | 206 | "(@friendID,@ownerID,@friendPerms,@datetimestamp)", |
207 | param)) | ||
208 | { | ||
213 | adder.ExecuteNonQuery(); | 209 | adder.ExecuteNonQuery(); |
214 | |||
215 | } | 210 | } |
216 | } | 211 | } |
217 | catch (Exception e) | 212 | catch (Exception e) |
218 | { | 213 | { |
219 | database.Reconnect(); | ||
220 | m_log.Error(e.ToString()); | 214 | m_log.Error(e.ToString()); |
221 | return; | 215 | return; |
222 | } | 216 | } |
@@ -236,27 +230,26 @@ namespace OpenSim.Data.MSSQL | |||
236 | 230 | ||
237 | try | 231 | try |
238 | { | 232 | { |
239 | lock (database) | 233 | using (IDbCommand updater = |
234 | database.Query( | ||
235 | "delete from " + m_userFriendsTableName + " where ownerID = @ownerID and friendID = @friendID", | ||
236 | param)) | ||
240 | { | 237 | { |
241 | IDbCommand updater = | ||
242 | database.Query( | ||
243 | "delete from " + m_userFriendsTableName + " where ownerID = @ownerID and friendID = @friendID", | ||
244 | param); | ||
245 | updater.ExecuteNonQuery(); | 238 | updater.ExecuteNonQuery(); |
239 | } | ||
246 | 240 | ||
247 | updater = | 241 | using (IDbCommand updater = |
248 | database.Query( | 242 | database.Query( |
249 | "delete from " + m_userFriendsTableName + " where ownerID = @friendID and friendID = @ownerID", | 243 | "delete from " + m_userFriendsTableName + " where ownerID = @friendID and friendID = @ownerID", |
250 | param); | 244 | param)) |
245 | { | ||
251 | updater.ExecuteNonQuery(); | 246 | updater.ExecuteNonQuery(); |
252 | |||
253 | } | 247 | } |
248 | |||
254 | } | 249 | } |
255 | catch (Exception e) | 250 | catch (Exception e) |
256 | { | 251 | { |
257 | database.Reconnect(); | ||
258 | m_log.Error(e.ToString()); | 252 | m_log.Error(e.ToString()); |
259 | return; | ||
260 | } | 253 | } |
261 | } | 254 | } |
262 | 255 | ||
@@ -276,23 +269,19 @@ namespace OpenSim.Data.MSSQL | |||
276 | 269 | ||
277 | try | 270 | try |
278 | { | 271 | { |
279 | lock (database) | 272 | using (IDbCommand updater = |
273 | database.Query( | ||
274 | "update " + m_userFriendsTableName + | ||
275 | " SET friendPerms = @friendPerms " + | ||
276 | "where ownerID = @ownerID and friendID = @friendID", | ||
277 | param)) | ||
280 | { | 278 | { |
281 | IDbCommand updater = | ||
282 | database.Query( | ||
283 | "update " + m_userFriendsTableName + | ||
284 | " SET friendPerms = @friendPerms " + | ||
285 | "where ownerID = @ownerID and friendID = @friendID", | ||
286 | param); | ||
287 | |||
288 | updater.ExecuteNonQuery(); | 279 | updater.ExecuteNonQuery(); |
289 | } | 280 | } |
290 | } | 281 | } |
291 | catch (Exception e) | 282 | catch (Exception e) |
292 | { | 283 | { |
293 | database.Reconnect(); | ||
294 | m_log.Error(e.ToString()); | 284 | m_log.Error(e.ToString()); |
295 | return; | ||
296 | } | 285 | } |
297 | } | 286 | } |
298 | 287 | ||
@@ -310,17 +299,14 @@ namespace OpenSim.Data.MSSQL | |||
310 | 299 | ||
311 | try | 300 | try |
312 | { | 301 | { |
313 | lock (database) | 302 | //Left Join userfriends to itself |
303 | using (IDbCommand result = | ||
304 | database.Query( | ||
305 | "select a.ownerID,a.friendID,a.friendPerms,b.friendPerms as ownerperms from " + m_userFriendsTableName + " as a, " + m_userFriendsTableName + " as b" + | ||
306 | " where a.ownerID = @ownerID and b.ownerID = a.friendID and b.friendID = a.ownerID", | ||
307 | param)) | ||
308 | using (IDataReader reader = result.ExecuteReader()) | ||
314 | { | 309 | { |
315 | //Left Join userfriends to itself | ||
316 | IDbCommand result = | ||
317 | database.Query( | ||
318 | "select a.ownerID,a.friendID,a.friendPerms,b.friendPerms as ownerperms from " + m_userFriendsTableName + " as a, " + m_userFriendsTableName + " as b" + | ||
319 | " where a.ownerID = @ownerID and b.ownerID = a.friendID and b.friendID = a.ownerID", | ||
320 | param); | ||
321 | IDataReader reader = result.ExecuteReader(); | ||
322 | |||
323 | |||
324 | while (reader.Read()) | 310 | while (reader.Read()) |
325 | { | 311 | { |
326 | FriendListItem fli = new FriendListItem(); | 312 | FriendListItem fli = new FriendListItem(); |
@@ -333,15 +319,11 @@ namespace OpenSim.Data.MSSQL | |||
333 | 319 | ||
334 | Lfli.Add(fli); | 320 | Lfli.Add(fli); |
335 | } | 321 | } |
336 | reader.Close(); | ||
337 | result.Dispose(); | ||
338 | } | 322 | } |
339 | } | 323 | } |
340 | catch (Exception e) | 324 | catch (Exception e) |
341 | { | 325 | { |
342 | database.Reconnect(); | ||
343 | m_log.Error(e.ToString()); | 326 | m_log.Error(e.ToString()); |
344 | return Lfli; | ||
345 | } | 327 | } |
346 | 328 | ||
347 | return Lfli; | 329 | return Lfli; |
@@ -375,19 +357,13 @@ namespace OpenSim.Data.MSSQL | |||
375 | { | 357 | { |
376 | try | 358 | try |
377 | { | 359 | { |
378 | lock (database) | 360 | Dictionary<string, string> param = new Dictionary<string, string>(); |
379 | { | 361 | param["first"] = querysplit[0]; |
380 | Dictionary<string, string> param = new Dictionary<string, string>(); | 362 | param["second"] = querysplit[1]; |
381 | param["first"] = querysplit[0]; | ||
382 | param["second"] = querysplit[1]; | ||
383 | |||
384 | IDbCommand result = | ||
385 | database.Query( | ||
386 | "SELECT UUID,username,lastname FROM " + m_usersTableName + " WHERE username = @first AND lastname = @second", | ||
387 | param); | ||
388 | IDataReader reader = result.ExecuteReader(); | ||
389 | |||
390 | 363 | ||
364 | using (IDbCommand result = database.Query("SELECT UUID,username,lastname FROM " + m_usersTableName + " WHERE username = @first AND lastname = @second", param)) | ||
365 | using (IDataReader reader = result.ExecuteReader()) | ||
366 | { | ||
391 | while (reader.Read()) | 367 | while (reader.Read()) |
392 | { | 368 | { |
393 | AvatarPickerAvatar user = new AvatarPickerAvatar(); | 369 | AvatarPickerAvatar user = new AvatarPickerAvatar(); |
@@ -395,34 +371,24 @@ namespace OpenSim.Data.MSSQL | |||
395 | user.firstName = (string)reader["username"]; | 371 | user.firstName = (string)reader["username"]; |
396 | user.lastName = (string)reader["lastname"]; | 372 | user.lastName = (string)reader["lastname"]; |
397 | returnlist.Add(user); | 373 | returnlist.Add(user); |
398 | } | 374 | } |
399 | reader.Close(); | ||
400 | result.Dispose(); | ||
401 | } | 375 | } |
402 | } | 376 | } |
403 | catch (Exception e) | 377 | catch (Exception e) |
404 | { | 378 | { |
405 | database.Reconnect(); | ||
406 | m_log.Error(e.ToString()); | 379 | m_log.Error(e.ToString()); |
407 | return returnlist; | ||
408 | } | 380 | } |
409 | } | 381 | } |
410 | else if (querysplit.Length == 1) | 382 | else if (querysplit.Length == 1) |
411 | { | 383 | { |
412 | try | 384 | try |
413 | { | 385 | { |
414 | lock (database) | 386 | Dictionary<string, string> param = new Dictionary<string, string>(); |
415 | { | 387 | param["first"] = querysplit[0]; |
416 | Dictionary<string, string> param = new Dictionary<string, string>(); | ||
417 | param["first"] = querysplit[0]; | ||
418 | |||
419 | IDbCommand result = | ||
420 | database.Query( | ||
421 | "SELECT UUID,username,lastname FROM " + m_usersTableName + " WHERE username = @first OR lastname = @first", | ||
422 | param); | ||
423 | IDataReader reader = result.ExecuteReader(); | ||
424 | |||
425 | 388 | ||
389 | using (IDbCommand result = database.Query("SELECT UUID,username,lastname FROM " + m_usersTableName + " WHERE username = @first OR lastname = @first", param)) | ||
390 | using (IDataReader reader = result.ExecuteReader()) | ||
391 | { | ||
426 | while (reader.Read()) | 392 | while (reader.Read()) |
427 | { | 393 | { |
428 | AvatarPickerAvatar user = new AvatarPickerAvatar(); | 394 | AvatarPickerAvatar user = new AvatarPickerAvatar(); |
@@ -431,15 +397,11 @@ namespace OpenSim.Data.MSSQL | |||
431 | user.lastName = (string)reader["lastname"]; | 397 | user.lastName = (string)reader["lastname"]; |
432 | returnlist.Add(user); | 398 | returnlist.Add(user); |
433 | } | 399 | } |
434 | reader.Close(); | ||
435 | result.Dispose(); | ||
436 | } | 400 | } |
437 | } | 401 | } |
438 | catch (Exception e) | 402 | catch (Exception e) |
439 | { | 403 | { |
440 | database.Reconnect(); | ||
441 | m_log.Error(e.ToString()); | 404 | m_log.Error(e.ToString()); |
442 | return returnlist; | ||
443 | } | 405 | } |
444 | } | 406 | } |
445 | return returnlist; | 407 | return returnlist; |
@@ -454,25 +416,17 @@ namespace OpenSim.Data.MSSQL | |||
454 | { | 416 | { |
455 | try | 417 | try |
456 | { | 418 | { |
457 | lock (database) | 419 | Dictionary<string, string> param = new Dictionary<string, string>(); |
458 | { | 420 | param["uuid"] = uuid.ToString(); |
459 | Dictionary<string, string> param = new Dictionary<string, string>(); | ||
460 | param["uuid"] = uuid.ToString(); | ||
461 | |||
462 | IDbCommand result = database.Query("SELECT * FROM " + m_usersTableName + " WHERE UUID = @uuid", param); | ||
463 | IDataReader reader = result.ExecuteReader(); | ||
464 | 421 | ||
465 | UserProfileData row = database.readUserRow(reader); | 422 | using (IDbCommand result = database.Query("SELECT * FROM " + m_usersTableName + " WHERE UUID = @uuid", param)) |
466 | 423 | using (IDataReader reader = result.ExecuteReader()) | |
467 | reader.Close(); | 424 | { |
468 | result.Dispose(); | 425 | return database.readUserRow(reader); |
469 | |||
470 | return row; | ||
471 | } | 426 | } |
472 | } | 427 | } |
473 | catch (Exception e) | 428 | catch (Exception e) |
474 | { | 429 | { |
475 | database.Reconnect(); | ||
476 | m_log.Error(e.ToString()); | 430 | m_log.Error(e.ToString()); |
477 | return null; | 431 | return null; |
478 | } | 432 | } |
@@ -509,25 +463,17 @@ namespace OpenSim.Data.MSSQL | |||
509 | { | 463 | { |
510 | try | 464 | try |
511 | { | 465 | { |
512 | lock (database) | 466 | Dictionary<string, string> param = new Dictionary<string, string>(); |
513 | { | 467 | param["uuid"] = uuid.ToString(); |
514 | Dictionary<string, string> param = new Dictionary<string, string>(); | ||
515 | param["uuid"] = uuid.ToString(); | ||
516 | |||
517 | IDbCommand result = database.Query("SELECT * FROM " + m_agentsTableName + " WHERE UUID = @uuid", param); | ||
518 | IDataReader reader = result.ExecuteReader(); | ||
519 | |||
520 | UserAgentData row = database.readAgentRow(reader); | ||
521 | 468 | ||
522 | reader.Close(); | 469 | using (IDbCommand result = database.Query("SELECT * FROM " + m_agentsTableName + " WHERE UUID = @uuid", param)) |
523 | result.Dispose(); | 470 | using (IDataReader reader = result.ExecuteReader()) |
524 | 471 | { | |
525 | return row; | 472 | return database.readAgentRow(reader); |
526 | } | 473 | } |
527 | } | 474 | } |
528 | catch (Exception e) | 475 | catch (Exception e) |
529 | { | 476 | { |
530 | database.Reconnect(); | ||
531 | m_log.Error(e.ToString()); | 477 | m_log.Error(e.ToString()); |
532 | return null; | 478 | return null; |
533 | } | 479 | } |
@@ -554,21 +500,17 @@ namespace OpenSim.Data.MSSQL | |||
554 | { | 500 | { |
555 | try | 501 | try |
556 | { | 502 | { |
557 | lock (database) | 503 | InsertUserRow(user.ID, user.FirstName, user.SurName, user.PasswordHash, user.PasswordSalt, |
558 | { | 504 | user.HomeRegion, user.HomeLocation.X, user.HomeLocation.Y, |
559 | InsertUserRow(user.ID, user.FirstName, user.SurName, user.PasswordHash, user.PasswordSalt, | 505 | user.HomeLocation.Z, |
560 | user.HomeRegion, user.HomeLocation.X, user.HomeLocation.Y, | 506 | user.HomeLookAt.X, user.HomeLookAt.Y, user.HomeLookAt.Z, user.Created, |
561 | user.HomeLocation.Z, | 507 | user.LastLogin, user.UserInventoryURI, user.UserAssetURI, |
562 | user.HomeLookAt.X, user.HomeLookAt.Y, user.HomeLookAt.Z, user.Created, | 508 | user.CanDoMask, user.WantDoMask, |
563 | user.LastLogin, user.UserInventoryURI, user.UserAssetURI, | 509 | user.AboutText, user.FirstLifeAboutText, user.Image, |
564 | user.CanDoMask, user.WantDoMask, | 510 | user.FirstLifeImage, user.WebLoginKey); |
565 | user.AboutText, user.FirstLifeAboutText, user.Image, | ||
566 | user.FirstLifeImage, user.WebLoginKey); | ||
567 | } | ||
568 | } | 511 | } |
569 | catch (Exception e) | 512 | catch (Exception e) |
570 | { | 513 | { |
571 | database.Reconnect(); | ||
572 | m_log.Error(e.ToString()); | 514 | m_log.Error(e.ToString()); |
573 | } | 515 | } |
574 | } | 516 | } |
@@ -646,16 +588,13 @@ namespace OpenSim.Data.MSSQL | |||
646 | parameters["profileFirstImage"] = firstImage.ToString(); | 588 | parameters["profileFirstImage"] = firstImage.ToString(); |
647 | parameters["webLoginKey"] = LLUUID.Random().ToString(); | 589 | parameters["webLoginKey"] = LLUUID.Random().ToString(); |
648 | 590 | ||
649 | bool returnval = false; | ||
650 | 591 | ||
651 | try | 592 | try |
652 | { | 593 | { |
653 | IDbCommand result = database.Query(sql, parameters); | 594 | using (IDbCommand result = database.Query(sql, parameters)) |
654 | 595 | { | |
655 | if (result.ExecuteNonQuery() == 1) | 596 | return (result.ExecuteNonQuery() == 1); |
656 | returnval = true; | 597 | } |
657 | |||
658 | result.Dispose(); | ||
659 | } | 598 | } |
660 | catch (Exception e) | 599 | catch (Exception e) |
661 | { | 600 | { |
@@ -663,7 +602,6 @@ namespace OpenSim.Data.MSSQL | |||
663 | return false; | 602 | return false; |
664 | } | 603 | } |
665 | 604 | ||
666 | return returnval; | ||
667 | } | 605 | } |
668 | 606 | ||
669 | /// <summary> | 607 | /// <summary> |
@@ -682,7 +620,7 @@ namespace OpenSim.Data.MSSQL | |||
682 | /// <returns></returns> | 620 | /// <returns></returns> |
683 | override public bool UpdateUserProfile(UserProfileData user) | 621 | override public bool UpdateUserProfile(UserProfileData user) |
684 | { | 622 | { |
685 | SqlCommand command = new SqlCommand("UPDATE " + m_usersTableName + " set UUID = @uuid, " + | 623 | using (IDbCommand command = database.Query("UPDATE " + m_usersTableName + " set UUID = @uuid, " + |
686 | "username = @username, " + | 624 | "username = @username, " + |
687 | "lastname = @lastname," + | 625 | "lastname = @lastname," + |
688 | "passwordHash = @passwordHash," + | 626 | "passwordHash = @passwordHash," + |
@@ -705,71 +643,66 @@ namespace OpenSim.Data.MSSQL | |||
705 | "profileImage = @profileImage," + | 643 | "profileImage = @profileImage," + |
706 | "profileFirstImage = @profileFirstImage, " + | 644 | "profileFirstImage = @profileFirstImage, " + |
707 | "webLoginKey = @webLoginKey where " + | 645 | "webLoginKey = @webLoginKey where " + |
708 | "UUID = @keyUUUID;", database.getConnection()); | 646 | "UUID = @keyUUUID;")) |
709 | SqlParameter param1 = new SqlParameter("@uuid", user.ID.ToString()); | 647 | { |
710 | SqlParameter param2 = new SqlParameter("@username", user.FirstName); | 648 | SqlParameter param1 = new SqlParameter("@uuid", user.ID.ToString()); |
711 | SqlParameter param3 = new SqlParameter("@lastname", user.SurName); | 649 | SqlParameter param2 = new SqlParameter("@username", user.FirstName); |
712 | SqlParameter param4 = new SqlParameter("@passwordHash", user.PasswordHash); | 650 | SqlParameter param3 = new SqlParameter("@lastname", user.SurName); |
713 | SqlParameter param5 = new SqlParameter("@passwordSalt", user.PasswordSalt); | 651 | SqlParameter param4 = new SqlParameter("@passwordHash", user.PasswordHash); |
714 | SqlParameter param6 = new SqlParameter("@homeRegion", Convert.ToInt64(user.HomeRegion)); | 652 | SqlParameter param5 = new SqlParameter("@passwordSalt", user.PasswordSalt); |
715 | SqlParameter param7 = new SqlParameter("@homeLocationX", user.HomeLocation.X); | 653 | SqlParameter param6 = new SqlParameter("@homeRegion", Convert.ToInt64(user.HomeRegion)); |
716 | SqlParameter param8 = new SqlParameter("@homeLocationY", user.HomeLocation.Y); | 654 | SqlParameter param7 = new SqlParameter("@homeLocationX", user.HomeLocation.X); |
717 | SqlParameter param9 = new SqlParameter("@homeLocationZ", user.HomeLocation.Y); | 655 | SqlParameter param8 = new SqlParameter("@homeLocationY", user.HomeLocation.Y); |
718 | SqlParameter param10 = new SqlParameter("@homeLookAtX", user.HomeLookAt.X); | 656 | SqlParameter param9 = new SqlParameter("@homeLocationZ", user.HomeLocation.Y); |
719 | SqlParameter param11 = new SqlParameter("@homeLookAtY", user.HomeLookAt.Y); | 657 | SqlParameter param10 = new SqlParameter("@homeLookAtX", user.HomeLookAt.X); |
720 | SqlParameter param12 = new SqlParameter("@homeLookAtZ", user.HomeLookAt.Z); | 658 | SqlParameter param11 = new SqlParameter("@homeLookAtY", user.HomeLookAt.Y); |
721 | SqlParameter param13 = new SqlParameter("@created", Convert.ToInt32(user.Created)); | 659 | SqlParameter param12 = new SqlParameter("@homeLookAtZ", user.HomeLookAt.Z); |
722 | SqlParameter param14 = new SqlParameter("@lastLogin", Convert.ToInt32(user.LastLogin)); | 660 | SqlParameter param13 = new SqlParameter("@created", Convert.ToInt32(user.Created)); |
723 | SqlParameter param15 = new SqlParameter("@userInventoryURI", user.UserInventoryURI); | 661 | SqlParameter param14 = new SqlParameter("@lastLogin", Convert.ToInt32(user.LastLogin)); |
724 | SqlParameter param16 = new SqlParameter("@userAssetURI", user.UserAssetURI); | 662 | SqlParameter param15 = new SqlParameter("@userInventoryURI", user.UserInventoryURI); |
725 | SqlParameter param17 = new SqlParameter("@profileCanDoMask", Convert.ToInt32(user.CanDoMask)); | 663 | SqlParameter param16 = new SqlParameter("@userAssetURI", user.UserAssetURI); |
726 | SqlParameter param18 = new SqlParameter("@profileWantDoMask", Convert.ToInt32(user.WantDoMask)); | 664 | SqlParameter param17 = new SqlParameter("@profileCanDoMask", Convert.ToInt32(user.CanDoMask)); |
727 | SqlParameter param19 = new SqlParameter("@profileAboutText", user.AboutText); | 665 | SqlParameter param18 = new SqlParameter("@profileWantDoMask", Convert.ToInt32(user.WantDoMask)); |
728 | SqlParameter param20 = new SqlParameter("@profileFirstText", user.FirstLifeAboutText); | 666 | SqlParameter param19 = new SqlParameter("@profileAboutText", user.AboutText); |
729 | SqlParameter param21 = new SqlParameter("@profileImage", user.Image.ToString()); | 667 | SqlParameter param20 = new SqlParameter("@profileFirstText", user.FirstLifeAboutText); |
730 | SqlParameter param22 = new SqlParameter("@profileFirstImage", user.FirstLifeImage.ToString()); | 668 | SqlParameter param21 = new SqlParameter("@profileImage", user.Image.ToString()); |
731 | SqlParameter param23 = new SqlParameter("@keyUUUID", user.ID.ToString()); | 669 | SqlParameter param22 = new SqlParameter("@profileFirstImage", user.FirstLifeImage.ToString()); |
732 | SqlParameter param24 = new SqlParameter("@webLoginKey", user.WebLoginKey.UUID.ToString()); | 670 | SqlParameter param23 = new SqlParameter("@keyUUUID", user.ID.ToString()); |
733 | command.Parameters.Add(param1); | 671 | SqlParameter param24 = new SqlParameter("@webLoginKey", user.WebLoginKey.UUID.ToString()); |
734 | command.Parameters.Add(param2); | 672 | command.Parameters.Add(param1); |
735 | command.Parameters.Add(param3); | 673 | command.Parameters.Add(param2); |
736 | command.Parameters.Add(param4); | 674 | command.Parameters.Add(param3); |
737 | command.Parameters.Add(param5); | 675 | command.Parameters.Add(param4); |
738 | command.Parameters.Add(param6); | 676 | command.Parameters.Add(param5); |
739 | command.Parameters.Add(param7); | 677 | command.Parameters.Add(param6); |
740 | command.Parameters.Add(param8); | 678 | command.Parameters.Add(param7); |
741 | command.Parameters.Add(param9); | 679 | command.Parameters.Add(param8); |
742 | command.Parameters.Add(param10); | 680 | command.Parameters.Add(param9); |
743 | command.Parameters.Add(param11); | 681 | command.Parameters.Add(param10); |
744 | command.Parameters.Add(param12); | 682 | command.Parameters.Add(param11); |
745 | command.Parameters.Add(param13); | 683 | command.Parameters.Add(param12); |
746 | command.Parameters.Add(param14); | 684 | command.Parameters.Add(param13); |
747 | command.Parameters.Add(param15); | 685 | command.Parameters.Add(param14); |
748 | command.Parameters.Add(param16); | 686 | command.Parameters.Add(param15); |
749 | command.Parameters.Add(param17); | 687 | command.Parameters.Add(param16); |
750 | command.Parameters.Add(param18); | 688 | command.Parameters.Add(param17); |
751 | command.Parameters.Add(param19); | 689 | command.Parameters.Add(param18); |
752 | command.Parameters.Add(param20); | 690 | command.Parameters.Add(param19); |
753 | command.Parameters.Add(param21); | 691 | command.Parameters.Add(param20); |
754 | command.Parameters.Add(param22); | 692 | command.Parameters.Add(param21); |
755 | command.Parameters.Add(param23); | 693 | command.Parameters.Add(param22); |
756 | command.Parameters.Add(param24); | 694 | command.Parameters.Add(param23); |
757 | try | 695 | command.Parameters.Add(param24); |
758 | { | 696 | try |
759 | int affected = command.ExecuteNonQuery(); | ||
760 | if (affected != 0) | ||
761 | { | 697 | { |
762 | return true; | 698 | int affected = command.ExecuteNonQuery(); |
699 | return (affected != 0); | ||
763 | } | 700 | } |
764 | else | 701 | catch (Exception e) |
765 | { | 702 | { |
766 | return false; | 703 | m_log.Error(e.ToString()); |
767 | } | 704 | } |
768 | } | 705 | } |
769 | catch (Exception e) | ||
770 | { | ||
771 | m_log.Error(e.ToString()); | ||
772 | } | ||
773 | return false; | 706 | return false; |
774 | } | 707 | } |
775 | 708 | ||
@@ -805,28 +738,21 @@ namespace OpenSim.Data.MSSQL | |||
805 | // return new AvatarAppearance(); | 738 | // return new AvatarAppearance(); |
806 | try | 739 | try |
807 | { | 740 | { |
808 | lock (database) | ||
809 | { | ||
810 | Dictionary<string, string> param = new Dictionary<string, string>(); | 741 | Dictionary<string, string> param = new Dictionary<string, string>(); |
811 | param["@UUID"] = user.ToString(); | 742 | param["@UUID"] = user.ToString(); |
812 | 743 | ||
813 | IDbCommand result = | 744 | using (IDbCommand result = |
814 | database.Query("SELECT * FROM avatarappearance WHERE owner = @UUID", param); | 745 | database.Query("SELECT * FROM avatarappearance WHERE owner = @UUID", param)) |
815 | IDataReader reader = result.ExecuteReader(); | 746 | using (IDataReader reader = result.ExecuteReader()) |
816 | 747 | { | |
817 | AvatarAppearance item = null; | 748 | AvatarAppearance item = null; |
818 | if (reader.Read()) | 749 | if (reader.Read()) |
819 | item = readUserAppearance(reader); | 750 | item = readUserAppearance(reader); |
820 | 751 | return item; | |
821 | reader.Close(); | 752 | } |
822 | result.Dispose(); | ||
823 | |||
824 | return item; | ||
825 | } | ||
826 | } | 753 | } |
827 | catch (Exception e) | 754 | catch (Exception e) |
828 | { | 755 | { |
829 | database.Reconnect(); | ||
830 | m_log.Error(e.ToString()); | 756 | m_log.Error(e.ToString()); |
831 | } | 757 | } |
832 | return null; | 758 | return null; |
@@ -906,49 +832,49 @@ namespace OpenSim.Data.MSSQL | |||
906 | sql += "@jacket_item, @jacket_asset, @gloves_item, @gloves_asset, @undershirt_item, @undershirt_asset, @underpants_item, @underpants_asset, "; | 832 | sql += "@jacket_item, @jacket_asset, @gloves_item, @gloves_asset, @undershirt_item, @undershirt_asset, @underpants_item, @underpants_asset, "; |
907 | sql += "@skirt_item, @skirt_asset)"; | 833 | sql += "@skirt_item, @skirt_asset)"; |
908 | 834 | ||
909 | SqlCommand cmd = new SqlCommand(sql, database.getConnection()); | 835 | using (AutoClosingSqlCommand cmd = database.Query(sql)) |
910 | cmd.Parameters.AddWithValue("@owner", appearance.Owner.ToString()); | 836 | { |
911 | cmd.Parameters.AddWithValue("@serial", appearance.Serial); | 837 | cmd.Parameters.AddWithValue("@owner", appearance.Owner.ToString()); |
912 | cmd.Parameters.AddWithValue("@visual_params", appearance.VisualParams); | 838 | cmd.Parameters.AddWithValue("@serial", appearance.Serial); |
913 | cmd.Parameters.AddWithValue("@texture", appearance.Texture.ToBytes()); | 839 | cmd.Parameters.AddWithValue("@visual_params", appearance.VisualParams); |
914 | cmd.Parameters.AddWithValue("@avatar_height", appearance.AvatarHeight); | 840 | cmd.Parameters.AddWithValue("@texture", appearance.Texture.ToBytes()); |
915 | cmd.Parameters.AddWithValue("@body_item", appearance.BodyItem.ToString()); | 841 | cmd.Parameters.AddWithValue("@avatar_height", appearance.AvatarHeight); |
916 | cmd.Parameters.AddWithValue("@body_asset", appearance.BodyAsset.ToString()); | 842 | cmd.Parameters.AddWithValue("@body_item", appearance.BodyItem.ToString()); |
917 | cmd.Parameters.AddWithValue("@skin_item", appearance.SkinItem.ToString()); | 843 | cmd.Parameters.AddWithValue("@body_asset", appearance.BodyAsset.ToString()); |
918 | cmd.Parameters.AddWithValue("@skin_asset", appearance.SkinAsset.ToString()); | 844 | cmd.Parameters.AddWithValue("@skin_item", appearance.SkinItem.ToString()); |
919 | cmd.Parameters.AddWithValue("@hair_item", appearance.HairItem.ToString()); | 845 | cmd.Parameters.AddWithValue("@skin_asset", appearance.SkinAsset.ToString()); |
920 | cmd.Parameters.AddWithValue("@hair_asset", appearance.HairAsset.ToString()); | 846 | cmd.Parameters.AddWithValue("@hair_item", appearance.HairItem.ToString()); |
921 | cmd.Parameters.AddWithValue("@eyes_item", appearance.EyesItem.ToString()); | 847 | cmd.Parameters.AddWithValue("@hair_asset", appearance.HairAsset.ToString()); |
922 | cmd.Parameters.AddWithValue("@eyes_asset", appearance.EyesAsset.ToString()); | 848 | cmd.Parameters.AddWithValue("@eyes_item", appearance.EyesItem.ToString()); |
923 | cmd.Parameters.AddWithValue("@shirt_item", appearance.ShirtItem.ToString()); | 849 | cmd.Parameters.AddWithValue("@eyes_asset", appearance.EyesAsset.ToString()); |
924 | cmd.Parameters.AddWithValue("@shirt_asset", appearance.ShirtAsset.ToString()); | 850 | cmd.Parameters.AddWithValue("@shirt_item", appearance.ShirtItem.ToString()); |
925 | cmd.Parameters.AddWithValue("@pants_item", appearance.PantsItem.ToString()); | 851 | cmd.Parameters.AddWithValue("@shirt_asset", appearance.ShirtAsset.ToString()); |
926 | cmd.Parameters.AddWithValue("@pants_asset", appearance.PantsAsset.ToString()); | 852 | cmd.Parameters.AddWithValue("@pants_item", appearance.PantsItem.ToString()); |
927 | cmd.Parameters.AddWithValue("@shoes_item", appearance.ShoesItem.ToString()); | 853 | cmd.Parameters.AddWithValue("@pants_asset", appearance.PantsAsset.ToString()); |
928 | cmd.Parameters.AddWithValue("@shoes_asset", appearance.ShoesAsset.ToString()); | 854 | cmd.Parameters.AddWithValue("@shoes_item", appearance.ShoesItem.ToString()); |
929 | cmd.Parameters.AddWithValue("@socks_item", appearance.SocksItem.ToString()); | 855 | cmd.Parameters.AddWithValue("@shoes_asset", appearance.ShoesAsset.ToString()); |
930 | cmd.Parameters.AddWithValue("@socks_asset", appearance.SocksAsset.ToString()); | 856 | cmd.Parameters.AddWithValue("@socks_item", appearance.SocksItem.ToString()); |
931 | cmd.Parameters.AddWithValue("@jacket_item", appearance.JacketItem.ToString()); | 857 | cmd.Parameters.AddWithValue("@socks_asset", appearance.SocksAsset.ToString()); |
932 | cmd.Parameters.AddWithValue("@jacket_asset", appearance.JacketAsset.ToString()); | 858 | cmd.Parameters.AddWithValue("@jacket_item", appearance.JacketItem.ToString()); |
933 | cmd.Parameters.AddWithValue("@gloves_item", appearance.GlovesItem.ToString()); | 859 | cmd.Parameters.AddWithValue("@jacket_asset", appearance.JacketAsset.ToString()); |
934 | cmd.Parameters.AddWithValue("@gloves_asset", appearance.GlovesAsset.ToString()); | 860 | cmd.Parameters.AddWithValue("@gloves_item", appearance.GlovesItem.ToString()); |
935 | cmd.Parameters.AddWithValue("@undershirt_item", appearance.UnderShirtItem.ToString()); | 861 | cmd.Parameters.AddWithValue("@gloves_asset", appearance.GlovesAsset.ToString()); |
936 | cmd.Parameters.AddWithValue("@undershirt_asset", appearance.UnderShirtAsset.ToString()); | 862 | cmd.Parameters.AddWithValue("@undershirt_item", appearance.UnderShirtItem.ToString()); |
937 | cmd.Parameters.AddWithValue("@underpants_item", appearance.UnderPantsItem.ToString()); | 863 | cmd.Parameters.AddWithValue("@undershirt_asset", appearance.UnderShirtAsset.ToString()); |
938 | cmd.Parameters.AddWithValue("@underpants_asset", appearance.UnderPantsAsset.ToString()); | 864 | cmd.Parameters.AddWithValue("@underpants_item", appearance.UnderPantsItem.ToString()); |
939 | cmd.Parameters.AddWithValue("@skirt_item", appearance.SkirtItem.ToString()); | 865 | cmd.Parameters.AddWithValue("@underpants_asset", appearance.UnderPantsAsset.ToString()); |
940 | cmd.Parameters.AddWithValue("@skirt_asset", appearance.SkirtAsset.ToString()); | 866 | cmd.Parameters.AddWithValue("@skirt_item", appearance.SkirtItem.ToString()); |
941 | 867 | cmd.Parameters.AddWithValue("@skirt_asset", appearance.SkirtAsset.ToString()); | |
942 | try | 868 | |
943 | { | 869 | try |
944 | cmd.ExecuteNonQuery(); | 870 | { |
945 | cmd.Dispose(); | 871 | cmd.ExecuteNonQuery(); |
946 | } | 872 | } |
947 | catch (Exception e) | 873 | catch (Exception e) |
948 | { | 874 | { |
949 | m_log.Error(e.ToString()); | 875 | m_log.Error(e.ToString()); |
876 | } | ||
950 | } | 877 | } |
951 | return; | ||
952 | } | 878 | } |
953 | 879 | ||
954 | /// <summary> | 880 | /// <summary> |
@@ -958,7 +884,7 @@ namespace OpenSim.Data.MSSQL | |||
958 | /// <param name="item">the item UUID</param> | 884 | /// <param name="item">the item UUID</param> |
959 | override public void AddAttachment(LLUUID user, LLUUID item) | 885 | override public void AddAttachment(LLUUID user, LLUUID item) |
960 | { | 886 | { |
961 | return; | 887 | // TBI? |
962 | } | 888 | } |
963 | 889 | ||
964 | /// <summary> | 890 | /// <summary> |
@@ -968,7 +894,7 @@ namespace OpenSim.Data.MSSQL | |||
968 | /// <param name="item">the item UUID</param> | 894 | /// <param name="item">the item UUID</param> |
969 | override public void RemoveAttachment(LLUUID user, LLUUID item) | 895 | override public void RemoveAttachment(LLUUID user, LLUUID item) |
970 | { | 896 | { |
971 | return; | 897 | // TBI? |
972 | } | 898 | } |
973 | 899 | ||
974 | /// <summary> | 900 | /// <summary> |