MSSQLGridData.cs 28 KB

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