aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/Data.MSSQL/MSSQLGridData.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Framework/Data.MSSQL/MSSQLGridData.cs')
-rw-r--r--OpenSim/Framework/Data.MSSQL/MSSQLGridData.cs127
1 files changed, 36 insertions, 91 deletions
diff --git a/OpenSim/Framework/Data.MSSQL/MSSQLGridData.cs b/OpenSim/Framework/Data.MSSQL/MSSQLGridData.cs
index 28eec3e..0df88b6 100644
--- a/OpenSim/Framework/Data.MSSQL/MSSQLGridData.cs
+++ b/OpenSim/Framework/Data.MSSQL/MSSQLGridData.cs
@@ -47,21 +47,48 @@ namespace OpenSim.Framework.Data.MSSQL
47 /// </summary> 47 /// </summary>
48 private MSSQLManager database; 48 private MSSQLManager database;
49 49
50 private string m_regionsTableName;
51
50 /// <summary> 52 /// <summary>
51 /// Initialises the Grid Interface 53 /// Initialises the Grid Interface
52 /// </summary> 54 /// </summary>
53 public void Initialise() 55 public void Initialise()
54 { 56 {
55 IniFile GridDataMySqlFile = new IniFile("mssql_connection.ini"); 57 IniFile iniFile = new IniFile("mssql_connection.ini");
56 string settingDataSource = GridDataMySqlFile.ParseFileReadValue("data_source"); 58
57 string settingInitialCatalog = GridDataMySqlFile.ParseFileReadValue("initial_catalog"); 59 string settingDataSource = iniFile.ParseFileReadValue("data_source");
58 string settingPersistSecurityInfo = GridDataMySqlFile.ParseFileReadValue("persist_security_info"); 60 string settingInitialCatalog = iniFile.ParseFileReadValue("initial_catalog");
59 string settingUserId = GridDataMySqlFile.ParseFileReadValue("user_id"); 61 string settingPersistSecurityInfo = iniFile.ParseFileReadValue("persist_security_info");
60 string settingPassword = GridDataMySqlFile.ParseFileReadValue("password"); 62 string settingUserId = iniFile.ParseFileReadValue("user_id");
63 string settingPassword = iniFile.ParseFileReadValue("password");
64
65 m_regionsTableName = iniFile.ParseFileReadValue("regionstablename");
66 if (m_regionsTableName == null)
67 {
68 m_regionsTableName = "regions";
69 }
61 70
62 database = 71 database =
63 new MSSQLManager(settingDataSource, settingInitialCatalog, settingPersistSecurityInfo, settingUserId, 72 new MSSQLManager(settingDataSource, settingInitialCatalog, settingPersistSecurityInfo, settingUserId,
64 settingPassword); 73 settingPassword);
74
75 TestTables();
76 }
77
78 private void TestTables()
79 {
80 IDbCommand cmd = database.Query("SELECT * FROM "+m_regionsTableName, new Dictionary<string, string>());
81
82 try
83 {
84 cmd.ExecuteNonQuery();
85 cmd.Dispose();
86 }
87 catch (Exception)
88 {
89 m_log.Info("[DATASTORE]: MSSQL Database doesn't exist... creating");
90 database.ExecuteResourceSql("Mssql-regions.sql");
91 }
65 } 92 }
66 93
67 /// <summary> 94 /// <summary>
@@ -115,7 +142,7 @@ namespace OpenSim.Framework.Data.MSSQL
115 { 142 {
116 Dictionary<string, string> param = new Dictionary<string, string>(); 143 Dictionary<string, string> param = new Dictionary<string, string>();
117 param["handle"] = handle.ToString(); 144 param["handle"] = handle.ToString();
118 IDbCommand result = database.Query("SELECT * FROM regions WHERE regionHandle = @handle", param); 145 IDbCommand result = database.Query("SELECT * FROM " + m_regionsTableName + " WHERE regionHandle = @handle", param);
119 reader = result.ExecuteReader(); 146 reader = result.ExecuteReader();
120 147
121 RegionProfileData row = database.getRegionRow(reader); 148 RegionProfileData row = database.getRegionRow(reader);
@@ -134,89 +161,7 @@ namespace OpenSim.Framework.Data.MSSQL
134 return null; 161 return null;
135 } 162 }
136 163
137 /// <summary> 164
138 /// // Returns a list of avatar and UUIDs that match the query
139 /// </summary>
140 public List<AvatarPickerAvatar> GeneratePickerResults(LLUUID queryID, string query)
141 {
142 List<AvatarPickerAvatar> returnlist = new List<AvatarPickerAvatar>();
143 string[] querysplit;
144 querysplit = query.Split(' ');
145 if (querysplit.Length == 2)
146 {
147 try
148 {
149 lock (database)
150 {
151 Dictionary<string, string> param = new Dictionary<string, string>();
152 param["first"] = querysplit[0];
153 param["second"] = querysplit[1];
154
155 IDbCommand result =
156 database.Query(
157 "SELECT UUID,username,surname FROM users WHERE username = @first AND lastname = @second",
158 param);
159 IDataReader reader = result.ExecuteReader();
160
161
162 while (reader.Read())
163 {
164 AvatarPickerAvatar user = new AvatarPickerAvatar();
165 user.AvatarID = new LLUUID((string) reader["UUID"]);
166 user.firstName = (string) reader["username"];
167 user.lastName = (string) reader["surname"];
168 returnlist.Add(user);
169 }
170 reader.Close();
171 result.Dispose();
172 }
173 }
174 catch (Exception e)
175 {
176 database.Reconnect();
177 m_log.Error(e.ToString());
178 return returnlist;
179 }
180 }
181 else if (querysplit.Length == 1)
182 {
183 try
184 {
185 lock (database)
186 {
187 Dictionary<string, string> param = new Dictionary<string, string>();
188 param["first"] = querysplit[0];
189 param["second"] = querysplit[1];
190
191 IDbCommand result =
192 database.Query(
193 "SELECT UUID,username,surname FROM users WHERE username = @first OR lastname = @second",
194 param);
195 IDataReader reader = result.ExecuteReader();
196
197
198 while (reader.Read())
199 {
200 AvatarPickerAvatar user = new AvatarPickerAvatar();
201 user.AvatarID = new LLUUID((string) reader["UUID"]);
202 user.firstName = (string) reader["username"];
203 user.lastName = (string) reader["surname"];
204 returnlist.Add(user);
205 }
206 reader.Close();
207 result.Dispose();
208 }
209 }
210 catch (Exception e)
211 {
212 database.Reconnect();
213 m_log.Error(e.ToString());
214 return returnlist;
215 }
216 }
217 return returnlist;
218 }
219
220 /// <summary> 165 /// <summary>
221 /// Returns a sim profile from it's UUID 166 /// Returns a sim profile from it's UUID
222 /// </summary> 167 /// </summary>
@@ -226,7 +171,7 @@ namespace OpenSim.Framework.Data.MSSQL
226 { 171 {
227 Dictionary<string, string> param = new Dictionary<string, string>(); 172 Dictionary<string, string> param = new Dictionary<string, string>();
228 param["uuid"] = uuid.ToString(); 173 param["uuid"] = uuid.ToString();
229 IDbCommand result = database.Query("SELECT * FROM regions WHERE uuid = @uuid", param); 174 IDbCommand result = database.Query("SELECT * FROM " + m_regionsTableName + " WHERE uuid = @uuid", param);
230 IDataReader reader = result.ExecuteReader(); 175 IDataReader reader = result.ExecuteReader();
231 176
232 RegionProfileData row = database.getRegionRow(reader); 177 RegionProfileData row = database.getRegionRow(reader);