diff options
Diffstat (limited to 'OpenSim/Framework/Data.MSSQL/MSSQLUserData.cs')
-rw-r--r-- | OpenSim/Framework/Data.MSSQL/MSSQLUserData.cs | 54 |
1 files changed, 44 insertions, 10 deletions
diff --git a/OpenSim/Framework/Data.MSSQL/MSSQLUserData.cs b/OpenSim/Framework/Data.MSSQL/MSSQLUserData.cs index 60e6df4..aacbb2d 100644 --- a/OpenSim/Framework/Data.MSSQL/MSSQLUserData.cs +++ b/OpenSim/Framework/Data.MSSQL/MSSQLUserData.cs | |||
@@ -85,8 +85,42 @@ namespace OpenSim.Framework.Data.MSSQL | |||
85 | database = | 85 | database = |
86 | new MSSQLManager(settingDataSource, settingInitialCatalog, settingPersistSecurityInfo, settingUserId, | 86 | new MSSQLManager(settingDataSource, settingInitialCatalog, settingPersistSecurityInfo, settingUserId, |
87 | settingPassword); | 87 | settingPassword); |
88 | |||
89 | if (!TestTables()) | ||
90 | { | ||
91 | database.ExecuteResourceSql("Mssql-agents.sql"); | ||
92 | database.ExecuteResourceSql("Mssql-users.sql"); | ||
93 | database.ExecuteResourceSql("Mssql-userfriends.sql"); | ||
94 | } | ||
88 | } | 95 | } |
89 | 96 | ||
97 | private bool TestTables() | ||
98 | { | ||
99 | IDbCommand cmd = database.Query("select top 1 webLoginKey from "+m_usersTableName, new Dictionary<string, string>()); | ||
100 | try | ||
101 | { | ||
102 | cmd.ExecuteNonQuery(); | ||
103 | cmd.Dispose(); | ||
104 | } | ||
105 | catch | ||
106 | { | ||
107 | database.Query("alter table "+m_usersTableName+" add column [webLoginKey] varchar(36) default NULL", new Dictionary<string, string>()); | ||
108 | cmd.ExecuteNonQuery(); | ||
109 | cmd.Dispose(); | ||
110 | } | ||
111 | |||
112 | cmd = database.Query("select top 1 * from "+m_usersTableName, new Dictionary<string, string>()); | ||
113 | try | ||
114 | { | ||
115 | cmd.ExecuteNonQuery(); | ||
116 | } | ||
117 | catch | ||
118 | { | ||
119 | return false; | ||
120 | } | ||
121 | |||
122 | return true; | ||
123 | } | ||
90 | /// <summary> | 124 | /// <summary> |
91 | /// Searches the database for a specified user profile by name components | 125 | /// Searches the database for a specified user profile by name components |
92 | /// </summary> | 126 | /// </summary> |
@@ -104,7 +138,7 @@ namespace OpenSim.Framework.Data.MSSQL | |||
104 | param["second"] = last; | 138 | param["second"] = last; |
105 | 139 | ||
106 | IDbCommand result = | 140 | IDbCommand result = |
107 | database.Query("SELECT * FROM "+m_usersTableName+" WHERE username = @first AND lastname = @second", param); | 141 | database.Query("SELECT * FROM " + m_usersTableName + " WHERE username = @first AND lastname = @second", param); |
108 | IDataReader reader = result.ExecuteReader(); | 142 | IDataReader reader = result.ExecuteReader(); |
109 | 143 | ||
110 | UserProfileData row = database.readUserRow(reader); | 144 | UserProfileData row = database.readUserRow(reader); |
@@ -153,7 +187,7 @@ namespace OpenSim.Framework.Data.MSSQL | |||
153 | m_log.Info("[USER]: Stub UpdateUserCUrrentRegion called"); | 187 | m_log.Info("[USER]: Stub UpdateUserCUrrentRegion called"); |
154 | } | 188 | } |
155 | 189 | ||
156 | 190 | ||
157 | 191 | ||
158 | public List<Framework.AvatarPickerAvatar> GeneratePickerResults(LLUUID queryID, string query) | 192 | public List<Framework.AvatarPickerAvatar> GeneratePickerResults(LLUUID queryID, string query) |
159 | { | 193 | { |
@@ -180,9 +214,9 @@ namespace OpenSim.Framework.Data.MSSQL | |||
180 | while (reader.Read()) | 214 | while (reader.Read()) |
181 | { | 215 | { |
182 | Framework.AvatarPickerAvatar user = new Framework.AvatarPickerAvatar(); | 216 | Framework.AvatarPickerAvatar user = new Framework.AvatarPickerAvatar(); |
183 | user.AvatarID = new LLUUID((string) reader["UUID"]); | 217 | user.AvatarID = new LLUUID((string)reader["UUID"]); |
184 | user.firstName = (string) reader["username"]; | 218 | user.firstName = (string)reader["username"]; |
185 | user.lastName = (string) reader["surname"]; | 219 | user.lastName = (string)reader["surname"]; |
186 | returnlist.Add(user); | 220 | returnlist.Add(user); |
187 | } | 221 | } |
188 | reader.Close(); | 222 | reader.Close(); |
@@ -216,9 +250,9 @@ namespace OpenSim.Framework.Data.MSSQL | |||
216 | while (reader.Read()) | 250 | while (reader.Read()) |
217 | { | 251 | { |
218 | Framework.AvatarPickerAvatar user = new Framework.AvatarPickerAvatar(); | 252 | Framework.AvatarPickerAvatar user = new Framework.AvatarPickerAvatar(); |
219 | user.AvatarID = new LLUUID((string) reader["UUID"]); | 253 | user.AvatarID = new LLUUID((string)reader["UUID"]); |
220 | user.firstName = (string) reader["username"]; | 254 | user.firstName = (string)reader["username"]; |
221 | user.lastName = (string) reader["surname"]; | 255 | user.lastName = (string)reader["surname"]; |
222 | returnlist.Add(user); | 256 | returnlist.Add(user); |
223 | } | 257 | } |
224 | reader.Close(); | 258 | reader.Close(); |
@@ -323,7 +357,7 @@ namespace OpenSim.Framework.Data.MSSQL | |||
323 | UserProfileData user = GetUserByUUID(AgentID); | 357 | UserProfileData user = GetUserByUUID(AgentID); |
324 | user.webLoginKey = WebLoginKey; | 358 | user.webLoginKey = WebLoginKey; |
325 | UpdateUserProfile(user); | 359 | UpdateUserProfile(user); |
326 | 360 | ||
327 | } | 361 | } |
328 | /// <summary> | 362 | /// <summary> |
329 | /// Creates a new users profile | 363 | /// Creates a new users profile |
@@ -342,7 +376,7 @@ namespace OpenSim.Framework.Data.MSSQL | |||
342 | user.lastLogin, user.userInventoryURI, user.userAssetURI, | 376 | user.lastLogin, user.userInventoryURI, user.userAssetURI, |
343 | user.profileCanDoMask, user.profileWantDoMask, | 377 | user.profileCanDoMask, user.profileWantDoMask, |
344 | user.profileAboutText, user.profileFirstText, user.profileImage, | 378 | user.profileAboutText, user.profileFirstText, user.profileImage, |
345 | user.profileFirstImage,user.webLoginKey); | 379 | user.profileFirstImage, user.webLoginKey); |
346 | } | 380 | } |
347 | } | 381 | } |
348 | catch (Exception e) | 382 | catch (Exception e) |