diff options
author | Melanie | 2010-03-23 02:05:56 +0000 |
---|---|---|
committer | Melanie | 2010-03-23 02:05:56 +0000 |
commit | dcf18689b9ab29d4ceb2348bb56fc1f77a7a8912 (patch) | |
tree | ef72d57634075b044c65428f31c8f04c4c53a7bb /OpenSim/Data | |
parent | Somehow the starting estate number in MySQL was lost. This adds a migration (diff) | |
download | opensim-SC-dcf18689b9ab29d4ceb2348bb56fc1f77a7a8912.zip opensim-SC-dcf18689b9ab29d4ceb2348bb56fc1f77a7a8912.tar.gz opensim-SC-dcf18689b9ab29d4ceb2348bb56fc1f77a7a8912.tar.bz2 opensim-SC-dcf18689b9ab29d4ceb2348bb56fc1f77a7a8912.tar.xz |
First stage of the new interactive region creation. This will allow creation
of a region and joining it to an existing estate or creating a new estate,
as well as creating an estate owner if in standalone, and assigning estate
owners. In Grid mode, existing users must be used. MySQL ONLY!!!! so far, as
I can't develop or test for either SQLite or MSSQL.
Diffstat (limited to 'OpenSim/Data')
-rw-r--r-- | OpenSim/Data/MSSQL/MSSQLEstateData.cs | 25 | ||||
-rw-r--r-- | OpenSim/Data/MySQL/MySQLEstateData.cs | 175 | ||||
-rw-r--r-- | OpenSim/Data/SQLite/SQLiteEstateData.cs | 25 |
3 files changed, 180 insertions, 45 deletions
diff --git a/OpenSim/Data/MSSQL/MSSQLEstateData.cs b/OpenSim/Data/MSSQL/MSSQLEstateData.cs index 1624f56..474f706 100644 --- a/OpenSim/Data/MSSQL/MSSQLEstateData.cs +++ b/OpenSim/Data/MSSQL/MSSQLEstateData.cs | |||
@@ -346,6 +346,31 @@ namespace OpenSim.Data.MSSQL | |||
346 | } | 346 | } |
347 | } | 347 | } |
348 | } | 348 | } |
349 | |||
350 | public EstateSettings LoadEstateSettings(int estateID) | ||
351 | { | ||
352 | return new EstateSettings(); | ||
353 | } | ||
354 | |||
355 | public List<int> GetEstates(string search) | ||
356 | { | ||
357 | return new List<int>(); | ||
358 | } | ||
359 | |||
360 | public bool LinkRegion(UUID regionID, int estateID) | ||
361 | { | ||
362 | return false; | ||
363 | } | ||
364 | |||
365 | public List<UUID> GetRegions(int estateID) | ||
366 | { | ||
367 | return new List<UUID>(); | ||
368 | } | ||
369 | |||
370 | public bool DeleteEstate(int estateID) | ||
371 | { | ||
372 | return false; | ||
373 | } | ||
349 | #endregion | 374 | #endregion |
350 | } | 375 | } |
351 | } | 376 | } |
diff --git a/OpenSim/Data/MySQL/MySQLEstateData.cs b/OpenSim/Data/MySQL/MySQLEstateData.cs index e94dcda..7fe1fcc 100644 --- a/OpenSim/Data/MySQL/MySQLEstateData.cs +++ b/OpenSim/Data/MySQL/MySQLEstateData.cs | |||
@@ -123,50 +123,57 @@ namespace OpenSim.Data.MySQL | |||
123 | 123 | ||
124 | public EstateSettings LoadEstateSettings(UUID regionID, bool create) | 124 | public EstateSettings LoadEstateSettings(UUID regionID, bool create) |
125 | { | 125 | { |
126 | EstateSettings es = new EstateSettings(); | ||
127 | es.OnSave += StoreEstateSettings; | ||
128 | |||
129 | string sql = "select estate_settings." + String.Join(",estate_settings.", FieldList) + | 126 | string sql = "select estate_settings." + String.Join(",estate_settings.", FieldList) + |
130 | " from estate_map left join estate_settings on estate_map.EstateID = estate_settings.EstateID where estate_settings.EstateID is not null and RegionID = ?RegionID"; | 127 | " from estate_map left join estate_settings on estate_map.EstateID = estate_settings.EstateID where estate_settings.EstateID is not null and RegionID = ?RegionID"; |
131 | 128 | ||
129 | using (MySqlCommand cmd = new MySqlCommand()) | ||
130 | { | ||
131 | cmd.CommandText = sql; | ||
132 | cmd.Parameters.AddWithValue("?RegionID", regionID.ToString()); | ||
133 | |||
134 | return DoLoad(cmd, regionID, create); | ||
135 | } | ||
136 | } | ||
137 | |||
138 | private EstateSettings DoLoad(MySqlCommand cmd, UUID regionID, bool create) | ||
139 | { | ||
140 | EstateSettings es = new EstateSettings(); | ||
141 | es.OnSave += StoreEstateSettings; | ||
142 | |||
132 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) | 143 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) |
133 | { | 144 | { |
134 | dbcon.Open(); | 145 | dbcon.Open(); |
135 | 146 | ||
147 | cmd.Connection = dbcon; | ||
148 | |||
136 | bool found = false; | 149 | bool found = false; |
137 | 150 | ||
138 | using (MySqlCommand cmd = dbcon.CreateCommand()) | 151 | using (IDataReader r = cmd.ExecuteReader()) |
139 | { | 152 | { |
140 | cmd.CommandText = sql; | 153 | if (r.Read()) |
141 | cmd.Parameters.AddWithValue("?RegionID", regionID.ToString()); | ||
142 | |||
143 | using (IDataReader r = cmd.ExecuteReader()) | ||
144 | { | 154 | { |
145 | if (r.Read()) | 155 | found = true; |
146 | { | ||
147 | found = true; | ||
148 | 156 | ||
149 | foreach (string name in FieldList) | 157 | foreach (string name in FieldList) |
158 | { | ||
159 | if (m_FieldMap[name].GetValue(es) is bool) | ||
150 | { | 160 | { |
151 | if (m_FieldMap[name].GetValue(es) is bool) | 161 | int v = Convert.ToInt32(r[name]); |
152 | { | 162 | if (v != 0) |
153 | int v = Convert.ToInt32(r[name]); | 163 | m_FieldMap[name].SetValue(es, true); |
154 | if (v != 0) | ||
155 | m_FieldMap[name].SetValue(es, true); | ||
156 | else | ||
157 | m_FieldMap[name].SetValue(es, false); | ||
158 | } | ||
159 | else if (m_FieldMap[name].GetValue(es) is UUID) | ||
160 | { | ||
161 | UUID uuid = UUID.Zero; | ||
162 | |||
163 | UUID.TryParse(r[name].ToString(), out uuid); | ||
164 | m_FieldMap[name].SetValue(es, uuid); | ||
165 | } | ||
166 | else | 164 | else |
167 | { | 165 | m_FieldMap[name].SetValue(es, false); |
168 | m_FieldMap[name].SetValue(es, r[name]); | 166 | } |
169 | } | 167 | else if (m_FieldMap[name].GetValue(es) is UUID) |
168 | { | ||
169 | UUID uuid = UUID.Zero; | ||
170 | |||
171 | UUID.TryParse(r[name].ToString(), out uuid); | ||
172 | m_FieldMap[name].SetValue(es, uuid); | ||
173 | } | ||
174 | else | ||
175 | { | ||
176 | m_FieldMap[name].SetValue(es, r[name]); | ||
170 | } | 177 | } |
171 | } | 178 | } |
172 | } | 179 | } |
@@ -179,45 +186,45 @@ namespace OpenSim.Data.MySQL | |||
179 | 186 | ||
180 | names.Remove("EstateID"); | 187 | names.Remove("EstateID"); |
181 | 188 | ||
182 | sql = "insert into estate_settings (" + String.Join(",", names.ToArray()) + ") values ( ?" + String.Join(", ?", names.ToArray()) + ")"; | 189 | string sql = "insert into estate_settings (" + String.Join(",", names.ToArray()) + ") values ( ?" + String.Join(", ?", names.ToArray()) + ")"; |
183 | 190 | ||
184 | using (MySqlCommand cmd = dbcon.CreateCommand()) | 191 | using (MySqlCommand cmd2 = dbcon.CreateCommand()) |
185 | { | 192 | { |
186 | cmd.CommandText = sql; | 193 | cmd2.CommandText = sql; |
187 | cmd.Parameters.Clear(); | 194 | cmd2.Parameters.Clear(); |
188 | 195 | ||
189 | foreach (string name in FieldList) | 196 | foreach (string name in FieldList) |
190 | { | 197 | { |
191 | if (m_FieldMap[name].GetValue(es) is bool) | 198 | if (m_FieldMap[name].GetValue(es) is bool) |
192 | { | 199 | { |
193 | if ((bool)m_FieldMap[name].GetValue(es)) | 200 | if ((bool)m_FieldMap[name].GetValue(es)) |
194 | cmd.Parameters.AddWithValue("?" + name, "1"); | 201 | cmd2.Parameters.AddWithValue("?" + name, "1"); |
195 | else | 202 | else |
196 | cmd.Parameters.AddWithValue("?" + name, "0"); | 203 | cmd2.Parameters.AddWithValue("?" + name, "0"); |
197 | } | 204 | } |
198 | else | 205 | else |
199 | { | 206 | { |
200 | cmd.Parameters.AddWithValue("?" + name, m_FieldMap[name].GetValue(es).ToString()); | 207 | cmd2.Parameters.AddWithValue("?" + name, m_FieldMap[name].GetValue(es).ToString()); |
201 | } | 208 | } |
202 | } | 209 | } |
203 | 210 | ||
204 | cmd.ExecuteNonQuery(); | 211 | cmd2.ExecuteNonQuery(); |
205 | 212 | ||
206 | cmd.CommandText = "select LAST_INSERT_ID() as id"; | 213 | cmd2.CommandText = "select LAST_INSERT_ID() as id"; |
207 | cmd.Parameters.Clear(); | 214 | cmd2.Parameters.Clear(); |
208 | 215 | ||
209 | using (IDataReader r = cmd.ExecuteReader()) | 216 | using (IDataReader r = cmd2.ExecuteReader()) |
210 | { | 217 | { |
211 | r.Read(); | 218 | r.Read(); |
212 | es.EstateID = Convert.ToUInt32(r["id"]); | 219 | es.EstateID = Convert.ToUInt32(r["id"]); |
213 | } | 220 | } |
214 | 221 | ||
215 | cmd.CommandText = "insert into estate_map values (?RegionID, ?EstateID)"; | 222 | cmd2.CommandText = "insert into estate_map values (?RegionID, ?EstateID)"; |
216 | cmd.Parameters.AddWithValue("?RegionID", regionID.ToString()); | 223 | cmd2.Parameters.AddWithValue("?RegionID", regionID.ToString()); |
217 | cmd.Parameters.AddWithValue("?EstateID", es.EstateID.ToString()); | 224 | cmd2.Parameters.AddWithValue("?EstateID", es.EstateID.ToString()); |
218 | 225 | ||
219 | // This will throw on dupe key | 226 | // This will throw on dupe key |
220 | try { cmd.ExecuteNonQuery(); } | 227 | try { cmd2.ExecuteNonQuery(); } |
221 | catch (Exception) { } | 228 | catch (Exception) { } |
222 | 229 | ||
223 | es.Save(); | 230 | es.Save(); |
@@ -390,5 +397,83 @@ namespace OpenSim.Data.MySQL | |||
390 | 397 | ||
391 | return uuids.ToArray(); | 398 | return uuids.ToArray(); |
392 | } | 399 | } |
400 | |||
401 | public EstateSettings LoadEstateSettings(int estateID) | ||
402 | { | ||
403 | using (MySqlCommand cmd = new MySqlCommand()) | ||
404 | { | ||
405 | string sql = "select estate_settings." + String.Join(",estate_settings.", FieldList) + " from estate_settings where EstateID = ?EstateID"; | ||
406 | |||
407 | cmd.CommandText = sql; | ||
408 | cmd.Parameters.AddWithValue("?EstateID", estateID); | ||
409 | |||
410 | return DoLoad(cmd, UUID.Zero, false); | ||
411 | } | ||
412 | } | ||
413 | |||
414 | public List<int> GetEstates(string search) | ||
415 | { | ||
416 | List<int> result = new List<int>(); | ||
417 | |||
418 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) | ||
419 | { | ||
420 | dbcon.Open(); | ||
421 | |||
422 | using (MySqlCommand cmd = dbcon.CreateCommand()) | ||
423 | { | ||
424 | cmd.CommandText = "select estateID from estate_settings where EstateName = ?EstateName"; | ||
425 | cmd.Parameters.AddWithValue("?EstateName", search); | ||
426 | |||
427 | using (IDataReader reader = cmd.ExecuteReader()) | ||
428 | { | ||
429 | while (reader.Read()) | ||
430 | { | ||
431 | result.Add(Convert.ToInt32(reader["EstateID"])); | ||
432 | } | ||
433 | reader.Close(); | ||
434 | } | ||
435 | } | ||
436 | |||
437 | |||
438 | dbcon.Close(); | ||
439 | } | ||
440 | |||
441 | return result; | ||
442 | } | ||
443 | |||
444 | public bool LinkRegion(UUID regionID, int estateID) | ||
445 | { | ||
446 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) | ||
447 | { | ||
448 | dbcon.Open(); | ||
449 | |||
450 | using (MySqlCommand cmd = dbcon.CreateCommand()) | ||
451 | { | ||
452 | cmd.CommandText = "insert into estate_map values (?RegionID, ?EstateID)"; | ||
453 | cmd.Parameters.AddWithValue("?RegionID", regionID); | ||
454 | cmd.Parameters.AddWithValue("?EstateID", estateID); | ||
455 | |||
456 | if (cmd.ExecuteNonQuery() == 0) | ||
457 | { | ||
458 | dbcon.Close(); | ||
459 | return false; | ||
460 | } | ||
461 | } | ||
462 | |||
463 | dbcon.Close(); | ||
464 | } | ||
465 | |||
466 | return true; | ||
467 | } | ||
468 | |||
469 | public List<UUID> GetRegions(int estateID) | ||
470 | { | ||
471 | return new List<UUID>(); | ||
472 | } | ||
473 | |||
474 | public bool DeleteEstate(int estateID) | ||
475 | { | ||
476 | return false; | ||
477 | } | ||
393 | } | 478 | } |
394 | } | 479 | } |
diff --git a/OpenSim/Data/SQLite/SQLiteEstateData.cs b/OpenSim/Data/SQLite/SQLiteEstateData.cs index 4a447d2..5b6135e 100644 --- a/OpenSim/Data/SQLite/SQLiteEstateData.cs +++ b/OpenSim/Data/SQLite/SQLiteEstateData.cs | |||
@@ -320,5 +320,30 @@ namespace OpenSim.Data.SQLite | |||
320 | 320 | ||
321 | return uuids.ToArray(); | 321 | return uuids.ToArray(); |
322 | } | 322 | } |
323 | |||
324 | public EstateSettings LoadEstateSettings(int estateID) | ||
325 | { | ||
326 | return new EstateSettings(); | ||
327 | } | ||
328 | |||
329 | public List<int> GetEstates(string search) | ||
330 | { | ||
331 | return new List<int>(); | ||
332 | } | ||
333 | |||
334 | public bool LinkRegion(UUID regionID, int estateID) | ||
335 | { | ||
336 | return false; | ||
337 | } | ||
338 | |||
339 | public List<UUID> GetRegions(int estateID) | ||
340 | { | ||
341 | return new List<UUID>(); | ||
342 | } | ||
343 | |||
344 | public bool DeleteEstate(int estateID) | ||
345 | { | ||
346 | return false; | ||
347 | } | ||
323 | } | 348 | } |
324 | } | 349 | } |