aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorAdam Frisby2007-06-01 23:53:02 +0000
committerAdam Frisby2007-06-01 23:53:02 +0000
commit14babaaeceded845f7dc88c03b145a43c799d47a (patch)
tree23345f630ac0cfe3510e7a64ccf13c65cf17282f
parent* DB4o Storage provider is now well documented (diff)
downloadopensim-SC_OLD-14babaaeceded845f7dc88c03b145a43c799d47a.zip
opensim-SC_OLD-14babaaeceded845f7dc88c03b145a43c799d47a.tar.gz
opensim-SC_OLD-14babaaeceded845f7dc88c03b145a43c799d47a.tar.bz2
opensim-SC_OLD-14babaaeceded845f7dc88c03b145a43c799d47a.tar.xz
* MS-SQL Interface is now well documented (and probably defunct)
-rw-r--r--OpenGridServices/OpenGrid.Framework.Data.MSSQL/MSSQLGridData.cs53
-rw-r--r--OpenGridServices/OpenGrid.Framework.Data.MSSQL/MSSQLManager.cs88
2 files changed, 115 insertions, 26 deletions
diff --git a/OpenGridServices/OpenGrid.Framework.Data.MSSQL/MSSQLGridData.cs b/OpenGridServices/OpenGrid.Framework.Data.MSSQL/MSSQLGridData.cs
index 0925df1..8362a1d 100644
--- a/OpenGridServices/OpenGrid.Framework.Data.MSSQL/MSSQLGridData.cs
+++ b/OpenGridServices/OpenGrid.Framework.Data.MSSQL/MSSQLGridData.cs
@@ -1,3 +1,29 @@
1/*
2* Copyright (c) OpenSim project, http://sim.opensecondlife.org/
3*
4* Redistribution and use in source and binary forms, with or without
5* modification, are permitted provided that the following conditions are met:
6* * Redistributions of source code must retain the above copyright
7* notice, this list of conditions and the following disclaimer.
8* * Redistributions in binary form must reproduce the above copyright
9* notice, this list of conditions and the following disclaimer in the
10* documentation and/or other materials provided with the distribution.
11* * Neither the name of the <organization> nor the
12* names of its contributors may be used to endorse or promote products
13* derived from this software without specific prior written permission.
14*
15* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
16* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18* DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY
19* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25*
26*/
1using System; 27using System;
2using System.Collections.Generic; 28using System.Collections.Generic;
3using System.Text; 29using System.Text;
@@ -5,8 +31,14 @@ using OpenGrid.Framework.Data;
5 31
6namespace OpenGrid.Framework.Data.MSSQL 32namespace OpenGrid.Framework.Data.MSSQL
7{ 33{
34 /// <summary>
35 /// A grid data interface for Microsoft SQL Server
36 /// </summary>
8 public class SqlGridData : IGridData 37 public class SqlGridData : IGridData
9 { 38 {
39 /// <summary>
40 /// Database manager
41 /// </summary>
10 private MSSqlManager database; 42 private MSSqlManager database;
11 43
12 /// <summary> 44 /// <summary>
@@ -25,16 +57,32 @@ namespace OpenGrid.Framework.Data.MSSQL
25 database.Close(); 57 database.Close();
26 } 58 }
27 59
60 /// <summary>
61 /// Returns the storage system name
62 /// </summary>
63 /// <returns>A string containing the storage system name</returns>
28 public string getName() 64 public string getName()
29 { 65 {
30 return "Sql OpenGridData"; 66 return "Sql OpenGridData";
31 } 67 }
32 68
69 /// <summary>
70 /// Returns the storage system version
71 /// </summary>
72 /// <returns>A string containing the storage system version</returns>
33 public string getVersion() 73 public string getVersion()
34 { 74 {
35 return "0.1"; 75 return "0.1";
36 } 76 }
37 77
78 /// <summary>
79 /// Returns a list of regions within the specified ranges
80 /// </summary>
81 /// <param name="a">minimum X coordinate</param>
82 /// <param name="b">minimum Y coordinate</param>
83 /// <param name="c">maximum X coordinate</param>
84 /// <param name="d">maximum Y coordinate</param>
85 /// <returns>An array of region profiles</returns>
38 public SimProfileData[] GetProfilesInRange(uint a, uint b, uint c, uint d) 86 public SimProfileData[] GetProfilesInRange(uint a, uint b, uint c, uint d)
39 { 87 {
40 return null; 88 return null;
@@ -80,6 +128,11 @@ namespace OpenGrid.Framework.Data.MSSQL
80 return row; 128 return row;
81 } 129 }
82 130
131 /// <summary>
132 /// Adds a new specified region to the database
133 /// </summary>
134 /// <param name="profile">The profile to add</param>
135 /// <returns>A dataresponse enum indicating success</returns>
83 public DataResponse AddProfile(SimProfileData profile) 136 public DataResponse AddProfile(SimProfileData profile)
84 { 137 {
85 if (database.insertRow(profile)) 138 if (database.insertRow(profile))
diff --git a/OpenGridServices/OpenGrid.Framework.Data.MSSQL/MSSQLManager.cs b/OpenGridServices/OpenGrid.Framework.Data.MSSQL/MSSQLManager.cs
index 12c166c..36d5744 100644
--- a/OpenGridServices/OpenGrid.Framework.Data.MSSQL/MSSQLManager.cs
+++ b/OpenGridServices/OpenGrid.Framework.Data.MSSQL/MSSQLManager.cs
@@ -1,3 +1,29 @@
1/*
2* Copyright (c) OpenSim project, http://sim.opensecondlife.org/
3*
4* Redistribution and use in source and binary forms, with or without
5* modification, are permitted provided that the following conditions are met:
6* * Redistributions of source code must retain the above copyright
7* notice, this list of conditions and the following disclaimer.
8* * Redistributions in binary form must reproduce the above copyright
9* notice, this list of conditions and the following disclaimer in the
10* documentation and/or other materials provided with the distribution.
11* * Neither the name of the <organization> nor the
12* names of its contributors may be used to endorse or promote products
13* derived from this software without specific prior written permission.
14*
15* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
16* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18* DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY
19* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25*
26*/
1using System; 27using System;
2using System.Collections.Generic; 28using System.Collections.Generic;
3using System.Text; 29using System.Text;
@@ -63,57 +89,67 @@ namespace OpenGrid.Framework.Data.MSSQL
63 return (IDbCommand)dbcommand; 89 return (IDbCommand)dbcommand;
64 } 90 }
65 91
92 /// <summary>
93 /// Runs a database reader object and returns a region row
94 /// </summary>
95 /// <param name="reader">An active database reader</param>
96 /// <returns>A region row</returns>
66 public SimProfileData getRow(IDataReader reader) 97 public SimProfileData getRow(IDataReader reader)
67 { 98 {
68 SimProfileData retval = new SimProfileData(); 99 SimProfileData regionprofile = new SimProfileData();
69 100
70 if (reader.Read()) 101 if (reader.Read())
71 { 102 {
72 // Region Main 103 // Region Main
73 retval.regionHandle = (ulong)reader["regionHandle"]; 104 regionprofile.regionHandle = (ulong)reader["regionHandle"];
74 retval.regionName = (string)reader["regionName"]; 105 regionprofile.regionName = (string)reader["regionName"];
75 retval.UUID = new libsecondlife.LLUUID((string)reader["uuid"]); 106 regionprofile.UUID = new libsecondlife.LLUUID((string)reader["uuid"]);
76 107
77 // Secrets 108 // Secrets
78 retval.regionRecvKey = (string)reader["regionRecvKey"]; 109 regionprofile.regionRecvKey = (string)reader["regionRecvKey"];
79 retval.regionSecret = (string)reader["regionSecret"]; 110 regionprofile.regionSecret = (string)reader["regionSecret"];
80 retval.regionSendKey = (string)reader["regionSendKey"]; 111 regionprofile.regionSendKey = (string)reader["regionSendKey"];
81 112
82 // Region Server 113 // Region Server
83 retval.regionDataURI = (string)reader["regionDataURI"]; 114 regionprofile.regionDataURI = (string)reader["regionDataURI"];
84 retval.regionOnline = false; // Needs to be pinged before this can be set. 115 regionprofile.regionOnline = false; // Needs to be pinged before this can be set.
85 retval.serverIP = (string)reader["serverIP"]; 116 regionprofile.serverIP = (string)reader["serverIP"];
86 retval.serverPort = (uint)reader["serverPort"]; 117 regionprofile.serverPort = (uint)reader["serverPort"];
87 retval.serverURI = (string)reader["serverURI"]; 118 regionprofile.serverURI = (string)reader["serverURI"];
88 119
89 // Location 120 // Location
90 retval.regionLocX = (uint)((int)reader["locX"]); 121 regionprofile.regionLocX = (uint)((int)reader["locX"]);
91 retval.regionLocY = (uint)((int)reader["locY"]); 122 regionprofile.regionLocY = (uint)((int)reader["locY"]);
92 retval.regionLocZ = (uint)((int)reader["locZ"]); 123 regionprofile.regionLocZ = (uint)((int)reader["locZ"]);
93 124
94 // Neighbours - 0 = No Override 125 // Neighbours - 0 = No Override
95 retval.regionEastOverrideHandle = (ulong)reader["eastOverrideHandle"]; 126 regionprofile.regionEastOverrideHandle = (ulong)reader["eastOverrideHandle"];
96 retval.regionWestOverrideHandle = (ulong)reader["westOverrideHandle"]; 127 regionprofile.regionWestOverrideHandle = (ulong)reader["westOverrideHandle"];
97 retval.regionSouthOverrideHandle = (ulong)reader["southOverrideHandle"]; 128 regionprofile.regionSouthOverrideHandle = (ulong)reader["southOverrideHandle"];
98 retval.regionNorthOverrideHandle = (ulong)reader["northOverrideHandle"]; 129 regionprofile.regionNorthOverrideHandle = (ulong)reader["northOverrideHandle"];
99 130
100 // Assets 131 // Assets
101 retval.regionAssetURI = (string)reader["regionAssetURI"]; 132 regionprofile.regionAssetURI = (string)reader["regionAssetURI"];
102 retval.regionAssetRecvKey = (string)reader["regionAssetRecvKey"]; 133 regionprofile.regionAssetRecvKey = (string)reader["regionAssetRecvKey"];
103 retval.regionAssetSendKey = (string)reader["regionAssetSendKey"]; 134 regionprofile.regionAssetSendKey = (string)reader["regionAssetSendKey"];
104 135
105 // Userserver 136 // Userserver
106 retval.regionUserURI = (string)reader["regionUserURI"]; 137 regionprofile.regionUserURI = (string)reader["regionUserURI"];
107 retval.regionUserRecvKey = (string)reader["regionUserRecvKey"]; 138 regionprofile.regionUserRecvKey = (string)reader["regionUserRecvKey"];
108 retval.regionUserSendKey = (string)reader["regionUserSendKey"]; 139 regionprofile.regionUserSendKey = (string)reader["regionUserSendKey"];
109 } 140 }
110 else 141 else
111 { 142 {
112 throw new Exception("No rows to return"); 143 throw new Exception("No rows to return");
113 } 144 }
114 return retval; 145 return regionprofile;
115 } 146 }
116 147
148 /// <summary>
149 /// Creates a new region in the database
150 /// </summary>
151 /// <param name="profile">The region profile to insert</param>
152 /// <returns>Successful?</returns>
117 public bool insertRow(SimProfileData profile) 153 public bool insertRow(SimProfileData profile)
118 { 154 {
119 string sql = "REPLACE INTO regions VALUES (regionHandle, regionName, uuid, regionRecvKey, regionSecret, regionSendKey, regionDataURI, "; 155 string sql = "REPLACE INTO regions VALUES (regionHandle, regionName, uuid, regionRecvKey, regionSecret, regionSendKey, regionDataURI, ";