aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/Data.MSSQL/MSSQLManager.cs
diff options
context:
space:
mode:
authorlbsa712007-12-27 21:41:48 +0000
committerlbsa712007-12-27 21:41:48 +0000
commitefd90b56b761219af6425b1c7a2cdd3b6ffb4de2 (patch)
treebf5b897e1e3c13211e3e2fc61d30508b94c928c0 /OpenSim/Framework/Data.MSSQL/MSSQLManager.cs
parent* removed always true if (diff)
downloadopensim-SC-efd90b56b761219af6425b1c7a2cdd3b6ffb4de2.zip
opensim-SC-efd90b56b761219af6425b1c7a2cdd3b6ffb4de2.tar.gz
opensim-SC-efd90b56b761219af6425b1c7a2cdd3b6ffb4de2.tar.bz2
opensim-SC-efd90b56b761219af6425b1c7a2cdd3b6ffb4de2.tar.xz
* Optimized usings
* shortened references * Removed redundant 'this' * Normalized EOF
Diffstat (limited to 'OpenSim/Framework/Data.MSSQL/MSSQLManager.cs')
-rw-r--r--OpenSim/Framework/Data.MSSQL/MSSQLManager.cs261
1 files changed, 134 insertions, 127 deletions
diff --git a/OpenSim/Framework/Data.MSSQL/MSSQLManager.cs b/OpenSim/Framework/Data.MSSQL/MSSQLManager.cs
index b009a56..0dc3338 100644
--- a/OpenSim/Framework/Data.MSSQL/MSSQLManager.cs
+++ b/OpenSim/Framework/Data.MSSQL/MSSQLManager.cs
@@ -25,6 +25,7 @@
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26* 26*
27*/ 27*/
28
28using System; 29using System;
29using System.Collections.Generic; 30using System.Collections.Generic;
30using System.Data; 31using System.Data;
@@ -32,7 +33,6 @@ using System.Data.SqlClient;
32using System.IO; 33using System.IO;
33using System.Reflection; 34using System.Reflection;
34using libsecondlife; 35using libsecondlife;
35
36using OpenSim.Framework.Console; 36using OpenSim.Framework.Console;
37 37
38namespace OpenSim.Framework.Data.MSSQL 38namespace OpenSim.Framework.Data.MSSQL
@@ -40,12 +40,12 @@ namespace OpenSim.Framework.Data.MSSQL
40 /// <summary> 40 /// <summary>
41 /// A management class for the MS SQL Storage Engine 41 /// A management class for the MS SQL Storage Engine
42 /// </summary> 42 /// </summary>
43 class MSSQLManager 43 internal class MSSQLManager
44 { 44 {
45 /// <summary> 45 /// <summary>
46 /// The database connection object 46 /// The database connection object
47 /// </summary> 47 /// </summary>
48 IDbConnection dbcon; 48 private IDbConnection dbcon;
49 49
50 /// <summary> 50 /// <summary>
51 /// Connection string for ADO.net 51 /// Connection string for ADO.net
@@ -60,12 +60,14 @@ namespace OpenSim.Framework.Data.MSSQL
60 /// <param name="username">The username logging into the database</param> 60 /// <param name="username">The username logging into the database</param>
61 /// <param name="password">The password for the user logging in</param> 61 /// <param name="password">The password for the user logging in</param>
62 /// <param name="cpooling">Whether to use connection pooling or not, can be one of the following: 'yes', 'true', 'no' or 'false', if unsure use 'false'.</param> 62 /// <param name="cpooling">Whether to use connection pooling or not, can be one of the following: 'yes', 'true', 'no' or 'false', if unsure use 'false'.</param>
63 public MSSQLManager(string dataSource, string initialCatalog, string persistSecurityInfo, string userId, string password) 63 public MSSQLManager(string dataSource, string initialCatalog, string persistSecurityInfo, string userId,
64 string password)
64 { 65 {
65 try 66 try
66 { 67 {
67 68 connectionString = "Data Source=" + dataSource + ";Initial Catalog=" + initialCatalog +
68 connectionString = "Data Source=" + dataSource + ";Initial Catalog=" + initialCatalog + ";Persist Security Info=" + persistSecurityInfo + ";User ID=" + userId + ";Password=" + password+";"; 69 ";Persist Security Info=" + persistSecurityInfo + ";User ID=" + userId + ";Password=" +
70 password + ";";
69 dbcon = new SqlConnection(connectionString); 71 dbcon = new SqlConnection(connectionString);
70 TestTables(dbcon); 72 TestTables(dbcon);
71 dbcon.Open(); 73 dbcon.Open();
@@ -78,7 +80,7 @@ namespace OpenSim.Framework.Data.MSSQL
78 80
79 private bool TestTables(IDbConnection conn) 81 private bool TestTables(IDbConnection conn)
80 { 82 {
81 IDbCommand cmd = this.Query("SELECT * FROM regions", new Dictionary<string, string>()); 83 IDbCommand cmd = Query("SELECT * FROM regions", new Dictionary<string, string>());
82 //SqlCommand cmd = (SqlCommand)dbcon.CreateCommand(); 84 //SqlCommand cmd = (SqlCommand)dbcon.CreateCommand();
83 //cmd.CommandText = "SELECT * FROM regions"; 85 //cmd.CommandText = "SELECT * FROM regions";
84 try 86 try
@@ -90,7 +92,7 @@ namespace OpenSim.Framework.Data.MSSQL
90 } 92 }
91 catch (Exception) 93 catch (Exception)
92 { 94 {
93 MainLog.Instance.Verbose("DATASTORE", "MSSQL Database doesn't exist... creating"); 95 MainLog.Instance.Verbose("DATASTORE", "MSSQL Database doesn't exist... creating");
94 InitDB(conn); 96 InitDB(conn);
95 } 97 }
96 return true; 98 return true;
@@ -100,66 +102,66 @@ namespace OpenSim.Framework.Data.MSSQL
100 { 102 {
101 string createRegions = defineTable(createRegionsTable()); 103 string createRegions = defineTable(createRegionsTable());
102 Dictionary<string, string> param = new Dictionary<string, string>(); 104 Dictionary<string, string> param = new Dictionary<string, string>();
103 IDbCommand pcmd = this.Query(createRegions, param); 105 IDbCommand pcmd = Query(createRegions, param);
104 if (conn.State == ConnectionState.Closed) { 106 if (conn.State == ConnectionState.Closed)
107 {
105 conn.Open(); 108 conn.Open();
106 } 109 }
107 pcmd.ExecuteNonQuery(); 110 pcmd.ExecuteNonQuery();
108 pcmd.Dispose(); 111 pcmd.Dispose();
109 112
110 this.ExecuteResourceSql("Mssql-users.sql"); 113 ExecuteResourceSql("Mssql-users.sql");
111 this.ExecuteResourceSql("Mssql-agents.sql"); 114 ExecuteResourceSql("Mssql-agents.sql");
112 this.ExecuteResourceSql("Mssql-logs.sql"); 115 ExecuteResourceSql("Mssql-logs.sql");
113 116
114 conn.Close(); 117 conn.Close();
115
116 } 118 }
117 119
118 private DataTable createRegionsTable() 120 private DataTable createRegionsTable()
119 { 121 {
120 DataTable regions = new DataTable("regions"); 122 DataTable regions = new DataTable("regions");
121 123
122 createCol(regions, "regionHandle", typeof(ulong)); 124 createCol(regions, "regionHandle", typeof (ulong));
123 createCol(regions, "regionName", typeof(System.String)); 125 createCol(regions, "regionName", typeof (String));
124 createCol(regions, "uuid", typeof(System.String)); 126 createCol(regions, "uuid", typeof (String));
125 127
126 createCol(regions, "regionRecvKey", typeof(System.String)); 128 createCol(regions, "regionRecvKey", typeof (String));
127 createCol(regions, "regionSecret", typeof(System.String)); 129 createCol(regions, "regionSecret", typeof (String));
128 createCol(regions, "regionSendKey", typeof(System.String)); 130 createCol(regions, "regionSendKey", typeof (String));
129 131
130 createCol(regions, "regionDataURI", typeof(System.String)); 132 createCol(regions, "regionDataURI", typeof (String));
131 createCol(regions, "serverIP", typeof(System.String)); 133 createCol(regions, "serverIP", typeof (String));
132 createCol(regions, "serverPort", typeof(System.String)); 134 createCol(regions, "serverPort", typeof (String));
133 createCol(regions, "serverURI", typeof(System.String)); 135 createCol(regions, "serverURI", typeof (String));
134 136
135 137
136 createCol(regions, "locX", typeof(uint)); 138 createCol(regions, "locX", typeof (uint));
137 createCol(regions, "locY", typeof(uint)); 139 createCol(regions, "locY", typeof (uint));
138 createCol(regions, "locZ", typeof(uint)); 140 createCol(regions, "locZ", typeof (uint));
139 141
140 createCol(regions, "eastOverrideHandle", typeof(ulong)); 142 createCol(regions, "eastOverrideHandle", typeof (ulong));
141 createCol(regions, "westOverrideHandle", typeof(ulong)); 143 createCol(regions, "westOverrideHandle", typeof (ulong));
142 createCol(regions, "southOverrideHandle", typeof(ulong)); 144 createCol(regions, "southOverrideHandle", typeof (ulong));
143 createCol(regions, "northOverrideHandle", typeof(ulong)); 145 createCol(regions, "northOverrideHandle", typeof (ulong));
144 146
145 createCol(regions, "regionAssetURI", typeof(System.String)); 147 createCol(regions, "regionAssetURI", typeof (String));
146 createCol(regions, "regionAssetRecvKey", typeof(System.String)); 148 createCol(regions, "regionAssetRecvKey", typeof (String));
147 createCol(regions, "regionAssetSendKey", typeof(System.String)); 149 createCol(regions, "regionAssetSendKey", typeof (String));
148 150
149 createCol(regions, "regionUserURI", typeof(System.String)); 151 createCol(regions, "regionUserURI", typeof (String));
150 createCol(regions, "regionUserRecvKey", typeof(System.String)); 152 createCol(regions, "regionUserRecvKey", typeof (String));
151 createCol(regions, "regionUserSendKey", typeof(System.String)); 153 createCol(regions, "regionUserSendKey", typeof (String));
152 154
153 createCol(regions, "regionMapTexture", typeof(System.String)); 155 createCol(regions, "regionMapTexture", typeof (String));
154 createCol(regions, "serverHttpPort", typeof(System.String)); 156 createCol(regions, "serverHttpPort", typeof (String));
155 createCol(regions, "serverRemotingPort", typeof(uint)); 157 createCol(regions, "serverRemotingPort", typeof (uint));
156 158
157 // Add in contraints 159 // Add in contraints
158 regions.PrimaryKey = new DataColumn[] { regions.Columns["UUID"] }; 160 regions.PrimaryKey = new DataColumn[] {regions.Columns["UUID"]};
159 return regions; 161 return regions;
160 } 162 }
161 163
162 protected static void createCol(DataTable dt, string name, System.Type type) 164 protected static void createCol(DataTable dt, string name, Type type)
163 { 165 {
164 DataColumn col = new DataColumn(name, type); 166 DataColumn col = new DataColumn(name, type);
165 dt.Columns.Add(col); 167 dt.Columns.Add(col);
@@ -172,10 +174,11 @@ namespace OpenSim.Framework.Data.MSSQL
172 foreach (DataColumn col in dt.Columns) 174 foreach (DataColumn col in dt.Columns)
173 { 175 {
174 if (subsql.Length > 0) 176 if (subsql.Length > 0)
175 { // a map function would rock so much here 177 {
178 // a map function would rock so much here
176 subsql += ",\n"; 179 subsql += ",\n";
177 } 180 }
178 181
179 subsql += col.ColumnName + " " + SqlType(col.DataType); 182 subsql += col.ColumnName + " " + SqlType(col.DataType);
180 if (col == dt.PrimaryKey[0]) 183 if (col == dt.PrimaryKey[0])
181 { 184 {
@@ -192,19 +195,19 @@ namespace OpenSim.Framework.Data.MSSQL
192 // slightly differently. 195 // slightly differently.
193 private static string SqlType(Type type) 196 private static string SqlType(Type type)
194 { 197 {
195 if (type == typeof(System.String)) 198 if (type == typeof (String))
196 { 199 {
197 return "varchar(255)"; 200 return "varchar(255)";
198 } 201 }
199 else if (type == typeof(System.Int32)) 202 else if (type == typeof (Int32))
200 { 203 {
201 return "integer"; 204 return "integer";
202 } 205 }
203 else if (type == typeof(System.Double)) 206 else if (type == typeof (Double))
204 { 207 {
205 return "float"; 208 return "float";
206 } 209 }
207 else if (type == typeof(System.Byte[])) 210 else if (type == typeof (Byte[]))
208 { 211 {
209 return "image"; 212 return "image";
210 } 213 }
@@ -254,14 +257,14 @@ namespace OpenSim.Framework.Data.MSSQL
254 /// <returns>A Sql DB Command</returns> 257 /// <returns>A Sql DB Command</returns>
255 public IDbCommand Query(string sql, Dictionary<string, string> parameters) 258 public IDbCommand Query(string sql, Dictionary<string, string> parameters)
256 { 259 {
257 SqlCommand dbcommand = (SqlCommand)dbcon.CreateCommand(); 260 SqlCommand dbcommand = (SqlCommand) dbcon.CreateCommand();
258 dbcommand.CommandText = sql; 261 dbcommand.CommandText = sql;
259 foreach (KeyValuePair<string, string> param in parameters) 262 foreach (KeyValuePair<string, string> param in parameters)
260 { 263 {
261 dbcommand.Parameters.AddWithValue(param.Key, param.Value); 264 dbcommand.Parameters.AddWithValue(param.Key, param.Value);
262 } 265 }
263 266
264 return (IDbCommand)dbcommand; 267 return (IDbCommand) dbcommand;
265 } 268 }
266 269
267 /// <summary> 270 /// <summary>
@@ -277,20 +280,20 @@ namespace OpenSim.Framework.Data.MSSQL
277 { 280 {
278 // Region Main 281 // Region Main
279 regionprofile.regionHandle = Convert.ToUInt64(reader["regionHandle"]); 282 regionprofile.regionHandle = Convert.ToUInt64(reader["regionHandle"]);
280 regionprofile.regionName = (string)reader["regionName"]; 283 regionprofile.regionName = (string) reader["regionName"];
281 regionprofile.UUID = new LLUUID((string)reader["uuid"]); 284 regionprofile.UUID = new LLUUID((string) reader["uuid"]);
282 285
283 // Secrets 286 // Secrets
284 regionprofile.regionRecvKey = (string)reader["regionRecvKey"]; 287 regionprofile.regionRecvKey = (string) reader["regionRecvKey"];
285 regionprofile.regionSecret = (string)reader["regionSecret"]; 288 regionprofile.regionSecret = (string) reader["regionSecret"];
286 regionprofile.regionSendKey = (string)reader["regionSendKey"]; 289 regionprofile.regionSendKey = (string) reader["regionSendKey"];
287 290
288 // Region Server 291 // Region Server
289 regionprofile.regionDataURI = (string)reader["regionDataURI"]; 292 regionprofile.regionDataURI = (string) reader["regionDataURI"];
290 regionprofile.regionOnline = false; // Needs to be pinged before this can be set. 293 regionprofile.regionOnline = false; // Needs to be pinged before this can be set.
291 regionprofile.serverIP = (string)reader["serverIP"]; 294 regionprofile.serverIP = (string) reader["serverIP"];
292 regionprofile.serverPort = Convert.ToUInt32(reader["serverPort"]); 295 regionprofile.serverPort = Convert.ToUInt32(reader["serverPort"]);
293 regionprofile.serverURI = (string)reader["serverURI"]; 296 regionprofile.serverURI = (string) reader["serverURI"];
294 regionprofile.httpPort = Convert.ToUInt32(reader["serverHttpPort"]); 297 regionprofile.httpPort = Convert.ToUInt32(reader["serverHttpPort"]);
295 regionprofile.remotingPort = Convert.ToUInt32(reader["serverRemotingPort"]); 298 regionprofile.remotingPort = Convert.ToUInt32(reader["serverRemotingPort"]);
296 299
@@ -307,14 +310,14 @@ namespace OpenSim.Framework.Data.MSSQL
307 regionprofile.regionNorthOverrideHandle = Convert.ToUInt64(reader["northOverrideHandle"]); 310 regionprofile.regionNorthOverrideHandle = Convert.ToUInt64(reader["northOverrideHandle"]);
308 311
309 // Assets 312 // Assets
310 regionprofile.regionAssetURI = (string)reader["regionAssetURI"]; 313 regionprofile.regionAssetURI = (string) reader["regionAssetURI"];
311 regionprofile.regionAssetRecvKey = (string)reader["regionAssetRecvKey"]; 314 regionprofile.regionAssetRecvKey = (string) reader["regionAssetRecvKey"];
312 regionprofile.regionAssetSendKey = (string)reader["regionAssetSendKey"]; 315 regionprofile.regionAssetSendKey = (string) reader["regionAssetSendKey"];
313 316
314 // Userserver 317 // Userserver
315 regionprofile.regionUserURI = (string)reader["regionUserURI"]; 318 regionprofile.regionUserURI = (string) reader["regionUserURI"];
316 regionprofile.regionUserRecvKey = (string)reader["regionUserRecvKey"]; 319 regionprofile.regionUserRecvKey = (string) reader["regionUserRecvKey"];
317 regionprofile.regionUserSendKey = (string)reader["regionUserSendKey"]; 320 regionprofile.regionUserSendKey = (string) reader["regionUserSendKey"];
318 321
319 // World Map Addition 322 // World Map Addition
320 string tempRegionMap = reader["regionMapTexture"].ToString(); 323 string tempRegionMap = reader["regionMapTexture"].ToString();
@@ -331,7 +334,6 @@ namespace OpenSim.Framework.Data.MSSQL
331 { 334 {
332 reader.Close(); 335 reader.Close();
333 throw new Exception("No rows to return"); 336 throw new Exception("No rows to return");
334
335 } 337 }
336 return regionprofile; 338 return regionprofile;
337 } 339 }
@@ -347,12 +349,12 @@ namespace OpenSim.Framework.Data.MSSQL
347 349
348 if (reader.Read()) 350 if (reader.Read())
349 { 351 {
350 retval.UUID = new LLUUID((string)reader["UUID"]); 352 retval.UUID = new LLUUID((string) reader["UUID"]);
351 retval.username = (string)reader["username"]; 353 retval.username = (string) reader["username"];
352 retval.surname = (string)reader["lastname"]; 354 retval.surname = (string) reader["lastname"];
353 355
354 retval.passwordHash = (string)reader["passwordHash"]; 356 retval.passwordHash = (string) reader["passwordHash"];
355 retval.passwordSalt = (string)reader["passwordSalt"]; 357 retval.passwordSalt = (string) reader["passwordSalt"];
356 358
357 retval.homeRegion = Convert.ToUInt64(reader["homeRegion"].ToString()); 359 retval.homeRegion = Convert.ToUInt64(reader["homeRegion"].ToString());
358 retval.homeLocation = new LLVector3( 360 retval.homeLocation = new LLVector3(
@@ -367,18 +369,17 @@ namespace OpenSim.Framework.Data.MSSQL
367 retval.created = Convert.ToInt32(reader["created"].ToString()); 369 retval.created = Convert.ToInt32(reader["created"].ToString());
368 retval.lastLogin = Convert.ToInt32(reader["lastLogin"].ToString()); 370 retval.lastLogin = Convert.ToInt32(reader["lastLogin"].ToString());
369 371
370 retval.userInventoryURI = (string)reader["userInventoryURI"]; 372 retval.userInventoryURI = (string) reader["userInventoryURI"];
371 retval.userAssetURI = (string)reader["userAssetURI"]; 373 retval.userAssetURI = (string) reader["userAssetURI"];
372 374
373 retval.profileCanDoMask = Convert.ToUInt32(reader["profileCanDoMask"].ToString()); 375 retval.profileCanDoMask = Convert.ToUInt32(reader["profileCanDoMask"].ToString());
374 retval.profileWantDoMask = Convert.ToUInt32(reader["profileWantDoMask"].ToString()); 376 retval.profileWantDoMask = Convert.ToUInt32(reader["profileWantDoMask"].ToString());
375 377
376 retval.profileAboutText = (string)reader["profileAboutText"]; 378 retval.profileAboutText = (string) reader["profileAboutText"];
377 retval.profileFirstText = (string)reader["profileFirstText"]; 379 retval.profileFirstText = (string) reader["profileFirstText"];
378
379 retval.profileImage = new LLUUID((string)reader["profileImage"]);
380 retval.profileFirstImage = new LLUUID((string)reader["profileFirstImage"]);
381 380
381 retval.profileImage = new LLUUID((string) reader["profileImage"]);
382 retval.profileFirstImage = new LLUUID((string) reader["profileFirstImage"]);
382 } 383 }
383 else 384 else
384 { 385 {
@@ -399,12 +400,12 @@ namespace OpenSim.Framework.Data.MSSQL
399 if (reader.Read()) 400 if (reader.Read())
400 { 401 {
401 // Agent IDs 402 // Agent IDs
402 retval.UUID = new LLUUID((string)reader["UUID"]); 403 retval.UUID = new LLUUID((string) reader["UUID"]);
403 retval.sessionID = new LLUUID((string)reader["sessionID"]); 404 retval.sessionID = new LLUUID((string) reader["sessionID"]);
404 retval.secureSessionID = new LLUUID((string)reader["secureSessionID"]); 405 retval.secureSessionID = new LLUUID((string) reader["secureSessionID"]);
405 406
406 // Agent Who? 407 // Agent Who?
407 retval.agentIP = (string)reader["agentIP"]; 408 retval.agentIP = (string) reader["agentIP"];
408 retval.agentPort = Convert.ToUInt32(reader["agentPort"].ToString()); 409 retval.agentPort = Convert.ToUInt32(reader["agentPort"].ToString());
409 retval.agentOnline = Convert.ToBoolean(reader["agentOnline"].ToString()); 410 retval.agentOnline = Convert.ToBoolean(reader["agentOnline"].ToString());
410 411
@@ -413,9 +414,9 @@ namespace OpenSim.Framework.Data.MSSQL
413 retval.logoutTime = Convert.ToInt32(reader["logoutTime"].ToString()); 414 retval.logoutTime = Convert.ToInt32(reader["logoutTime"].ToString());
414 415
415 // Current position 416 // Current position
416 retval.currentRegion = (string)reader["currentRegion"]; 417 retval.currentRegion = (string) reader["currentRegion"];
417 retval.currentHandle = Convert.ToUInt64(reader["currentHandle"].ToString()); 418 retval.currentHandle = Convert.ToUInt64(reader["currentHandle"].ToString());
418 LLVector3.TryParse((string)reader["currentPos"], out retval.currentPos); 419 LLVector3.TryParse((string) reader["currentPos"], out retval.currentPos);
419 } 420 }
420 else 421 else
421 { 422 {
@@ -426,20 +427,19 @@ namespace OpenSim.Framework.Data.MSSQL
426 427
427 public AssetBase getAssetRow(IDataReader reader) 428 public AssetBase getAssetRow(IDataReader reader)
428 { 429 {
429 AssetBase asset = new AssetBase(); 430 AssetBase asset = new AssetBase();
430 if (reader.Read()) 431 if (reader.Read())
431 { 432 {
432 // Region Main 433 // Region Main
433 434
434 asset = new AssetBase(); 435 asset = new AssetBase();
435 asset.Data = (byte[])reader["data"]; 436 asset.Data = (byte[]) reader["data"];
436 asset.Description = (string)reader["description"]; 437 asset.Description = (string) reader["description"];
437 asset.FullID = new LLUUID((string)reader["id"]); 438 asset.FullID = new LLUUID((string) reader["id"]);
438 asset.InvType = Convert.ToSByte(reader["invType"]); 439 asset.InvType = Convert.ToSByte(reader["invType"]);
439 asset.Local = Convert.ToBoolean(reader["local"]); // ((sbyte)reader["local"]) != 0 ? true : false; 440 asset.Local = Convert.ToBoolean(reader["local"]); // ((sbyte)reader["local"]) != 0 ? true : false;
440 asset.Name = (string)reader["name"]; 441 asset.Name = (string) reader["name"];
441 asset.Type = Convert.ToSByte(reader["assetType"]); 442 asset.Type = Convert.ToSByte(reader["assetType"]);
442
443 } 443 }
444 else 444 else
445 { 445 {
@@ -455,15 +455,19 @@ namespace OpenSim.Framework.Data.MSSQL
455 /// <returns>Successful?</returns> 455 /// <returns>Successful?</returns>
456 public bool insertRegionRow(RegionProfileData profile) 456 public bool insertRegionRow(RegionProfileData profile)
457 { 457 {
458
459 //Insert new region 458 //Insert new region
460 string sql = "INSERT INTO regions ([regionHandle], [regionName], [uuid], [regionRecvKey], [regionSecret], [regionSendKey], [regionDataURI], "; 459 string sql =
461 sql += "[serverIP], [serverPort], [serverURI], [locX], [locY], [locZ], [eastOverrideHandle], [westOverrideHandle], [southOverrideHandle], [northOverrideHandle], [regionAssetURI], [regionAssetRecvKey], "; 460 "INSERT INTO regions ([regionHandle], [regionName], [uuid], [regionRecvKey], [regionSecret], [regionSendKey], [regionDataURI], ";
462 sql += "[regionAssetSendKey], [regionUserURI], [regionUserRecvKey], [regionUserSendKey], [regionMapTexture], [serverHttpPort], [serverRemotingPort]) VALUES "; 461 sql +=
462 "[serverIP], [serverPort], [serverURI], [locX], [locY], [locZ], [eastOverrideHandle], [westOverrideHandle], [southOverrideHandle], [northOverrideHandle], [regionAssetURI], [regionAssetRecvKey], ";
463 sql +=
464 "[regionAssetSendKey], [regionUserURI], [regionUserRecvKey], [regionUserSendKey], [regionMapTexture], [serverHttpPort], [serverRemotingPort]) VALUES ";
463 465
464 sql += "(@regionHandle, @regionName, @uuid, @regionRecvKey, @regionSecret, @regionSendKey, @regionDataURI, "; 466 sql += "(@regionHandle, @regionName, @uuid, @regionRecvKey, @regionSecret, @regionSendKey, @regionDataURI, ";
465 sql += "@serverIP, @serverPort, @serverURI, @locX, @locY, @locZ, @eastOverrideHandle, @westOverrideHandle, @southOverrideHandle, @northOverrideHandle, @regionAssetURI, @regionAssetRecvKey, "; 467 sql +=
466 sql += "@regionAssetSendKey, @regionUserURI, @regionUserRecvKey, @regionUserSendKey, @regionMapTexture, @serverHttpPort, @serverRemotingPort);"; 468 "@serverIP, @serverPort, @serverURI, @locX, @locY, @locZ, @eastOverrideHandle, @westOverrideHandle, @southOverrideHandle, @northOverrideHandle, @regionAssetURI, @regionAssetRecvKey, ";
469 sql +=
470 "@regionAssetSendKey, @regionUserURI, @regionUserRecvKey, @regionUserSendKey, @regionMapTexture, @serverHttpPort, @serverRemotingPort);";
467 471
468 Dictionary<string, string> parameters = new Dictionary<string, string>(); 472 Dictionary<string, string> parameters = new Dictionary<string, string>();
469 473
@@ -498,9 +502,9 @@ namespace OpenSim.Framework.Data.MSSQL
498 bool returnval = false; 502 bool returnval = false;
499 503
500 try 504 try
501 { 505 {
502 IDbCommand result = Query(sql, parameters); 506 IDbCommand result = Query(sql, parameters);
503 507
504 if (result.ExecuteNonQuery() == 1) 508 if (result.ExecuteNonQuery() == 1)
505 returnval = true; 509 returnval = true;
506 510
@@ -509,15 +513,12 @@ namespace OpenSim.Framework.Data.MSSQL
509 catch (Exception e) 513 catch (Exception e)
510 { 514 {
511 MainLog.Instance.Error("MSSQLManager : " + e.ToString()); 515 MainLog.Instance.Error("MSSQLManager : " + e.ToString());
512
513 } 516 }
514 517
515 return returnval; 518 return returnval;
516
517 } 519 }
518 520
519 521
520
521 /// <summary> 522 /// <summary>
522 /// Inserts a new row into the log database 523 /// Inserts a new row into the log database
523 /// </summary> 524 /// </summary>
@@ -528,7 +529,8 @@ namespace OpenSim.Framework.Data.MSSQL
528 /// <param name="priority">How critical is this?</param> 529 /// <param name="priority">How critical is this?</param>
529 /// <param name="logMessage">Extra message info</param> 530 /// <param name="logMessage">Extra message info</param>
530 /// <returns>Saved successfully?</returns> 531 /// <returns>Saved successfully?</returns>
531 public bool insertLogRow(string serverDaemon, string target, string methodCall, string arguments, int priority, string logMessage) 532 public bool insertLogRow(string serverDaemon, string target, string methodCall, string arguments, int priority,
533 string logMessage)
532 { 534 {
533 string sql = "INSERT INTO logs ([target], [server], [method], [arguments], [priority], [message]) VALUES "; 535 string sql = "INSERT INTO logs ([target], [server], [method], [arguments], [priority], [message]) VALUES ";
534 sql += "(@target, @server, @method, @arguments, @priority, @message);"; 536 sql += "(@target, @server, @method, @arguments, @priority, @message);";
@@ -588,19 +590,26 @@ namespace OpenSim.Framework.Data.MSSQL
588 /// <param name="profileImage">UUID for profile image</param> 590 /// <param name="profileImage">UUID for profile image</param>
589 /// <param name="firstImage">UUID for firstlife image</param> 591 /// <param name="firstImage">UUID for firstlife image</param>
590 /// <returns>Success?</returns> 592 /// <returns>Success?</returns>
591 public bool insertUserRow(libsecondlife.LLUUID uuid, string username, string lastname, string passwordHash, string passwordSalt, UInt64 homeRegion, float homeLocX, float homeLocY, float homeLocZ, 593 public bool insertUserRow(LLUUID uuid, string username, string lastname, string passwordHash,
592 float homeLookAtX, float homeLookAtY, float homeLookAtZ, int created, int lastlogin, string inventoryURI, string assetURI, uint canDoMask, uint wantDoMask, string aboutText, string firstText, 594 string passwordSalt, UInt64 homeRegion, float homeLocX, float homeLocY, float homeLocZ,
593 libsecondlife.LLUUID profileImage, libsecondlife.LLUUID firstImage) 595 float homeLookAtX, float homeLookAtY, float homeLookAtZ, int created, int lastlogin,
596 string inventoryURI, string assetURI, uint canDoMask, uint wantDoMask,
597 string aboutText, string firstText,
598 LLUUID profileImage, LLUUID firstImage)
594 { 599 {
595 string sql = "INSERT INTO users "; 600 string sql = "INSERT INTO users ";
596 sql += "([UUID], [username], [lastname], [passwordHash], [passwordSalt], [homeRegion], "; 601 sql += "([UUID], [username], [lastname], [passwordHash], [passwordSalt], [homeRegion], ";
597 sql += "[homeLocationX], [homeLocationY], [homeLocationZ], [homeLookAtX], [homeLookAtY], [homeLookAtZ], [created], "; 602 sql +=
598 sql += "[lastLogin], [userInventoryURI], [userAssetURI], [profileCanDoMask], [profileWantDoMask], [profileAboutText], "; 603 "[homeLocationX], [homeLocationY], [homeLocationZ], [homeLookAtX], [homeLookAtY], [homeLookAtZ], [created], ";
604 sql +=
605 "[lastLogin], [userInventoryURI], [userAssetURI], [profileCanDoMask], [profileWantDoMask], [profileAboutText], ";
599 sql += "[profileFirstText], [profileImage], [profileFirstImage]) VALUES "; 606 sql += "[profileFirstText], [profileImage], [profileFirstImage]) VALUES ";
600 607
601 sql += "(@UUID, @username, @lastname, @passwordHash, @passwordSalt, @homeRegion, "; 608 sql += "(@UUID, @username, @lastname, @passwordHash, @passwordSalt, @homeRegion, ";
602 sql += "@homeLocationX, @homeLocationY, @homeLocationZ, @homeLookAtX, @homeLookAtY, @homeLookAtZ, @created, "; 609 sql +=
603 sql += "@lastLogin, @userInventoryURI, @userAssetURI, @profileCanDoMask, @profileWantDoMask, @profileAboutText, "; 610 "@homeLocationX, @homeLocationY, @homeLocationZ, @homeLookAtX, @homeLookAtY, @homeLookAtZ, @created, ";
611 sql +=
612 "@lastLogin, @userInventoryURI, @userAssetURI, @profileCanDoMask, @profileWantDoMask, @profileAboutText, ";
604 sql += "@profileFirstText, @profileImage, @profileFirstImage);"; 613 sql += "@profileFirstText, @profileImage, @profileFirstImage);";
605 614
606 Dictionary<string, string> parameters = new Dictionary<string, string>(); 615 Dictionary<string, string> parameters = new Dictionary<string, string>();
@@ -624,13 +633,13 @@ namespace OpenSim.Framework.Data.MSSQL
624 parameters["profileWantDoMask"] = "0"; 633 parameters["profileWantDoMask"] = "0";
625 parameters["profileAboutText"] = ""; 634 parameters["profileAboutText"] = "";
626 parameters["profileFirstText"] = ""; 635 parameters["profileFirstText"] = "";
627 parameters["profileImage"] = libsecondlife.LLUUID.Zero.ToString(); 636 parameters["profileImage"] = LLUUID.Zero.ToString();
628 parameters["profileFirstImage"] = libsecondlife.LLUUID.Zero.ToString(); 637 parameters["profileFirstImage"] = LLUUID.Zero.ToString();
629 638
630 bool returnval = false; 639 bool returnval = false;
631 640
632 try 641 try
633 { 642 {
634 IDbCommand result = Query(sql, parameters); 643 IDbCommand result = Query(sql, parameters);
635 644
636 if (result.ExecuteNonQuery() == 1) 645 if (result.ExecuteNonQuery() == 1)
@@ -655,8 +664,7 @@ namespace OpenSim.Framework.Data.MSSQL
655 { 664 {
656 try 665 try
657 { 666 {
658 667 SqlCommand cmd = new SqlCommand(getResourceString(name), (SqlConnection) dbcon);
659 SqlCommand cmd = new SqlCommand(getResourceString(name), (SqlConnection)dbcon);
660 cmd.ExecuteNonQuery(); 668 cmd.ExecuteNonQuery();
661 cmd.Dispose(); 669 cmd.Dispose();
662 } 670 }
@@ -668,7 +676,7 @@ namespace OpenSim.Framework.Data.MSSQL
668 676
669 public SqlConnection getConnection() 677 public SqlConnection getConnection()
670 { 678 {
671 return (SqlConnection)dbcon; 679 return (SqlConnection) dbcon;
672 } 680 }
673 681
674 /// <summary> 682 /// <summary>
@@ -681,14 +689,15 @@ namespace OpenSim.Framework.Data.MSSQL
681 { 689 {
682 Dictionary<string, string> param = new Dictionary<string, string>(); 690 Dictionary<string, string> param = new Dictionary<string, string>();
683 param["dbname"] = dbcon.Database; 691 param["dbname"] = dbcon.Database;
684 IDbCommand tablesCmd = this.Query("SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_CATALOG=@dbname", param); 692 IDbCommand tablesCmd =
693 Query("SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_CATALOG=@dbname", param);
685 using (IDataReader tables = tablesCmd.ExecuteReader()) 694 using (IDataReader tables = tablesCmd.ExecuteReader())
686 { 695 {
687 while (tables.Read()) 696 while (tables.Read())
688 { 697 {
689 try 698 try
690 { 699 {
691 string tableName = (string)tables["TABLE_NAME"]; 700 string tableName = (string) tables["TABLE_NAME"];
692 if (tableList.ContainsKey(tableName)) 701 if (tableList.ContainsKey(tableName))
693 tableList[tableName] = tableName; 702 tableList[tableName] = tableName;
694 } 703 }
@@ -704,7 +713,7 @@ namespace OpenSim.Framework.Data.MSSQL
704 713
705 private string getResourceString(string name) 714 private string getResourceString(string name)
706 { 715 {
707 Assembly assem = this.GetType().Assembly; 716 Assembly assem = GetType().Assembly;
708 string[] names = assem.GetManifestResourceNames(); 717 string[] names = assem.GetManifestResourceNames();
709 718
710 foreach (string s in names) 719 foreach (string s in names)
@@ -726,16 +735,14 @@ namespace OpenSim.Framework.Data.MSSQL
726 /// <returns>A string containing the DB provider</returns> 735 /// <returns>A string containing the DB provider</returns>
727 public string getVersion() 736 public string getVersion()
728 { 737 {
729 System.Reflection.Module module = this.GetType().Module; 738 Module module = GetType().Module;
730 string dllName = module.Assembly.ManifestModule.Name; 739 string dllName = module.Assembly.ManifestModule.Name;
731 Version dllVersion = module.Assembly.GetName().Version; 740 Version dllVersion = module.Assembly.GetName().Version;
732 741
733 742
734 return string.Format("{0}.{1}.{2}.{3}", dllVersion.Major, dllVersion.Minor, dllVersion.Build, dllVersion.Revision); 743 return
744 string.Format("{0}.{1}.{2}.{3}", dllVersion.Major, dllVersion.Minor, dllVersion.Build,
745 dllVersion.Revision);
735 } 746 }
736
737 } 747 }
738 748} \ No newline at end of file
739
740
741}