30 using System.Reflection;
32 using OpenSim.Framework;
33 using MySql.Data.MySqlClient;
35 using OpenMetaverse.StructuredData;
38 namespace OpenSim.Data.MySQL
42 static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
45 string ConnectionString
50 protected virtual Assembly Assembly
52 get {
return GetType().Assembly; }
57 #region class Member Functions
60 ConnectionString = connectionString;
66 using (MySqlConnection dbcon =
new MySqlConnection(ConnectionString))
74 #endregion Member Functions
76 #region Classifieds Queries
77 public OSDArray GetClassifiedRecords(UUID creatorId)
90 using (MySqlConnection dbcon =
new MySqlConnection(ConnectionString))
92 string query =
"SELECT classifieduuid, name FROM classifieds WHERE creatoruuid = ?Id";
94 using (MySqlCommand cmd =
new MySqlCommand(query, dbcon))
96 cmd.Parameters.AddWithValue(
"?Id", creatorId);
97 using( MySqlDataReader reader = cmd.ExecuteReader(CommandBehavior.Default))
101 while (reader.Read())
109 UUID.TryParse(Convert.ToString( reader[
"classifieduuid"]), out Id);
110 Name = Convert.ToString(reader[
"name"]);
114 m_log.ErrorFormat(
"[PROFILES_DATA]" +
115 ": UserAccount exception {0}", e.Message);
117 n.Add(
"classifieduuid", OSD.FromUUID(Id));
118 n.Add(
"name", OSD.FromString(Name));
130 string query = string.Empty;
133 query +=
"INSERT INTO classifieds (";
134 query +=
"`classifieduuid`,";
135 query +=
"`creatoruuid`,";
136 query +=
"`creationdate`,";
137 query +=
"`expirationdate`,";
138 query +=
"`category`,";
140 query +=
"`description`,";
141 query +=
"`parceluuid`,";
142 query +=
"`parentestate`,";
143 query +=
"`snapshotuuid`,";
144 query +=
"`simname`,";
145 query +=
"`posglobal`,";
146 query +=
"`parcelname`,";
147 query +=
"`classifiedflags`,";
148 query +=
"`priceforlisting`) ";
150 query +=
"?ClassifiedId,";
151 query +=
"?CreatorId,";
152 query +=
"?CreatedDate,";
153 query +=
"?ExpirationDate,";
154 query +=
"?Category,";
156 query +=
"?Description,";
157 query +=
"?ParcelId,";
158 query +=
"?ParentEstate,";
159 query +=
"?SnapshotId,";
160 query +=
"?SimName,";
161 query +=
"?GlobalPos,";
162 query +=
"?ParcelName,";
164 query +=
"?ListingPrice ) ";
165 query +=
"ON DUPLICATE KEY UPDATE ";
166 query +=
"category=?Category, ";
167 query +=
"expirationdate=?ExpirationDate, ";
168 query +=
"name=?Name, ";
169 query +=
"description=?Description, ";
170 query +=
"parentestate=?ParentEstate, ";
171 query +=
"posglobal=?GlobalPos, ";
172 query +=
"parcelname=?ParcelName, ";
173 query +=
"classifiedflags=?Flags, ";
174 query +=
"priceforlisting=?ListingPrice, ";
175 query +=
"snapshotuuid=?SnapshotId";
178 ad.ParcelName =
"Unknown";
180 ad.ParcelId = UUID.Zero;
182 ad.Description =
"No Description";
184 DateTime epoch =
new DateTime(1970, 1, 1);
185 DateTime now = DateTime.Now;
186 TimeSpan epochnow = now - epoch;
193 duration =
new TimeSpan(7,0,0,0);
194 expiration = now.Add(duration);
195 epochexp = expiration - epoch;
199 duration =
new TimeSpan(365,0,0,0);
200 expiration = now.Add(duration);
201 epochexp = expiration - epoch;
203 ad.CreationDate = (int)epochnow.TotalSeconds;
208 using (MySqlConnection dbcon =
new MySqlConnection(ConnectionString))
211 using (MySqlCommand cmd =
new MySqlCommand(query, dbcon))
213 cmd.Parameters.AddWithValue(
"?ClassifiedId", ad.ClassifiedId.ToString());
214 cmd.Parameters.AddWithValue(
"?CreatorId", ad.CreatorId.ToString());
215 cmd.Parameters.AddWithValue(
"?CreatedDate", ad.CreationDate.ToString());
216 cmd.Parameters.AddWithValue(
"?ExpirationDate", ad.ExpirationDate.ToString());
217 cmd.Parameters.AddWithValue(
"?Category", ad.Category.ToString());
218 cmd.Parameters.AddWithValue(
"?Name", ad.Name.ToString());
219 cmd.Parameters.AddWithValue(
"?Description", ad.Description.ToString());
220 cmd.Parameters.AddWithValue(
"?ParcelId", ad.ParcelId.ToString());
221 cmd.Parameters.AddWithValue(
"?ParentEstate", ad.ParentEstate.ToString());
222 cmd.Parameters.AddWithValue(
"?SnapshotId", ad.SnapshotId.ToString ());
223 cmd.Parameters.AddWithValue(
"?SimName", ad.SimName.ToString());
224 cmd.Parameters.AddWithValue(
"?GlobalPos", ad.GlobalPos.ToString());
225 cmd.Parameters.AddWithValue(
"?ParcelName", ad.ParcelName.ToString());
226 cmd.Parameters.AddWithValue(
"?Flags", ad.Flags.ToString());
227 cmd.Parameters.AddWithValue(
"?ListingPrice", ad.Price.ToString ());
229 cmd.ExecuteNonQuery();
235 m_log.ErrorFormat(
"[PROFILES_DATA]" +
236 ": ClassifiedesUpdate exception {0}", e.Message);
245 string query = string.Empty;
247 query +=
"DELETE FROM classifieds WHERE ";
248 query +=
"classifieduuid = ?recordId";
252 using (MySqlConnection dbcon =
new MySqlConnection(ConnectionString))
256 using (MySqlCommand cmd =
new MySqlCommand(query, dbcon))
258 cmd.Parameters.AddWithValue(
"?recordId", recordId.ToString());
259 cmd.ExecuteNonQuery();
265 m_log.ErrorFormat(
"[PROFILES_DATA]" +
266 ": DeleteClassifiedRecord exception {0}", e.Message);
274 string query = string.Empty;
276 query +=
"SELECT * FROM classifieds WHERE ";
277 query +=
"classifieduuid = ?AdId";
281 using (MySqlConnection dbcon =
new MySqlConnection(ConnectionString))
284 using (MySqlCommand cmd =
new MySqlCommand(query, dbcon))
286 cmd.Parameters.AddWithValue(
"?AdId", ad.ClassifiedId.ToString());
288 using (MySqlDataReader reader = cmd.ExecuteReader())
292 ad.CreatorId =
new UUID(reader.GetGuid(
"creatoruuid"));
293 ad.ParcelId =
new UUID(reader.GetGuid(
"parceluuid"));
294 ad.SnapshotId =
new UUID(reader.GetGuid(
"snapshotuuid"));
295 ad.CreationDate = Convert.ToInt32(reader[
"creationdate"]);
296 ad.ExpirationDate = Convert.ToInt32(reader[
"expirationdate"]);
297 ad.ParentEstate = Convert.ToInt32(reader[
"parentestate"]);
298 ad.Flags = (byte)reader.GetUInt32(
"classifiedflags");
299 ad.Category = reader.GetInt32(
"category");
300 ad.Price = reader.GetInt16(
"priceforlisting");
301 ad.Name = reader.GetString(
"name");
302 ad.Description = reader.GetString(
"description");
303 ad.SimName = reader.GetString(
"simname");
304 ad.GlobalPos = reader.GetString(
"posglobal");
305 ad.ParcelName = reader.GetString(
"parcelname");
315 m_log.ErrorFormat(
"[PROFILES_DATA]" +
316 ": GetPickInfo exception {0}", e.Message);
320 #endregion Classifieds Queries
322 #region Picks Queries
325 string query = string.Empty;
327 query +=
"SELECT `pickuuid`,`name` FROM userpicks WHERE ";
328 query +=
"creatoruuid = ?Id";
333 using (MySqlConnection dbcon =
new MySqlConnection(ConnectionString))
336 using (MySqlCommand cmd =
new MySqlCommand(query, dbcon))
338 cmd.Parameters.AddWithValue(
"?Id", avatarId.ToString());
340 using (MySqlDataReader reader = cmd.ExecuteReader())
344 while (reader.Read())
348 record.Add(
"pickuuid",OSD.FromString((string)reader[
"pickuuid"]));
349 record.Add(
"name",OSD.FromString((string)reader[
"name"]));
359 m_log.ErrorFormat(
"[PROFILES_DATA]" +
360 ": GetAvatarPicks exception {0}", e.Message);
367 string query = string.Empty;
370 query +=
"SELECT * FROM userpicks WHERE ";
371 query +=
"creatoruuid = ?CreatorId AND ";
372 query +=
"pickuuid = ?PickId";
376 using (MySqlConnection dbcon =
new MySqlConnection(ConnectionString))
379 using (MySqlCommand cmd =
new MySqlCommand(query, dbcon))
381 cmd.Parameters.AddWithValue(
"?CreatorId", avatarId.ToString());
382 cmd.Parameters.AddWithValue(
"?PickId", pickId.ToString());
384 using (MySqlDataReader reader = cmd.ExecuteReader())
390 string description = (string)reader[
"description"];
392 if (
string.IsNullOrEmpty(description))
393 description =
"No description given.";
395 UUID.TryParse((string)reader[
"pickuuid"], out pick.
PickId);
396 UUID.TryParse((string)reader[
"creatoruuid"], out pick.
CreatorId);
397 UUID.TryParse((string)reader[
"parceluuid"], out pick.
ParcelId);
398 UUID.TryParse((string)reader[
"snapshotuuid"], out pick.
SnapshotId);
399 pick.GlobalPos = (string)reader[
"posglobal"];
400 pick.Gatekeeper = (string)reader[
"gatekeeper"];
401 bool.TryParse((string)reader[
"toppick"], out pick.
TopPick);
402 bool.TryParse((string)reader[
"enabled"], out pick.
Enabled);
403 pick.Name = (string)reader[
"name"];
404 pick.Desc = description;
405 pick.ParcelName = (string)reader[
"user"];
406 pick.OriginalName = (string)reader[
"originalname"];
407 pick.SimName = (string)reader[
"simname"];
408 pick.SortOrder = (int)reader[
"sortorder"];
417 m_log.ErrorFormat(
"[PROFILES_DATA]" +
418 ": GetPickInfo exception {0}", e.Message);
425 string query = string.Empty;
427 query +=
"INSERT INTO userpicks VALUES (";
429 query +=
"?CreatorId,";
430 query +=
"?TopPick,";
431 query +=
"?ParcelId,";
434 query +=
"?SnapshotId,";
436 query +=
"?Original,";
437 query +=
"?SimName,";
438 query +=
"?GlobalPos,";
439 query +=
"?SortOrder,";
440 query +=
"?Enabled,";
441 query +=
"?Gatekeeper)";
442 query +=
"ON DUPLICATE KEY UPDATE ";
443 query +=
"parceluuid=?ParcelId,";
444 query +=
"name=?Name,";
445 query +=
"description=?Desc,";
446 query +=
"user=?User,";
447 query +=
"simname=?SimName,";
448 query +=
"snapshotuuid=?SnapshotId,";
449 query +=
"pickuuid=?PickId,";
450 query +=
"posglobal=?GlobalPos,";
451 query +=
"gatekeeper=?Gatekeeper";
455 using (MySqlConnection dbcon =
new MySqlConnection(ConnectionString))
458 using (MySqlCommand cmd =
new MySqlCommand(query, dbcon))
460 cmd.Parameters.AddWithValue(
"?PickId", pick.PickId.ToString());
461 cmd.Parameters.AddWithValue(
"?CreatorId", pick.CreatorId.ToString());
462 cmd.Parameters.AddWithValue(
"?TopPick", pick.TopPick.ToString());
463 cmd.Parameters.AddWithValue(
"?ParcelId", pick.ParcelId.ToString());
464 cmd.Parameters.AddWithValue(
"?Name", pick.Name.ToString());
465 cmd.Parameters.AddWithValue(
"?Desc", pick.Desc.ToString());
466 cmd.Parameters.AddWithValue(
"?SnapshotId", pick.SnapshotId.ToString());
467 cmd.Parameters.AddWithValue(
"?User", pick.ParcelName.ToString());
468 cmd.Parameters.AddWithValue(
"?Original", pick.OriginalName.ToString());
469 cmd.Parameters.AddWithValue(
"?SimName",pick.SimName.ToString());
470 cmd.Parameters.AddWithValue(
"?GlobalPos", pick.GlobalPos);
471 cmd.Parameters.AddWithValue(
"?Gatekeeper",pick.Gatekeeper);
472 cmd.Parameters.AddWithValue(
"?SortOrder", pick.SortOrder.ToString ());
473 cmd.Parameters.AddWithValue(
"?Enabled", pick.Enabled.ToString());
475 cmd.ExecuteNonQuery();
481 m_log.ErrorFormat(
"[PROFILES_DATA]" +
482 ": UpdateAvatarNotes exception {0}", e.Message);
490 string query = string.Empty;
492 query +=
"DELETE FROM userpicks WHERE ";
493 query +=
"pickuuid = ?PickId";
497 using (MySqlConnection dbcon =
new MySqlConnection(ConnectionString))
501 using (MySqlCommand cmd =
new MySqlCommand(query, dbcon))
503 cmd.Parameters.AddWithValue(
"?PickId", pickId.ToString());
505 cmd.ExecuteNonQuery();
511 m_log.ErrorFormat(
"[PROFILES_DATA]" +
512 ": DeleteUserPickRecord exception {0}", e.Message);
517 #endregion Picks Queries
519 #region Avatar Notes Queries
522 string query = string.Empty;
524 query +=
"SELECT `notes` FROM usernotes WHERE ";
525 query +=
"useruuid = ?Id AND ";
526 query +=
"targetuuid = ?TargetId";
531 using (MySqlConnection dbcon =
new MySqlConnection(ConnectionString))
534 using (MySqlCommand cmd =
new MySqlCommand(query, dbcon))
536 cmd.Parameters.AddWithValue(
"?Id", notes.UserId.ToString());
537 cmd.Parameters.AddWithValue(
"?TargetId", notes.TargetId.ToString());
539 using (MySqlDataReader reader = cmd.ExecuteReader(CommandBehavior.SingleRow))
544 notes.Notes = OSD.FromString((string)reader[
"notes"]);
548 notes.Notes = OSD.FromString(
"");
556 m_log.ErrorFormat(
"[PROFILES_DATA]" +
557 ": GetAvatarNotes exception {0}", e.Message);
564 string query = string.Empty;
567 if(
string.IsNullOrEmpty(note.Notes))
570 query +=
"DELETE FROM usernotes WHERE ";
571 query +=
"useruuid=?UserId AND ";
572 query +=
"targetuuid=?TargetId";
577 query +=
"INSERT INTO usernotes VALUES ( ";
579 query +=
"?TargetId,";
581 query +=
"ON DUPLICATE KEY ";
583 query +=
"notes=?Notes";
588 using (MySqlConnection dbcon =
new MySqlConnection(ConnectionString))
591 using (MySqlCommand cmd =
new MySqlCommand(query, dbcon))
594 cmd.Parameters.AddWithValue(
"?Notes", note.Notes);
595 cmd.Parameters.AddWithValue(
"?TargetId", note.TargetId.ToString ());
596 cmd.Parameters.AddWithValue(
"?UserId", note.UserId.ToString());
598 cmd.ExecuteNonQuery();
604 m_log.ErrorFormat(
"[PROFILES_DATA]" +
605 ": UpdateAvatarNotes exception {0}", e.Message);
611 #endregion Avatar Notes Queries
613 #region Avatar Properties
616 string query = string.Empty;
618 query +=
"SELECT * FROM userprofile WHERE ";
619 query +=
"useruuid = ?Id";
623 using (MySqlConnection dbcon =
new MySqlConnection(ConnectionString))
626 using (MySqlCommand cmd =
new MySqlCommand(query, dbcon))
628 cmd.Parameters.AddWithValue(
"?Id", props.UserId.ToString());
630 using (MySqlDataReader reader = cmd.ExecuteReader(CommandBehavior.SingleRow))
634 m_log.DebugFormat(
"[PROFILES_DATA]" +
635 ": Getting data for {0}.", props.UserId);
637 props.WebUrl = (string)reader[
"profileURL"];
638 UUID.TryParse((string)reader[
"profileImage"], out props.ImageId);
639 props.AboutText = (string)reader[
"profileAboutText"];
640 UUID.TryParse((string)reader[
"profileFirstImage"], out props.FirstLifeImageId);
641 props.FirstLifeText = (string)reader[
"profileFirstText"];
642 UUID.TryParse((string)reader[
"profilePartner"], out props.PartnerId);
643 props.WantToMask = (int)reader[
"profileWantToMask"];
644 props.WantToText = (string)reader[
"profileWantToText"];
645 props.SkillsMask = (int)reader[
"profileSkillsMask"];
646 props.SkillsText = (string)reader[
"profileSkillsText"];
647 props.Language = (string)reader[
"profileLanguages"];
651 m_log.DebugFormat(
"[PROFILES_DATA]" +
652 ": No data for {0}", props.UserId);
654 props.WebUrl = string.Empty;
655 props.ImageId = UUID.Zero;
656 props.AboutText = string.Empty;
657 props.FirstLifeImageId = UUID.Zero;
658 props.FirstLifeText = string.Empty;
659 props.PartnerId = UUID.Zero;
660 props.WantToMask = 0;
661 props.WantToText = string.Empty;
662 props.SkillsMask = 0;
663 props.SkillsText = string.Empty;
664 props.Language = string.Empty;
665 props.PublishProfile =
false;
666 props.PublishMature =
false;
668 query =
"INSERT INTO userprofile (";
669 query +=
"useruuid, ";
670 query +=
"profilePartner, ";
671 query +=
"profileAllowPublish, ";
672 query +=
"profileMaturePublish, ";
673 query +=
"profileURL, ";
674 query +=
"profileWantToMask, ";
675 query +=
"profileWantToText, ";
676 query +=
"profileSkillsMask, ";
677 query +=
"profileSkillsText, ";
678 query +=
"profileLanguages, ";
679 query +=
"profileImage, ";
680 query +=
"profileAboutText, ";
681 query +=
"profileFirstImage, ";
682 query +=
"profileFirstText) VALUES (";
683 query +=
"?userId, ";
684 query +=
"?profilePartner, ";
685 query +=
"?profileAllowPublish, ";
686 query +=
"?profileMaturePublish, ";
687 query +=
"?profileURL, ";
688 query +=
"?profileWantToMask, ";
689 query +=
"?profileWantToText, ";
690 query +=
"?profileSkillsMask, ";
691 query +=
"?profileSkillsText, ";
692 query +=
"?profileLanguages, ";
693 query +=
"?profileImage, ";
694 query +=
"?profileAboutText, ";
695 query +=
"?profileFirstImage, ";
696 query +=
"?profileFirstText)";
701 using (MySqlCommand put =
new MySqlCommand(query, dbcon))
703 put.Parameters.AddWithValue(
"?userId", props.UserId.ToString());
704 put.Parameters.AddWithValue(
"?profilePartner", props.PartnerId.ToString());
705 put.Parameters.AddWithValue(
"?profileAllowPublish", props.PublishProfile);
706 put.Parameters.AddWithValue(
"?profileMaturePublish", props.PublishMature);
707 put.Parameters.AddWithValue(
"?profileURL", props.WebUrl);
708 put.Parameters.AddWithValue(
"?profileWantToMask", props.WantToMask);
709 put.Parameters.AddWithValue(
"?profileWantToText", props.WantToText);
710 put.Parameters.AddWithValue(
"?profileSkillsMask", props.SkillsMask);
711 put.Parameters.AddWithValue(
"?profileSkillsText", props.SkillsText);
712 put.Parameters.AddWithValue(
"?profileLanguages", props.Language);
713 put.Parameters.AddWithValue(
"?profileImage", props.ImageId.ToString());
714 put.Parameters.AddWithValue(
"?profileAboutText", props.AboutText);
715 put.Parameters.AddWithValue(
"?profileFirstImage", props.FirstLifeImageId.ToString());
716 put.Parameters.AddWithValue(
"?profileFirstText", props.FirstLifeText);
718 put.ExecuteNonQuery();
727 m_log.ErrorFormat(
"[PROFILES_DATA]" +
728 ": Requst properties exception {0}", e.Message);
737 string query = string.Empty;
739 query +=
"UPDATE userprofile SET ";
740 query +=
"profileURL=?profileURL, ";
741 query +=
"profileImage=?image, ";
742 query +=
"profileAboutText=?abouttext,";
743 query +=
"profileFirstImage=?firstlifeimage,";
744 query +=
"profileFirstText=?firstlifetext ";
745 query +=
"WHERE useruuid=?uuid";
749 using (MySqlConnection dbcon =
new MySqlConnection(ConnectionString))
752 using (MySqlCommand cmd =
new MySqlCommand(query, dbcon))
754 cmd.Parameters.AddWithValue(
"?profileURL", props.WebUrl);
755 cmd.Parameters.AddWithValue(
"?image", props.ImageId.ToString());
756 cmd.Parameters.AddWithValue(
"?abouttext", props.AboutText);
757 cmd.Parameters.AddWithValue(
"?firstlifeimage", props.FirstLifeImageId.ToString());
758 cmd.Parameters.AddWithValue(
"?firstlifetext", props.FirstLifeText);
759 cmd.Parameters.AddWithValue(
"?uuid", props.UserId.ToString());
761 cmd.ExecuteNonQuery();
767 m_log.ErrorFormat(
"[PROFILES_DATA]" +
768 ": AgentPropertiesUpdate exception {0}", e.Message);
774 #endregion Avatar Properties
776 #region Avatar Interests
779 string query = string.Empty;
781 query +=
"UPDATE userprofile SET ";
782 query +=
"profileWantToMask=?WantMask, ";
783 query +=
"profileWantToText=?WantText,";
784 query +=
"profileSkillsMask=?SkillsMask,";
785 query +=
"profileSkillsText=?SkillsText, ";
786 query +=
"profileLanguages=?Languages ";
787 query +=
"WHERE useruuid=?uuid";
791 using (MySqlConnection dbcon =
new MySqlConnection(ConnectionString))
794 using (MySqlCommand cmd =
new MySqlCommand(query, dbcon))
796 cmd.Parameters.AddWithValue(
"?WantMask", up.WantToMask);
797 cmd.Parameters.AddWithValue(
"?WantText", up.WantToText);
798 cmd.Parameters.AddWithValue(
"?SkillsMask", up.SkillsMask);
799 cmd.Parameters.AddWithValue(
"?SkillsText", up.SkillsText);
800 cmd.Parameters.AddWithValue(
"?Languages", up.Language);
801 cmd.Parameters.AddWithValue(
"?uuid", up.UserId.ToString());
803 cmd.ExecuteNonQuery();
809 m_log.ErrorFormat(
"[PROFILES_DATA]" +
810 ": AgentInterestsUpdate exception {0}", e.Message);
816 #endregion Avatar Interests
821 string query =
"SELECT `snapshotuuid` FROM {0} WHERE `creatoruuid` = ?Id";
828 using (MySqlConnection dbcon =
new MySqlConnection(ConnectionString))
832 using (MySqlCommand cmd =
new MySqlCommand(
string.Format (query,
"`classifieds`"), dbcon))
834 cmd.Parameters.AddWithValue(
"?Id", avatarId.ToString());
836 using (MySqlDataReader reader = cmd.ExecuteReader(CommandBehavior.SingleRow))
840 while (reader.Read())
842 data.Add(
new OSDString((
string)reader[
"snapshotuuid"].ToString ()));
851 using (MySqlCommand cmd =
new MySqlCommand(
string.Format (query,
"`userpicks`"), dbcon))
853 cmd.Parameters.AddWithValue(
"?Id", avatarId.ToString());
855 using (MySqlDataReader reader = cmd.ExecuteReader(CommandBehavior.SingleRow))
859 while (reader.Read())
861 data.Add(
new OSDString((
string)reader[
"snapshotuuid"].ToString ()));
870 query =
"SELECT `profileImage`, `profileFirstImage` FROM `userprofile` WHERE `useruuid` = ?Id";
872 using (MySqlCommand cmd =
new MySqlCommand(
string.Format (query,
"`userpicks`"), dbcon))
874 cmd.Parameters.AddWithValue(
"?Id", avatarId.ToString());
876 using (MySqlDataReader reader = cmd.ExecuteReader(CommandBehavior.SingleRow))
880 while (reader.Read())
882 data.Add(
new OSDString((
string)reader[
"profileImage"].ToString ()));
883 data.Add(
new OSDString((
string)reader[
"profileFirstImage"].ToString ()));
892 m_log.ErrorFormat(
"[PROFILES_DATA]" +
893 ": GetAvatarNotes exception {0}", e.Message);
898 #region User Preferences
901 string query = string.Empty;
903 query +=
"SELECT imviaemail,visible,email FROM ";
904 query +=
"usersettings WHERE ";
905 query +=
"useruuid = ?Id";
911 using (MySqlConnection dbcon =
new MySqlConnection(ConnectionString))
914 using (MySqlCommand cmd =
new MySqlCommand(query, dbcon))
916 cmd.Parameters.AddWithValue(
"?Id", pref.UserId.ToString());
917 using (MySqlDataReader reader = cmd.ExecuteReader())
922 bool.TryParse((string)reader[
"imviaemail"], out pref.IMViaEmail);
923 bool.TryParse((string)reader[
"visible"], out pref.Visible);
924 pref.EMail = (string)reader[
"email"];
931 query =
"INSERT INTO usersettings VALUES ";
932 query +=
"(?uuid,'false','false', ?Email)";
934 using (MySqlCommand put =
new MySqlCommand(query, dbcon))
937 put.Parameters.AddWithValue(
"?Email", pref.EMail);
938 put.Parameters.AddWithValue(
"?uuid", pref.UserId.ToString());
940 put.ExecuteNonQuery();
949 m_log.ErrorFormat(
"[PROFILES_DATA]" +
950 ": Get preferences exception {0}", e.Message);
959 string query = string.Empty;
961 query +=
"UPDATE usersettings SET ";
962 query +=
"imviaemail=?ImViaEmail, ";
963 query +=
"visible=?Visible, ";
964 query +=
"email=?EMail ";
965 query +=
"WHERE useruuid=?uuid";
969 using (MySqlConnection dbcon =
new MySqlConnection(ConnectionString))
972 using (MySqlCommand cmd =
new MySqlCommand(query, dbcon))
974 cmd.Parameters.AddWithValue(
"?ImViaEmail", pref.IMViaEmail.ToString().ToLower());
975 cmd.Parameters.AddWithValue(
"?Visible", pref.Visible.ToString().ToLower());
976 cmd.Parameters.AddWithValue(
"?uuid", pref.UserId.ToString());
977 cmd.Parameters.AddWithValue(
"?EMail", pref.EMail.ToString().ToLower());
979 cmd.ExecuteNonQuery();
985 m_log.ErrorFormat(
"[PROFILES_DATA]" +
986 ": UserPreferencesUpdate exception {0} {1}", e.Message, e.InnerException);
992 #endregion User Preferences
997 string query = string.Empty;
999 query +=
"SELECT * FROM `userdata` WHERE ";
1000 query +=
"UserId = ?Id AND ";
1001 query +=
"TagId = ?TagId";
1005 using (MySqlConnection dbcon =
new MySqlConnection(ConnectionString))
1008 using (MySqlCommand cmd =
new MySqlCommand(query, dbcon))
1010 cmd.Parameters.AddWithValue(
"?Id", props.UserId.ToString());
1011 cmd.Parameters.AddWithValue (
"?TagId", props.TagId.ToString());
1013 using (MySqlDataReader reader = cmd.ExecuteReader(CommandBehavior.SingleRow))
1018 props.DataKey = (string)reader[
"DataKey"];
1019 props.DataVal = (string)reader[
"DataVal"];
1023 query +=
"INSERT INTO userdata VALUES ( ";
1024 query +=
"?UserId,";
1026 query +=
"?DataKey,";
1027 query +=
"?DataVal) ";
1029 using (MySqlCommand put =
new MySqlCommand(query, dbcon))
1031 put.Parameters.AddWithValue(
"?UserId", props.UserId.ToString());
1032 put.Parameters.AddWithValue(
"?TagId", props.TagId.ToString());
1033 put.Parameters.AddWithValue(
"?DataKey", props.DataKey.ToString());
1034 put.Parameters.AddWithValue(
"?DataVal", props.DataVal.ToString());
1036 put.ExecuteNonQuery();
1045 m_log.ErrorFormat(
"[PROFILES_DATA]" +
1046 ": Requst application data exception {0}", e.Message);
1055 string query = string.Empty;
1057 query +=
"UPDATE userdata SET ";
1058 query +=
"TagId = ?TagId, ";
1059 query +=
"DataKey = ?DataKey, ";
1060 query +=
"DataVal = ?DataVal WHERE ";
1061 query +=
"UserId = ?UserId AND ";
1062 query +=
"TagId = ?TagId";
1066 using (MySqlConnection dbcon =
new MySqlConnection(ConnectionString))
1069 using (MySqlCommand cmd =
new MySqlCommand(query, dbcon))
1071 cmd.Parameters.AddWithValue(
"?UserId", props.UserId.ToString());
1072 cmd.Parameters.AddWithValue(
"?TagId", props.TagId.ToString());
1073 cmd.Parameters.AddWithValue(
"?DataKey", props.DataKey.ToString());
1074 cmd.Parameters.AddWithValue(
"?DataVal", props.DataKey.ToString());
1076 cmd.ExecuteNonQuery();
1082 m_log.ErrorFormat(
"[PROFILES_DATA]" +
1083 ": SetUserData exception {0}", e.Message);
1088 #endregion Integration
bool UpdateAvatarInterests(UserProfileProperties up, ref string result)
OpenMetaverse.StructuredData.OSDArray OSDArray
bool GetAvatarProperties(ref UserProfileProperties props, ref string result)
OSDArray GetUserImageAssets(UUID avatarId)
OpenMetaverse.StructuredData.OSDMap OSDMap
bool GetUserPreferences(ref UserPreferences pref, ref string result)
bool SetUserAppData(UserAppData props, ref string result)
bool UpdatePicksRecord(UserProfilePick pick)
UserProfilePick GetPickInfo(UUID avatarId, UUID pickId)
bool GetClassifiedInfo(ref UserClassifiedAdd ad, ref string result)
bool UpdateUserPreferences(ref UserPreferences pref, ref string result)
bool UpdateAvatarProperties(ref UserProfileProperties props, ref string result)
bool DeleteClassifiedRecord(UUID recordId)
UserProfilesData(string connectionString)
bool GetAvatarNotes(ref UserProfileNotes notes)
bool GetUserAppData(ref UserAppData props, ref string result)
bool DeletePicksRecord(UUID pickId)
OSDArray GetAvatarPicks(UUID avatarId)
bool UpdateAvatarNotes(ref UserProfileNotes note, ref string result)
bool UpdateClassifiedRecord(UserClassifiedAdd ad, ref string result)