diff options
Diffstat (limited to 'OpenSim/Data/MySQL/MySQLUserProfilesData.cs')
-rw-r--r-- | OpenSim/Data/MySQL/MySQLUserProfilesData.cs | 363 |
1 files changed, 162 insertions, 201 deletions
diff --git a/OpenSim/Data/MySQL/MySQLUserProfilesData.cs b/OpenSim/Data/MySQL/MySQLUserProfilesData.cs index 8af2a3e..c98e017 100644 --- a/OpenSim/Data/MySQL/MySQLUserProfilesData.cs +++ b/OpenSim/Data/MySQL/MySQLUserProfilesData.cs | |||
@@ -69,6 +69,7 @@ namespace OpenSim.Data.MySQL | |||
69 | 69 | ||
70 | Migration m = new Migration(dbcon, Assembly, "UserProfiles"); | 70 | Migration m = new Migration(dbcon, Assembly, "UserProfiles"); |
71 | m.Update(); | 71 | m.Update(); |
72 | dbcon.Close(); | ||
72 | } | 73 | } |
73 | } | 74 | } |
74 | #endregion Member Functions | 75 | #endregion Member Functions |
@@ -89,7 +90,7 @@ namespace OpenSim.Data.MySQL | |||
89 | 90 | ||
90 | using (MySqlConnection dbcon = new MySqlConnection(ConnectionString)) | 91 | using (MySqlConnection dbcon = new MySqlConnection(ConnectionString)) |
91 | { | 92 | { |
92 | string query = "SELECT classifieduuid, name FROM classifieds WHERE creatoruuid = ?Id"; | 93 | const string query = "SELECT classifieduuid, name FROM classifieds WHERE creatoruuid = ?Id"; |
93 | dbcon.Open(); | 94 | dbcon.Open(); |
94 | using (MySqlCommand cmd = new MySqlCommand(query, dbcon)) | 95 | using (MySqlCommand cmd = new MySqlCommand(query, dbcon)) |
95 | { | 96 | { |
@@ -121,58 +122,58 @@ namespace OpenSim.Data.MySQL | |||
121 | } | 122 | } |
122 | } | 123 | } |
123 | } | 124 | } |
125 | dbcon.Close(); | ||
124 | } | 126 | } |
125 | return data; | 127 | return data; |
126 | } | 128 | } |
127 | 129 | ||
128 | public bool UpdateClassifiedRecord(UserClassifiedAdd ad, ref string result) | 130 | public bool UpdateClassifiedRecord(UserClassifiedAdd ad, ref string result) |
129 | { | 131 | { |
130 | string query = string.Empty; | 132 | const string query = |
131 | 133 | "INSERT INTO classifieds (" | |
132 | 134 | + "`classifieduuid`," | |
133 | query += "INSERT INTO classifieds ("; | 135 | + "`creatoruuid`," |
134 | query += "`classifieduuid`,"; | 136 | + "`creationdate`," |
135 | query += "`creatoruuid`,"; | 137 | + "`expirationdate`," |
136 | query += "`creationdate`,"; | 138 | + "`category`," |
137 | query += "`expirationdate`,"; | 139 | + "`name`," |
138 | query += "`category`,"; | 140 | + "`description`," |
139 | query += "`name`,"; | 141 | + "`parceluuid`," |
140 | query += "`description`,"; | 142 | + "`parentestate`," |
141 | query += "`parceluuid`,"; | 143 | + "`snapshotuuid`," |
142 | query += "`parentestate`,"; | 144 | + "`simname`," |
143 | query += "`snapshotuuid`,"; | 145 | + "`posglobal`," |
144 | query += "`simname`,"; | 146 | + "`parcelname`," |
145 | query += "`posglobal`,"; | 147 | + "`classifiedflags`," |
146 | query += "`parcelname`,"; | 148 | + "`priceforlisting`) " |
147 | query += "`classifiedflags`,"; | 149 | + "VALUES (" |
148 | query += "`priceforlisting`) "; | 150 | + "?ClassifiedId," |
149 | query += "VALUES ("; | 151 | + "?CreatorId," |
150 | query += "?ClassifiedId,"; | 152 | + "?CreatedDate," |
151 | query += "?CreatorId,"; | 153 | + "?ExpirationDate," |
152 | query += "?CreatedDate,"; | 154 | + "?Category," |
153 | query += "?ExpirationDate,"; | 155 | + "?Name," |
154 | query += "?Category,"; | 156 | + "?Description," |
155 | query += "?Name,"; | 157 | + "?ParcelId," |
156 | query += "?Description,"; | 158 | + "?ParentEstate," |
157 | query += "?ParcelId,"; | 159 | + "?SnapshotId," |
158 | query += "?ParentEstate,"; | 160 | + "?SimName," |
159 | query += "?SnapshotId,"; | 161 | + "?GlobalPos," |
160 | query += "?SimName,"; | 162 | + "?ParcelName," |
161 | query += "?GlobalPos,"; | 163 | + "?Flags," |
162 | query += "?ParcelName,"; | 164 | + "?ListingPrice ) " |
163 | query += "?Flags,"; | 165 | + "ON DUPLICATE KEY UPDATE " |
164 | query += "?ListingPrice ) "; | 166 | + "category=?Category, " |
165 | query += "ON DUPLICATE KEY UPDATE "; | 167 | + "expirationdate=?ExpirationDate, " |
166 | query += "category=?Category, "; | 168 | + "name=?Name, " |
167 | query += "expirationdate=?ExpirationDate, "; | 169 | + "description=?Description, " |
168 | query += "name=?Name, "; | 170 | + "parentestate=?ParentEstate, " |
169 | query += "description=?Description, "; | 171 | + "posglobal=?GlobalPos, " |
170 | query += "parentestate=?ParentEstate, "; | 172 | + "parcelname=?ParcelName, " |
171 | query += "posglobal=?GlobalPos, "; | 173 | + "classifiedflags=?Flags, " |
172 | query += "parcelname=?ParcelName, "; | 174 | + "priceforlisting=?ListingPrice, " |
173 | query += "classifiedflags=?Flags, "; | 175 | + "snapshotuuid=?SnapshotId" |
174 | query += "priceforlisting=?ListingPrice, "; | 176 | ; |
175 | query += "snapshotuuid=?SnapshotId"; | ||
176 | 177 | ||
177 | if(string.IsNullOrEmpty(ad.ParcelName)) | 178 | if(string.IsNullOrEmpty(ad.ParcelName)) |
178 | ad.ParcelName = "Unknown"; | 179 | ad.ParcelName = "Unknown"; |
@@ -228,6 +229,7 @@ namespace OpenSim.Data.MySQL | |||
228 | 229 | ||
229 | cmd.ExecuteNonQuery(); | 230 | cmd.ExecuteNonQuery(); |
230 | } | 231 | } |
232 | dbcon.Close(); | ||
231 | } | 233 | } |
232 | } | 234 | } |
233 | catch (Exception e) | 235 | catch (Exception e) |
@@ -242,10 +244,7 @@ namespace OpenSim.Data.MySQL | |||
242 | 244 | ||
243 | public bool DeleteClassifiedRecord(UUID recordId) | 245 | public bool DeleteClassifiedRecord(UUID recordId) |
244 | { | 246 | { |
245 | string query = string.Empty; | 247 | const string query = "DELETE FROM classifieds WHERE classifieduuid = ?recordId"; |
246 | |||
247 | query += "DELETE FROM classifieds WHERE "; | ||
248 | query += "classifieduuid = ?recordId"; | ||
249 | 248 | ||
250 | try | 249 | try |
251 | { | 250 | { |
@@ -258,6 +257,7 @@ namespace OpenSim.Data.MySQL | |||
258 | cmd.Parameters.AddWithValue("?recordId", recordId.ToString()); | 257 | cmd.Parameters.AddWithValue("?recordId", recordId.ToString()); |
259 | cmd.ExecuteNonQuery(); | 258 | cmd.ExecuteNonQuery(); |
260 | } | 259 | } |
260 | dbcon.Close(); | ||
261 | } | 261 | } |
262 | } | 262 | } |
263 | catch (Exception e) | 263 | catch (Exception e) |
@@ -271,10 +271,8 @@ namespace OpenSim.Data.MySQL | |||
271 | 271 | ||
272 | public bool GetClassifiedInfo(ref UserClassifiedAdd ad, ref string result) | 272 | public bool GetClassifiedInfo(ref UserClassifiedAdd ad, ref string result) |
273 | { | 273 | { |
274 | string query = string.Empty; | ||
275 | 274 | ||
276 | query += "SELECT * FROM classifieds WHERE "; | 275 | const string query = "SELECT * FROM classifieds WHERE classifieduuid = ?AdId"; |
277 | query += "classifieduuid = ?AdId"; | ||
278 | 276 | ||
279 | try | 277 | try |
280 | { | 278 | { |
@@ -322,10 +320,8 @@ namespace OpenSim.Data.MySQL | |||
322 | #region Picks Queries | 320 | #region Picks Queries |
323 | public OSDArray GetAvatarPicks(UUID avatarId) | 321 | public OSDArray GetAvatarPicks(UUID avatarId) |
324 | { | 322 | { |
325 | string query = string.Empty; | 323 | const string query = "SELECT `pickuuid`,`name` FROM userpicks WHERE creatoruuid = ?Id"; |
326 | 324 | ||
327 | query += "SELECT `pickuuid`,`name` FROM userpicks WHERE "; | ||
328 | query += "creatoruuid = ?Id"; | ||
329 | OSDArray data = new OSDArray(); | 325 | OSDArray data = new OSDArray(); |
330 | 326 | ||
331 | try | 327 | try |
@@ -352,6 +348,7 @@ namespace OpenSim.Data.MySQL | |||
352 | } | 348 | } |
353 | } | 349 | } |
354 | } | 350 | } |
351 | dbcon.Close(); | ||
355 | } | 352 | } |
356 | } | 353 | } |
357 | catch (Exception e) | 354 | catch (Exception e) |
@@ -364,12 +361,8 @@ namespace OpenSim.Data.MySQL | |||
364 | 361 | ||
365 | public UserProfilePick GetPickInfo(UUID avatarId, UUID pickId) | 362 | public UserProfilePick GetPickInfo(UUID avatarId, UUID pickId) |
366 | { | 363 | { |
367 | string query = string.Empty; | ||
368 | UserProfilePick pick = new UserProfilePick(); | 364 | UserProfilePick pick = new UserProfilePick(); |
369 | 365 | const string query = "SELECT * FROM userpicks WHERE creatoruuid = ?CreatorId AND pickuuid = ?PickId"; | |
370 | query += "SELECT * FROM userpicks WHERE "; | ||
371 | query += "creatoruuid = ?CreatorId AND "; | ||
372 | query += "pickuuid = ?PickId"; | ||
373 | 366 | ||
374 | try | 367 | try |
375 | { | 368 | { |
@@ -422,33 +415,33 @@ namespace OpenSim.Data.MySQL | |||
422 | 415 | ||
423 | public bool UpdatePicksRecord(UserProfilePick pick) | 416 | public bool UpdatePicksRecord(UserProfilePick pick) |
424 | { | 417 | { |
425 | string query = string.Empty; | 418 | const string query = |
426 | 419 | "INSERT INTO userpicks VALUES (" | |
427 | query += "INSERT INTO userpicks VALUES ("; | 420 | + "?PickId," |
428 | query += "?PickId,"; | 421 | + "?CreatorId," |
429 | query += "?CreatorId,"; | 422 | + "?TopPick," |
430 | query += "?TopPick,"; | 423 | + "?ParcelId," |
431 | query += "?ParcelId,"; | 424 | + "?Name," |
432 | query += "?Name,"; | 425 | + "?Desc," |
433 | query += "?Desc,"; | 426 | + "?SnapshotId," |
434 | query += "?SnapshotId,"; | 427 | + "?User," |
435 | query += "?User,"; | 428 | + "?Original," |
436 | query += "?Original,"; | 429 | + "?SimName," |
437 | query += "?SimName,"; | 430 | + "?GlobalPos," |
438 | query += "?GlobalPos,"; | 431 | + "?SortOrder," |
439 | query += "?SortOrder,"; | 432 | + "?Enabled," |
440 | query += "?Enabled,"; | 433 | + "?Gatekeeper)" |
441 | query += "?Gatekeeper)"; | 434 | + "ON DUPLICATE KEY UPDATE " |
442 | query += "ON DUPLICATE KEY UPDATE "; | 435 | + "parceluuid=?ParcelId," |
443 | query += "parceluuid=?ParcelId,"; | 436 | + "name=?Name," |
444 | query += "name=?Name,"; | 437 | + "description=?Desc," |
445 | query += "description=?Desc,"; | 438 | + "user=?User," |
446 | query += "user=?User,"; | 439 | + "simname=?SimName," |
447 | query += "simname=?SimName,"; | 440 | + "snapshotuuid=?SnapshotId," |
448 | query += "snapshotuuid=?SnapshotId,"; | 441 | + "pickuuid=?PickId," |
449 | query += "pickuuid=?PickId,"; | 442 | + "posglobal=?GlobalPos," |
450 | query += "posglobal=?GlobalPos,"; | 443 | + "gatekeeper=?Gatekeeper" |
451 | query += "gatekeeper=?Gatekeeper"; | 444 | ; |
452 | 445 | ||
453 | try | 446 | try |
454 | { | 447 | { |
@@ -474,6 +467,7 @@ namespace OpenSim.Data.MySQL | |||
474 | 467 | ||
475 | cmd.ExecuteNonQuery(); | 468 | cmd.ExecuteNonQuery(); |
476 | } | 469 | } |
470 | dbcon.Close(); | ||
477 | } | 471 | } |
478 | } | 472 | } |
479 | catch (Exception e) | 473 | catch (Exception e) |
@@ -487,10 +481,7 @@ namespace OpenSim.Data.MySQL | |||
487 | 481 | ||
488 | public bool DeletePicksRecord(UUID pickId) | 482 | public bool DeletePicksRecord(UUID pickId) |
489 | { | 483 | { |
490 | string query = string.Empty; | 484 | string query = "DELETE FROM userpicks WHERE pickuuid = ?PickId"; |
491 | |||
492 | query += "DELETE FROM userpicks WHERE "; | ||
493 | query += "pickuuid = ?PickId"; | ||
494 | 485 | ||
495 | try | 486 | try |
496 | { | 487 | { |
@@ -504,6 +495,7 @@ namespace OpenSim.Data.MySQL | |||
504 | 495 | ||
505 | cmd.ExecuteNonQuery(); | 496 | cmd.ExecuteNonQuery(); |
506 | } | 497 | } |
498 | dbcon.Close(); | ||
507 | } | 499 | } |
508 | } | 500 | } |
509 | catch (Exception e) | 501 | catch (Exception e) |
@@ -519,11 +511,7 @@ namespace OpenSim.Data.MySQL | |||
519 | #region Avatar Notes Queries | 511 | #region Avatar Notes Queries |
520 | public bool GetAvatarNotes(ref UserProfileNotes notes) | 512 | public bool GetAvatarNotes(ref UserProfileNotes notes) |
521 | { // WIP | 513 | { // WIP |
522 | string query = string.Empty; | 514 | const string query = "SELECT `notes` FROM usernotes WHERE useruuid = ?Id AND targetuuid = ?TargetId"; |
523 | |||
524 | query += "SELECT `notes` FROM usernotes WHERE "; | ||
525 | query += "useruuid = ?Id AND "; | ||
526 | query += "targetuuid = ?TargetId"; | ||
527 | 515 | ||
528 | try | 516 | try |
529 | { | 517 | { |
@@ -548,6 +536,7 @@ namespace OpenSim.Data.MySQL | |||
548 | } | 536 | } |
549 | } | 537 | } |
550 | } | 538 | } |
539 | dbcon.Close(); | ||
551 | } | 540 | } |
552 | } | 541 | } |
553 | catch (Exception e) | 542 | catch (Exception e) |
@@ -560,26 +549,25 @@ namespace OpenSim.Data.MySQL | |||
560 | 549 | ||
561 | public bool UpdateAvatarNotes(ref UserProfileNotes note, ref string result) | 550 | public bool UpdateAvatarNotes(ref UserProfileNotes note, ref string result) |
562 | { | 551 | { |
563 | string query = string.Empty; | 552 | string query; |
564 | bool remove; | 553 | bool remove; |
565 | 554 | ||
566 | if(string.IsNullOrEmpty(note.Notes)) | 555 | if(string.IsNullOrEmpty(note.Notes)) |
567 | { | 556 | { |
568 | remove = true; | 557 | remove = true; |
569 | query += "DELETE FROM usernotes WHERE "; | 558 | query = "DELETE FROM usernotes WHERE useruuid=?UserId AND targetuuid=?TargetId"; |
570 | query += "useruuid=?UserId AND "; | ||
571 | query += "targetuuid=?TargetId"; | ||
572 | } | 559 | } |
573 | else | 560 | else |
574 | { | 561 | { |
575 | remove = false; | 562 | remove = false; |
576 | query += "INSERT INTO usernotes VALUES ( "; | 563 | query = "INSERT INTO usernotes VALUES (" |
577 | query += "?UserId,"; | 564 | + "?UserId," |
578 | query += "?TargetId,"; | 565 | + "?TargetId," |
579 | query += "?Notes )"; | 566 | + "?Notes )" |
580 | query += "ON DUPLICATE KEY "; | 567 | + "ON DUPLICATE KEY " |
581 | query += "UPDATE "; | 568 | + "UPDATE " |
582 | query += "notes=?Notes"; | 569 | + "notes=?Notes" |
570 | ; | ||
583 | } | 571 | } |
584 | 572 | ||
585 | try | 573 | try |
@@ -596,6 +584,7 @@ namespace OpenSim.Data.MySQL | |||
596 | 584 | ||
597 | cmd.ExecuteNonQuery(); | 585 | cmd.ExecuteNonQuery(); |
598 | } | 586 | } |
587 | dbcon.Close(); | ||
599 | } | 588 | } |
600 | } | 589 | } |
601 | catch (Exception e) | 590 | catch (Exception e) |
@@ -612,10 +601,7 @@ namespace OpenSim.Data.MySQL | |||
612 | #region Avatar Properties | 601 | #region Avatar Properties |
613 | public bool GetAvatarProperties(ref UserProfileProperties props, ref string result) | 602 | public bool GetAvatarProperties(ref UserProfileProperties props, ref string result) |
614 | { | 603 | { |
615 | string query = string.Empty; | 604 | string query = "SELECT * FROM userprofile WHERE useruuid = ?Id"; |
616 | |||
617 | query += "SELECT * FROM userprofile WHERE "; | ||
618 | query += "useruuid = ?Id"; | ||
619 | 605 | ||
620 | try | 606 | try |
621 | { | 607 | { |
@@ -664,35 +650,36 @@ namespace OpenSim.Data.MySQL | |||
664 | props.PublishProfile = false; | 650 | props.PublishProfile = false; |
665 | props.PublishMature = false; | 651 | props.PublishMature = false; |
666 | 652 | ||
667 | query = "INSERT INTO userprofile ("; | 653 | query = "INSERT INTO userprofile (" |
668 | query += "useruuid, "; | 654 | + "useruuid, " |
669 | query += "profilePartner, "; | 655 | + "profilePartner, " |
670 | query += "profileAllowPublish, "; | 656 | + "profileAllowPublish, " |
671 | query += "profileMaturePublish, "; | 657 | + "profileMaturePublish, " |
672 | query += "profileURL, "; | 658 | + "profileURL, " |
673 | query += "profileWantToMask, "; | 659 | + "profileWantToMask, " |
674 | query += "profileWantToText, "; | 660 | + "profileWantToText, " |
675 | query += "profileSkillsMask, "; | 661 | + "profileSkillsMask, " |
676 | query += "profileSkillsText, "; | 662 | + "profileSkillsText, " |
677 | query += "profileLanguages, "; | 663 | + "profileLanguages, " |
678 | query += "profileImage, "; | 664 | + "profileImage, " |
679 | query += "profileAboutText, "; | 665 | + "profileAboutText, " |
680 | query += "profileFirstImage, "; | 666 | + "profileFirstImage, " |
681 | query += "profileFirstText) VALUES ("; | 667 | + "profileFirstText) VALUES (" |
682 | query += "?userId, "; | 668 | + "?userId, " |
683 | query += "?profilePartner, "; | 669 | + "?profilePartner, " |
684 | query += "?profileAllowPublish, "; | 670 | + "?profileAllowPublish, " |
685 | query += "?profileMaturePublish, "; | 671 | + "?profileMaturePublish, " |
686 | query += "?profileURL, "; | 672 | + "?profileURL, " |
687 | query += "?profileWantToMask, "; | 673 | + "?profileWantToMask, " |
688 | query += "?profileWantToText, "; | 674 | + "?profileWantToText, " |
689 | query += "?profileSkillsMask, "; | 675 | + "?profileSkillsMask, " |
690 | query += "?profileSkillsText, "; | 676 | + "?profileSkillsText, " |
691 | query += "?profileLanguages, "; | 677 | + "?profileLanguages, " |
692 | query += "?profileImage, "; | 678 | + "?profileImage, " |
693 | query += "?profileAboutText, "; | 679 | + "?profileAboutText, " |
694 | query += "?profileFirstImage, "; | 680 | + "?profileFirstImage, " |
695 | query += "?profileFirstText)"; | 681 | + "?profileFirstText)" |
682 | ; | ||
696 | 683 | ||
697 | dbcon.Close(); | 684 | dbcon.Close(); |
698 | dbcon.Open(); | 685 | dbcon.Open(); |
@@ -719,6 +706,7 @@ namespace OpenSim.Data.MySQL | |||
719 | } | 706 | } |
720 | } | 707 | } |
721 | } | 708 | } |
709 | dbcon.Close(); | ||
722 | } | 710 | } |
723 | } | 711 | } |
724 | catch (Exception e) | 712 | catch (Exception e) |
@@ -733,15 +721,10 @@ namespace OpenSim.Data.MySQL | |||
733 | 721 | ||
734 | public bool UpdateAvatarProperties(ref UserProfileProperties props, ref string result) | 722 | public bool UpdateAvatarProperties(ref UserProfileProperties props, ref string result) |
735 | { | 723 | { |
736 | string query = string.Empty; | 724 | const string query = "UPDATE userprofile SET profileURL=?profileURL," |
737 | 725 | + "profileImage=?image, profileAboutText=?abouttext," | |
738 | query += "UPDATE userprofile SET "; | 726 | + "profileFirstImage=?firstlifeimage, profileFirstText=?firstlifetext " |
739 | query += "profileURL=?profileURL, "; | 727 | + "WHERE useruuid=?uuid"; |
740 | query += "profileImage=?image, "; | ||
741 | query += "profileAboutText=?abouttext,"; | ||
742 | query += "profileFirstImage=?firstlifeimage,"; | ||
743 | query += "profileFirstText=?firstlifetext "; | ||
744 | query += "WHERE useruuid=?uuid"; | ||
745 | 728 | ||
746 | try | 729 | try |
747 | { | 730 | { |
@@ -759,6 +742,7 @@ namespace OpenSim.Data.MySQL | |||
759 | 742 | ||
760 | cmd.ExecuteNonQuery(); | 743 | cmd.ExecuteNonQuery(); |
761 | } | 744 | } |
745 | dbcon.Close(); | ||
762 | } | 746 | } |
763 | } | 747 | } |
764 | catch (Exception e) | 748 | catch (Exception e) |
@@ -775,15 +759,13 @@ namespace OpenSim.Data.MySQL | |||
775 | #region Avatar Interests | 759 | #region Avatar Interests |
776 | public bool UpdateAvatarInterests(UserProfileProperties up, ref string result) | 760 | public bool UpdateAvatarInterests(UserProfileProperties up, ref string result) |
777 | { | 761 | { |
778 | string query = string.Empty; | 762 | const string query = "UPDATE userprofile SET " |
779 | 763 | + "profileWantToMask=?WantMask, " | |
780 | query += "UPDATE userprofile SET "; | 764 | + "profileWantToText=?WantText," |
781 | query += "profileWantToMask=?WantMask, "; | 765 | + "profileSkillsMask=?SkillsMask," |
782 | query += "profileWantToText=?WantText,"; | 766 | + "profileSkillsText=?SkillsText, " |
783 | query += "profileSkillsMask=?SkillsMask,"; | 767 | + "profileLanguages=?Languages " |
784 | query += "profileSkillsText=?SkillsText, "; | 768 | + "WHERE useruuid=?uuid"; |
785 | query += "profileLanguages=?Languages "; | ||
786 | query += "WHERE useruuid=?uuid"; | ||
787 | 769 | ||
788 | try | 770 | try |
789 | { | 771 | { |
@@ -817,18 +799,17 @@ namespace OpenSim.Data.MySQL | |||
817 | public OSDArray GetUserImageAssets(UUID avatarId) | 799 | public OSDArray GetUserImageAssets(UUID avatarId) |
818 | { | 800 | { |
819 | OSDArray data = new OSDArray(); | 801 | OSDArray data = new OSDArray(); |
820 | string query = "SELECT `snapshotuuid` FROM {0} WHERE `creatoruuid` = ?Id"; | 802 | const string queryA = "SELECT `snapshotuuid` FROM {0} WHERE `creatoruuid` = ?Id"; |
821 | 803 | ||
822 | // Get classified image assets | 804 | // Get classified image assets |
823 | 805 | ||
824 | |||
825 | try | 806 | try |
826 | { | 807 | { |
827 | using (MySqlConnection dbcon = new MySqlConnection(ConnectionString)) | 808 | using (MySqlConnection dbcon = new MySqlConnection(ConnectionString)) |
828 | { | 809 | { |
829 | dbcon.Open(); | 810 | dbcon.Open(); |
830 | 811 | ||
831 | using (MySqlCommand cmd = new MySqlCommand(string.Format (query,"`classifieds`"), dbcon)) | 812 | using (MySqlCommand cmd = new MySqlCommand(string.Format (queryA,"`classifieds`"), dbcon)) |
832 | { | 813 | { |
833 | cmd.Parameters.AddWithValue("?Id", avatarId.ToString()); | 814 | cmd.Parameters.AddWithValue("?Id", avatarId.ToString()); |
834 | 815 | ||
@@ -847,7 +828,7 @@ namespace OpenSim.Data.MySQL | |||
847 | dbcon.Close(); | 828 | dbcon.Close(); |
848 | dbcon.Open(); | 829 | dbcon.Open(); |
849 | 830 | ||
850 | using (MySqlCommand cmd = new MySqlCommand(string.Format (query,"`userpicks`"), dbcon)) | 831 | using (MySqlCommand cmd = new MySqlCommand(string.Format (queryA,"`userpicks`"), dbcon)) |
851 | { | 832 | { |
852 | cmd.Parameters.AddWithValue("?Id", avatarId.ToString()); | 833 | cmd.Parameters.AddWithValue("?Id", avatarId.ToString()); |
853 | 834 | ||
@@ -866,9 +847,9 @@ namespace OpenSim.Data.MySQL | |||
866 | dbcon.Close(); | 847 | dbcon.Close(); |
867 | dbcon.Open(); | 848 | dbcon.Open(); |
868 | 849 | ||
869 | query = "SELECT `profileImage`, `profileFirstImage` FROM `userprofile` WHERE `useruuid` = ?Id"; | 850 | const string queryB = "SELECT `profileImage`, `profileFirstImage` FROM `userprofile` WHERE `useruuid` = ?Id"; |
870 | 851 | ||
871 | using (MySqlCommand cmd = new MySqlCommand(string.Format (query,"`userpicks`"), dbcon)) | 852 | using (MySqlCommand cmd = new MySqlCommand(string.Format (queryB,"`userpicks`"), dbcon)) |
872 | { | 853 | { |
873 | cmd.Parameters.AddWithValue("?Id", avatarId.ToString()); | 854 | cmd.Parameters.AddWithValue("?Id", avatarId.ToString()); |
874 | 855 | ||
@@ -884,6 +865,7 @@ namespace OpenSim.Data.MySQL | |||
884 | } | 865 | } |
885 | } | 866 | } |
886 | } | 867 | } |
868 | dbcon.Close(); | ||
887 | } | 869 | } |
888 | } | 870 | } |
889 | catch (Exception e) | 871 | catch (Exception e) |
@@ -897,11 +879,7 @@ namespace OpenSim.Data.MySQL | |||
897 | #region User Preferences | 879 | #region User Preferences |
898 | public bool GetUserPreferences(ref UserPreferences pref, ref string result) | 880 | public bool GetUserPreferences(ref UserPreferences pref, ref string result) |
899 | { | 881 | { |
900 | string query = string.Empty; | 882 | const string query = "SELECT imviaemail,visible,email FROM usersettings WHERE useruuid = ?Id"; |
901 | |||
902 | query += "SELECT imviaemail,visible,email FROM "; | ||
903 | query += "usersettings WHERE "; | ||
904 | query += "useruuid = ?Id"; | ||
905 | 883 | ||
906 | try | 884 | try |
907 | { | 885 | { |
@@ -925,10 +903,9 @@ namespace OpenSim.Data.MySQL | |||
925 | dbcon.Close(); | 903 | dbcon.Close(); |
926 | dbcon.Open(); | 904 | dbcon.Open(); |
927 | 905 | ||
928 | query = "INSERT INTO usersettings VALUES "; | 906 | const string queryB = "INSERT INTO usersettings VALUES (?uuid,'false','false', ?Email)"; |
929 | query += "(?uuid,'false','false', ?Email)"; | ||
930 | 907 | ||
931 | using (MySqlCommand put = new MySqlCommand(query, dbcon)) | 908 | using (MySqlCommand put = new MySqlCommand(queryB, dbcon)) |
932 | { | 909 | { |
933 | 910 | ||
934 | put.Parameters.AddWithValue("?Email", pref.EMail); | 911 | put.Parameters.AddWithValue("?Email", pref.EMail); |
@@ -939,6 +916,7 @@ namespace OpenSim.Data.MySQL | |||
939 | } | 916 | } |
940 | } | 917 | } |
941 | } | 918 | } |
919 | dbcon.Close(); | ||
942 | } | 920 | } |
943 | } | 921 | } |
944 | catch (Exception e) | 922 | catch (Exception e) |
@@ -953,13 +931,9 @@ namespace OpenSim.Data.MySQL | |||
953 | 931 | ||
954 | public bool UpdateUserPreferences(ref UserPreferences pref, ref string result) | 932 | public bool UpdateUserPreferences(ref UserPreferences pref, ref string result) |
955 | { | 933 | { |
956 | string query = string.Empty; | 934 | const string query = "UPDATE usersettings SET imviaemail=?ImViaEmail," |
957 | 935 | + "visible=?Visible, email=?EMail " | |
958 | query += "UPDATE usersettings SET "; | 936 | + "WHERE useruuid=?uuid"; |
959 | query += "imviaemail=?ImViaEmail, "; | ||
960 | query += "visible=?Visible, "; | ||
961 | query += "email=?EMail "; | ||
962 | query += "WHERE useruuid=?uuid"; | ||
963 | 937 | ||
964 | try | 938 | try |
965 | { | 939 | { |
@@ -975,6 +949,7 @@ namespace OpenSim.Data.MySQL | |||
975 | 949 | ||
976 | cmd.ExecuteNonQuery(); | 950 | cmd.ExecuteNonQuery(); |
977 | } | 951 | } |
952 | dbcon.Close(); | ||
978 | } | 953 | } |
979 | } | 954 | } |
980 | catch (Exception e) | 955 | catch (Exception e) |
@@ -991,11 +966,7 @@ namespace OpenSim.Data.MySQL | |||
991 | #region Integration | 966 | #region Integration |
992 | public bool GetUserAppData(ref UserAppData props, ref string result) | 967 | public bool GetUserAppData(ref UserAppData props, ref string result) |
993 | { | 968 | { |
994 | string query = string.Empty; | 969 | const string query = "SELECT * FROM `userdata` WHERE UserId = ?Id AND TagId = ?TagId"; |
995 | |||
996 | query += "SELECT * FROM `userdata` WHERE "; | ||
997 | query += "UserId = ?Id AND "; | ||
998 | query += "TagId = ?TagId"; | ||
999 | 970 | ||
1000 | try | 971 | try |
1001 | { | 972 | { |
@@ -1017,13 +988,8 @@ namespace OpenSim.Data.MySQL | |||
1017 | } | 988 | } |
1018 | else | 989 | else |
1019 | { | 990 | { |
1020 | query += "INSERT INTO userdata VALUES ( "; | 991 | const string queryB = "INSERT INTO userdata VALUES (?UserId, ?TagId, ?DataKey, ?DataVal)"; |
1021 | query += "?UserId,"; | 992 | using (MySqlCommand put = new MySqlCommand(queryB, dbcon)) |
1022 | query += "?TagId,"; | ||
1023 | query += "?DataKey,"; | ||
1024 | query += "?DataVal) "; | ||
1025 | |||
1026 | using (MySqlCommand put = new MySqlCommand(query, dbcon)) | ||
1027 | { | 993 | { |
1028 | put.Parameters.AddWithValue("?UserId", props.UserId.ToString()); | 994 | put.Parameters.AddWithValue("?UserId", props.UserId.ToString()); |
1029 | put.Parameters.AddWithValue("?TagId", props.TagId.ToString()); | 995 | put.Parameters.AddWithValue("?TagId", props.TagId.ToString()); |
@@ -1035,6 +1001,7 @@ namespace OpenSim.Data.MySQL | |||
1035 | } | 1001 | } |
1036 | } | 1002 | } |
1037 | } | 1003 | } |
1004 | dbcon.Close(); | ||
1038 | } | 1005 | } |
1039 | } | 1006 | } |
1040 | catch (Exception e) | 1007 | catch (Exception e) |
@@ -1049,14 +1016,7 @@ namespace OpenSim.Data.MySQL | |||
1049 | 1016 | ||
1050 | public bool SetUserAppData(UserAppData props, ref string result) | 1017 | public bool SetUserAppData(UserAppData props, ref string result) |
1051 | { | 1018 | { |
1052 | string query = string.Empty; | 1019 | const string query = "UPDATE userdata SET TagId = ?TagId, DataKey = ?DataKey, DataVal = ?DataVal WHERE UserId = ?UserId AND TagId = ?TagId"; |
1053 | |||
1054 | query += "UPDATE userdata SET "; | ||
1055 | query += "TagId = ?TagId, "; | ||
1056 | query += "DataKey = ?DataKey, "; | ||
1057 | query += "DataVal = ?DataVal WHERE "; | ||
1058 | query += "UserId = ?UserId AND "; | ||
1059 | query += "TagId = ?TagId"; | ||
1060 | 1020 | ||
1061 | try | 1021 | try |
1062 | { | 1022 | { |
@@ -1072,6 +1032,7 @@ namespace OpenSim.Data.MySQL | |||
1072 | 1032 | ||
1073 | cmd.ExecuteNonQuery(); | 1033 | cmd.ExecuteNonQuery(); |
1074 | } | 1034 | } |
1035 | dbcon.Close(); | ||
1075 | } | 1036 | } |
1076 | } | 1037 | } |
1077 | catch (Exception e) | 1038 | catch (Exception e) |