diff options
Diffstat (limited to 'OpenSim/Framework/Data.MSSQL/MSSQLUserData.cs')
-rw-r--r-- | OpenSim/Framework/Data.MSSQL/MSSQLUserData.cs | 142 |
1 files changed, 74 insertions, 68 deletions
diff --git a/OpenSim/Framework/Data.MSSQL/MSSQLUserData.cs b/OpenSim/Framework/Data.MSSQL/MSSQLUserData.cs index eac9826..01ef559 100644 --- a/OpenSim/Framework/Data.MSSQL/MSSQLUserData.cs +++ b/OpenSim/Framework/Data.MSSQL/MSSQLUserData.cs | |||
@@ -37,7 +37,7 @@ namespace OpenSim.Framework.Data.MSSQL | |||
37 | /// <summary> | 37 | /// <summary> |
38 | /// A database interface class to a user profile storage system | 38 | /// A database interface class to a user profile storage system |
39 | /// </summary> | 39 | /// </summary> |
40 | class MSSQLUserData : IUserData | 40 | internal class MSSQLUserData : IUserData |
41 | { | 41 | { |
42 | /// <summary> | 42 | /// <summary> |
43 | /// Database manager for MySQL | 43 | /// Database manager for MySQL |
@@ -58,7 +58,9 @@ namespace OpenSim.Framework.Data.MSSQL | |||
58 | string settingUserId = GridDataMySqlFile.ParseFileReadValue("user_id"); | 58 | string settingUserId = GridDataMySqlFile.ParseFileReadValue("user_id"); |
59 | string settingPassword = GridDataMySqlFile.ParseFileReadValue("password"); | 59 | string settingPassword = GridDataMySqlFile.ParseFileReadValue("password"); |
60 | 60 | ||
61 | database = new MSSQLManager(settingDataSource, settingInitialCatalog, settingPersistSecurityInfo, settingUserId, settingPassword); | 61 | database = |
62 | new MSSQLManager(settingDataSource, settingInitialCatalog, settingPersistSecurityInfo, settingUserId, | ||
63 | settingPassword); | ||
62 | } | 64 | } |
63 | 65 | ||
64 | /// <summary> | 66 | /// <summary> |
@@ -77,11 +79,12 @@ namespace OpenSim.Framework.Data.MSSQL | |||
77 | param["first"] = user; | 79 | param["first"] = user; |
78 | param["second"] = last; | 80 | param["second"] = last; |
79 | 81 | ||
80 | IDbCommand result = database.Query("SELECT * FROM users WHERE username = @first AND lastname = @second", param); | 82 | IDbCommand result = |
83 | database.Query("SELECT * FROM users WHERE username = @first AND lastname = @second", param); | ||
81 | IDataReader reader = result.ExecuteReader(); | 84 | IDataReader reader = result.ExecuteReader(); |
82 | 85 | ||
83 | UserProfileData row = database.readUserRow(reader); | 86 | UserProfileData row = database.readUserRow(reader); |
84 | 87 | ||
85 | reader.Close(); | 88 | reader.Close(); |
86 | result.Dispose(); | 89 | result.Dispose(); |
87 | 90 | ||
@@ -96,9 +99,9 @@ namespace OpenSim.Framework.Data.MSSQL | |||
96 | } | 99 | } |
97 | } | 100 | } |
98 | 101 | ||
99 | public List<OpenSim.Framework.AvatarPickerAvatar> GeneratePickerResults(LLUUID queryID, string query) | 102 | public List<Framework.AvatarPickerAvatar> GeneratePickerResults(LLUUID queryID, string query) |
100 | { | 103 | { |
101 | List<OpenSim.Framework.AvatarPickerAvatar> returnlist = new List<OpenSim.Framework.AvatarPickerAvatar>(); | 104 | List<Framework.AvatarPickerAvatar> returnlist = new List<Framework.AvatarPickerAvatar>(); |
102 | string[] querysplit; | 105 | string[] querysplit; |
103 | querysplit = query.Split(' '); | 106 | querysplit = query.Split(' '); |
104 | if (querysplit.Length == 2) | 107 | if (querysplit.Length == 2) |
@@ -112,18 +115,19 @@ namespace OpenSim.Framework.Data.MSSQL | |||
112 | param["second"] = querysplit[1]; | 115 | param["second"] = querysplit[1]; |
113 | 116 | ||
114 | IDbCommand result = | 117 | IDbCommand result = |
115 | database.Query("SELECT UUID,username,surname FROM users WHERE username = @first AND lastname = @second", param); | 118 | database.Query( |
119 | "SELECT UUID,username,surname FROM users WHERE username = @first AND lastname = @second", | ||
120 | param); | ||
116 | IDataReader reader = result.ExecuteReader(); | 121 | IDataReader reader = result.ExecuteReader(); |
117 | 122 | ||
118 | 123 | ||
119 | while (reader.Read()) | 124 | while (reader.Read()) |
120 | { | 125 | { |
121 | OpenSim.Framework.AvatarPickerAvatar user = new OpenSim.Framework.AvatarPickerAvatar(); | 126 | Framework.AvatarPickerAvatar user = new Framework.AvatarPickerAvatar(); |
122 | user.AvatarID = new LLUUID((string)reader["UUID"]); | 127 | user.AvatarID = new LLUUID((string) reader["UUID"]); |
123 | user.firstName = (string)reader["username"]; | 128 | user.firstName = (string) reader["username"]; |
124 | user.lastName = (string)reader["surname"]; | 129 | user.lastName = (string) reader["surname"]; |
125 | returnlist.Add(user); | 130 | returnlist.Add(user); |
126 | |||
127 | } | 131 | } |
128 | reader.Close(); | 132 | reader.Close(); |
129 | result.Dispose(); | 133 | result.Dispose(); |
@@ -135,13 +139,9 @@ namespace OpenSim.Framework.Data.MSSQL | |||
135 | MainLog.Instance.Error(e.ToString()); | 139 | MainLog.Instance.Error(e.ToString()); |
136 | return returnlist; | 140 | return returnlist; |
137 | } | 141 | } |
138 | |||
139 | |||
140 | |||
141 | } | 142 | } |
142 | else if (querysplit.Length == 1) | 143 | else if (querysplit.Length == 1) |
143 | { | 144 | { |
144 | |||
145 | try | 145 | try |
146 | { | 146 | { |
147 | lock (database) | 147 | lock (database) |
@@ -151,18 +151,19 @@ namespace OpenSim.Framework.Data.MSSQL | |||
151 | param["second"] = querysplit[1]; | 151 | param["second"] = querysplit[1]; |
152 | 152 | ||
153 | IDbCommand result = | 153 | IDbCommand result = |
154 | database.Query("SELECT UUID,username,surname FROM users WHERE username = @first OR lastname = @second", param); | 154 | database.Query( |
155 | "SELECT UUID,username,surname FROM users WHERE username = @first OR lastname = @second", | ||
156 | param); | ||
155 | IDataReader reader = result.ExecuteReader(); | 157 | IDataReader reader = result.ExecuteReader(); |
156 | 158 | ||
157 | 159 | ||
158 | while (reader.Read()) | 160 | while (reader.Read()) |
159 | { | 161 | { |
160 | OpenSim.Framework.AvatarPickerAvatar user = new OpenSim.Framework.AvatarPickerAvatar(); | 162 | Framework.AvatarPickerAvatar user = new Framework.AvatarPickerAvatar(); |
161 | user.AvatarID = new LLUUID((string)reader["UUID"]); | 163 | user.AvatarID = new LLUUID((string) reader["UUID"]); |
162 | user.firstName = (string)reader["username"]; | 164 | user.firstName = (string) reader["username"]; |
163 | user.lastName = (string)reader["surname"]; | 165 | user.lastName = (string) reader["surname"]; |
164 | returnlist.Add(user); | 166 | returnlist.Add(user); |
165 | |||
166 | } | 167 | } |
167 | reader.Close(); | 168 | reader.Close(); |
168 | result.Dispose(); | 169 | result.Dispose(); |
@@ -268,21 +269,25 @@ namespace OpenSim.Framework.Data.MSSQL | |||
268 | /// <param name="user">The user profile to create</param> | 269 | /// <param name="user">The user profile to create</param> |
269 | public void AddNewUserProfile(UserProfileData user) | 270 | public void AddNewUserProfile(UserProfileData user) |
270 | { | 271 | { |
271 | try | 272 | try |
272 | { | 273 | { |
273 | lock (database) | 274 | lock (database) |
274 | { | 275 | { |
275 | database.insertUserRow(user.UUID, user.username, user.surname, user.passwordHash, user.passwordSalt, user.homeRegion, user.homeLocation.X, user.homeLocation.Y, user.homeLocation.Z, | 276 | database.insertUserRow(user.UUID, user.username, user.surname, user.passwordHash, user.passwordSalt, |
276 | user.homeLookAt.X, user.homeLookAt.Y, user.homeLookAt.Z, user.created, user.lastLogin, user.userInventoryURI, user.userAssetURI, user.profileCanDoMask, user.profileWantDoMask, | 277 | user.homeRegion, user.homeLocation.X, user.homeLocation.Y, |
277 | user.profileAboutText, user.profileFirstText, user.profileImage, user.profileFirstImage); | 278 | user.homeLocation.Z, |
278 | } | 279 | user.homeLookAt.X, user.homeLookAt.Y, user.homeLookAt.Z, user.created, |
279 | } | 280 | user.lastLogin, user.userInventoryURI, user.userAssetURI, |
280 | catch (Exception e) | 281 | user.profileCanDoMask, user.profileWantDoMask, |
281 | { | 282 | user.profileAboutText, user.profileFirstText, user.profileImage, |
282 | database.Reconnect(); | 283 | user.profileFirstImage); |
283 | MainLog.Instance.Error(e.ToString()); | 284 | } |
284 | } | 285 | } |
285 | 286 | catch (Exception e) | |
287 | { | ||
288 | database.Reconnect(); | ||
289 | MainLog.Instance.Error(e.ToString()); | ||
290 | } | ||
286 | } | 291 | } |
287 | 292 | ||
288 | /// <summary> | 293 | /// <summary> |
@@ -293,34 +298,33 @@ namespace OpenSim.Framework.Data.MSSQL | |||
293 | { | 298 | { |
294 | // Do nothing. | 299 | // Do nothing. |
295 | } | 300 | } |
296 | 301 | ||
297 | 302 | ||
298 | public bool UpdateUserProfile(UserProfileData user) | 303 | public bool UpdateUserProfile(UserProfileData user) |
299 | { | 304 | { |
300 | |||
301 | SqlCommand command = new SqlCommand("UPDATE users set UUID = @uuid, " + | 305 | SqlCommand command = new SqlCommand("UPDATE users set UUID = @uuid, " + |
302 | "username = @username, " + | 306 | "username = @username, " + |
303 | "lastname = @lastname," + | 307 | "lastname = @lastname," + |
304 | "passwordHash = @passwordHash," + | 308 | "passwordHash = @passwordHash," + |
305 | "passwordSalt = @passwordSalt," + | 309 | "passwordSalt = @passwordSalt," + |
306 | "homeRegion = @homeRegion," + | 310 | "homeRegion = @homeRegion," + |
307 | "homeLocationX = @homeLocationX," + | 311 | "homeLocationX = @homeLocationX," + |
308 | "homeLocationY = @homeLocationY," + | 312 | "homeLocationY = @homeLocationY," + |
309 | "homeLocationZ = @homeLocationZ," + | 313 | "homeLocationZ = @homeLocationZ," + |
310 | "homeLookAtX = @homeLookAtX," + | 314 | "homeLookAtX = @homeLookAtX," + |
311 | "homeLookAtY = @homeLookAtY," + | 315 | "homeLookAtY = @homeLookAtY," + |
312 | "homeLookAtZ = @homeLookAtZ," + | 316 | "homeLookAtZ = @homeLookAtZ," + |
313 | "created = @created," + | 317 | "created = @created," + |
314 | "lastLogin = @lastLogin," + | 318 | "lastLogin = @lastLogin," + |
315 | "userInventoryURI = @userInventoryURI," + | 319 | "userInventoryURI = @userInventoryURI," + |
316 | "userAssetURI = @userAssetURI," + | 320 | "userAssetURI = @userAssetURI," + |
317 | "profileCanDoMask = @profileCanDoMask," + | 321 | "profileCanDoMask = @profileCanDoMask," + |
318 | "profileWantDoMask = @profileWantDoMask," + | 322 | "profileWantDoMask = @profileWantDoMask," + |
319 | "profileAboutText = @profileAboutText," + | 323 | "profileAboutText = @profileAboutText," + |
320 | "profileFirstText = @profileFirstText," + | 324 | "profileFirstText = @profileFirstText," + |
321 | "profileImage = @profileImage," + | 325 | "profileImage = @profileImage," + |
322 | "profileFirstImage = @profileFirstImage where " + | 326 | "profileFirstImage = @profileFirstImage where " + |
323 | "UUID = @keyUUUID;", database.getConnection()); | 327 | "UUID = @keyUUUID;", database.getConnection()); |
324 | SqlParameter param1 = new SqlParameter("@uuid", user.UUID.ToString()); | 328 | SqlParameter param1 = new SqlParameter("@uuid", user.UUID.ToString()); |
325 | SqlParameter param2 = new SqlParameter("@username", user.username); | 329 | SqlParameter param2 = new SqlParameter("@username", user.username); |
326 | SqlParameter param3 = new SqlParameter("@lastname", user.surname); | 330 | SqlParameter param3 = new SqlParameter("@lastname", user.surname); |
@@ -341,8 +345,8 @@ namespace OpenSim.Framework.Data.MSSQL | |||
341 | SqlParameter param18 = new SqlParameter("@profileWantDoMask", Convert.ToInt32(user.profileWantDoMask)); | 345 | SqlParameter param18 = new SqlParameter("@profileWantDoMask", Convert.ToInt32(user.profileWantDoMask)); |
342 | SqlParameter param19 = new SqlParameter("@profileAboutText", user.profileAboutText); | 346 | SqlParameter param19 = new SqlParameter("@profileAboutText", user.profileAboutText); |
343 | SqlParameter param20 = new SqlParameter("@profileFirstText", user.profileFirstText); | 347 | SqlParameter param20 = new SqlParameter("@profileFirstText", user.profileFirstText); |
344 | SqlParameter param21 = new SqlParameter("@profileImage", libsecondlife.LLUUID.Zero.ToString()); | 348 | SqlParameter param21 = new SqlParameter("@profileImage", LLUUID.Zero.ToString()); |
345 | SqlParameter param22 = new SqlParameter("@profileFirstImage", libsecondlife.LLUUID.Zero.ToString()); | 349 | SqlParameter param22 = new SqlParameter("@profileFirstImage", LLUUID.Zero.ToString()); |
346 | SqlParameter param23 = new SqlParameter("@keyUUUID", user.UUID.ToString()); | 350 | SqlParameter param23 = new SqlParameter("@keyUUUID", user.UUID.ToString()); |
347 | command.Parameters.Add(param1); | 351 | command.Parameters.Add(param1); |
348 | command.Parameters.Add(param2); | 352 | command.Parameters.Add(param2); |
@@ -370,9 +374,12 @@ namespace OpenSim.Framework.Data.MSSQL | |||
370 | try | 374 | try |
371 | { | 375 | { |
372 | int affected = command.ExecuteNonQuery(); | 376 | int affected = command.ExecuteNonQuery(); |
373 | if (affected != 0) { | 377 | if (affected != 0) |
378 | { | ||
374 | return true; | 379 | return true; |
375 | } else { | 380 | } |
381 | else | ||
382 | { | ||
376 | return false; | 383 | return false; |
377 | } | 384 | } |
378 | } | 385 | } |
@@ -433,6 +440,5 @@ namespace OpenSim.Framework.Data.MSSQL | |||
433 | public void runQuery(string query) | 440 | public void runQuery(string query) |
434 | { | 441 | { |
435 | } | 442 | } |
436 | |||
437 | } | 443 | } |
438 | } | 444 | } \ No newline at end of file |