diff options
Diffstat (limited to 'OpenSim/Data/MSSQL/MSSQLGridData.cs')
-rw-r--r-- | OpenSim/Data/MSSQL/MSSQLGridData.cs | 587 |
1 files changed, 0 insertions, 587 deletions
diff --git a/OpenSim/Data/MSSQL/MSSQLGridData.cs b/OpenSim/Data/MSSQL/MSSQLGridData.cs deleted file mode 100644 index 8a3d332..0000000 --- a/OpenSim/Data/MSSQL/MSSQLGridData.cs +++ /dev/null | |||
@@ -1,587 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using System.Data; | ||
31 | using System.Data.SqlClient; | ||
32 | using System.Reflection; | ||
33 | using log4net; | ||
34 | using OpenMetaverse; | ||
35 | using OpenSim.Framework; | ||
36 | |||
37 | namespace OpenSim.Data.MSSQL | ||
38 | { | ||
39 | /// <summary> | ||
40 | /// A grid data interface for MSSQL Server | ||
41 | /// </summary> | ||
42 | public class MSSQLGridData : GridDataBase | ||
43 | { | ||
44 | private const string _migrationStore = "GridStore"; | ||
45 | |||
46 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
47 | |||
48 | /// <summary> | ||
49 | /// Database manager | ||
50 | /// </summary> | ||
51 | private MSSQLManager database; | ||
52 | |||
53 | private string m_regionsTableName = "regions"; | ||
54 | |||
55 | #region IPlugin Members | ||
56 | |||
57 | // [Obsolete("Cannot be default-initialized!")] | ||
58 | override public void Initialise() | ||
59 | { | ||
60 | m_log.Info("[GRID DB]: " + Name + " cannot be default-initialized!"); | ||
61 | throw new PluginNotInitialisedException(Name); | ||
62 | } | ||
63 | |||
64 | /// <summary> | ||
65 | /// Initialises the Grid Interface | ||
66 | /// </summary> | ||
67 | /// <param name="connectionString">connect string</param> | ||
68 | /// <remarks>use mssql_connection.ini</remarks> | ||
69 | override public void Initialise(string connectionString) | ||
70 | { | ||
71 | if (!string.IsNullOrEmpty(connectionString)) | ||
72 | { | ||
73 | database = new MSSQLManager(connectionString); | ||
74 | } | ||
75 | else | ||
76 | { | ||
77 | // TODO: make the connect string actually do something | ||
78 | IniFile iniFile = new IniFile("mssql_connection.ini"); | ||
79 | |||
80 | string settingDataSource = iniFile.ParseFileReadValue("data_source"); | ||
81 | string settingInitialCatalog = iniFile.ParseFileReadValue("initial_catalog"); | ||
82 | string settingPersistSecurityInfo = iniFile.ParseFileReadValue("persist_security_info"); | ||
83 | string settingUserId = iniFile.ParseFileReadValue("user_id"); | ||
84 | string settingPassword = iniFile.ParseFileReadValue("password"); | ||
85 | |||
86 | m_regionsTableName = iniFile.ParseFileReadValue("regionstablename"); | ||
87 | if (m_regionsTableName == null) | ||
88 | { | ||
89 | m_regionsTableName = "regions"; | ||
90 | } | ||
91 | |||
92 | database = | ||
93 | new MSSQLManager(settingDataSource, settingInitialCatalog, settingPersistSecurityInfo, settingUserId, | ||
94 | settingPassword); | ||
95 | } | ||
96 | |||
97 | //New migrations check of store | ||
98 | database.CheckMigration(_migrationStore); | ||
99 | } | ||
100 | |||
101 | /// <summary> | ||
102 | /// Shuts down the grid interface | ||
103 | /// </summary> | ||
104 | override public void Dispose() | ||
105 | { | ||
106 | database = null; | ||
107 | } | ||
108 | |||
109 | /// <summary> | ||
110 | /// The name of this DB provider. | ||
111 | /// </summary> | ||
112 | /// <returns>A string containing the storage system name</returns> | ||
113 | override public string Name | ||
114 | { | ||
115 | get { return "MSSQL OpenGridData"; } | ||
116 | } | ||
117 | |||
118 | /// <summary> | ||
119 | /// Database provider version. | ||
120 | /// </summary> | ||
121 | /// <returns>A string containing the storage system version</returns> | ||
122 | override public string Version | ||
123 | { | ||
124 | get { return "0.1"; } | ||
125 | } | ||
126 | |||
127 | #endregion | ||
128 | |||
129 | #region Public override GridDataBase methods | ||
130 | |||
131 | /// <summary> | ||
132 | /// Returns a list of regions within the specified ranges | ||
133 | /// </summary> | ||
134 | /// <param name="xmin">minimum X coordinate</param> | ||
135 | /// <param name="ymin">minimum Y coordinate</param> | ||
136 | /// <param name="xmax">maximum X coordinate</param> | ||
137 | /// <param name="ymax">maximum Y coordinate</param> | ||
138 | /// <returns>null</returns> | ||
139 | /// <remarks>always return null</remarks> | ||
140 | override public RegionProfileData[] GetProfilesInRange(uint xmin, uint ymin, uint xmax, uint ymax) | ||
141 | { | ||
142 | using (AutoClosingSqlCommand command = database.Query("SELECT * FROM regions WHERE locX >= @xmin AND locX <= @xmax AND locY >= @ymin AND locY <= @ymax")) | ||
143 | { | ||
144 | command.Parameters.Add(database.CreateParameter("xmin", xmin)); | ||
145 | command.Parameters.Add(database.CreateParameter("ymin", ymin)); | ||
146 | command.Parameters.Add(database.CreateParameter("xmax", xmax)); | ||
147 | command.Parameters.Add(database.CreateParameter("ymax", ymax)); | ||
148 | |||
149 | List<RegionProfileData> rows = new List<RegionProfileData>(); | ||
150 | |||
151 | using (SqlDataReader reader = command.ExecuteReader()) | ||
152 | { | ||
153 | while (reader.Read()) | ||
154 | { | ||
155 | rows.Add(ReadSimRow(reader)); | ||
156 | } | ||
157 | } | ||
158 | |||
159 | if (rows.Count > 0) | ||
160 | { | ||
161 | return rows.ToArray(); | ||
162 | } | ||
163 | } | ||
164 | m_log.Info("[GRID DB] : Found no regions within range."); | ||
165 | return null; | ||
166 | } | ||
167 | |||
168 | |||
169 | /// <summary> | ||
170 | /// Returns up to maxNum profiles of regions that have a name starting with namePrefix | ||
171 | /// </summary> | ||
172 | /// <param name="namePrefix">The name to match against</param> | ||
173 | /// <param name="maxNum">Maximum number of profiles to return</param> | ||
174 | /// <returns>A list of sim profiles</returns> | ||
175 | override public List<RegionProfileData> GetRegionsByName (string namePrefix, uint maxNum) | ||
176 | { | ||
177 | using (AutoClosingSqlCommand command = database.Query("SELECT * FROM regions WHERE regionName LIKE @name")) | ||
178 | { | ||
179 | command.Parameters.Add(database.CreateParameter("name", namePrefix + "%")); | ||
180 | |||
181 | List<RegionProfileData> rows = new List<RegionProfileData>(); | ||
182 | |||
183 | using (SqlDataReader reader = command.ExecuteReader()) | ||
184 | { | ||
185 | while (rows.Count < maxNum && reader.Read()) | ||
186 | { | ||
187 | rows.Add(ReadSimRow(reader)); | ||
188 | } | ||
189 | } | ||
190 | |||
191 | return rows; | ||
192 | } | ||
193 | } | ||
194 | |||
195 | /// <summary> | ||
196 | /// Returns a sim profile from its location | ||
197 | /// </summary> | ||
198 | /// <param name="handle">Region location handle</param> | ||
199 | /// <returns>Sim profile</returns> | ||
200 | override public RegionProfileData GetProfileByHandle(ulong handle) | ||
201 | { | ||
202 | using (AutoClosingSqlCommand command = database.Query("SELECT * FROM " + m_regionsTableName + " WHERE regionHandle = @handle")) | ||
203 | { | ||
204 | command.Parameters.Add(database.CreateParameter("handle", handle)); | ||
205 | |||
206 | using (SqlDataReader reader = command.ExecuteReader()) | ||
207 | { | ||
208 | if (reader.Read()) | ||
209 | { | ||
210 | return ReadSimRow(reader); | ||
211 | } | ||
212 | } | ||
213 | } | ||
214 | m_log.InfoFormat("[GRID DB] : No region found with handle : {0}", handle); | ||
215 | return null; | ||
216 | } | ||
217 | |||
218 | /// <summary> | ||
219 | /// Returns a sim profile from its UUID | ||
220 | /// </summary> | ||
221 | /// <param name="uuid">The region UUID</param> | ||
222 | /// <returns>The sim profile</returns> | ||
223 | override public RegionProfileData GetProfileByUUID(UUID uuid) | ||
224 | { | ||
225 | using (AutoClosingSqlCommand command = database.Query("SELECT * FROM " + m_regionsTableName + " WHERE uuid = @uuid")) | ||
226 | { | ||
227 | command.Parameters.Add(database.CreateParameter("uuid", uuid)); | ||
228 | |||
229 | using (SqlDataReader reader = command.ExecuteReader()) | ||
230 | { | ||
231 | if (reader.Read()) | ||
232 | { | ||
233 | return ReadSimRow(reader); | ||
234 | } | ||
235 | } | ||
236 | } | ||
237 | m_log.InfoFormat("[GRID DB] : No region found with UUID : {0}", uuid); | ||
238 | return null; | ||
239 | } | ||
240 | |||
241 | /// <summary> | ||
242 | /// Returns a sim profile from it's Region name string | ||
243 | /// </summary> | ||
244 | /// <param name="regionName">The region name search query</param> | ||
245 | /// <returns>The sim profile</returns> | ||
246 | override public RegionProfileData GetProfileByString(string regionName) | ||
247 | { | ||
248 | if (regionName.Length > 2) | ||
249 | { | ||
250 | using (AutoClosingSqlCommand command = database.Query("SELECT top 1 * FROM " + m_regionsTableName + " WHERE regionName like @regionName order by regionName")) | ||
251 | { | ||
252 | command.Parameters.Add(database.CreateParameter("regionName", regionName + "%")); | ||
253 | |||
254 | using (SqlDataReader reader = command.ExecuteReader()) | ||
255 | { | ||
256 | if (reader.Read()) | ||
257 | { | ||
258 | return ReadSimRow(reader); | ||
259 | } | ||
260 | } | ||
261 | } | ||
262 | m_log.InfoFormat("[GRID DB] : No region found with regionName : {0}", regionName); | ||
263 | return null; | ||
264 | } | ||
265 | |||
266 | m_log.Error("[GRID DB]: Searched for a Region Name shorter then 3 characters"); | ||
267 | return null; | ||
268 | } | ||
269 | |||
270 | /// <summary> | ||
271 | /// Adds a new specified region to the database | ||
272 | /// </summary> | ||
273 | /// <param name="profile">The profile to add</param> | ||
274 | /// <returns>A dataresponse enum indicating success</returns> | ||
275 | override public DataResponse StoreProfile(RegionProfileData profile) | ||
276 | { | ||
277 | if (GetProfileByUUID(profile.UUID) == null) | ||
278 | { | ||
279 | if (InsertRegionRow(profile)) | ||
280 | { | ||
281 | return DataResponse.RESPONSE_OK; | ||
282 | } | ||
283 | } | ||
284 | else | ||
285 | { | ||
286 | if (UpdateRegionRow(profile)) | ||
287 | { | ||
288 | return DataResponse.RESPONSE_OK; | ||
289 | } | ||
290 | } | ||
291 | |||
292 | return DataResponse.RESPONSE_ERROR; | ||
293 | } | ||
294 | |||
295 | /// <summary> | ||
296 | /// Deletes a sim profile from the database | ||
297 | /// </summary> | ||
298 | /// <param name="uuid">the sim UUID</param> | ||
299 | /// <returns>Successful?</returns> | ||
300 | //public DataResponse DeleteProfile(RegionProfileData profile) | ||
301 | override public DataResponse DeleteProfile(string uuid) | ||
302 | { | ||
303 | using (AutoClosingSqlCommand command = database.Query("DELETE FROM regions WHERE uuid = @uuid;")) | ||
304 | { | ||
305 | command.Parameters.Add(database.CreateParameter("uuid", uuid)); | ||
306 | try | ||
307 | { | ||
308 | command.ExecuteNonQuery(); | ||
309 | return DataResponse.RESPONSE_OK; | ||
310 | } | ||
311 | catch (Exception e) | ||
312 | { | ||
313 | m_log.DebugFormat("[GRID DB] : Error deleting region info, error is : {0}", e.Message); | ||
314 | return DataResponse.RESPONSE_ERROR; | ||
315 | } | ||
316 | } | ||
317 | } | ||
318 | |||
319 | #endregion | ||
320 | |||
321 | #region Methods that are not used or deprecated (still needed because of base class) | ||
322 | |||
323 | /// <summary> | ||
324 | /// DEPRECATED. Attempts to authenticate a region by comparing a shared secret. | ||
325 | /// </summary> | ||
326 | /// <param name="uuid">The UUID of the challenger</param> | ||
327 | /// <param name="handle">The attempted regionHandle of the challenger</param> | ||
328 | /// <param name="authkey">The secret</param> | ||
329 | /// <returns>Whether the secret and regionhandle match the database entry for UUID</returns> | ||
330 | override public bool AuthenticateSim(UUID uuid, ulong handle, string authkey) | ||
331 | { | ||
332 | bool throwHissyFit = false; // Should be true by 1.0 | ||
333 | |||
334 | if (throwHissyFit) | ||
335 | throw new Exception("CRYPTOWEAK AUTHENTICATE: Refusing to authenticate due to replay potential."); | ||
336 | |||
337 | RegionProfileData data = GetProfileByUUID(uuid); | ||
338 | |||
339 | return (handle == data.regionHandle && authkey == data.regionSecret); | ||
340 | } | ||
341 | |||
342 | /// <summary> | ||
343 | /// NOT YET FUNCTIONAL. Provides a cryptographic authentication of a region | ||
344 | /// </summary> | ||
345 | /// <remarks>This requires a security audit.</remarks> | ||
346 | /// <param name="uuid"></param> | ||
347 | /// <param name="handle"></param> | ||
348 | /// <param name="authhash"></param> | ||
349 | /// <param name="challenge"></param> | ||
350 | /// <returns></returns> | ||
351 | public bool AuthenticateSim(UUID uuid, ulong handle, string authhash, string challenge) | ||
352 | { | ||
353 | // SHA512Managed HashProvider = new SHA512Managed(); | ||
354 | // Encoding TextProvider = new UTF8Encoding(); | ||
355 | |||
356 | // byte[] stream = TextProvider.GetBytes(uuid.ToString() + ":" + handle.ToString() + ":" + challenge); | ||
357 | // byte[] hash = HashProvider.ComputeHash(stream); | ||
358 | return false; | ||
359 | } | ||
360 | |||
361 | /// <summary> | ||
362 | /// NOT IMPLEMENTED | ||
363 | /// WHEN IS THIS GONNA BE IMPLEMENTED. | ||
364 | /// </summary> | ||
365 | /// <param name="x"></param> | ||
366 | /// <param name="y"></param> | ||
367 | /// <returns>null</returns> | ||
368 | override public ReservationData GetReservationAtPoint(uint x, uint y) | ||
369 | { | ||
370 | return null; | ||
371 | } | ||
372 | |||
373 | #endregion | ||
374 | |||
375 | #region private methods | ||
376 | |||
377 | /// <summary> | ||
378 | /// Reads a region row from a database reader | ||
379 | /// </summary> | ||
380 | /// <param name="reader">An active database reader</param> | ||
381 | /// <returns>A region profile</returns> | ||
382 | private static RegionProfileData ReadSimRow(IDataRecord reader) | ||
383 | { | ||
384 | RegionProfileData retval = new RegionProfileData(); | ||
385 | |||
386 | // Region Main gotta-have-or-we-return-null parts | ||
387 | UInt64 tmp64; | ||
388 | if (!UInt64.TryParse(reader["regionHandle"].ToString(), out tmp64)) | ||
389 | { | ||
390 | return null; | ||
391 | } | ||
392 | |||
393 | retval.regionHandle = tmp64; | ||
394 | |||
395 | // UUID tmp_uuid; | ||
396 | // if (!UUID.TryParse((string)reader["uuid"], out tmp_uuid)) | ||
397 | // { | ||
398 | // return null; | ||
399 | // } | ||
400 | |||
401 | retval.UUID = new UUID((Guid)reader["uuid"]); // tmp_uuid; | ||
402 | |||
403 | // non-critical parts | ||
404 | retval.regionName = reader["regionName"].ToString(); | ||
405 | retval.originUUID = new UUID((Guid)reader["originUUID"]); | ||
406 | |||
407 | // Secrets | ||
408 | retval.regionRecvKey = reader["regionRecvKey"].ToString(); | ||
409 | retval.regionSecret = reader["regionSecret"].ToString(); | ||
410 | retval.regionSendKey = reader["regionSendKey"].ToString(); | ||
411 | |||
412 | // Region Server | ||
413 | retval.regionDataURI = reader["regionDataURI"].ToString(); | ||
414 | retval.regionOnline = false; // Needs to be pinged before this can be set. | ||
415 | retval.serverIP = reader["serverIP"].ToString(); | ||
416 | retval.serverPort = Convert.ToUInt32(reader["serverPort"]); | ||
417 | retval.serverURI = reader["serverURI"].ToString(); | ||
418 | retval.httpPort = Convert.ToUInt32(reader["serverHttpPort"].ToString()); | ||
419 | retval.remotingPort = Convert.ToUInt32(reader["serverRemotingPort"].ToString()); | ||
420 | |||
421 | // Location | ||
422 | retval.regionLocX = Convert.ToUInt32(reader["locX"].ToString()); | ||
423 | retval.regionLocY = Convert.ToUInt32(reader["locY"].ToString()); | ||
424 | retval.regionLocZ = Convert.ToUInt32(reader["locZ"].ToString()); | ||
425 | |||
426 | // Neighbours - 0 = No Override | ||
427 | retval.regionEastOverrideHandle = Convert.ToUInt64(reader["eastOverrideHandle"].ToString()); | ||
428 | retval.regionWestOverrideHandle = Convert.ToUInt64(reader["westOverrideHandle"].ToString()); | ||
429 | retval.regionSouthOverrideHandle = Convert.ToUInt64(reader["southOverrideHandle"].ToString()); | ||
430 | retval.regionNorthOverrideHandle = Convert.ToUInt64(reader["northOverrideHandle"].ToString()); | ||
431 | |||
432 | // Assets | ||
433 | retval.regionAssetURI = reader["regionAssetURI"].ToString(); | ||
434 | retval.regionAssetRecvKey = reader["regionAssetRecvKey"].ToString(); | ||
435 | retval.regionAssetSendKey = reader["regionAssetSendKey"].ToString(); | ||
436 | |||
437 | // Userserver | ||
438 | retval.regionUserURI = reader["regionUserURI"].ToString(); | ||
439 | retval.regionUserRecvKey = reader["regionUserRecvKey"].ToString(); | ||
440 | retval.regionUserSendKey = reader["regionUserSendKey"].ToString(); | ||
441 | |||
442 | // World Map Addition | ||
443 | retval.regionMapTextureID = new UUID((Guid)reader["regionMapTexture"]); | ||
444 | retval.owner_uuid = new UUID((Guid)reader["owner_uuid"]); | ||
445 | retval.maturity = Convert.ToUInt32(reader["access"]); | ||
446 | return retval; | ||
447 | } | ||
448 | |||
449 | /// <summary> | ||
450 | /// Update the specified region in the database | ||
451 | /// </summary> | ||
452 | /// <param name="profile">The profile to update</param> | ||
453 | /// <returns>success ?</returns> | ||
454 | private bool UpdateRegionRow(RegionProfileData profile) | ||
455 | { | ||
456 | bool returnval = false; | ||
457 | |||
458 | //Insert new region | ||
459 | string sql = | ||
460 | "UPDATE " + m_regionsTableName + @" SET | ||
461 | [regionHandle]=@regionHandle, [regionName]=@regionName, | ||
462 | [regionRecvKey]=@regionRecvKey, [regionSecret]=@regionSecret, [regionSendKey]=@regionSendKey, | ||
463 | [regionDataURI]=@regionDataURI, [serverIP]=@serverIP, [serverPort]=@serverPort, [serverURI]=@serverURI, | ||
464 | [locX]=@locX, [locY]=@locY, [locZ]=@locZ, [eastOverrideHandle]=@eastOverrideHandle, | ||
465 | [westOverrideHandle]=@westOverrideHandle, [southOverrideHandle]=@southOverrideHandle, | ||
466 | [northOverrideHandle]=@northOverrideHandle, [regionAssetURI]=@regionAssetURI, | ||
467 | [regionAssetRecvKey]=@regionAssetRecvKey, [regionAssetSendKey]=@regionAssetSendKey, | ||
468 | [regionUserURI]=@regionUserURI, [regionUserRecvKey]=@regionUserRecvKey, [regionUserSendKey]=@regionUserSendKey, | ||
469 | [regionMapTexture]=@regionMapTexture, [serverHttpPort]=@serverHttpPort, | ||
470 | [serverRemotingPort]=@serverRemotingPort, [owner_uuid]=@owner_uuid , [originUUID]=@originUUID | ||
471 | where [uuid]=@uuid"; | ||
472 | |||
473 | using (AutoClosingSqlCommand command = database.Query(sql)) | ||
474 | { | ||
475 | command.Parameters.Add(database.CreateParameter("regionHandle", profile.regionHandle)); | ||
476 | command.Parameters.Add(database.CreateParameter("regionName", profile.regionName)); | ||
477 | command.Parameters.Add(database.CreateParameter("uuid", profile.UUID)); | ||
478 | command.Parameters.Add(database.CreateParameter("regionRecvKey", profile.regionRecvKey)); | ||
479 | command.Parameters.Add(database.CreateParameter("regionSecret", profile.regionSecret)); | ||
480 | command.Parameters.Add(database.CreateParameter("regionSendKey", profile.regionSendKey)); | ||
481 | command.Parameters.Add(database.CreateParameter("regionDataURI", profile.regionDataURI)); | ||
482 | command.Parameters.Add(database.CreateParameter("serverIP", profile.serverIP)); | ||
483 | command.Parameters.Add(database.CreateParameter("serverPort", profile.serverPort)); | ||
484 | command.Parameters.Add(database.CreateParameter("serverURI", profile.serverURI)); | ||
485 | command.Parameters.Add(database.CreateParameter("locX", profile.regionLocX)); | ||
486 | command.Parameters.Add(database.CreateParameter("locY", profile.regionLocY)); | ||
487 | command.Parameters.Add(database.CreateParameter("locZ", profile.regionLocZ)); | ||
488 | command.Parameters.Add(database.CreateParameter("eastOverrideHandle", profile.regionEastOverrideHandle)); | ||
489 | command.Parameters.Add(database.CreateParameter("westOverrideHandle", profile.regionWestOverrideHandle)); | ||
490 | command.Parameters.Add(database.CreateParameter("northOverrideHandle", profile.regionNorthOverrideHandle)); | ||
491 | command.Parameters.Add(database.CreateParameter("southOverrideHandle", profile.regionSouthOverrideHandle)); | ||
492 | command.Parameters.Add(database.CreateParameter("regionAssetURI", profile.regionAssetURI)); | ||
493 | command.Parameters.Add(database.CreateParameter("regionAssetRecvKey", profile.regionAssetRecvKey)); | ||
494 | command.Parameters.Add(database.CreateParameter("regionAssetSendKey", profile.regionAssetSendKey)); | ||
495 | command.Parameters.Add(database.CreateParameter("regionUserURI", profile.regionUserURI)); | ||
496 | command.Parameters.Add(database.CreateParameter("regionUserRecvKey", profile.regionUserRecvKey)); | ||
497 | command.Parameters.Add(database.CreateParameter("regionUserSendKey", profile.regionUserSendKey)); | ||
498 | command.Parameters.Add(database.CreateParameter("regionMapTexture", profile.regionMapTextureID)); | ||
499 | command.Parameters.Add(database.CreateParameter("serverHttpPort", profile.httpPort)); | ||
500 | command.Parameters.Add(database.CreateParameter("serverRemotingPort", profile.remotingPort)); | ||
501 | command.Parameters.Add(database.CreateParameter("owner_uuid", profile.owner_uuid)); | ||
502 | command.Parameters.Add(database.CreateParameter("originUUID", profile.originUUID)); | ||
503 | |||
504 | try | ||
505 | { | ||
506 | command.ExecuteNonQuery(); | ||
507 | returnval = true; | ||
508 | } | ||
509 | catch (Exception e) | ||
510 | { | ||
511 | m_log.Error("[GRID DB] : Error updating region, error: " + e.Message); | ||
512 | } | ||
513 | } | ||
514 | |||
515 | return returnval; | ||
516 | } | ||
517 | |||
518 | /// <summary> | ||
519 | /// Creates a new region in the database | ||
520 | /// </summary> | ||
521 | /// <param name="profile">The region profile to insert</param> | ||
522 | /// <returns>Successful?</returns> | ||
523 | private bool InsertRegionRow(RegionProfileData profile) | ||
524 | { | ||
525 | bool returnval = false; | ||
526 | |||
527 | //Insert new region | ||
528 | string sql = | ||
529 | "INSERT INTO " + m_regionsTableName + @" ([regionHandle], [regionName], [uuid], [regionRecvKey], [regionSecret], [regionSendKey], [regionDataURI], | ||
530 | [serverIP], [serverPort], [serverURI], [locX], [locY], [locZ], [eastOverrideHandle], [westOverrideHandle], | ||
531 | [southOverrideHandle], [northOverrideHandle], [regionAssetURI], [regionAssetRecvKey], [regionAssetSendKey], | ||
532 | [regionUserURI], [regionUserRecvKey], [regionUserSendKey], [regionMapTexture], [serverHttpPort], | ||
533 | [serverRemotingPort], [owner_uuid], [originUUID], [access]) | ||
534 | VALUES (@regionHandle, @regionName, @uuid, @regionRecvKey, @regionSecret, @regionSendKey, @regionDataURI, | ||
535 | @serverIP, @serverPort, @serverURI, @locX, @locY, @locZ, @eastOverrideHandle, @westOverrideHandle, | ||
536 | @southOverrideHandle, @northOverrideHandle, @regionAssetURI, @regionAssetRecvKey, @regionAssetSendKey, | ||
537 | @regionUserURI, @regionUserRecvKey, @regionUserSendKey, @regionMapTexture, @serverHttpPort, @serverRemotingPort, @owner_uuid, @originUUID, @access);"; | ||
538 | |||
539 | using (AutoClosingSqlCommand command = database.Query(sql)) | ||
540 | { | ||
541 | command.Parameters.Add(database.CreateParameter("regionHandle", profile.regionHandle)); | ||
542 | command.Parameters.Add(database.CreateParameter("regionName", profile.regionName)); | ||
543 | command.Parameters.Add(database.CreateParameter("uuid", profile.UUID)); | ||
544 | command.Parameters.Add(database.CreateParameter("regionRecvKey", profile.regionRecvKey)); | ||
545 | command.Parameters.Add(database.CreateParameter("regionSecret", profile.regionSecret)); | ||
546 | command.Parameters.Add(database.CreateParameter("regionSendKey", profile.regionSendKey)); | ||
547 | command.Parameters.Add(database.CreateParameter("regionDataURI", profile.regionDataURI)); | ||
548 | command.Parameters.Add(database.CreateParameter("serverIP", profile.serverIP)); | ||
549 | command.Parameters.Add(database.CreateParameter("serverPort", profile.serverPort)); | ||
550 | command.Parameters.Add(database.CreateParameter("serverURI", profile.serverURI)); | ||
551 | command.Parameters.Add(database.CreateParameter("locX", profile.regionLocX)); | ||
552 | command.Parameters.Add(database.CreateParameter("locY", profile.regionLocY)); | ||
553 | command.Parameters.Add(database.CreateParameter("locZ", profile.regionLocZ)); | ||
554 | command.Parameters.Add(database.CreateParameter("eastOverrideHandle", profile.regionEastOverrideHandle)); | ||
555 | command.Parameters.Add(database.CreateParameter("westOverrideHandle", profile.regionWestOverrideHandle)); | ||
556 | command.Parameters.Add(database.CreateParameter("northOverrideHandle", profile.regionNorthOverrideHandle)); | ||
557 | command.Parameters.Add(database.CreateParameter("southOverrideHandle", profile.regionSouthOverrideHandle)); | ||
558 | command.Parameters.Add(database.CreateParameter("regionAssetURI", profile.regionAssetURI)); | ||
559 | command.Parameters.Add(database.CreateParameter("regionAssetRecvKey", profile.regionAssetRecvKey)); | ||
560 | command.Parameters.Add(database.CreateParameter("regionAssetSendKey", profile.regionAssetSendKey)); | ||
561 | command.Parameters.Add(database.CreateParameter("regionUserURI", profile.regionUserURI)); | ||
562 | command.Parameters.Add(database.CreateParameter("regionUserRecvKey", profile.regionUserRecvKey)); | ||
563 | command.Parameters.Add(database.CreateParameter("regionUserSendKey", profile.regionUserSendKey)); | ||
564 | command.Parameters.Add(database.CreateParameter("regionMapTexture", profile.regionMapTextureID)); | ||
565 | command.Parameters.Add(database.CreateParameter("serverHttpPort", profile.httpPort)); | ||
566 | command.Parameters.Add(database.CreateParameter("serverRemotingPort", profile.remotingPort)); | ||
567 | command.Parameters.Add(database.CreateParameter("owner_uuid", profile.owner_uuid)); | ||
568 | command.Parameters.Add(database.CreateParameter("originUUID", profile.originUUID)); | ||
569 | command.Parameters.Add(database.CreateParameter("access", profile.maturity)); | ||
570 | |||
571 | try | ||
572 | { | ||
573 | command.ExecuteNonQuery(); | ||
574 | returnval = true; | ||
575 | } | ||
576 | catch (Exception e) | ||
577 | { | ||
578 | m_log.Error("[GRID DB] : Error inserting region, error: " + e.Message); | ||
579 | } | ||
580 | } | ||
581 | |||
582 | return returnval; | ||
583 | } | ||
584 | |||
585 | #endregion | ||
586 | } | ||
587 | } | ||