MSSQLGridData.cs 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587
  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. 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 StoreProfile(RegionProfileData profile)
  242. {
  243. if (GetProfileByUUID(profile.UUID) == null)
  244. {
  245. if (InsertRegionRow(profile))
  246. {
  247. return DataResponse.RESPONSE_OK;
  248. }
  249. }
  250. else
  251. {
  252. if (UpdateRegionRow(profile))
  253. {
  254. return DataResponse.RESPONSE_OK;
  255. }
  256. }
  257. return DataResponse.RESPONSE_ERROR;
  258. }
  259. /// <summary>
  260. /// Deletes a sim profile from the database
  261. /// </summary>
  262. /// <param name="uuid">the sim UUID</param>
  263. /// <returns>Successful?</returns>
  264. //public DataResponse DeleteProfile(RegionProfileData profile)
  265. override public DataResponse DeleteProfile(string uuid)
  266. {
  267. using (AutoClosingSqlCommand command = database.Query("DELETE FROM regions WHERE uuid = @uuid;"))
  268. {
  269. command.Parameters.Add(database.CreateParameter("uuid", uuid));
  270. try
  271. {
  272. command.ExecuteNonQuery();
  273. return DataResponse.RESPONSE_OK;
  274. }
  275. catch (Exception e)
  276. {
  277. m_log.DebugFormat("[GRID DB] : Error deleting region info, error is : {0}", e.Message);
  278. return DataResponse.RESPONSE_ERROR;
  279. }
  280. }
  281. }
  282. #endregion
  283. #region Methods that are not used or deprecated (still needed because of base class)
  284. /// <summary>
  285. /// DEPRECATED. Attempts to authenticate a region by comparing a shared secret.
  286. /// </summary>
  287. /// <param name="uuid">The UUID of the challenger</param>
  288. /// <param name="handle">The attempted regionHandle of the challenger</param>
  289. /// <param name="authkey">The secret</param>
  290. /// <returns>Whether the secret and regionhandle match the database entry for UUID</returns>
  291. override public bool AuthenticateSim(UUID uuid, ulong handle, string authkey)
  292. {
  293. bool throwHissyFit = false; // Should be true by 1.0
  294. if (throwHissyFit)
  295. throw new Exception("CRYPTOWEAK AUTHENTICATE: Refusing to authenticate due to replay potential.");
  296. RegionProfileData data = GetProfileByUUID(uuid);
  297. return (handle == data.regionHandle && authkey == data.regionSecret);
  298. }
  299. /// <summary>
  300. /// NOT YET FUNCTIONAL. Provides a cryptographic authentication of a region
  301. /// </summary>
  302. /// <remarks>This requires a security audit.</remarks>
  303. /// <param name="uuid"></param>
  304. /// <param name="handle"></param>
  305. /// <param name="authhash"></param>
  306. /// <param name="challenge"></param>
  307. /// <returns></returns>
  308. public bool AuthenticateSim(UUID uuid, ulong handle, string authhash, string challenge)
  309. {
  310. // SHA512Managed HashProvider = new SHA512Managed();
  311. // Encoding TextProvider = new UTF8Encoding();
  312. // byte[] stream = TextProvider.GetBytes(uuid.ToString() + ":" + handle.ToString() + ":" + challenge);
  313. // byte[] hash = HashProvider.ComputeHash(stream);
  314. return false;
  315. }
  316. /// <summary>
  317. /// NOT IMPLEMENTED
  318. /// WHEN IS THIS GONNA BE IMPLEMENTED.
  319. /// </summary>
  320. /// <param name="x"></param>
  321. /// <param name="y"></param>
  322. /// <returns>null</returns>
  323. override public ReservationData GetReservationAtPoint(uint x, uint y)
  324. {
  325. return null;
  326. }
  327. #endregion
  328. #region private methods
  329. /// <summary>
  330. /// Reads a region row from a database reader
  331. /// </summary>
  332. /// <param name="reader">An active database reader</param>
  333. /// <returns>A region profile</returns>
  334. private static RegionProfileData ReadSimRow(IDataRecord reader)
  335. {
  336. RegionProfileData retval = new RegionProfileData();
  337. // Region Main gotta-have-or-we-return-null parts
  338. UInt64 tmp64;
  339. if (!UInt64.TryParse(reader["regionHandle"].ToString(), out tmp64))
  340. {
  341. return null;
  342. }
  343. retval.regionHandle = tmp64;
  344. // UUID tmp_uuid;
  345. // if (!UUID.TryParse((string)reader["uuid"], out tmp_uuid))
  346. // {
  347. // return null;
  348. // }
  349. retval.UUID = new UUID((Guid)reader["uuid"]); // tmp_uuid;
  350. // non-critical parts
  351. retval.regionName = reader["regionName"].ToString();
  352. retval.originUUID = new UUID((Guid)reader["originUUID"]);
  353. // Secrets
  354. retval.regionRecvKey = reader["regionRecvKey"].ToString();
  355. retval.regionSecret = reader["regionSecret"].ToString();
  356. retval.regionSendKey = reader["regionSendKey"].ToString();
  357. // Region Server
  358. retval.regionDataURI = reader["regionDataURI"].ToString();
  359. retval.regionOnline = false; // Needs to be pinged before this can be set.
  360. retval.serverIP = reader["serverIP"].ToString();
  361. retval.serverPort = Convert.ToUInt32(reader["serverPort"]);
  362. retval.serverURI = reader["serverURI"].ToString();
  363. retval.httpPort = Convert.ToUInt32(reader["serverHttpPort"].ToString());
  364. retval.remotingPort = Convert.ToUInt32(reader["serverRemotingPort"].ToString());
  365. // Location
  366. retval.regionLocX = Convert.ToUInt32(reader["locX"].ToString());
  367. retval.regionLocY = Convert.ToUInt32(reader["locY"].ToString());
  368. retval.regionLocZ = Convert.ToUInt32(reader["locZ"].ToString());
  369. // Neighbours - 0 = No Override
  370. retval.regionEastOverrideHandle = Convert.ToUInt64(reader["eastOverrideHandle"].ToString());
  371. retval.regionWestOverrideHandle = Convert.ToUInt64(reader["westOverrideHandle"].ToString());
  372. retval.regionSouthOverrideHandle = Convert.ToUInt64(reader["southOverrideHandle"].ToString());
  373. retval.regionNorthOverrideHandle = Convert.ToUInt64(reader["northOverrideHandle"].ToString());
  374. // Assets
  375. retval.regionAssetURI = reader["regionAssetURI"].ToString();
  376. retval.regionAssetRecvKey = reader["regionAssetRecvKey"].ToString();
  377. retval.regionAssetSendKey = reader["regionAssetSendKey"].ToString();
  378. // Userserver
  379. retval.regionUserURI = reader["regionUserURI"].ToString();
  380. retval.regionUserRecvKey = reader["regionUserRecvKey"].ToString();
  381. retval.regionUserSendKey = reader["regionUserSendKey"].ToString();
  382. // World Map Addition
  383. retval.regionMapTextureID = new UUID((Guid)reader["regionMapTexture"]);
  384. retval.owner_uuid = new UUID((Guid)reader["owner_uuid"]);
  385. retval.maturity = Convert.ToUInt32(reader["access"]);
  386. return retval;
  387. }
  388. /// <summary>
  389. /// Update the specified region in the database
  390. /// </summary>
  391. /// <param name="profile">The profile to update</param>
  392. /// <returns>success ?</returns>
  393. private bool UpdateRegionRow(RegionProfileData profile)
  394. {
  395. bool returnval = false;
  396. //Insert new region
  397. string sql =
  398. "UPDATE " + m_regionsTableName + @" SET
  399. [regionHandle]=@regionHandle, [regionName]=@regionName,
  400. [regionRecvKey]=@regionRecvKey, [regionSecret]=@regionSecret, [regionSendKey]=@regionSendKey,
  401. [regionDataURI]=@regionDataURI, [serverIP]=@serverIP, [serverPort]=@serverPort, [serverURI]=@serverURI,
  402. [locX]=@locX, [locY]=@locY, [locZ]=@locZ, [eastOverrideHandle]=@eastOverrideHandle,
  403. [westOverrideHandle]=@westOverrideHandle, [southOverrideHandle]=@southOverrideHandle,
  404. [northOverrideHandle]=@northOverrideHandle, [regionAssetURI]=@regionAssetURI,
  405. [regionAssetRecvKey]=@regionAssetRecvKey, [regionAssetSendKey]=@regionAssetSendKey,
  406. [regionUserURI]=@regionUserURI, [regionUserRecvKey]=@regionUserRecvKey, [regionUserSendKey]=@regionUserSendKey,
  407. [regionMapTexture]=@regionMapTexture, [serverHttpPort]=@serverHttpPort,
  408. [serverRemotingPort]=@serverRemotingPort, [owner_uuid]=@owner_uuid , [originUUID]=@originUUID
  409. where [uuid]=@uuid";
  410. using (AutoClosingSqlCommand command = database.Query(sql))
  411. {
  412. command.Parameters.Add(database.CreateParameter("regionHandle", profile.regionHandle));
  413. command.Parameters.Add(database.CreateParameter("regionName", profile.regionName));
  414. command.Parameters.Add(database.CreateParameter("uuid", profile.UUID));
  415. command.Parameters.Add(database.CreateParameter("regionRecvKey", profile.regionRecvKey));
  416. command.Parameters.Add(database.CreateParameter("regionSecret", profile.regionSecret));
  417. command.Parameters.Add(database.CreateParameter("regionSendKey", profile.regionSendKey));
  418. command.Parameters.Add(database.CreateParameter("regionDataURI", profile.regionDataURI));
  419. command.Parameters.Add(database.CreateParameter("serverIP", profile.serverIP));
  420. command.Parameters.Add(database.CreateParameter("serverPort", profile.serverPort));
  421. command.Parameters.Add(database.CreateParameter("serverURI", profile.serverURI));
  422. command.Parameters.Add(database.CreateParameter("locX", profile.regionLocX));
  423. command.Parameters.Add(database.CreateParameter("locY", profile.regionLocY));
  424. command.Parameters.Add(database.CreateParameter("locZ", profile.regionLocZ));
  425. command.Parameters.Add(database.CreateParameter("eastOverrideHandle", profile.regionEastOverrideHandle));
  426. command.Parameters.Add(database.CreateParameter("westOverrideHandle", profile.regionWestOverrideHandle));
  427. command.Parameters.Add(database.CreateParameter("northOverrideHandle", profile.regionNorthOverrideHandle));
  428. command.Parameters.Add(database.CreateParameter("southOverrideHandle", profile.regionSouthOverrideHandle));
  429. command.Parameters.Add(database.CreateParameter("regionAssetURI", profile.regionAssetURI));
  430. command.Parameters.Add(database.CreateParameter("regionAssetRecvKey", profile.regionAssetRecvKey));
  431. command.Parameters.Add(database.CreateParameter("regionAssetSendKey", profile.regionAssetSendKey));
  432. command.Parameters.Add(database.CreateParameter("regionUserURI", profile.regionUserURI));
  433. command.Parameters.Add(database.CreateParameter("regionUserRecvKey", profile.regionUserRecvKey));
  434. command.Parameters.Add(database.CreateParameter("regionUserSendKey", profile.regionUserSendKey));
  435. command.Parameters.Add(database.CreateParameter("regionMapTexture", profile.regionMapTextureID));
  436. command.Parameters.Add(database.CreateParameter("serverHttpPort", profile.httpPort));
  437. command.Parameters.Add(database.CreateParameter("serverRemotingPort", profile.remotingPort));
  438. command.Parameters.Add(database.CreateParameter("owner_uuid", profile.owner_uuid));
  439. command.Parameters.Add(database.CreateParameter("originUUID", profile.originUUID));
  440. try
  441. {
  442. command.ExecuteNonQuery();
  443. returnval = true;
  444. }
  445. catch (Exception e)
  446. {
  447. m_log.Error("[GRID DB] : Error updating region, error: " + e.Message);
  448. }
  449. }
  450. return returnval;
  451. }
  452. /// <summary>
  453. /// Creates a new region in the database
  454. /// </summary>
  455. /// <param name="profile">The region profile to insert</param>
  456. /// <returns>Successful?</returns>
  457. private bool InsertRegionRow(RegionProfileData profile)
  458. {
  459. bool returnval = false;
  460. //Insert new region
  461. string sql =
  462. "INSERT INTO " + m_regionsTableName + @" ([regionHandle], [regionName], [uuid], [regionRecvKey], [regionSecret], [regionSendKey], [regionDataURI],
  463. [serverIP], [serverPort], [serverURI], [locX], [locY], [locZ], [eastOverrideHandle], [westOverrideHandle],
  464. [southOverrideHandle], [northOverrideHandle], [regionAssetURI], [regionAssetRecvKey], [regionAssetSendKey],
  465. [regionUserURI], [regionUserRecvKey], [regionUserSendKey], [regionMapTexture], [serverHttpPort],
  466. [serverRemotingPort], [owner_uuid], [originUUID], [access])
  467. VALUES (@regionHandle, @regionName, @uuid, @regionRecvKey, @regionSecret, @regionSendKey, @regionDataURI,
  468. @serverIP, @serverPort, @serverURI, @locX, @locY, @locZ, @eastOverrideHandle, @westOverrideHandle,
  469. @southOverrideHandle, @northOverrideHandle, @regionAssetURI, @regionAssetRecvKey, @regionAssetSendKey,
  470. @regionUserURI, @regionUserRecvKey, @regionUserSendKey, @regionMapTexture, @serverHttpPort, @serverRemotingPort, @owner_uuid, @originUUID, @access);";
  471. using (AutoClosingSqlCommand command = database.Query(sql))
  472. {
  473. command.Parameters.Add(database.CreateParameter("regionHandle", profile.regionHandle));
  474. command.Parameters.Add(database.CreateParameter("regionName", profile.regionName));
  475. command.Parameters.Add(database.CreateParameter("uuid", profile.UUID));
  476. command.Parameters.Add(database.CreateParameter("regionRecvKey", profile.regionRecvKey));
  477. command.Parameters.Add(database.CreateParameter("regionSecret", profile.regionSecret));
  478. command.Parameters.Add(database.CreateParameter("regionSendKey", profile.regionSendKey));
  479. command.Parameters.Add(database.CreateParameter("regionDataURI", profile.regionDataURI));
  480. command.Parameters.Add(database.CreateParameter("serverIP", profile.serverIP));
  481. command.Parameters.Add(database.CreateParameter("serverPort", profile.serverPort));
  482. command.Parameters.Add(database.CreateParameter("serverURI", profile.serverURI));
  483. command.Parameters.Add(database.CreateParameter("locX", profile.regionLocX));
  484. command.Parameters.Add(database.CreateParameter("locY", profile.regionLocY));
  485. command.Parameters.Add(database.CreateParameter("locZ", profile.regionLocZ));
  486. command.Parameters.Add(database.CreateParameter("eastOverrideHandle", profile.regionEastOverrideHandle));
  487. command.Parameters.Add(database.CreateParameter("westOverrideHandle", profile.regionWestOverrideHandle));
  488. command.Parameters.Add(database.CreateParameter("northOverrideHandle", profile.regionNorthOverrideHandle));
  489. command.Parameters.Add(database.CreateParameter("southOverrideHandle", profile.regionSouthOverrideHandle));
  490. command.Parameters.Add(database.CreateParameter("regionAssetURI", profile.regionAssetURI));
  491. command.Parameters.Add(database.CreateParameter("regionAssetRecvKey", profile.regionAssetRecvKey));
  492. command.Parameters.Add(database.CreateParameter("regionAssetSendKey", profile.regionAssetSendKey));
  493. command.Parameters.Add(database.CreateParameter("regionUserURI", profile.regionUserURI));
  494. command.Parameters.Add(database.CreateParameter("regionUserRecvKey", profile.regionUserRecvKey));
  495. command.Parameters.Add(database.CreateParameter("regionUserSendKey", profile.regionUserSendKey));
  496. command.Parameters.Add(database.CreateParameter("regionMapTexture", profile.regionMapTextureID));
  497. command.Parameters.Add(database.CreateParameter("serverHttpPort", profile.httpPort));
  498. command.Parameters.Add(database.CreateParameter("serverRemotingPort", profile.remotingPort));
  499. command.Parameters.Add(database.CreateParameter("owner_uuid", profile.owner_uuid));
  500. command.Parameters.Add(database.CreateParameter("originUUID", profile.originUUID));
  501. command.Parameters.Add(database.CreateParameter("access", profile.maturity));
  502. try
  503. {
  504. command.ExecuteNonQuery();
  505. returnval = true;
  506. }
  507. catch (Exception e)
  508. {
  509. m_log.Error("[GRID DB] : Error inserting region, error: " + e.Message);
  510. }
  511. }
  512. return returnval;
  513. }
  514. #endregion
  515. }
  516. }