diff options
author | lbsa71 | 2007-10-30 09:05:31 +0000 |
---|---|---|
committer | lbsa71 | 2007-10-30 09:05:31 +0000 |
commit | 67e12b95ea7b68f4904a7484d77ecfd787d16d0c (patch) | |
tree | 20b00d24c8a7617017960432ec044852e3ad5fa9 /OpenSim/Framework/Data.SQLite/SQLiteUserData.cs | |
parent | * Deleted .user file (diff) | |
download | opensim-SC-67e12b95ea7b68f4904a7484d77ecfd787d16d0c.zip opensim-SC-67e12b95ea7b68f4904a7484d77ecfd787d16d0c.tar.gz opensim-SC-67e12b95ea7b68f4904a7484d77ecfd787d16d0c.tar.bz2 opensim-SC-67e12b95ea7b68f4904a7484d77ecfd787d16d0c.tar.xz |
* Optimized usings
* Shortened type references
* Removed redundant 'this' qualifier
Diffstat (limited to 'OpenSim/Framework/Data.SQLite/SQLiteUserData.cs')
-rw-r--r-- | OpenSim/Framework/Data.SQLite/SQLiteUserData.cs | 261 |
1 files changed, 139 insertions, 122 deletions
diff --git a/OpenSim/Framework/Data.SQLite/SQLiteUserData.cs b/OpenSim/Framework/Data.SQLite/SQLiteUserData.cs index 37a8be5..d7a6b39 100644 --- a/OpenSim/Framework/Data.SQLite/SQLiteUserData.cs +++ b/OpenSim/Framework/Data.SQLite/SQLiteUserData.cs | |||
@@ -26,12 +26,8 @@ | |||
26 | * | 26 | * |
27 | */ | 27 | */ |
28 | using System; | 28 | using System; |
29 | using System.IO; | ||
30 | using libsecondlife; | ||
31 | using OpenSim.Framework; | ||
32 | using OpenSim.Framework; | ||
33 | using System.Data; | 29 | using System.Data; |
34 | using System.Data.SqlTypes; | 30 | using libsecondlife; |
35 | using Mono.Data.SqliteClient; | 31 | using Mono.Data.SqliteClient; |
36 | using OpenSim.Framework.Console; | 32 | using OpenSim.Framework.Console; |
37 | 33 | ||
@@ -45,30 +41,31 @@ namespace OpenSim.Framework.Data.SQLite | |||
45 | /// <summary> | 41 | /// <summary> |
46 | /// The database manager | 42 | /// The database manager |
47 | /// </summary> | 43 | /// </summary> |
48 | |||
49 | /// <summary> | 44 | /// <summary> |
50 | /// Artificial constructor called upon plugin load | 45 | /// Artificial constructor called upon plugin load |
51 | /// </summary> | 46 | /// </summary> |
52 | private const string userSelect = "select * from users"; | 47 | private const string userSelect = "select * from users"; |
48 | |||
53 | private DataSet ds; | 49 | private DataSet ds; |
54 | private SqliteDataAdapter da; | 50 | private SqliteDataAdapter da; |
55 | 51 | ||
56 | public void Initialise() | 52 | public void Initialise() |
57 | { | 53 | { |
58 | SqliteConnection conn = new SqliteConnection("URI=file:userprofiles.db,version=3"); | 54 | SqliteConnection conn = new SqliteConnection("URI=file:userprofiles.db,version=3"); |
59 | TestTables(conn); | 55 | TestTables(conn); |
60 | 56 | ||
61 | ds = new DataSet(); | 57 | ds = new DataSet(); |
62 | da = new SqliteDataAdapter(new SqliteCommand(userSelect, conn)); | 58 | da = new SqliteDataAdapter(new SqliteCommand(userSelect, conn)); |
63 | 59 | ||
64 | lock (ds) { | 60 | lock (ds) |
61 | { | ||
65 | ds.Tables.Add(createUsersTable()); | 62 | ds.Tables.Add(createUsersTable()); |
66 | ds.Tables.Add(createUserAgentsTable()); | 63 | ds.Tables.Add(createUserAgentsTable()); |
67 | 64 | ||
68 | setupUserCommands(da, conn); | 65 | setupUserCommands(da, conn); |
69 | da.Fill(ds.Tables["users"]); | 66 | da.Fill(ds.Tables["users"]); |
70 | } | 67 | } |
71 | 68 | ||
72 | return; | 69 | return; |
73 | } | 70 | } |
74 | 71 | ||
@@ -79,16 +76,21 @@ namespace OpenSim.Framework.Data.SQLite | |||
79 | /// <returns>A user profile</returns> | 76 | /// <returns>A user profile</returns> |
80 | public UserProfileData GetUserByUUID(LLUUID uuid) | 77 | public UserProfileData GetUserByUUID(LLUUID uuid) |
81 | { | 78 | { |
82 | lock (ds) { | 79 | lock (ds) |
80 | { | ||
83 | DataRow row = ds.Tables["users"].Rows.Find(uuid); | 81 | DataRow row = ds.Tables["users"].Rows.Find(uuid); |
84 | if(row != null) { | 82 | if (row != null) |
83 | { | ||
85 | UserProfileData user = buildUserProfile(row); | 84 | UserProfileData user = buildUserProfile(row); |
86 | row = ds.Tables["useragents"].Rows.Find(uuid); | 85 | row = ds.Tables["useragents"].Rows.Find(uuid); |
87 | if(row != null) { | 86 | if (row != null) |
87 | { | ||
88 | user.currentAgent = buildUserAgent(row); | 88 | user.currentAgent = buildUserAgent(row); |
89 | } | 89 | } |
90 | return user; | 90 | return user; |
91 | } else { | 91 | } |
92 | else | ||
93 | { | ||
92 | return null; | 94 | return null; |
93 | } | 95 | } |
94 | } | 96 | } |
@@ -113,16 +115,21 @@ namespace OpenSim.Framework.Data.SQLite | |||
113 | public UserProfileData GetUserByName(string fname, string lname) | 115 | public UserProfileData GetUserByName(string fname, string lname) |
114 | { | 116 | { |
115 | string select = "surname = '" + lname + "' and username = '" + fname + "'"; | 117 | string select = "surname = '" + lname + "' and username = '" + fname + "'"; |
116 | lock (ds) { | 118 | lock (ds) |
119 | { | ||
117 | DataRow[] rows = ds.Tables["users"].Select(select); | 120 | DataRow[] rows = ds.Tables["users"].Select(select); |
118 | if(rows.Length > 0) { | 121 | if (rows.Length > 0) |
122 | { | ||
119 | UserProfileData user = buildUserProfile(rows[0]); | 123 | UserProfileData user = buildUserProfile(rows[0]); |
120 | DataRow row = ds.Tables["useragents"].Rows.Find(user.UUID); | 124 | DataRow row = ds.Tables["useragents"].Rows.Find(user.UUID); |
121 | if(row != null) { | 125 | if (row != null) |
126 | { | ||
122 | user.currentAgent = buildUserAgent(row); | 127 | user.currentAgent = buildUserAgent(row); |
123 | } | 128 | } |
124 | return user; | 129 | return user; |
125 | } else { | 130 | } |
131 | else | ||
132 | { | ||
126 | return null; | 133 | return null; |
127 | } | 134 | } |
128 | } | 135 | } |
@@ -134,7 +141,7 @@ namespace OpenSim.Framework.Data.SQLite | |||
134 | /// <param name="uuid">The users account ID</param> | 141 | /// <param name="uuid">The users account ID</param> |
135 | /// <returns>A matching users profile</returns> | 142 | /// <returns>A matching users profile</returns> |
136 | public UserAgentData GetAgentByUUID(LLUUID uuid) | 143 | public UserAgentData GetAgentByUUID(LLUUID uuid) |
137 | { | 144 | { |
138 | try | 145 | try |
139 | { | 146 | { |
140 | return GetUserByUUID(uuid).currentAgent; | 147 | return GetUserByUUID(uuid).currentAgent; |
@@ -165,7 +172,7 @@ namespace OpenSim.Framework.Data.SQLite | |||
165 | { | 172 | { |
166 | try | 173 | try |
167 | { | 174 | { |
168 | return GetUserByName(fname,lname).currentAgent; | 175 | return GetUserByName(fname, lname).currentAgent; |
169 | } | 176 | } |
170 | catch (Exception) | 177 | catch (Exception) |
171 | { | 178 | { |
@@ -180,8 +187,9 @@ namespace OpenSim.Framework.Data.SQLite | |||
180 | public void AddNewUserProfile(UserProfileData user) | 187 | public void AddNewUserProfile(UserProfileData user) |
181 | { | 188 | { |
182 | DataTable users = ds.Tables["users"]; | 189 | DataTable users = ds.Tables["users"]; |
183 | lock (ds) { | 190 | lock (ds) |
184 | DataRow row = users.Rows.Find(user.UUID); | 191 | { |
192 | DataRow row = users.Rows.Find(user.UUID); | ||
185 | if (row == null) | 193 | if (row == null) |
186 | { | 194 | { |
187 | row = users.NewRow(); | 195 | row = users.NewRow(); |
@@ -192,10 +200,11 @@ namespace OpenSim.Framework.Data.SQLite | |||
192 | { | 200 | { |
193 | fillUserRow(row, user); | 201 | fillUserRow(row, user); |
194 | } | 202 | } |
195 | 203 | ||
196 | if(user.currentAgent != null) { | 204 | if (user.currentAgent != null) |
205 | { | ||
197 | DataTable ua = ds.Tables["useragents"]; | 206 | DataTable ua = ds.Tables["useragents"]; |
198 | row = ua.Rows.Find(user.UUID); | 207 | row = ua.Rows.Find(user.UUID); |
199 | if (row == null) | 208 | if (row == null) |
200 | { | 209 | { |
201 | row = ua.NewRow(); | 210 | row = ua.NewRow(); |
@@ -207,12 +216,13 @@ namespace OpenSim.Framework.Data.SQLite | |||
207 | fillUserAgentRow(row, user.currentAgent); | 216 | fillUserAgentRow(row, user.currentAgent); |
208 | } | 217 | } |
209 | } | 218 | } |
210 | MainLog.Instance.Verbose("SQLITE", "Syncing user database: " + ds.Tables["users"].Rows.Count + " users stored"); | 219 | MainLog.Instance.Verbose("SQLITE", |
220 | "Syncing user database: " + ds.Tables["users"].Rows.Count + " users stored"); | ||
211 | // save changes off to disk | 221 | // save changes off to disk |
212 | da.Update(ds, "users"); | 222 | da.Update(ds, "users"); |
213 | } | 223 | } |
214 | } | 224 | } |
215 | 225 | ||
216 | /// <summary> | 226 | /// <summary> |
217 | /// Creates a new user profile | 227 | /// Creates a new user profile |
218 | /// </summary> | 228 | /// </summary> |
@@ -220,10 +230,13 @@ namespace OpenSim.Framework.Data.SQLite | |||
220 | /// <returns>True on success, false on error</returns> | 230 | /// <returns>True on success, false on error</returns> |
221 | public bool UpdateUserProfile(UserProfileData user) | 231 | public bool UpdateUserProfile(UserProfileData user) |
222 | { | 232 | { |
223 | try { | 233 | try |
234 | { | ||
224 | AddNewUserProfile(user); | 235 | AddNewUserProfile(user); |
225 | return true; | 236 | return true; |
226 | } catch (Exception) { | 237 | } |
238 | catch (Exception) | ||
239 | { | ||
227 | return false; | 240 | return false; |
228 | } | 241 | } |
229 | } | 242 | } |
@@ -279,51 +292,51 @@ namespace OpenSim.Framework.Data.SQLite | |||
279 | { | 292 | { |
280 | return "0.1"; | 293 | return "0.1"; |
281 | } | 294 | } |
282 | 295 | ||
283 | /*********************************************************************** | 296 | /*********************************************************************** |
284 | * | 297 | * |
285 | * DataTable creation | 298 | * DataTable creation |
286 | * | 299 | * |
287 | **********************************************************************/ | 300 | **********************************************************************/ |
288 | /*********************************************************************** | 301 | /*********************************************************************** |
289 | * | 302 | * |
290 | * Database Definition Functions | 303 | * Database Definition Functions |
291 | * | 304 | * |
292 | * This should be db agnostic as we define them in ADO.NET terms | 305 | * This should be db agnostic as we define them in ADO.NET terms |
293 | * | 306 | * |
294 | **********************************************************************/ | 307 | **********************************************************************/ |
295 | 308 | ||
296 | private DataTable createUsersTable() | 309 | private DataTable createUsersTable() |
297 | { | 310 | { |
298 | DataTable users = new DataTable("users"); | 311 | DataTable users = new DataTable("users"); |
299 | 312 | ||
300 | createCol(users, "UUID", typeof(System.String)); | 313 | createCol(users, "UUID", typeof (String)); |
301 | createCol(users, "username", typeof(System.String)); | 314 | createCol(users, "username", typeof (String)); |
302 | createCol(users, "surname", typeof(System.String)); | 315 | createCol(users, "surname", typeof (String)); |
303 | createCol(users, "passwordHash", typeof(System.String)); | 316 | createCol(users, "passwordHash", typeof (String)); |
304 | createCol(users, "passwordSalt", typeof(System.String)); | 317 | createCol(users, "passwordSalt", typeof (String)); |
305 | 318 | ||
306 | createCol(users, "homeRegionX", typeof(System.Int32)); | 319 | createCol(users, "homeRegionX", typeof (Int32)); |
307 | createCol(users, "homeRegionY", typeof(System.Int32)); | 320 | createCol(users, "homeRegionY", typeof (Int32)); |
308 | createCol(users, "homeLocationX", typeof(System.Double)); | 321 | createCol(users, "homeLocationX", typeof (Double)); |
309 | createCol(users, "homeLocationY", typeof(System.Double)); | 322 | createCol(users, "homeLocationY", typeof (Double)); |
310 | createCol(users, "homeLocationZ", typeof(System.Double)); | 323 | createCol(users, "homeLocationZ", typeof (Double)); |
311 | createCol(users, "homeLookAtX", typeof(System.Double)); | 324 | createCol(users, "homeLookAtX", typeof (Double)); |
312 | createCol(users, "homeLookAtY", typeof(System.Double)); | 325 | createCol(users, "homeLookAtY", typeof (Double)); |
313 | createCol(users, "homeLookAtZ", typeof(System.Double)); | 326 | createCol(users, "homeLookAtZ", typeof (Double)); |
314 | createCol(users, "created", typeof(System.Int32)); | 327 | createCol(users, "created", typeof (Int32)); |
315 | createCol(users, "lastLogin", typeof(System.Int32)); | 328 | createCol(users, "lastLogin", typeof (Int32)); |
316 | createCol(users, "rootInventoryFolderID", typeof(System.String)); | 329 | createCol(users, "rootInventoryFolderID", typeof (String)); |
317 | createCol(users, "userInventoryURI", typeof(System.String)); | 330 | createCol(users, "userInventoryURI", typeof (String)); |
318 | createCol(users, "userAssetURI", typeof(System.String)); | 331 | createCol(users, "userAssetURI", typeof (String)); |
319 | createCol(users, "profileCanDoMask", typeof(System.Int32)); | 332 | createCol(users, "profileCanDoMask", typeof (Int32)); |
320 | createCol(users, "profileWantDoMask", typeof(System.Int32)); | 333 | createCol(users, "profileWantDoMask", typeof (Int32)); |
321 | createCol(users, "profileAboutText", typeof(System.String)); | 334 | createCol(users, "profileAboutText", typeof (String)); |
322 | createCol(users, "profileFirstText", typeof(System.String)); | 335 | createCol(users, "profileFirstText", typeof (String)); |
323 | createCol(users, "profileImage", typeof(System.String)); | 336 | createCol(users, "profileImage", typeof (String)); |
324 | createCol(users, "profileFirstImage", typeof(System.String)); | 337 | createCol(users, "profileFirstImage", typeof (String)); |
325 | // Add in contraints | 338 | // Add in contraints |
326 | users.PrimaryKey = new DataColumn[] { users.Columns["UUID"] }; | 339 | users.PrimaryKey = new DataColumn[] {users.Columns["UUID"]}; |
327 | return users; | 340 | return users; |
328 | } | 341 | } |
329 | 342 | ||
@@ -331,27 +344,27 @@ namespace OpenSim.Framework.Data.SQLite | |||
331 | { | 344 | { |
332 | DataTable ua = new DataTable("useragents"); | 345 | DataTable ua = new DataTable("useragents"); |
333 | // this is the UUID of the user | 346 | // this is the UUID of the user |
334 | createCol(ua, "UUID", typeof(System.String)); | 347 | createCol(ua, "UUID", typeof (String)); |
335 | createCol(ua, "agentIP", typeof(System.String)); | 348 | createCol(ua, "agentIP", typeof (String)); |
336 | createCol(ua, "agentPort", typeof(System.Int32)); | 349 | createCol(ua, "agentPort", typeof (Int32)); |
337 | createCol(ua, "agentOnline", typeof(System.Boolean)); | 350 | createCol(ua, "agentOnline", typeof (Boolean)); |
338 | createCol(ua, "sessionID", typeof(System.String)); | 351 | createCol(ua, "sessionID", typeof (String)); |
339 | createCol(ua, "secureSessionID", typeof(System.String)); | 352 | createCol(ua, "secureSessionID", typeof (String)); |
340 | createCol(ua, "regionID", typeof(System.String)); | 353 | createCol(ua, "regionID", typeof (String)); |
341 | createCol(ua, "loginTime", typeof(System.Int32)); | 354 | createCol(ua, "loginTime", typeof (Int32)); |
342 | createCol(ua, "logoutTime", typeof(System.Int32)); | 355 | createCol(ua, "logoutTime", typeof (Int32)); |
343 | createCol(ua, "currentRegion", typeof(System.String)); | 356 | createCol(ua, "currentRegion", typeof (String)); |
344 | createCol(ua, "currentHandle", typeof(System.Int32)); | 357 | createCol(ua, "currentHandle", typeof (Int32)); |
345 | // vectors | 358 | // vectors |
346 | createCol(ua, "currentPosX", typeof(System.Double)); | 359 | createCol(ua, "currentPosX", typeof (Double)); |
347 | createCol(ua, "currentPosY", typeof(System.Double)); | 360 | createCol(ua, "currentPosY", typeof (Double)); |
348 | createCol(ua, "currentPosZ", typeof(System.Double)); | 361 | createCol(ua, "currentPosZ", typeof (Double)); |
349 | // constraints | 362 | // constraints |
350 | ua.PrimaryKey = new DataColumn[] { ua.Columns["UUID"] }; | 363 | ua.PrimaryKey = new DataColumn[] {ua.Columns["UUID"]}; |
351 | 364 | ||
352 | return ua; | 365 | return ua; |
353 | } | 366 | } |
354 | 367 | ||
355 | /*********************************************************************** | 368 | /*********************************************************************** |
356 | * | 369 | * |
357 | * Convert between ADO.NET <=> OpenSim Objects | 370 | * Convert between ADO.NET <=> OpenSim Objects |
@@ -366,35 +379,35 @@ namespace OpenSim.Framework.Data.SQLite | |||
366 | // interesting has to be done to actually get these values | 379 | // interesting has to be done to actually get these values |
367 | // back out. Not enough time to figure it out yet. | 380 | // back out. Not enough time to figure it out yet. |
368 | UserProfileData user = new UserProfileData(); | 381 | UserProfileData user = new UserProfileData(); |
369 | user.UUID = new LLUUID((String)row["UUID"]); | 382 | user.UUID = new LLUUID((String) row["UUID"]); |
370 | user.username = (String)row["username"]; | 383 | user.username = (String) row["username"]; |
371 | user.surname = (String)row["surname"]; | 384 | user.surname = (String) row["surname"]; |
372 | user.passwordHash = (String)row["passwordHash"]; | 385 | user.passwordHash = (String) row["passwordHash"]; |
373 | user.passwordSalt = (String)row["passwordSalt"]; | 386 | user.passwordSalt = (String) row["passwordSalt"]; |
374 | 387 | ||
375 | user.homeRegionX = Convert.ToUInt32(row["homeRegionX"]); | 388 | user.homeRegionX = Convert.ToUInt32(row["homeRegionX"]); |
376 | user.homeRegionY = Convert.ToUInt32(row["homeRegionY"]); | 389 | user.homeRegionY = Convert.ToUInt32(row["homeRegionY"]); |
377 | user.homeLocation = new LLVector3( | 390 | user.homeLocation = new LLVector3( |
378 | Convert.ToSingle(row["homeLocationX"]), | 391 | Convert.ToSingle(row["homeLocationX"]), |
379 | Convert.ToSingle(row["homeLocationY"]), | 392 | Convert.ToSingle(row["homeLocationY"]), |
380 | Convert.ToSingle(row["homeLocationZ"]) | 393 | Convert.ToSingle(row["homeLocationZ"]) |
381 | ); | 394 | ); |
382 | user.homeLookAt = new LLVector3( | 395 | user.homeLookAt = new LLVector3( |
383 | Convert.ToSingle(row["homeLookAtX"]), | 396 | Convert.ToSingle(row["homeLookAtX"]), |
384 | Convert.ToSingle(row["homeLookAtY"]), | 397 | Convert.ToSingle(row["homeLookAtY"]), |
385 | Convert.ToSingle(row["homeLookAtZ"]) | 398 | Convert.ToSingle(row["homeLookAtZ"]) |
386 | ); | 399 | ); |
387 | user.created = Convert.ToInt32(row["created"]); | 400 | user.created = Convert.ToInt32(row["created"]); |
388 | user.lastLogin = Convert.ToInt32(row["lastLogin"]); | 401 | user.lastLogin = Convert.ToInt32(row["lastLogin"]); |
389 | user.rootInventoryFolderID = new LLUUID((String)row["rootInventoryFolderID"]); | 402 | user.rootInventoryFolderID = new LLUUID((String) row["rootInventoryFolderID"]); |
390 | user.userInventoryURI = (String)row["userInventoryURI"]; | 403 | user.userInventoryURI = (String) row["userInventoryURI"]; |
391 | user.userAssetURI = (String)row["userAssetURI"]; | 404 | user.userAssetURI = (String) row["userAssetURI"]; |
392 | user.profileCanDoMask = Convert.ToUInt32(row["profileCanDoMask"]); | 405 | user.profileCanDoMask = Convert.ToUInt32(row["profileCanDoMask"]); |
393 | user.profileWantDoMask = Convert.ToUInt32(row["profileWantDoMask"]); | 406 | user.profileWantDoMask = Convert.ToUInt32(row["profileWantDoMask"]); |
394 | user.profileAboutText = (String)row["profileAboutText"]; | 407 | user.profileAboutText = (String) row["profileAboutText"]; |
395 | user.profileFirstText = (String)row["profileFirstText"]; | 408 | user.profileFirstText = (String) row["profileFirstText"]; |
396 | user.profileImage = new LLUUID((String)row["profileImage"]); | 409 | user.profileImage = new LLUUID((String) row["profileImage"]); |
397 | user.profileFirstImage = new LLUUID((String)row["profileFirstImage"]); | 410 | user.profileFirstImage = new LLUUID((String) row["profileFirstImage"]); |
398 | return user; | 411 | return user; |
399 | } | 412 | } |
400 | 413 | ||
@@ -405,8 +418,8 @@ namespace OpenSim.Framework.Data.SQLite | |||
405 | row["surname"] = user.surname; | 418 | row["surname"] = user.surname; |
406 | row["passwordHash"] = user.passwordHash; | 419 | row["passwordHash"] = user.passwordHash; |
407 | row["passwordSalt"] = user.passwordSalt; | 420 | row["passwordSalt"] = user.passwordSalt; |
408 | 421 | ||
409 | 422 | ||
410 | row["homeRegionX"] = user.homeRegionX; | 423 | row["homeRegionX"] = user.homeRegionX; |
411 | row["homeRegionY"] = user.homeRegionY; | 424 | row["homeRegionY"] = user.homeRegionY; |
412 | row["homeLocationX"] = user.homeLocation.X; | 425 | row["homeLocationX"] = user.homeLocation.X; |
@@ -427,10 +440,12 @@ namespace OpenSim.Framework.Data.SQLite | |||
427 | row["profileFirstText"] = user.profileFirstText; | 440 | row["profileFirstText"] = user.profileFirstText; |
428 | row["profileImage"] = user.profileImage; | 441 | row["profileImage"] = user.profileImage; |
429 | row["profileFirstImage"] = user.profileFirstImage; | 442 | row["profileFirstImage"] = user.profileFirstImage; |
430 | 443 | ||
431 | // ADO.NET doesn't handle NULL very well | 444 | // ADO.NET doesn't handle NULL very well |
432 | foreach (DataColumn col in ds.Tables["users"].Columns) { | 445 | foreach (DataColumn col in ds.Tables["users"].Columns) |
433 | if (row[col] == null) { | 446 | { |
447 | if (row[col] == null) | ||
448 | { | ||
434 | row[col] = ""; | 449 | row[col] = ""; |
435 | } | 450 | } |
436 | } | 451 | } |
@@ -439,33 +454,33 @@ namespace OpenSim.Framework.Data.SQLite | |||
439 | private UserAgentData buildUserAgent(DataRow row) | 454 | private UserAgentData buildUserAgent(DataRow row) |
440 | { | 455 | { |
441 | UserAgentData ua = new UserAgentData(); | 456 | UserAgentData ua = new UserAgentData(); |
442 | 457 | ||
443 | ua.UUID = new LLUUID((String)row["UUID"]); | 458 | ua.UUID = new LLUUID((String) row["UUID"]); |
444 | ua.agentIP = (String)row["agentIP"]; | 459 | ua.agentIP = (String) row["agentIP"]; |
445 | ua.agentPort = Convert.ToUInt32(row["agentPort"]); | 460 | ua.agentPort = Convert.ToUInt32(row["agentPort"]); |
446 | ua.agentOnline = Convert.ToBoolean(row["agentOnline"]); | 461 | ua.agentOnline = Convert.ToBoolean(row["agentOnline"]); |
447 | ua.sessionID = new LLUUID((String)row["sessionID"]); | 462 | ua.sessionID = new LLUUID((String) row["sessionID"]); |
448 | ua.secureSessionID = new LLUUID((String)row["secureSessionID"]); | 463 | ua.secureSessionID = new LLUUID((String) row["secureSessionID"]); |
449 | ua.regionID = new LLUUID((String)row["regionID"]); | 464 | ua.regionID = new LLUUID((String) row["regionID"]); |
450 | ua.loginTime = Convert.ToInt32(row["loginTime"]); | 465 | ua.loginTime = Convert.ToInt32(row["loginTime"]); |
451 | ua.logoutTime = Convert.ToInt32(row["logoutTime"]); | 466 | ua.logoutTime = Convert.ToInt32(row["logoutTime"]); |
452 | ua.currentRegion = new LLUUID((String)row["currentRegion"]); | 467 | ua.currentRegion = new LLUUID((String) row["currentRegion"]); |
453 | ua.currentHandle = Convert.ToUInt32(row["currentHandle"]); | 468 | ua.currentHandle = Convert.ToUInt32(row["currentHandle"]); |
454 | ua.currentPos = new LLVector3( | 469 | ua.currentPos = new LLVector3( |
455 | Convert.ToSingle(row["currentPosX"]), | 470 | Convert.ToSingle(row["currentPosX"]), |
456 | Convert.ToSingle(row["currentPosY"]), | 471 | Convert.ToSingle(row["currentPosY"]), |
457 | Convert.ToSingle(row["currentPosZ"]) | 472 | Convert.ToSingle(row["currentPosZ"]) |
458 | ); | 473 | ); |
459 | return ua; | 474 | return ua; |
460 | } | 475 | } |
461 | 476 | ||
462 | private void fillUserAgentRow(DataRow row, UserAgentData ua) | 477 | private void fillUserAgentRow(DataRow row, UserAgentData ua) |
463 | { | 478 | { |
464 | row["UUID"] = ua.UUID; | 479 | row["UUID"] = ua.UUID; |
465 | row["agentIP"] = ua.agentIP; | 480 | row["agentIP"] = ua.agentIP; |
466 | row["agentPort"] = ua.agentPort; | 481 | row["agentPort"] = ua.agentPort; |
467 | row["agentOnline"] = ua.agentOnline; | 482 | row["agentOnline"] = ua.agentOnline; |
468 | row["sessionID"] = ua.sessionID; | 483 | row["sessionID"] = ua.sessionID; |
469 | row["secureSessionID"] = ua.secureSessionID; | 484 | row["secureSessionID"] = ua.secureSessionID; |
470 | row["regionID"] = ua.regionID; | 485 | row["regionID"] = ua.regionID; |
471 | row["loginTime"] = ua.loginTime; | 486 | row["loginTime"] = ua.loginTime; |
@@ -496,18 +511,18 @@ namespace OpenSim.Framework.Data.SQLite | |||
496 | da.UpdateCommand.Connection = conn; | 511 | da.UpdateCommand.Connection = conn; |
497 | 512 | ||
498 | SqliteCommand delete = new SqliteCommand("delete from users where UUID = :UUID"); | 513 | SqliteCommand delete = new SqliteCommand("delete from users where UUID = :UUID"); |
499 | delete.Parameters.Add(createSqliteParameter("UUID", typeof(System.String))); | 514 | delete.Parameters.Add(createSqliteParameter("UUID", typeof (String))); |
500 | delete.Connection = conn; | 515 | delete.Connection = conn; |
501 | da.DeleteCommand = delete; | 516 | da.DeleteCommand = delete; |
502 | } | 517 | } |
503 | 518 | ||
504 | private void InitDB(SqliteConnection conn) | 519 | private void InitDB(SqliteConnection conn) |
505 | { | 520 | { |
506 | string createUsers = defineTable(createUsersTable()); | 521 | string createUsers = defineTable(createUsersTable()); |
507 | SqliteCommand pcmd = new SqliteCommand(createUsers, conn); | 522 | SqliteCommand pcmd = new SqliteCommand(createUsers, conn); |
508 | conn.Open(); | 523 | conn.Open(); |
509 | pcmd.ExecuteNonQuery(); | 524 | pcmd.ExecuteNonQuery(); |
510 | conn.Close(); | 525 | conn.Close(); |
511 | } | 526 | } |
512 | 527 | ||
513 | private bool TestTables(SqliteConnection conn) | 528 | private bool TestTables(SqliteConnection conn) |
@@ -515,14 +530,16 @@ namespace OpenSim.Framework.Data.SQLite | |||
515 | SqliteCommand cmd = new SqliteCommand(userSelect, conn); | 530 | SqliteCommand cmd = new SqliteCommand(userSelect, conn); |
516 | SqliteDataAdapter pDa = new SqliteDataAdapter(cmd); | 531 | SqliteDataAdapter pDa = new SqliteDataAdapter(cmd); |
517 | DataSet tmpDS = new DataSet(); | 532 | DataSet tmpDS = new DataSet(); |
518 | try { | 533 | try |
534 | { | ||
519 | pDa.Fill(tmpDS, "users"); | 535 | pDa.Fill(tmpDS, "users"); |
520 | } catch (Mono.Data.SqliteClient.SqliteSyntaxException) { | 536 | } |
537 | catch (SqliteSyntaxException) | ||
538 | { | ||
521 | MainLog.Instance.Verbose("DATASTORE", "SQLite Database doesn't exist... creating"); | 539 | MainLog.Instance.Verbose("DATASTORE", "SQLite Database doesn't exist... creating"); |
522 | InitDB(conn); | 540 | InitDB(conn); |
523 | } | 541 | } |
524 | return true; | 542 | return true; |
525 | } | 543 | } |
526 | |||
527 | } | 544 | } |
528 | } | 545 | } \ No newline at end of file |