diff options
author | Melanie | 2010-02-24 16:00:06 +0000 |
---|---|---|
committer | Melanie | 2010-02-24 16:00:06 +0000 |
commit | 92029dc171b466f4bdaf0a882426f4202f3e6162 (patch) | |
tree | 925c71d103bfe70b96945dcb0102d5f3e755b3cd /OpenSim/Data/MSSQL/MSSQLGridData.cs | |
parent | MSSQL Additions for Presence Refactor branch. Most functionality tested and w... (diff) | |
download | opensim-SC-92029dc171b466f4bdaf0a882426f4202f3e6162.zip opensim-SC-92029dc171b466f4bdaf0a882426f4202f3e6162.tar.gz opensim-SC-92029dc171b466f4bdaf0a882426f4202f3e6162.tar.bz2 opensim-SC-92029dc171b466f4bdaf0a882426f4202f3e6162.tar.xz |
Remove some obsolete files from MSSQL. Fix a missing constructor arg that
was introdiced by the latest jhurlipatch
Diffstat (limited to 'OpenSim/Data/MSSQL/MSSQLGridData.cs')
-rw-r--r-- | OpenSim/Data/MSSQL/MSSQLGridData.cs | 582 |
1 files changed, 0 insertions, 582 deletions
diff --git a/OpenSim/Data/MSSQL/MSSQLGridData.cs b/OpenSim/Data/MSSQL/MSSQLGridData.cs deleted file mode 100644 index 6adb5f3..0000000 --- a/OpenSim/Data/MSSQL/MSSQLGridData.cs +++ /dev/null | |||
@@ -1,582 +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 | private string m_connectionString; | ||
53 | |||
54 | private string m_regionsTableName = "regions"; | ||
55 | |||
56 | #region IPlugin Members | ||
57 | |||
58 | // [Obsolete("Cannot be default-initialized!")] | ||
59 | override public void Initialise() | ||
60 | { | ||
61 | m_log.Info("[GRID DB]: " + Name + " cannot be default-initialized!"); | ||
62 | throw new PluginNotInitialisedException(Name); | ||
63 | } | ||
64 | |||
65 | /// <summary> | ||
66 | /// Initialises the Grid Interface | ||
67 | /// </summary> | ||
68 | /// <param name="connectionString">connect string</param> | ||
69 | /// <remarks>use mssql_connection.ini</remarks> | ||
70 | override public void Initialise(string connectionString) | ||
71 | { | ||
72 | m_connectionString = connectionString; | ||
73 | database = new MSSQLManager(connectionString); | ||
74 | |||
75 | //New migrations check of store | ||
76 | database.CheckMigration(_migrationStore); | ||
77 | } | ||
78 | |||
79 | /// <summary> | ||
80 | /// Shuts down the grid interface | ||
81 | /// </summary> | ||
82 | override public void Dispose() | ||
83 | { | ||
84 | database = null; | ||
85 | } | ||
86 | |||
87 | /// <summary> | ||
88 | /// The name of this DB provider. | ||
89 | /// </summary> | ||
90 | /// <returns>A string containing the storage system name</returns> | ||
91 | override public string Name | ||
92 | { | ||
93 | get { return "MSSQL OpenGridData"; } | ||
94 | } | ||
95 | |||
96 | /// <summary> | ||
97 | /// Database provider version. | ||
98 | /// </summary> | ||
99 | /// <returns>A string containing the storage system version</returns> | ||
100 | override public string Version | ||
101 | { | ||
102 | get { return "0.1"; } | ||
103 | } | ||
104 | |||
105 | #endregion | ||
106 | |||
107 | #region Public override GridDataBase methods | ||
108 | |||
109 | /// <summary> | ||
110 | /// Returns a list of regions within the specified ranges | ||
111 | /// </summary> | ||
112 | /// <param name="xmin">minimum X coordinate</param> | ||
113 | /// <param name="ymin">minimum Y coordinate</param> | ||
114 | /// <param name="xmax">maximum X coordinate</param> | ||
115 | /// <param name="ymax">maximum Y coordinate</param> | ||
116 | /// <returns>null</returns> | ||
117 | /// <remarks>always return null</remarks> | ||
118 | override public RegionProfileData[] GetProfilesInRange(uint xmin, uint ymin, uint xmax, uint ymax) | ||
119 | { | ||
120 | string sql = "SELECT * FROM regions WHERE locX >= @xmin AND locX <= @xmax AND locY >= @ymin AND locY <= @ymax"; | ||
121 | using (SqlConnection conn = new SqlConnection(m_connectionString)) | ||
122 | using (SqlCommand cmd = new SqlCommand(sql, conn)) | ||
123 | { | ||
124 | cmd.Parameters.Add(database.CreateParameter("xmin", xmin)); | ||
125 | cmd.Parameters.Add(database.CreateParameter("ymin", ymin)); | ||
126 | cmd.Parameters.Add(database.CreateParameter("xmax", xmax)); | ||
127 | cmd.Parameters.Add(database.CreateParameter("ymax", ymax)); | ||
128 | |||
129 | List<RegionProfileData> rows = new List<RegionProfileData>(); | ||
130 | conn.Open(); | ||
131 | using (SqlDataReader reader = cmd.ExecuteReader()) | ||
132 | { | ||
133 | while (reader.Read()) | ||
134 | { | ||
135 | rows.Add(ReadSimRow(reader)); | ||
136 | } | ||
137 | } | ||
138 | |||
139 | if (rows.Count > 0) | ||
140 | { | ||
141 | return rows.ToArray(); | ||
142 | } | ||
143 | } | ||
144 | m_log.Info("[GRID DB] : Found no regions within range."); | ||
145 | return null; | ||
146 | } | ||
147 | |||
148 | |||
149 | /// <summary> | ||
150 | /// Returns up to maxNum profiles of regions that have a name starting with namePrefix | ||
151 | /// </summary> | ||
152 | /// <param name="namePrefix">The name to match against</param> | ||
153 | /// <param name="maxNum">Maximum number of profiles to return</param> | ||
154 | /// <returns>A list of sim profiles</returns> | ||
155 | override public List<RegionProfileData> GetRegionsByName (string namePrefix, uint maxNum) | ||
156 | { | ||
157 | string sql = "SELECT * FROM regions WHERE regionName LIKE @name"; | ||
158 | using (SqlConnection conn = new SqlConnection(m_connectionString)) | ||
159 | using (SqlCommand cmd = new SqlCommand(sql, conn)) | ||
160 | { | ||
161 | cmd.Parameters.Add(database.CreateParameter("name", namePrefix + "%")); | ||
162 | |||
163 | List<RegionProfileData> rows = new List<RegionProfileData>(); | ||
164 | conn.Open(); | ||
165 | using (SqlDataReader reader = cmd.ExecuteReader()) | ||
166 | { | ||
167 | while (rows.Count < maxNum && reader.Read()) | ||
168 | { | ||
169 | rows.Add(ReadSimRow(reader)); | ||
170 | } | ||
171 | } | ||
172 | |||
173 | return rows; | ||
174 | } | ||
175 | } | ||
176 | |||
177 | /// <summary> | ||
178 | /// Returns a sim profile from its location | ||
179 | /// </summary> | ||
180 | /// <param name="handle">Region location handle</param> | ||
181 | /// <returns>Sim profile</returns> | ||
182 | override public RegionProfileData GetProfileByHandle(ulong handle) | ||
183 | { | ||
184 | string sql = "SELECT * FROM " + m_regionsTableName + " WHERE regionHandle = @handle"; | ||
185 | using (SqlConnection conn = new SqlConnection(m_connectionString)) | ||
186 | using (SqlCommand cmd = new SqlCommand(sql, conn)) | ||
187 | { | ||
188 | cmd.Parameters.Add(database.CreateParameter("handle", handle)); | ||
189 | conn.Open(); | ||
190 | using (SqlDataReader reader = cmd.ExecuteReader()) | ||
191 | { | ||
192 | if (reader.Read()) | ||
193 | { | ||
194 | return ReadSimRow(reader); | ||
195 | } | ||
196 | } | ||
197 | } | ||
198 | m_log.InfoFormat("[GRID DB] : No region found with handle : {0}", handle); | ||
199 | return null; | ||
200 | } | ||
201 | |||
202 | /// <summary> | ||
203 | /// Returns a sim profile from its UUID | ||
204 | /// </summary> | ||
205 | /// <param name="uuid">The region UUID</param> | ||
206 | /// <returns>The sim profile</returns> | ||
207 | override public RegionProfileData GetProfileByUUID(UUID uuid) | ||
208 | { | ||
209 | string sql = "SELECT * FROM " + m_regionsTableName + " WHERE uuid = @uuid"; | ||
210 | using (SqlConnection conn = new SqlConnection(m_connectionString)) | ||
211 | using (SqlCommand cmd = new SqlCommand(sql, conn)) | ||
212 | { | ||
213 | cmd.Parameters.Add(database.CreateParameter("uuid", uuid)); | ||
214 | conn.Open(); | ||
215 | using (SqlDataReader reader = cmd.ExecuteReader()) | ||
216 | { | ||
217 | if (reader.Read()) | ||
218 | { | ||
219 | return ReadSimRow(reader); | ||
220 | } | ||
221 | } | ||
222 | } | ||
223 | m_log.InfoFormat("[GRID DB] : No region found with UUID : {0}", uuid); | ||
224 | return null; | ||
225 | } | ||
226 | |||
227 | /// <summary> | ||
228 | /// Returns a sim profile from it's Region name string | ||
229 | /// </summary> | ||
230 | /// <param name="regionName">The region name search query</param> | ||
231 | /// <returns>The sim profile</returns> | ||
232 | override public RegionProfileData GetProfileByString(string regionName) | ||
233 | { | ||
234 | if (regionName.Length > 2) | ||
235 | { | ||
236 | string sql = "SELECT top 1 * FROM " + m_regionsTableName + " WHERE regionName like @regionName order by regionName"; | ||
237 | |||
238 | using (SqlConnection conn = new SqlConnection(m_connectionString)) | ||
239 | using (SqlCommand cmd = new SqlCommand(sql, conn)) | ||
240 | { | ||
241 | cmd.Parameters.Add(database.CreateParameter("regionName", regionName + "%")); | ||
242 | conn.Open(); | ||
243 | using (SqlDataReader reader = cmd.ExecuteReader()) | ||
244 | { | ||
245 | if (reader.Read()) | ||
246 | { | ||
247 | return ReadSimRow(reader); | ||
248 | } | ||
249 | } | ||
250 | } | ||
251 | m_log.InfoFormat("[GRID DB] : No region found with regionName : {0}", regionName); | ||
252 | return null; | ||
253 | } | ||
254 | |||
255 | m_log.Error("[GRID DB]: Searched for a Region Name shorter then 3 characters"); | ||
256 | return null; | ||
257 | } | ||
258 | |||
259 | /// <summary> | ||
260 | /// Adds a new specified region to the database | ||
261 | /// </summary> | ||
262 | /// <param name="profile">The profile to add</param> | ||
263 | /// <returns>A dataresponse enum indicating success</returns> | ||
264 | override public DataResponse StoreProfile(RegionProfileData profile) | ||
265 | { | ||
266 | if (GetProfileByUUID(profile.UUID) == null) | ||
267 | { | ||
268 | if (InsertRegionRow(profile)) | ||
269 | { | ||
270 | return DataResponse.RESPONSE_OK; | ||
271 | } | ||
272 | } | ||
273 | else | ||
274 | { | ||
275 | if (UpdateRegionRow(profile)) | ||
276 | { | ||
277 | return DataResponse.RESPONSE_OK; | ||
278 | } | ||
279 | } | ||
280 | |||
281 | return DataResponse.RESPONSE_ERROR; | ||
282 | } | ||
283 | |||
284 | /// <summary> | ||
285 | /// Deletes a sim profile from the database | ||
286 | /// </summary> | ||
287 | /// <param name="uuid">the sim UUID</param> | ||
288 | /// <returns>Successful?</returns> | ||
289 | //public DataResponse DeleteProfile(RegionProfileData profile) | ||
290 | override public DataResponse DeleteProfile(string uuid) | ||
291 | { | ||
292 | string sql = "DELETE FROM regions WHERE uuid = @uuid;"; | ||
293 | |||
294 | using (SqlConnection conn = new SqlConnection(m_connectionString)) | ||
295 | using (SqlCommand cmd = new SqlCommand(sql, conn)) | ||
296 | { | ||
297 | cmd.Parameters.Add(database.CreateParameter("uuid", uuid)); | ||
298 | try | ||
299 | { | ||
300 | conn.Open(); | ||
301 | cmd.ExecuteNonQuery(); | ||
302 | return DataResponse.RESPONSE_OK; | ||
303 | } | ||
304 | catch (Exception e) | ||
305 | { | ||
306 | m_log.DebugFormat("[GRID DB] : Error deleting region info, error is : {0}", e.Message); | ||
307 | return DataResponse.RESPONSE_ERROR; | ||
308 | } | ||
309 | } | ||
310 | } | ||
311 | |||
312 | #endregion | ||
313 | |||
314 | #region Methods that are not used or deprecated (still needed because of base class) | ||
315 | |||
316 | /// <summary> | ||
317 | /// DEPRECATED. Attempts to authenticate a region by comparing a shared secret. | ||
318 | /// </summary> | ||
319 | /// <param name="uuid">The UUID of the challenger</param> | ||
320 | /// <param name="handle">The attempted regionHandle of the challenger</param> | ||
321 | /// <param name="authkey">The secret</param> | ||
322 | /// <returns>Whether the secret and regionhandle match the database entry for UUID</returns> | ||
323 | override public bool AuthenticateSim(UUID uuid, ulong handle, string authkey) | ||
324 | { | ||
325 | bool throwHissyFit = false; // Should be true by 1.0 | ||
326 | |||
327 | if (throwHissyFit) | ||
328 | throw new Exception("CRYPTOWEAK AUTHENTICATE: Refusing to authenticate due to replay potential."); | ||
329 | |||
330 | RegionProfileData data = GetProfileByUUID(uuid); | ||
331 | |||
332 | return (handle == data.regionHandle && authkey == data.regionSecret); | ||
333 | } | ||
334 | |||
335 | /// <summary> | ||
336 | /// NOT YET FUNCTIONAL. Provides a cryptographic authentication of a region | ||
337 | /// </summary> | ||
338 | /// <remarks>This requires a security audit.</remarks> | ||
339 | /// <param name="uuid"></param> | ||
340 | /// <param name="handle"></param> | ||
341 | /// <param name="authhash"></param> | ||
342 | /// <param name="challenge"></param> | ||
343 | /// <returns></returns> | ||
344 | public bool AuthenticateSim(UUID uuid, ulong handle, string authhash, string challenge) | ||
345 | { | ||
346 | // SHA512Managed HashProvider = new SHA512Managed(); | ||
347 | // Encoding TextProvider = new UTF8Encoding(); | ||
348 | |||
349 | // byte[] stream = TextProvider.GetBytes(uuid.ToString() + ":" + handle.ToString() + ":" + challenge); | ||
350 | // byte[] hash = HashProvider.ComputeHash(stream); | ||
351 | return false; | ||
352 | } | ||
353 | |||
354 | /// <summary> | ||
355 | /// NOT IMPLEMENTED | ||
356 | /// WHEN IS THIS GONNA BE IMPLEMENTED. | ||
357 | /// </summary> | ||
358 | /// <param name="x"></param> | ||
359 | /// <param name="y"></param> | ||
360 | /// <returns>null</returns> | ||
361 | override public ReservationData GetReservationAtPoint(uint x, uint y) | ||
362 | { | ||
363 | return null; | ||
364 | } | ||
365 | |||
366 | #endregion | ||
367 | |||
368 | #region private methods | ||
369 | |||
370 | /// <summary> | ||
371 | /// Reads a region row from a database reader | ||
372 | /// </summary> | ||
373 | /// <param name="reader">An active database reader</param> | ||
374 | /// <returns>A region profile</returns> | ||
375 | private static RegionProfileData ReadSimRow(IDataRecord reader) | ||
376 | { | ||
377 | RegionProfileData retval = new RegionProfileData(); | ||
378 | |||
379 | // Region Main gotta-have-or-we-return-null parts | ||
380 | UInt64 tmp64; | ||
381 | if (!UInt64.TryParse(reader["regionHandle"].ToString(), out tmp64)) | ||
382 | { | ||
383 | return null; | ||
384 | } | ||
385 | |||
386 | retval.regionHandle = tmp64; | ||
387 | |||
388 | // UUID tmp_uuid; | ||
389 | // if (!UUID.TryParse((string)reader["uuid"], out tmp_uuid)) | ||
390 | // { | ||
391 | // return null; | ||
392 | // } | ||
393 | |||
394 | retval.UUID = new UUID((Guid)reader["uuid"]); // tmp_uuid; | ||
395 | |||
396 | // non-critical parts | ||
397 | retval.regionName = reader["regionName"].ToString(); | ||
398 | retval.originUUID = new UUID((Guid)reader["originUUID"]); | ||
399 | |||
400 | // Secrets | ||
401 | retval.regionRecvKey = reader["regionRecvKey"].ToString(); | ||
402 | retval.regionSecret = reader["regionSecret"].ToString(); | ||
403 | retval.regionSendKey = reader["regionSendKey"].ToString(); | ||
404 | |||
405 | // Region Server | ||
406 | retval.regionDataURI = reader["regionDataURI"].ToString(); | ||
407 | retval.regionOnline = false; // Needs to be pinged before this can be set. | ||
408 | retval.serverIP = reader["serverIP"].ToString(); | ||
409 | retval.serverPort = Convert.ToUInt32(reader["serverPort"]); | ||
410 | retval.serverURI = reader["serverURI"].ToString(); | ||
411 | retval.httpPort = Convert.ToUInt32(reader["serverHttpPort"].ToString()); | ||
412 | retval.remotingPort = Convert.ToUInt32(reader["serverRemotingPort"].ToString()); | ||
413 | |||
414 | // Location | ||
415 | retval.regionLocX = Convert.ToUInt32(reader["locX"].ToString()); | ||
416 | retval.regionLocY = Convert.ToUInt32(reader["locY"].ToString()); | ||
417 | retval.regionLocZ = Convert.ToUInt32(reader["locZ"].ToString()); | ||
418 | |||
419 | // Neighbours - 0 = No Override | ||
420 | retval.regionEastOverrideHandle = Convert.ToUInt64(reader["eastOverrideHandle"].ToString()); | ||
421 | retval.regionWestOverrideHandle = Convert.ToUInt64(reader["westOverrideHandle"].ToString()); | ||
422 | retval.regionSouthOverrideHandle = Convert.ToUInt64(reader["southOverrideHandle"].ToString()); | ||
423 | retval.regionNorthOverrideHandle = Convert.ToUInt64(reader["northOverrideHandle"].ToString()); | ||
424 | |||
425 | // Assets | ||
426 | retval.regionAssetURI = reader["regionAssetURI"].ToString(); | ||
427 | retval.regionAssetRecvKey = reader["regionAssetRecvKey"].ToString(); | ||
428 | retval.regionAssetSendKey = reader["regionAssetSendKey"].ToString(); | ||
429 | |||
430 | // Userserver | ||
431 | retval.regionUserURI = reader["regionUserURI"].ToString(); | ||
432 | retval.regionUserRecvKey = reader["regionUserRecvKey"].ToString(); | ||
433 | retval.regionUserSendKey = reader["regionUserSendKey"].ToString(); | ||
434 | |||
435 | // World Map Addition | ||
436 | retval.regionMapTextureID = new UUID((Guid)reader["regionMapTexture"]); | ||
437 | retval.owner_uuid = new UUID((Guid)reader["owner_uuid"]); | ||
438 | retval.maturity = Convert.ToUInt32(reader["access"]); | ||
439 | return retval; | ||
440 | } | ||
441 | |||
442 | /// <summary> | ||
443 | /// Update the specified region in the database | ||
444 | /// </summary> | ||
445 | /// <param name="profile">The profile to update</param> | ||
446 | /// <returns>success ?</returns> | ||
447 | private bool UpdateRegionRow(RegionProfileData profile) | ||
448 | { | ||
449 | bool returnval = false; | ||
450 | |||
451 | //Insert new region | ||
452 | string sql = | ||
453 | "UPDATE " + m_regionsTableName + @" SET | ||
454 | [regionHandle]=@regionHandle, [regionName]=@regionName, | ||
455 | [regionRecvKey]=@regionRecvKey, [regionSecret]=@regionSecret, [regionSendKey]=@regionSendKey, | ||
456 | [regionDataURI]=@regionDataURI, [serverIP]=@serverIP, [serverPort]=@serverPort, [serverURI]=@serverURI, | ||
457 | [locX]=@locX, [locY]=@locY, [locZ]=@locZ, [eastOverrideHandle]=@eastOverrideHandle, | ||
458 | [westOverrideHandle]=@westOverrideHandle, [southOverrideHandle]=@southOverrideHandle, | ||
459 | [northOverrideHandle]=@northOverrideHandle, [regionAssetURI]=@regionAssetURI, | ||
460 | [regionAssetRecvKey]=@regionAssetRecvKey, [regionAssetSendKey]=@regionAssetSendKey, | ||
461 | [regionUserURI]=@regionUserURI, [regionUserRecvKey]=@regionUserRecvKey, [regionUserSendKey]=@regionUserSendKey, | ||
462 | [regionMapTexture]=@regionMapTexture, [serverHttpPort]=@serverHttpPort, | ||
463 | [serverRemotingPort]=@serverRemotingPort, [owner_uuid]=@owner_uuid , [originUUID]=@originUUID | ||
464 | where [uuid]=@uuid"; | ||
465 | |||
466 | using (SqlConnection conn = new SqlConnection(m_connectionString)) | ||
467 | using (SqlCommand command = new SqlCommand(sql, conn)) | ||
468 | { | ||
469 | command.Parameters.Add(database.CreateParameter("regionHandle", profile.regionHandle)); | ||
470 | command.Parameters.Add(database.CreateParameter("regionName", profile.regionName)); | ||
471 | command.Parameters.Add(database.CreateParameter("uuid", profile.UUID)); | ||
472 | command.Parameters.Add(database.CreateParameter("regionRecvKey", profile.regionRecvKey)); | ||
473 | command.Parameters.Add(database.CreateParameter("regionSecret", profile.regionSecret)); | ||
474 | command.Parameters.Add(database.CreateParameter("regionSendKey", profile.regionSendKey)); | ||
475 | command.Parameters.Add(database.CreateParameter("regionDataURI", profile.regionDataURI)); | ||
476 | command.Parameters.Add(database.CreateParameter("serverIP", profile.serverIP)); | ||
477 | command.Parameters.Add(database.CreateParameter("serverPort", profile.serverPort)); | ||
478 | command.Parameters.Add(database.CreateParameter("serverURI", profile.serverURI)); | ||
479 | command.Parameters.Add(database.CreateParameter("locX", profile.regionLocX)); | ||
480 | command.Parameters.Add(database.CreateParameter("locY", profile.regionLocY)); | ||
481 | command.Parameters.Add(database.CreateParameter("locZ", profile.regionLocZ)); | ||
482 | command.Parameters.Add(database.CreateParameter("eastOverrideHandle", profile.regionEastOverrideHandle)); | ||
483 | command.Parameters.Add(database.CreateParameter("westOverrideHandle", profile.regionWestOverrideHandle)); | ||
484 | command.Parameters.Add(database.CreateParameter("northOverrideHandle", profile.regionNorthOverrideHandle)); | ||
485 | command.Parameters.Add(database.CreateParameter("southOverrideHandle", profile.regionSouthOverrideHandle)); | ||
486 | command.Parameters.Add(database.CreateParameter("regionAssetURI", profile.regionAssetURI)); | ||
487 | command.Parameters.Add(database.CreateParameter("regionAssetRecvKey", profile.regionAssetRecvKey)); | ||
488 | command.Parameters.Add(database.CreateParameter("regionAssetSendKey", profile.regionAssetSendKey)); | ||
489 | command.Parameters.Add(database.CreateParameter("regionUserURI", profile.regionUserURI)); | ||
490 | command.Parameters.Add(database.CreateParameter("regionUserRecvKey", profile.regionUserRecvKey)); | ||
491 | command.Parameters.Add(database.CreateParameter("regionUserSendKey", profile.regionUserSendKey)); | ||
492 | command.Parameters.Add(database.CreateParameter("regionMapTexture", profile.regionMapTextureID)); | ||
493 | command.Parameters.Add(database.CreateParameter("serverHttpPort", profile.httpPort)); | ||
494 | command.Parameters.Add(database.CreateParameter("serverRemotingPort", profile.remotingPort)); | ||
495 | command.Parameters.Add(database.CreateParameter("owner_uuid", profile.owner_uuid)); | ||
496 | command.Parameters.Add(database.CreateParameter("originUUID", profile.originUUID)); | ||
497 | conn.Open(); | ||
498 | try | ||
499 | { | ||
500 | command.ExecuteNonQuery(); | ||
501 | returnval = true; | ||
502 | } | ||
503 | catch (Exception e) | ||
504 | { | ||
505 | m_log.Error("[GRID DB] : Error updating region, error: " + e.Message); | ||
506 | } | ||
507 | } | ||
508 | |||
509 | return returnval; | ||
510 | } | ||
511 | |||
512 | /// <summary> | ||
513 | /// Creates a new region in the database | ||
514 | /// </summary> | ||
515 | /// <param name="profile">The region profile to insert</param> | ||
516 | /// <returns>Successful?</returns> | ||
517 | private bool InsertRegionRow(RegionProfileData profile) | ||
518 | { | ||
519 | bool returnval = false; | ||
520 | |||
521 | //Insert new region | ||
522 | string sql = | ||
523 | "INSERT INTO " + m_regionsTableName + @" ([regionHandle], [regionName], [uuid], [regionRecvKey], [regionSecret], [regionSendKey], [regionDataURI], | ||
524 | [serverIP], [serverPort], [serverURI], [locX], [locY], [locZ], [eastOverrideHandle], [westOverrideHandle], | ||
525 | [southOverrideHandle], [northOverrideHandle], [regionAssetURI], [regionAssetRecvKey], [regionAssetSendKey], | ||
526 | [regionUserURI], [regionUserRecvKey], [regionUserSendKey], [regionMapTexture], [serverHttpPort], | ||
527 | [serverRemotingPort], [owner_uuid], [originUUID], [access]) | ||
528 | VALUES (@regionHandle, @regionName, @uuid, @regionRecvKey, @regionSecret, @regionSendKey, @regionDataURI, | ||
529 | @serverIP, @serverPort, @serverURI, @locX, @locY, @locZ, @eastOverrideHandle, @westOverrideHandle, | ||
530 | @southOverrideHandle, @northOverrideHandle, @regionAssetURI, @regionAssetRecvKey, @regionAssetSendKey, | ||
531 | @regionUserURI, @regionUserRecvKey, @regionUserSendKey, @regionMapTexture, @serverHttpPort, @serverRemotingPort, @owner_uuid, @originUUID, @access);"; | ||
532 | |||
533 | using (SqlConnection conn = new SqlConnection(m_connectionString)) | ||
534 | using (SqlCommand command = new SqlCommand(sql, conn)) | ||
535 | { | ||
536 | command.Parameters.Add(database.CreateParameter("regionHandle", profile.regionHandle)); | ||
537 | command.Parameters.Add(database.CreateParameter("regionName", profile.regionName)); | ||
538 | command.Parameters.Add(database.CreateParameter("uuid", profile.UUID)); | ||
539 | command.Parameters.Add(database.CreateParameter("regionRecvKey", profile.regionRecvKey)); | ||
540 | command.Parameters.Add(database.CreateParameter("regionSecret", profile.regionSecret)); | ||
541 | command.Parameters.Add(database.CreateParameter("regionSendKey", profile.regionSendKey)); | ||
542 | command.Parameters.Add(database.CreateParameter("regionDataURI", profile.regionDataURI)); | ||
543 | command.Parameters.Add(database.CreateParameter("serverIP", profile.serverIP)); | ||
544 | command.Parameters.Add(database.CreateParameter("serverPort", profile.serverPort)); | ||
545 | command.Parameters.Add(database.CreateParameter("serverURI", profile.serverURI)); | ||
546 | command.Parameters.Add(database.CreateParameter("locX", profile.regionLocX)); | ||
547 | command.Parameters.Add(database.CreateParameter("locY", profile.regionLocY)); | ||
548 | command.Parameters.Add(database.CreateParameter("locZ", profile.regionLocZ)); | ||
549 | command.Parameters.Add(database.CreateParameter("eastOverrideHandle", profile.regionEastOverrideHandle)); | ||
550 | command.Parameters.Add(database.CreateParameter("westOverrideHandle", profile.regionWestOverrideHandle)); | ||
551 | command.Parameters.Add(database.CreateParameter("northOverrideHandle", profile.regionNorthOverrideHandle)); | ||
552 | command.Parameters.Add(database.CreateParameter("southOverrideHandle", profile.regionSouthOverrideHandle)); | ||
553 | command.Parameters.Add(database.CreateParameter("regionAssetURI", profile.regionAssetURI)); | ||
554 | command.Parameters.Add(database.CreateParameter("regionAssetRecvKey", profile.regionAssetRecvKey)); | ||
555 | command.Parameters.Add(database.CreateParameter("regionAssetSendKey", profile.regionAssetSendKey)); | ||
556 | command.Parameters.Add(database.CreateParameter("regionUserURI", profile.regionUserURI)); | ||
557 | command.Parameters.Add(database.CreateParameter("regionUserRecvKey", profile.regionUserRecvKey)); | ||
558 | command.Parameters.Add(database.CreateParameter("regionUserSendKey", profile.regionUserSendKey)); | ||
559 | command.Parameters.Add(database.CreateParameter("regionMapTexture", profile.regionMapTextureID)); | ||
560 | command.Parameters.Add(database.CreateParameter("serverHttpPort", profile.httpPort)); | ||
561 | command.Parameters.Add(database.CreateParameter("serverRemotingPort", profile.remotingPort)); | ||
562 | command.Parameters.Add(database.CreateParameter("owner_uuid", profile.owner_uuid)); | ||
563 | command.Parameters.Add(database.CreateParameter("originUUID", profile.originUUID)); | ||
564 | command.Parameters.Add(database.CreateParameter("access", profile.maturity)); | ||
565 | conn.Open(); | ||
566 | try | ||
567 | { | ||
568 | command.ExecuteNonQuery(); | ||
569 | returnval = true; | ||
570 | } | ||
571 | catch (Exception e) | ||
572 | { | ||
573 | m_log.Error("[GRID DB] : Error inserting region, error: " + e.Message); | ||
574 | } | ||
575 | } | ||
576 | |||
577 | return returnval; | ||
578 | } | ||
579 | |||
580 | #endregion | ||
581 | } | ||
582 | } | ||