diff options
Diffstat (limited to 'OpenSim/Data')
-rw-r--r-- | OpenSim/Data/MSSQL/MSSQLEstateData.cs | 90 |
1 files changed, 41 insertions, 49 deletions
diff --git a/OpenSim/Data/MSSQL/MSSQLEstateData.cs b/OpenSim/Data/MSSQL/MSSQLEstateData.cs index 474f706..66931e2 100644 --- a/OpenSim/Data/MSSQL/MSSQLEstateData.cs +++ b/OpenSim/Data/MSSQL/MSSQLEstateData.cs | |||
@@ -101,22 +101,30 @@ namespace OpenSim.Data.MSSQL | |||
101 | { | 101 | { |
102 | foreach (string name in FieldList) | 102 | foreach (string name in FieldList) |
103 | { | 103 | { |
104 | if (_FieldMap[name].GetValue(es) is bool) | 104 | FieldInfo f = _FieldMap[name]; |
105 | object v = reader[name]; | ||
106 | if (f.FieldType == typeof(bool) ) | ||
105 | { | 107 | { |
106 | int v = Convert.ToInt32(reader[name]); | 108 | f.SetValue(es, Convert.ToInt32(v) != 0); |
107 | if (v != 0) | ||
108 | _FieldMap[name].SetValue(es, true); | ||
109 | else | ||
110 | _FieldMap[name].SetValue(es, false); | ||
111 | } | 109 | } |
112 | else if (_FieldMap[name].GetValue(es) is UUID) | 110 | else if (f.FieldType == typeof(UUID) ) |
113 | { | 111 | { |
114 | _FieldMap[name].SetValue(es, new UUID((Guid)reader[name])); // uuid); | 112 | f.SetValue(es, new UUID((Guid)v)); // uuid); |
115 | } | 113 | } |
116 | else | 114 | else if (f.FieldType == typeof(string)) |
115 | { | ||
116 | f.SetValue(es, v.ToString()); | ||
117 | } | ||
118 | else if (f.FieldType == typeof(UInt32)) | ||
117 | { | 119 | { |
118 | es.EstateID = Convert.ToUInt32(reader["EstateID"].ToString()); | 120 | f.SetValue(es, Convert.ToUInt32(v)); |
119 | } | 121 | } |
122 | else if (f.FieldType == typeof(Single)) | ||
123 | { | ||
124 | f.SetValue(es, Convert.ToSingle(v)); | ||
125 | } | ||
126 | else | ||
127 | f.SetValue(es, v); | ||
120 | } | 128 | } |
121 | } | 129 | } |
122 | else | 130 | else |
@@ -288,61 +296,45 @@ namespace OpenSim.Data.MSSQL | |||
288 | private void SaveBanList(EstateSettings es) | 296 | private void SaveBanList(EstateSettings es) |
289 | { | 297 | { |
290 | //Delete first | 298 | //Delete first |
291 | string sql = "delete from estateban where EstateID = @EstateID"; | ||
292 | using (SqlConnection conn = new SqlConnection(m_connectionString)) | 299 | using (SqlConnection conn = new SqlConnection(m_connectionString)) |
293 | using (SqlCommand cmd = new SqlCommand(sql, conn)) | ||
294 | { | 300 | { |
295 | cmd.Parameters.Add(_Database.CreateParameter("@EstateID", es.EstateID)); | ||
296 | conn.Open(); | 301 | conn.Open(); |
297 | cmd.ExecuteNonQuery(); | 302 | using (SqlCommand cmd = conn.CreateCommand()) |
298 | } | ||
299 | |||
300 | //Insert after | ||
301 | sql = "insert into estateban (EstateID, bannedUUID) values ( @EstateID, @bannedUUID )"; | ||
302 | using (SqlConnection conn = new SqlConnection(m_connectionString)) | ||
303 | using (SqlCommand cmd = new SqlCommand(sql, conn)) | ||
304 | { | ||
305 | foreach (EstateBan b in es.EstateBans) | ||
306 | { | 303 | { |
307 | cmd.Parameters.Add(_Database.CreateParameter("@EstateID", es.EstateID)); | 304 | cmd.CommandText = "delete from estateban where EstateID = @EstateID"; |
308 | cmd.Parameters.Add(_Database.CreateParameter("@bannedUUID", b.BannedUserID)); | 305 | cmd.Parameters.AddWithValue("@EstateID", (int)es.EstateID); |
309 | conn.Open(); | ||
310 | cmd.ExecuteNonQuery(); | 306 | cmd.ExecuteNonQuery(); |
311 | cmd.Parameters.Clear(); | 307 | |
308 | //Insert after | ||
309 | cmd.CommandText = "insert into estateban (EstateID, bannedUUID) values ( @EstateID, @bannedUUID )"; | ||
310 | cmd.Parameters.AddWithValue("@bannedUUID", Guid.Empty); | ||
311 | foreach (EstateBan b in es.EstateBans) | ||
312 | { | ||
313 | cmd.Parameters["@bannedUUID"].Value = b.BannedUserID.Guid; | ||
314 | cmd.ExecuteNonQuery(); | ||
315 | } | ||
312 | } | 316 | } |
313 | } | 317 | } |
314 | } | 318 | } |
315 | 319 | ||
316 | private void SaveUUIDList(uint estateID, string table, UUID[] data) | 320 | private void SaveUUIDList(uint estateID, string table, UUID[] data) |
317 | { | 321 | { |
318 | //Delete first | ||
319 | string sql = string.Format("delete from {0} where EstateID = @EstateID", table); | ||
320 | using (SqlConnection conn = new SqlConnection(m_connectionString)) | 322 | using (SqlConnection conn = new SqlConnection(m_connectionString)) |
321 | using (SqlCommand cmd = new SqlCommand(sql, conn)) | ||
322 | { | ||
323 | cmd.Parameters.Add(_Database.CreateParameter("@EstateID", estateID)); | ||
324 | cmd.ExecuteNonQuery(); | ||
325 | } | ||
326 | |||
327 | sql = string.Format("insert into {0} (EstateID, uuid) values ( @EstateID, @uuid )", table); | ||
328 | using (SqlConnection conn = new SqlConnection(m_connectionString)) | ||
329 | using (SqlCommand cmd = new SqlCommand(sql, conn)) | ||
330 | { | 323 | { |
331 | cmd.Parameters.Add(_Database.CreateParameter("@EstateID", estateID)); | 324 | conn.Open(); |
332 | 325 | using (SqlCommand cmd = conn.CreateCommand()) | |
333 | bool createParamOnce = true; | ||
334 | |||
335 | foreach (UUID uuid in data) | ||
336 | { | 326 | { |
337 | if (createParamOnce) | 327 | cmd.Parameters.AddWithValue("@EstateID", (int)estateID); |
328 | cmd.CommandText = string.Format("delete from {0} where EstateID = @EstateID", table); | ||
329 | cmd.ExecuteNonQuery(); | ||
330 | |||
331 | cmd.CommandText = string.Format("insert into {0} (EstateID, uuid) values ( @EstateID, @uuid )", table); | ||
332 | cmd.Parameters.AddWithValue("@uuid", Guid.Empty); | ||
333 | foreach (UUID uuid in data) | ||
338 | { | 334 | { |
339 | cmd.Parameters.Add(_Database.CreateParameter("@uuid", uuid)); | ||
340 | createParamOnce = false; | ||
341 | } | ||
342 | else | ||
343 | cmd.Parameters["@uuid"].Value = uuid.Guid; //.ToString(); //TODO check if this works | 335 | cmd.Parameters["@uuid"].Value = uuid.Guid; //.ToString(); //TODO check if this works |
344 | conn.Open(); | 336 | cmd.ExecuteNonQuery(); |
345 | cmd.ExecuteNonQuery(); | 337 | } |
346 | } | 338 | } |
347 | } | 339 | } |
348 | } | 340 | } |