aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/Data.SQLite/SQLiteManager.cs
diff options
context:
space:
mode:
authorlbsa712007-10-30 09:05:31 +0000
committerlbsa712007-10-30 09:05:31 +0000
commit67e12b95ea7b68f4904a7484d77ecfd787d16d0c (patch)
tree20b00d24c8a7617017960432ec044852e3ad5fa9 /OpenSim/Framework/Data.SQLite/SQLiteManager.cs
parent* Deleted .user file (diff)
downloadopensim-SC_OLD-67e12b95ea7b68f4904a7484d77ecfd787d16d0c.zip
opensim-SC_OLD-67e12b95ea7b68f4904a7484d77ecfd787d16d0c.tar.gz
opensim-SC_OLD-67e12b95ea7b68f4904a7484d77ecfd787d16d0c.tar.bz2
opensim-SC_OLD-67e12b95ea7b68f4904a7484d77ecfd787d16d0c.tar.xz
* Optimized usings
* Shortened type references * Removed redundant 'this' qualifier
Diffstat (limited to 'OpenSim/Framework/Data.SQLite/SQLiteManager.cs')
-rw-r--r--OpenSim/Framework/Data.SQLite/SQLiteManager.cs132
1 files changed, 68 insertions, 64 deletions
diff --git a/OpenSim/Framework/Data.SQLite/SQLiteManager.cs b/OpenSim/Framework/Data.SQLite/SQLiteManager.cs
index 5954fba..e102da3 100644
--- a/OpenSim/Framework/Data.SQLite/SQLiteManager.cs
+++ b/OpenSim/Framework/Data.SQLite/SQLiteManager.cs
@@ -30,13 +30,14 @@ using System.Collections.Generic;
30using System.Data; 30using System.Data;
31using System.Data.SQLite; 31using System.Data.SQLite;
32using libsecondlife; 32using libsecondlife;
33using Mono.Data.SqliteClient;
33using OpenSim.Framework.Console; 34using OpenSim.Framework.Console;
34 35
35namespace OpenSim.Framework.Data.SQLite 36namespace OpenSim.Framework.Data.SQLite
36{ 37{
37 class SQLiteManager : SQLiteBase 38 internal class SQLiteManager : SQLiteBase
38 { 39 {
39 IDbConnection dbcon; 40 private IDbConnection dbcon;
40 41
41 /// <summary> 42 /// <summary>
42 /// Initialises and creates a new SQLite connection and maintains it. 43 /// Initialises and creates a new SQLite connection and maintains it.
@@ -78,15 +79,15 @@ namespace OpenSim.Framework.Data.SQLite
78 /// <returns>A SQLite DB Command</returns> 79 /// <returns>A SQLite DB Command</returns>
79 public IDbCommand Query(string sql, Dictionary<string, string> parameters) 80 public IDbCommand Query(string sql, Dictionary<string, string> parameters)
80 { 81 {
81 SQLiteCommand dbcommand = (SQLiteCommand)dbcon.CreateCommand(); 82 SQLiteCommand dbcommand = (SQLiteCommand) dbcon.CreateCommand();
82 dbcommand.CommandText = sql; 83 dbcommand.CommandText = sql;
83 foreach (KeyValuePair<string, string> param in parameters) 84 foreach (KeyValuePair<string, string> param in parameters)
84 { 85 {
85 SQLiteParameter paramx = new SQLiteParameter(param.Key,param.Value); 86 SQLiteParameter paramx = new SQLiteParameter(param.Key, param.Value);
86 dbcommand.Parameters.Add(paramx); 87 dbcommand.Parameters.Add(paramx);
87 } 88 }
88 89
89 return (IDbCommand)dbcommand; 90 return (IDbCommand) dbcommand;
90 } 91 }
91 92
92 private bool TestTables(SQLiteConnection conn) 93 private bool TestTables(SQLiteConnection conn)
@@ -98,7 +99,7 @@ namespace OpenSim.Framework.Data.SQLite
98 { 99 {
99 pDa.Fill(tmpDS, "regions"); 100 pDa.Fill(tmpDS, "regions");
100 } 101 }
101 catch (Mono.Data.SqliteClient.SqliteSyntaxException) 102 catch (SqliteSyntaxException)
102 { 103 {
103 MainLog.Instance.Verbose("DATASTORE", "SQLite Database doesn't exist... creating"); 104 MainLog.Instance.Verbose("DATASTORE", "SQLite Database doesn't exist... creating");
104 InitDB(conn); 105 InitDB(conn);
@@ -110,39 +111,39 @@ namespace OpenSim.Framework.Data.SQLite
110 { 111 {
111 DataTable regions = new DataTable("regions"); 112 DataTable regions = new DataTable("regions");
112 113
113 createCol(regions, "regionHandle", typeof(ulong)); 114 createCol(regions, "regionHandle", typeof (ulong));
114 createCol(regions, "regionName", typeof(System.String)); 115 createCol(regions, "regionName", typeof (String));
115 createCol(regions, "uuid", typeof(System.String)); 116 createCol(regions, "uuid", typeof (String));
116 117
117 createCol(regions, "regionRecvKey", typeof(System.String)); 118 createCol(regions, "regionRecvKey", typeof (String));
118 createCol(regions, "regionSecret", typeof(System.String)); 119 createCol(regions, "regionSecret", typeof (String));
119 createCol(regions, "regionSendKey", typeof(System.String)); 120 createCol(regions, "regionSendKey", typeof (String));
120 121
121 createCol(regions, "regionDataURI", typeof(System.String)); 122 createCol(regions, "regionDataURI", typeof (String));
122 createCol(regions, "serverIP", typeof(System.String)); 123 createCol(regions, "serverIP", typeof (String));
123 createCol(regions, "serverPort", typeof(System.String)); 124 createCol(regions, "serverPort", typeof (String));
124 createCol(regions, "serverURI", typeof(System.String)); 125 createCol(regions, "serverURI", typeof (String));
125 126
126 127
127 createCol(regions, "locX", typeof( uint)); 128 createCol(regions, "locX", typeof (uint));
128 createCol(regions, "locY", typeof( uint)); 129 createCol(regions, "locY", typeof (uint));
129 createCol(regions, "locZ", typeof( uint)); 130 createCol(regions, "locZ", typeof (uint));
130 131
131 createCol(regions, "eastOverrideHandle", typeof( ulong )); 132 createCol(regions, "eastOverrideHandle", typeof (ulong));
132 createCol(regions, "westOverrideHandle", typeof( ulong )); 133 createCol(regions, "westOverrideHandle", typeof (ulong));
133 createCol(regions, "southOverrideHandle", typeof( ulong )); 134 createCol(regions, "southOverrideHandle", typeof (ulong));
134 createCol(regions, "northOverrideHandle", typeof( ulong )); 135 createCol(regions, "northOverrideHandle", typeof (ulong));
135 136
136 createCol(regions, "regionAssetURI", typeof(System.String)); 137 createCol(regions, "regionAssetURI", typeof (String));
137 createCol(regions, "regionAssetRecvKey", typeof(System.String)); 138 createCol(regions, "regionAssetRecvKey", typeof (String));
138 createCol(regions, "regionAssetSendKey", typeof(System.String)); 139 createCol(regions, "regionAssetSendKey", typeof (String));
139 140
140 createCol(regions, "regionUserURI", typeof(System.String)); 141 createCol(regions, "regionUserURI", typeof (String));
141 createCol(regions, "regionUserRecvKey", typeof(System.String)); 142 createCol(regions, "regionUserRecvKey", typeof (String));
142 createCol(regions, "regionUserSendKey", typeof(System.String)); 143 createCol(regions, "regionUserSendKey", typeof (String));
143 144
144 // Add in contraints 145 // Add in contraints
145 regions.PrimaryKey = new DataColumn[] { regions.Columns["UUID"] }; 146 regions.PrimaryKey = new DataColumn[] {regions.Columns["UUID"]};
146 return regions; 147 return regions;
147 } 148 }
148 149
@@ -168,42 +169,42 @@ namespace OpenSim.Framework.Data.SQLite
168 if (reader.Read()) 169 if (reader.Read())
169 { 170 {
170 // Region Main 171 // Region Main
171 retval.regionHandle = (ulong)reader["regionHandle"]; 172 retval.regionHandle = (ulong) reader["regionHandle"];
172 retval.regionName = (string)reader["regionName"]; 173 retval.regionName = (string) reader["regionName"];
173 retval.UUID = new LLUUID((string)reader["uuid"]); 174 retval.UUID = new LLUUID((string) reader["uuid"]);
174 175
175 // Secrets 176 // Secrets
176 retval.regionRecvKey = (string)reader["regionRecvKey"]; 177 retval.regionRecvKey = (string) reader["regionRecvKey"];
177 retval.regionSecret = (string)reader["regionSecret"]; 178 retval.regionSecret = (string) reader["regionSecret"];
178 retval.regionSendKey = (string)reader["regionSendKey"]; 179 retval.regionSendKey = (string) reader["regionSendKey"];
179 180
180 // Region Server 181 // Region Server
181 retval.regionDataURI = (string)reader["regionDataURI"]; 182 retval.regionDataURI = (string) reader["regionDataURI"];
182 retval.regionOnline = false; // Needs to be pinged before this can be set. 183 retval.regionOnline = false; // Needs to be pinged before this can be set.
183 retval.serverIP = (string)reader["serverIP"]; 184 retval.serverIP = (string) reader["serverIP"];
184 retval.serverPort = (uint)reader["serverPort"]; 185 retval.serverPort = (uint) reader["serverPort"];
185 retval.serverURI = (string)reader["serverURI"]; 186 retval.serverURI = (string) reader["serverURI"];
186 187
187 // Location 188 // Location
188 retval.regionLocX = (uint)((int)reader["locX"]); 189 retval.regionLocX = (uint) ((int) reader["locX"]);
189 retval.regionLocY = (uint)((int)reader["locY"]); 190 retval.regionLocY = (uint) ((int) reader["locY"]);
190 retval.regionLocZ = (uint)((int)reader["locZ"]); 191 retval.regionLocZ = (uint) ((int) reader["locZ"]);
191 192
192 // Neighbours - 0 = No Override 193 // Neighbours - 0 = No Override
193 retval.regionEastOverrideHandle = (ulong)reader["eastOverrideHandle"]; 194 retval.regionEastOverrideHandle = (ulong) reader["eastOverrideHandle"];
194 retval.regionWestOverrideHandle = (ulong)reader["westOverrideHandle"]; 195 retval.regionWestOverrideHandle = (ulong) reader["westOverrideHandle"];
195 retval.regionSouthOverrideHandle = (ulong)reader["southOverrideHandle"]; 196 retval.regionSouthOverrideHandle = (ulong) reader["southOverrideHandle"];
196 retval.regionNorthOverrideHandle = (ulong)reader["northOverrideHandle"]; 197 retval.regionNorthOverrideHandle = (ulong) reader["northOverrideHandle"];
197 198
198 // Assets 199 // Assets
199 retval.regionAssetURI = (string)reader["regionAssetURI"]; 200 retval.regionAssetURI = (string) reader["regionAssetURI"];
200 retval.regionAssetRecvKey = (string)reader["regionAssetRecvKey"]; 201 retval.regionAssetRecvKey = (string) reader["regionAssetRecvKey"];
201 retval.regionAssetSendKey = (string)reader["regionAssetSendKey"]; 202 retval.regionAssetSendKey = (string) reader["regionAssetSendKey"];
202 203
203 // Userserver 204 // Userserver
204 retval.regionUserURI = (string)reader["regionUserURI"]; 205 retval.regionUserURI = (string) reader["regionUserURI"];
205 retval.regionUserRecvKey = (string)reader["regionUserRecvKey"]; 206 retval.regionUserRecvKey = (string) reader["regionUserRecvKey"];
206 retval.regionUserSendKey = (string)reader["regionUserSendKey"]; 207 retval.regionUserSendKey = (string) reader["regionUserSendKey"];
207 } 208 }
208 else 209 else
209 { 210 {
@@ -219,12 +220,15 @@ namespace OpenSim.Framework.Data.SQLite
219 /// <returns>Success?</returns> 220 /// <returns>Success?</returns>
220 public bool insertRow(RegionProfileData profile) 221 public bool insertRow(RegionProfileData profile)
221 { 222 {
222 string sql = "REPLACE INTO regions VALUES (regionHandle, regionName, uuid, regionRecvKey, regionSecret, regionSendKey, regionDataURI, "; 223 string sql =
223 sql += "serverIP, serverPort, serverURI, locX, locY, locZ, eastOverrideHandle, westOverrideHandle, southOverrideHandle, northOverrideHandle, regionAssetURI, regionAssetRecvKey, "; 224 "REPLACE INTO regions VALUES (regionHandle, regionName, uuid, regionRecvKey, regionSecret, regionSendKey, regionDataURI, ";
225 sql +=
226 "serverIP, serverPort, serverURI, locX, locY, locZ, eastOverrideHandle, westOverrideHandle, southOverrideHandle, northOverrideHandle, regionAssetURI, regionAssetRecvKey, ";
224 sql += "regionAssetSendKey, regionUserURI, regionUserRecvKey, regionUserSendKey) VALUES "; 227 sql += "regionAssetSendKey, regionUserURI, regionUserRecvKey, regionUserSendKey) VALUES ";
225 228
226 sql += "(@regionHandle, @regionName, @uuid, @regionRecvKey, @regionSecret, @regionSendKey, @regionDataURI, "; 229 sql += "(@regionHandle, @regionName, @uuid, @regionRecvKey, @regionSecret, @regionSendKey, @regionDataURI, ";
227 sql += "@serverIP, @serverPort, @serverURI, @locX, @locY, @locZ, @eastOverrideHandle, @westOverrideHandle, @southOverrideHandle, @northOverrideHandle, @regionAssetURI, @regionAssetRecvKey, "; 230 sql +=
231 "@serverIP, @serverPort, @serverURI, @locX, @locY, @locZ, @eastOverrideHandle, @westOverrideHandle, @southOverrideHandle, @northOverrideHandle, @regionAssetURI, @regionAssetRecvKey, ";
228 sql += "@regionAssetSendKey, @regionUserURI, @regionUserRecvKey, @regionUserSendKey);"; 232 sql += "@regionAssetSendKey, @regionUserURI, @regionUserRecvKey, @regionUserSendKey);";
229 233
230 Dictionary<string, string> parameters = new Dictionary<string, string>(); 234 Dictionary<string, string> parameters = new Dictionary<string, string>();
@@ -271,4 +275,4 @@ namespace OpenSim.Framework.Data.SQLite
271 return returnval; 275 return returnval;
272 } 276 }
273 } 277 }
274} 278} \ No newline at end of file