aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenGrid.Framework.Data.MySQL/MySQLManager.cs
diff options
context:
space:
mode:
authorAdam Frisby2007-05-13 14:59:24 +0000
committerAdam Frisby2007-05-13 14:59:24 +0000
commitb1101797307504cfc2eea6317d4c4dc2b5964480 (patch)
tree35d7ec88ff9ce0171260ba7166bc6cb3c1fcbb4d /OpenGrid.Framework.Data.MySQL/MySQLManager.cs
parentInventory should be working again in sandbox mode (diff)
downloadopensim-SC_OLD-b1101797307504cfc2eea6317d4c4dc2b5964480.zip
opensim-SC_OLD-b1101797307504cfc2eea6317d4c4dc2b5964480.tar.gz
opensim-SC_OLD-b1101797307504cfc2eea6317d4c4dc2b5964480.tar.bz2
opensim-SC_OLD-b1101797307504cfc2eea6317d4c4dc2b5964480.tar.xz
* Fixed MySQL Grid Manager
* Added preliminary support for DB UserServer (incomplete) * Added better handling of defaults to Grid Manager. * Renamed SQL/regions.sql to SQL/mysql-regions.sql.
Diffstat (limited to '')
-rw-r--r--OpenGrid.Framework.Data.MySQL/MySQLManager.cs109
1 files changed, 62 insertions, 47 deletions
diff --git a/OpenGrid.Framework.Data.MySQL/MySQLManager.cs b/OpenGrid.Framework.Data.MySQL/MySQLManager.cs
index d3bfa18..7461b14 100644
--- a/OpenGrid.Framework.Data.MySQL/MySQLManager.cs
+++ b/OpenGrid.Framework.Data.MySQL/MySQLManager.cs
@@ -29,7 +29,7 @@ namespace OpenGrid.Framework.Data.MySQL
29 { 29 {
30 try 30 try
31 { 31 {
32 string connectionString = "Server=" + hostname + ";Database=" + database + ";User ID=" + username + ";Password=" + password + ";Pooling=" + cpooling + ";"; 32 string connectionString = "Server=" + hostname + ";Port=13306;Database=" + database + ";User ID=" + username + ";Password=" + password + ";Pooling=" + cpooling + ";";
33 dbcon = new MySqlConnection(connectionString); 33 dbcon = new MySqlConnection(connectionString);
34 34
35 dbcon.Open(); 35 dbcon.Open();
@@ -57,24 +57,32 @@ namespace OpenGrid.Framework.Data.MySQL
57 /// <returns>A MySQL DB Command</returns> 57 /// <returns>A MySQL DB Command</returns>
58 public IDbCommand Query(string sql, Dictionary<string, string> parameters) 58 public IDbCommand Query(string sql, Dictionary<string, string> parameters)
59 { 59 {
60 MySqlCommand dbcommand = (MySqlCommand)dbcon.CreateCommand(); 60 try
61 dbcommand.CommandText = sql;
62 foreach (KeyValuePair<string, string> param in parameters)
63 { 61 {
64 dbcommand.Parameters.Add(param.Key, param.Value); 62 MySqlCommand dbcommand = (MySqlCommand)dbcon.CreateCommand();
63 dbcommand.CommandText = sql;
64 foreach (KeyValuePair<string, string> param in parameters)
65 {
66 dbcommand.Parameters.Add(param.Key, param.Value);
67 }
68
69 return (IDbCommand)dbcommand;
70 }
71 catch (Exception e)
72 {
73 Console.WriteLine("Failed during Query generation: " + e.ToString());
74 return null;
65 } 75 }
66
67 return (IDbCommand)dbcommand;
68 } 76 }
69 77
70 public SimProfileData getRow(IDataReader reader) 78 public SimProfileData getSimRow(IDataReader reader)
71 { 79 {
72 SimProfileData retval = new SimProfileData(); 80 SimProfileData retval = new SimProfileData();
73 81
74 if (reader.Read()) 82 if (reader.Read())
75 { 83 {
76 // Region Main 84 // Region Main
77 retval.regionHandle = (ulong)reader["regionHandle"]; 85 retval.regionHandle = Convert.ToUInt64(reader["regionHandle"].ToString());
78 retval.regionName = (string)reader["regionName"]; 86 retval.regionName = (string)reader["regionName"];
79 retval.UUID = new libsecondlife.LLUUID((string)reader["uuid"]); 87 retval.UUID = new libsecondlife.LLUUID((string)reader["uuid"]);
80 88
@@ -91,15 +99,15 @@ namespace OpenGrid.Framework.Data.MySQL
91 retval.serverURI = (string)reader["serverURI"]; 99 retval.serverURI = (string)reader["serverURI"];
92 100
93 // Location 101 // Location
94 retval.regionLocX = (uint)((int)reader["locX"]); 102 retval.regionLocX = Convert.ToUInt32(reader["locX"].ToString());
95 retval.regionLocY = (uint)((int)reader["locY"]); 103 retval.regionLocY = Convert.ToUInt32(reader["locY"].ToString());
96 retval.regionLocZ = (uint)((int)reader["locZ"]); 104 retval.regionLocZ = Convert.ToUInt32(reader["locZ"].ToString());
97 105
98 // Neighbours - 0 = No Override 106 // Neighbours - 0 = No Override
99 retval.regionEastOverrideHandle = (ulong)reader["eastOverrideHandle"]; 107 retval.regionEastOverrideHandle = Convert.ToUInt64(reader["eastOverrideHandle"].ToString());
100 retval.regionWestOverrideHandle = (ulong)reader["westOverrideHandle"]; 108 retval.regionWestOverrideHandle = Convert.ToUInt64(reader["westOverrideHandle"].ToString());
101 retval.regionSouthOverrideHandle = (ulong)reader["southOverrideHandle"]; 109 retval.regionSouthOverrideHandle = Convert.ToUInt64(reader["southOverrideHandle"].ToString());
102 retval.regionNorthOverrideHandle = (ulong)reader["northOverrideHandle"]; 110 retval.regionNorthOverrideHandle = Convert.ToUInt64(reader["northOverrideHandle"].ToString());
103 111
104 // Assets 112 // Assets
105 retval.regionAssetURI = (string)reader["regionAssetURI"]; 113 retval.regionAssetURI = (string)reader["regionAssetURI"];
@@ -113,51 +121,57 @@ namespace OpenGrid.Framework.Data.MySQL
113 } 121 }
114 else 122 else
115 { 123 {
116 throw new Exception("No rows to return"); 124 throw new Exception("Unable to find region at coordinates");
125 return null;
117 } 126 }
118 return retval; 127 return retval;
119 } 128 }
120 129
121 public bool insertRow(SimProfileData profile) { 130 public bool insertRow(SimProfileData profile)
122 string sql = "REPLACE INTO regions VALUES (regionHandle, regionName, uuid, regionRecvKey, regionSecret, regionSendKey, regionDataURI, "; 131 {
132 string sql = "REPLACE INTO regions (regionHandle, regionName, uuid, regionRecvKey, regionSecret, regionSendKey, regionDataURI, ";
123 sql += "serverIP, serverPort, serverURI, locX, locY, locZ, eastOverrideHandle, westOverrideHandle, southOverrideHandle, northOverrideHandle, regionAssetURI, regionAssetRecvKey, "; 133 sql += "serverIP, serverPort, serverURI, locX, locY, locZ, eastOverrideHandle, westOverrideHandle, southOverrideHandle, northOverrideHandle, regionAssetURI, regionAssetRecvKey, ";
124 sql += "regionAssetSendKey, regionUserURI, regionUserRecvKey, regionUserSendKey) VALUES "; 134 sql += "regionAssetSendKey, regionUserURI, regionUserRecvKey, regionUserSendKey) VALUES ";
125 135
126 sql += "(@regionHandle, @regionName, @uuid, @regionRecvKey, @regionSecret, @regionSendKey, @regionDataURI, "; 136 sql += "(?regionHandle, ?regionName, ?uuid, ?regionRecvKey, ?regionSecret, ?regionSendKey, ?regionDataURI, ";
127 sql += "@serverIP, @serverPort, @serverURI, @locX, @locY, @locZ, @eastOverrideHandle, @westOverrideHandle, @southOverrideHandle, @northOverrideHandle, @regionAssetURI, @regionAssetRecvKey, "; 137 sql += "?serverIP, ?serverPort, ?serverURI, ?locX, ?locY, ?locZ, ?eastOverrideHandle, ?westOverrideHandle, ?southOverrideHandle, ?northOverrideHandle, ?regionAssetURI, ?regionAssetRecvKey, ";
128 sql += "@regionAssetSendKey, @regionUserURI, @regionUserRecvKey, @regionUserSendKey);"; 138 sql += "?regionAssetSendKey, ?regionUserURI, ?regionUserRecvKey, ?regionUserSendKey);";
129 139
130 Dictionary<string, string> parameters = new Dictionary<string,string>(); 140 Dictionary<string, string> parameters = new Dictionary<string, string>();
131 141
132 parameters["regionHandle"] = profile.regionHandle.ToString(); 142 parameters["?regionHandle"] = profile.regionHandle.ToString();
133 parameters["regionName"] = profile.regionName; 143 parameters["?regionName"] = profile.regionName.ToString();
134 parameters["uuid"] = profile.UUID.ToString(); 144 parameters["?uuid"] = profile.UUID.ToStringHyphenated();
135 parameters["regionRecvKey"] = profile.regionRecvKey; 145 parameters["?regionRecvKey"] = profile.regionRecvKey.ToString();
136 parameters["regionSendKey"] = profile.regionSendKey; 146 parameters["?regionSecret"] = profile.regionSecret.ToString();
137 parameters["regionDataURI"] = profile.regionDataURI; 147 parameters["?regionSendKey"] = profile.regionSendKey.ToString();
138 parameters["serverIP"] = profile.serverIP; 148 parameters["?regionDataURI"] = profile.regionDataURI.ToString();
139 parameters["serverPort"] = profile.serverPort.ToString(); 149 parameters["?serverIP"] = profile.serverIP.ToString();
140 parameters["serverURI"] = profile.serverURI; 150 parameters["?serverPort"] = profile.serverPort.ToString();
141 parameters["locX"] = profile.regionLocX.ToString(); 151 parameters["?serverURI"] = profile.serverURI.ToString();
142 parameters["locY"] = profile.regionLocY.ToString(); 152 parameters["?locX"] = profile.regionLocX.ToString();
143 parameters["locZ"] = profile.regionLocZ.ToString(); 153 parameters["?locY"] = profile.regionLocY.ToString();
144 parameters["eastOverrideHandle"] = profile.regionEastOverrideHandle.ToString(); 154 parameters["?locZ"] = profile.regionLocZ.ToString();
145 parameters["westOverrideHandle"] = profile.regionWestOverrideHandle.ToString(); 155 parameters["?eastOverrideHandle"] = profile.regionEastOverrideHandle.ToString();
146 parameters["northOverrideHandle"] = profile.regionNorthOverrideHandle.ToString(); 156 parameters["?westOverrideHandle"] = profile.regionWestOverrideHandle.ToString();
147 parameters["southOverrideHandle"] = profile.regionSouthOverrideHandle.ToString(); 157 parameters["?northOverrideHandle"] = profile.regionNorthOverrideHandle.ToString();
148 parameters["regionAssetURI"] = profile.regionAssetURI; 158 parameters["?southOverrideHandle"] = profile.regionSouthOverrideHandle.ToString();
149 parameters["regionAssetRecvKey"] = profile.regionAssetRecvKey; 159 parameters["?regionAssetURI"] = profile.regionAssetURI.ToString();
150 parameters["regionAssetSendKey"] = profile.regionAssetSendKey; 160 parameters["?regionAssetRecvKey"] = profile.regionAssetRecvKey.ToString();
151 parameters["regionUserURI"] = profile.regionUserURI; 161 parameters["?regionAssetSendKey"] = profile.regionAssetSendKey.ToString();
152 parameters["regionUserRecvKey"] = profile.regionUserRecvKey; 162 parameters["?regionUserURI"] = profile.regionUserURI.ToString();
153 parameters["regionUserSendKey"] = profile.regionUserSendKey; 163 parameters["?regionUserRecvKey"] = profile.regionUserRecvKey.ToString();
164 parameters["?regionUserSendKey"] = profile.regionUserSendKey.ToString();
154 165
155 bool returnval = false; 166 bool returnval = false;
156 167
157 try 168 try
158 { 169 {
170
159 IDbCommand result = Query(sql, parameters); 171 IDbCommand result = Query(sql, parameters);
160 172
173 //Console.WriteLine(result.CommandText);
174
161 if (result.ExecuteNonQuery() == 1) 175 if (result.ExecuteNonQuery() == 1)
162 returnval = true; 176 returnval = true;
163 177
@@ -165,6 +179,7 @@ namespace OpenGrid.Framework.Data.MySQL
165 } 179 }
166 catch (Exception e) 180 catch (Exception e)
167 { 181 {
182 Console.WriteLine(e.ToString());
168 return false; 183 return false;
169 } 184 }
170 185