diff options
author | Diva Canto | 2015-06-25 15:02:06 -0700 |
---|---|---|
committer | Diva Canto | 2015-06-25 15:02:06 -0700 |
commit | 0e401238e765d1dbf9785ae5b480817f1adae902 (patch) | |
tree | 22b070fae88c4693c0f4dca3b427f7972c8403fd | |
parent | Fixed bad-ish code in login patch (diff) | |
parent | Thanks Gavin Hird for a fix for Mantis 0007604: DeleteClassifiedRecord except... (diff) | |
download | opensim-SC-0e401238e765d1dbf9785ae5b480817f1adae902.zip opensim-SC-0e401238e765d1dbf9785ae5b480817f1adae902.tar.gz opensim-SC-0e401238e765d1dbf9785ae5b480817f1adae902.tar.bz2 opensim-SC-0e401238e765d1dbf9785ae5b480817f1adae902.tar.xz |
Merge branch 'master' of ssh://opensimulator.org/var/git/opensim
-rw-r--r-- | OpenSim/Data/PGSQL/PGSQLEstateData.cs | 6 | ||||
-rw-r--r-- | OpenSim/Data/PGSQL/PGSQLUserProfilesData.cs | 247 |
2 files changed, 127 insertions, 126 deletions
diff --git a/OpenSim/Data/PGSQL/PGSQLEstateData.cs b/OpenSim/Data/PGSQL/PGSQLEstateData.cs index 5ad0eaa..b5ca235 100644 --- a/OpenSim/Data/PGSQL/PGSQLEstateData.cs +++ b/OpenSim/Data/PGSQL/PGSQLEstateData.cs | |||
@@ -107,8 +107,8 @@ namespace OpenSim.Data.PGSQL | |||
107 | { | 107 | { |
108 | EstateSettings es = new EstateSettings(); | 108 | EstateSettings es = new EstateSettings(); |
109 | 109 | ||
110 | string sql = "select estate_settings.\"" + String.Join("\",estate_settings.\"", FieldList) + | 110 | string sql = "select estate_settings.\"" + String.Join("\",estate_settings.\"", FieldList) + |
111 | "\" from estate_map left join estate_settings on estate_map.\"EstateID\" = estate_settings.\"EstateID\" " + | 111 | "\" from estate_map left join estate_settings on estate_map.\"EstateID\" = estate_settings.\"EstateID\" " + |
112 | " where estate_settings.\"EstateID\" is not null and \"RegionID\" = :RegionID"; | 112 | " where estate_settings.\"EstateID\" is not null and \"RegionID\" = :RegionID"; |
113 | 113 | ||
114 | bool insertEstate = false; | 114 | bool insertEstate = false; |
@@ -500,7 +500,7 @@ namespace OpenSim.Data.PGSQL | |||
500 | public List<int> GetEstatesByOwner(UUID ownerID) | 500 | public List<int> GetEstatesByOwner(UUID ownerID) |
501 | { | 501 | { |
502 | List<int> result = new List<int>(); | 502 | List<int> result = new List<int>(); |
503 | string sql = "select \"estateID\" from estate_settings where \"EstateOwner\" = :EstateOwner"; | 503 | string sql = "select \"EstateID\" from estate_settings where \"EstateOwner\" = :EstateOwner"; |
504 | using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString)) | 504 | using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString)) |
505 | { | 505 | { |
506 | conn.Open(); | 506 | conn.Open(); |
diff --git a/OpenSim/Data/PGSQL/PGSQLUserProfilesData.cs b/OpenSim/Data/PGSQL/PGSQLUserProfilesData.cs index a003e07..70c67dd 100644 --- a/OpenSim/Data/PGSQL/PGSQLUserProfilesData.cs +++ b/OpenSim/Data/PGSQL/PGSQLUserProfilesData.cs | |||
@@ -37,45 +37,46 @@ using Npgsql; | |||
37 | 37 | ||
38 | namespace OpenSim.Data.PGSQL | 38 | namespace OpenSim.Data.PGSQL |
39 | { | 39 | { |
40 | public class UserProfilesData: IProfilesData | 40 | public class UserProfilesData : IProfilesData |
41 | { | 41 | { |
42 | static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 42 | static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
43 | 43 | ||
44 | protected PGSQLManager m_database; | 44 | protected PGSQLManager m_database; |
45 | 45 | ||
46 | #region Properites | 46 | #region Properites |
47 | string ConnectionString | 47 | string ConnectionString |
48 | { | 48 | { |
49 | get; set; | 49 | get; |
50 | set; | ||
50 | } | 51 | } |
51 | 52 | ||
52 | protected virtual Assembly Assembly | 53 | protected virtual Assembly Assembly |
53 | { | 54 | { |
54 | get { return GetType().Assembly; } | 55 | get { return GetType().Assembly; } |
55 | } | 56 | } |
56 | 57 | ||
57 | #endregion Properties | 58 | #endregion Properties |
58 | 59 | ||
59 | #region class Member Functions | 60 | #region class Member Functions |
60 | public UserProfilesData(string connectionString) | 61 | public UserProfilesData(string connectionString) |
61 | { | 62 | { |
62 | ConnectionString = connectionString; | 63 | ConnectionString = connectionString; |
63 | Init(); | 64 | Init(); |
64 | } | 65 | } |
65 | 66 | ||
66 | void Init() | 67 | void Init() |
67 | { | 68 | { |
68 | using (NpgsqlConnection dbcon = new NpgsqlConnection(ConnectionString)) | 69 | using (NpgsqlConnection dbcon = new NpgsqlConnection(ConnectionString)) |
69 | { | 70 | { |
70 | dbcon.Open(); | 71 | dbcon.Open(); |
71 | 72 | ||
72 | Migration m = new Migration(dbcon, Assembly, "UserProfiles"); | 73 | Migration m = new Migration(dbcon, Assembly, "UserProfiles"); |
73 | m.Update(); | 74 | m.Update(); |
74 | m_database = new PGSQLManager(ConnectionString); | 75 | m_database = new PGSQLManager(ConnectionString); |
75 | } | 76 | } |
76 | } | 77 | } |
77 | #endregion Member Functions | 78 | #endregion Member Functions |
78 | 79 | ||
79 | #region Classifieds Queries | 80 | #region Classifieds Queries |
80 | /// <summary> | 81 | /// <summary> |
81 | /// Gets the classified records. | 82 | /// Gets the classified records. |
@@ -89,7 +90,7 @@ namespace OpenSim.Data.PGSQL | |||
89 | public OSDArray GetClassifiedRecords(UUID creatorId) | 90 | public OSDArray GetClassifiedRecords(UUID creatorId) |
90 | { | 91 | { |
91 | OSDArray data = new OSDArray(); | 92 | OSDArray data = new OSDArray(); |
92 | 93 | ||
93 | using (NpgsqlConnection dbcon = new NpgsqlConnection(ConnectionString)) | 94 | using (NpgsqlConnection dbcon = new NpgsqlConnection(ConnectionString)) |
94 | { | 95 | { |
95 | string query = @"SELECT classifieduuid, name FROM classifieds WHERE creatoruuid = :Id"; | 96 | string query = @"SELECT classifieduuid, name FROM classifieds WHERE creatoruuid = :Id"; |
@@ -97,15 +98,15 @@ namespace OpenSim.Data.PGSQL | |||
97 | using (NpgsqlCommand cmd = new NpgsqlCommand(query, dbcon)) | 98 | using (NpgsqlCommand cmd = new NpgsqlCommand(query, dbcon)) |
98 | { | 99 | { |
99 | cmd.Parameters.Add(m_database.CreateParameter("Id", creatorId)); | 100 | cmd.Parameters.Add(m_database.CreateParameter("Id", creatorId)); |
100 | using( NpgsqlDataReader reader = cmd.ExecuteReader(CommandBehavior.Default)) | 101 | using (NpgsqlDataReader reader = cmd.ExecuteReader(CommandBehavior.Default)) |
101 | { | 102 | { |
102 | if(reader.HasRows) | 103 | if (reader.HasRows) |
103 | { | 104 | { |
104 | while (reader.Read()) | 105 | while (reader.Read()) |
105 | { | 106 | { |
106 | OSDMap n = new OSDMap(); | 107 | OSDMap n = new OSDMap(); |
107 | UUID Id = UUID.Zero; | 108 | UUID Id = UUID.Zero; |
108 | 109 | ||
109 | string Name = null; | 110 | string Name = null; |
110 | try | 111 | try |
111 | { | 112 | { |
@@ -127,7 +128,7 @@ namespace OpenSim.Data.PGSQL | |||
127 | } | 128 | } |
128 | return data; | 129 | return data; |
129 | } | 130 | } |
130 | 131 | ||
131 | public bool UpdateClassifiedRecord(UserClassifiedAdd ad, ref string result) | 132 | public bool UpdateClassifiedRecord(UserClassifiedAdd ad, ref string result) |
132 | { | 133 | { |
133 | string query = string.Empty; | 134 | string query = string.Empty; |
@@ -149,35 +150,35 @@ namespace OpenSim.Data.PGSQL | |||
149 | WHERE NOT EXISTS ( | 150 | WHERE NOT EXISTS ( |
150 | SELECT * FROM upsert )"; | 151 | SELECT * FROM upsert )"; |
151 | 152 | ||
152 | if(string.IsNullOrEmpty(ad.ParcelName)) | 153 | if (string.IsNullOrEmpty(ad.ParcelName)) |
153 | ad.ParcelName = "Unknown"; | 154 | ad.ParcelName = "Unknown"; |
154 | if(ad.ParcelId == null) | 155 | if (ad.ParcelId == null) |
155 | ad.ParcelId = UUID.Zero; | 156 | ad.ParcelId = UUID.Zero; |
156 | if(string.IsNullOrEmpty(ad.Description)) | 157 | if (string.IsNullOrEmpty(ad.Description)) |
157 | ad.Description = "No Description"; | 158 | ad.Description = "No Description"; |
158 | 159 | ||
159 | DateTime epoch = new DateTime(1970, 1, 1); | 160 | DateTime epoch = new DateTime(1970, 1, 1); |
160 | DateTime now = DateTime.Now; | 161 | DateTime now = DateTime.Now; |
161 | TimeSpan epochnow = now - epoch; | 162 | TimeSpan epochnow = now - epoch; |
162 | TimeSpan duration; | 163 | TimeSpan duration; |
163 | DateTime expiration; | 164 | DateTime expiration; |
164 | TimeSpan epochexp; | 165 | TimeSpan epochexp; |
165 | 166 | ||
166 | if(ad.Flags == 2) | 167 | if (ad.Flags == 2) |
167 | { | 168 | { |
168 | duration = new TimeSpan(7,0,0,0); | 169 | duration = new TimeSpan(7, 0, 0, 0); |
169 | expiration = now.Add(duration); | 170 | expiration = now.Add(duration); |
170 | epochexp = expiration - epoch; | 171 | epochexp = expiration - epoch; |
171 | } | 172 | } |
172 | else | 173 | else |
173 | { | 174 | { |
174 | duration = new TimeSpan(365,0,0,0); | 175 | duration = new TimeSpan(365, 0, 0, 0); |
175 | expiration = now.Add(duration); | 176 | expiration = now.Add(duration); |
176 | epochexp = expiration - epoch; | 177 | epochexp = expiration - epoch; |
177 | } | 178 | } |
178 | ad.CreationDate = (int)epochnow.TotalSeconds; | 179 | ad.CreationDate = (int)epochnow.TotalSeconds; |
179 | ad.ExpirationDate = (int)epochexp.TotalSeconds; | 180 | ad.ExpirationDate = (int)epochexp.TotalSeconds; |
180 | 181 | ||
181 | try | 182 | try |
182 | { | 183 | { |
183 | using (NpgsqlConnection dbcon = new NpgsqlConnection(ConnectionString)) | 184 | using (NpgsqlConnection dbcon = new NpgsqlConnection(ConnectionString)) |
@@ -200,7 +201,7 @@ namespace OpenSim.Data.PGSQL | |||
200 | cmd.Parameters.Add(m_database.CreateParameter("ParcelName", ad.ParcelName.ToString())); | 201 | cmd.Parameters.Add(m_database.CreateParameter("ParcelName", ad.ParcelName.ToString())); |
201 | cmd.Parameters.Add(m_database.CreateParameter("Flags", (int)Convert.ToInt32(ad.Flags))); | 202 | cmd.Parameters.Add(m_database.CreateParameter("Flags", (int)Convert.ToInt32(ad.Flags))); |
202 | cmd.Parameters.Add(m_database.CreateParameter("ListingPrice", (int)Convert.ToInt32(ad.Price))); | 203 | cmd.Parameters.Add(m_database.CreateParameter("ListingPrice", (int)Convert.ToInt32(ad.Price))); |
203 | 204 | ||
204 | cmd.ExecuteNonQuery(); | 205 | cmd.ExecuteNonQuery(); |
205 | } | 206 | } |
206 | } | 207 | } |
@@ -214,19 +215,19 @@ namespace OpenSim.Data.PGSQL | |||
214 | 215 | ||
215 | return true; | 216 | return true; |
216 | } | 217 | } |
217 | 218 | ||
218 | public bool DeleteClassifiedRecord(UUID recordId) | 219 | public bool DeleteClassifiedRecord(UUID recordId) |
219 | { | 220 | { |
220 | string query = string.Empty; | 221 | string query = string.Empty; |
221 | 222 | ||
222 | query = @"DELETE FROM classifieds WHERE classifieduuid = :ClasifiedId ;"; | 223 | query = @"DELETE FROM classifieds WHERE classifieduuid = :ClassifiedId ;"; |
223 | 224 | ||
224 | try | 225 | try |
225 | { | 226 | { |
226 | using (NpgsqlConnection dbcon = new NpgsqlConnection(ConnectionString)) | 227 | using (NpgsqlConnection dbcon = new NpgsqlConnection(ConnectionString)) |
227 | { | 228 | { |
228 | dbcon.Open(); | 229 | dbcon.Open(); |
229 | 230 | ||
230 | using (NpgsqlCommand cmd = new NpgsqlCommand(query, dbcon)) | 231 | using (NpgsqlCommand cmd = new NpgsqlCommand(query, dbcon)) |
231 | { | 232 | { |
232 | cmd.Parameters.Add(m_database.CreateParameter("ClassifiedId", recordId)); | 233 | cmd.Parameters.Add(m_database.CreateParameter("ClassifiedId", recordId)); |
@@ -242,14 +243,14 @@ namespace OpenSim.Data.PGSQL | |||
242 | 243 | ||
243 | return true; | 244 | return true; |
244 | } | 245 | } |
245 | 246 | ||
246 | public bool GetClassifiedInfo(ref UserClassifiedAdd ad, ref string result) | 247 | public bool GetClassifiedInfo(ref UserClassifiedAdd ad, ref string result) |
247 | { | 248 | { |
248 | string query = string.Empty; | 249 | string query = string.Empty; |
249 | 250 | ||
250 | query += "SELECT * FROM classifieds WHERE "; | 251 | query += "SELECT * FROM classifieds WHERE "; |
251 | query += "classifieduuid = :AdId"; | 252 | query += "classifieduuid = :AdId"; |
252 | 253 | ||
253 | try | 254 | try |
254 | { | 255 | { |
255 | using (NpgsqlConnection dbcon = new NpgsqlConnection(ConnectionString)) | 256 | using (NpgsqlConnection dbcon = new NpgsqlConnection(ConnectionString)) |
@@ -258,10 +259,10 @@ namespace OpenSim.Data.PGSQL | |||
258 | using (NpgsqlCommand cmd = new NpgsqlCommand(query, dbcon)) | 259 | using (NpgsqlCommand cmd = new NpgsqlCommand(query, dbcon)) |
259 | { | 260 | { |
260 | cmd.Parameters.Add(m_database.CreateParameter("AdId", ad.ClassifiedId)); | 261 | cmd.Parameters.Add(m_database.CreateParameter("AdId", ad.ClassifiedId)); |
261 | 262 | ||
262 | using (NpgsqlDataReader reader = cmd.ExecuteReader()) | 263 | using (NpgsqlDataReader reader = cmd.ExecuteReader()) |
263 | { | 264 | { |
264 | if(reader.Read ()) | 265 | if (reader.Read()) |
265 | { | 266 | { |
266 | ad.CreatorId = DBGuid.FromDB(reader["creatoruuid"]); | 267 | ad.CreatorId = DBGuid.FromDB(reader["creatoruuid"]); |
267 | ad.ParcelId = DBGuid.FromDB(reader["parceluuid"]); | 268 | ad.ParcelId = DBGuid.FromDB(reader["parceluuid"]); |
@@ -291,7 +292,7 @@ namespace OpenSim.Data.PGSQL | |||
291 | return true; | 292 | return true; |
292 | } | 293 | } |
293 | 294 | ||
294 | public static UUID GetUUID(object uuidValue) | 295 | public static UUID GetUUID(object uuidValue) |
295 | { | 296 | { |
296 | 297 | ||
297 | UUID ret = UUID.Zero; | 298 | UUID ret = UUID.Zero; |
@@ -307,11 +308,11 @@ namespace OpenSim.Data.PGSQL | |||
307 | public OSDArray GetAvatarPicks(UUID avatarId) | 308 | public OSDArray GetAvatarPicks(UUID avatarId) |
308 | { | 309 | { |
309 | string query = string.Empty; | 310 | string query = string.Empty; |
310 | 311 | ||
311 | query += "SELECT pickuuid, name FROM userpicks WHERE "; | 312 | query += "SELECT pickuuid, name FROM userpicks WHERE "; |
312 | query += "creatoruuid = :Id"; | 313 | query += "creatoruuid = :Id"; |
313 | OSDArray data = new OSDArray(); | 314 | OSDArray data = new OSDArray(); |
314 | 315 | ||
315 | try | 316 | try |
316 | { | 317 | { |
317 | using (NpgsqlConnection dbcon = new NpgsqlConnection(ConnectionString)) | 318 | using (NpgsqlConnection dbcon = new NpgsqlConnection(ConnectionString)) |
@@ -320,17 +321,17 @@ namespace OpenSim.Data.PGSQL | |||
320 | using (NpgsqlCommand cmd = new NpgsqlCommand(query, dbcon)) | 321 | using (NpgsqlCommand cmd = new NpgsqlCommand(query, dbcon)) |
321 | { | 322 | { |
322 | cmd.Parameters.Add(m_database.CreateParameter("Id", avatarId)); | 323 | cmd.Parameters.Add(m_database.CreateParameter("Id", avatarId)); |
323 | 324 | ||
324 | using (NpgsqlDataReader reader = cmd.ExecuteReader()) | 325 | using (NpgsqlDataReader reader = cmd.ExecuteReader()) |
325 | { | 326 | { |
326 | if(reader.HasRows) | 327 | if (reader.HasRows) |
327 | { | 328 | { |
328 | while (reader.Read()) | 329 | while (reader.Read()) |
329 | { | 330 | { |
330 | OSDMap record = new OSDMap(); | 331 | OSDMap record = new OSDMap(); |
331 | 332 | ||
332 | record.Add("pickuuid",OSD.FromUUID(DBGuid.FromDB(reader["pickuuid"]))); | 333 | record.Add("pickuuid", OSD.FromUUID(DBGuid.FromDB(reader["pickuuid"]))); |
333 | record.Add("name",OSD.FromString((string)reader["name"])); | 334 | record.Add("name", OSD.FromString((string)reader["name"])); |
334 | data.Add(record); | 335 | data.Add(record); |
335 | } | 336 | } |
336 | } | 337 | } |
@@ -345,16 +346,16 @@ namespace OpenSim.Data.PGSQL | |||
345 | 346 | ||
346 | return data; | 347 | return data; |
347 | } | 348 | } |
348 | 349 | ||
349 | public UserProfilePick GetPickInfo(UUID avatarId, UUID pickId) | 350 | public UserProfilePick GetPickInfo(UUID avatarId, UUID pickId) |
350 | { | 351 | { |
351 | string query = string.Empty; | 352 | string query = string.Empty; |
352 | UserProfilePick pick = new UserProfilePick(); | 353 | UserProfilePick pick = new UserProfilePick(); |
353 | 354 | ||
354 | query += "SELECT * FROM userpicks WHERE "; | 355 | query += "SELECT * FROM userpicks WHERE "; |
355 | query += "creatoruuid = :CreatorId AND "; | 356 | query += "creatoruuid = :CreatorId AND "; |
356 | query += "pickuuid = :PickId"; | 357 | query += "pickuuid = :PickId"; |
357 | 358 | ||
358 | try | 359 | try |
359 | { | 360 | { |
360 | using (NpgsqlConnection dbcon = new NpgsqlConnection(ConnectionString)) | 361 | using (NpgsqlConnection dbcon = new NpgsqlConnection(ConnectionString)) |
@@ -364,18 +365,18 @@ namespace OpenSim.Data.PGSQL | |||
364 | { | 365 | { |
365 | cmd.Parameters.Add(m_database.CreateParameter("CreatorId", avatarId)); | 366 | cmd.Parameters.Add(m_database.CreateParameter("CreatorId", avatarId)); |
366 | cmd.Parameters.Add(m_database.CreateParameter("PickId", pickId)); | 367 | cmd.Parameters.Add(m_database.CreateParameter("PickId", pickId)); |
367 | 368 | ||
368 | using (NpgsqlDataReader reader = cmd.ExecuteReader()) | 369 | using (NpgsqlDataReader reader = cmd.ExecuteReader()) |
369 | { | 370 | { |
370 | if(reader.HasRows) | 371 | if (reader.HasRows) |
371 | { | 372 | { |
372 | reader.Read(); | 373 | reader.Read(); |
373 | 374 | ||
374 | string description = (string)reader["description"]; | 375 | string description = (string)reader["description"]; |
375 | 376 | ||
376 | if (string.IsNullOrEmpty(description)) | 377 | if (string.IsNullOrEmpty(description)) |
377 | description = "No description given."; | 378 | description = "No description given."; |
378 | 379 | ||
379 | pick.PickId = DBGuid.FromDB(reader["pickuuid"]); | 380 | pick.PickId = DBGuid.FromDB(reader["pickuuid"]); |
380 | pick.CreatorId = DBGuid.FromDB(reader["creatoruuid"]); | 381 | pick.CreatorId = DBGuid.FromDB(reader["creatoruuid"]); |
381 | pick.ParcelId = DBGuid.FromDB(reader["parceluuid"]); | 382 | pick.ParcelId = DBGuid.FromDB(reader["parceluuid"]); |
@@ -383,7 +384,7 @@ namespace OpenSim.Data.PGSQL | |||
383 | pick.GlobalPos = (string)reader["posglobal"].ToString(); | 384 | pick.GlobalPos = (string)reader["posglobal"].ToString(); |
384 | pick.TopPick = Convert.ToBoolean(reader["toppick"]); | 385 | pick.TopPick = Convert.ToBoolean(reader["toppick"]); |
385 | pick.Enabled = Convert.ToBoolean(reader["enabled"]); | 386 | pick.Enabled = Convert.ToBoolean(reader["enabled"]); |
386 | pick.Name = reader["name"].ToString (); | 387 | pick.Name = reader["name"].ToString(); |
387 | pick.Desc = reader["description"].ToString(); | 388 | pick.Desc = reader["description"].ToString(); |
388 | pick.ParcelName = reader["user"].ToString(); | 389 | pick.ParcelName = reader["user"].ToString(); |
389 | pick.OriginalName = reader["originalname"].ToString(); | 390 | pick.OriginalName = reader["originalname"].ToString(); |
@@ -402,9 +403,9 @@ namespace OpenSim.Data.PGSQL | |||
402 | 403 | ||
403 | return pick; | 404 | return pick; |
404 | } | 405 | } |
405 | 406 | ||
406 | public bool UpdatePicksRecord(UserProfilePick pick) | 407 | public bool UpdatePicksRecord(UserProfilePick pick) |
407 | { | 408 | { |
408 | string query = string.Empty; | 409 | string query = string.Empty; |
409 | 410 | ||
410 | 411 | ||
@@ -422,7 +423,7 @@ namespace OpenSim.Data.PGSQL | |||
422 | :Original,:SimName,:GlobalPos,:SortOrder,:Enabled | 423 | :Original,:SimName,:GlobalPos,:SortOrder,:Enabled |
423 | WHERE NOT EXISTS ( | 424 | WHERE NOT EXISTS ( |
424 | SELECT * FROM upsert )"; | 425 | SELECT * FROM upsert )"; |
425 | 426 | ||
426 | try | 427 | try |
427 | { | 428 | { |
428 | using (NpgsqlConnection dbcon = new NpgsqlConnection(ConnectionString)) | 429 | using (NpgsqlConnection dbcon = new NpgsqlConnection(ConnectionString)) |
@@ -439,11 +440,11 @@ namespace OpenSim.Data.PGSQL | |||
439 | cmd.Parameters.Add(m_database.CreateParameter("SnapshotId", pick.SnapshotId)); | 440 | cmd.Parameters.Add(m_database.CreateParameter("SnapshotId", pick.SnapshotId)); |
440 | cmd.Parameters.Add(m_database.CreateParameter("User", pick.ParcelName)); | 441 | cmd.Parameters.Add(m_database.CreateParameter("User", pick.ParcelName)); |
441 | cmd.Parameters.Add(m_database.CreateParameter("Original", pick.OriginalName)); | 442 | cmd.Parameters.Add(m_database.CreateParameter("Original", pick.OriginalName)); |
442 | cmd.Parameters.Add(m_database.CreateParameter("SimName",pick.SimName)); | 443 | cmd.Parameters.Add(m_database.CreateParameter("SimName", pick.SimName)); |
443 | cmd.Parameters.Add(m_database.CreateParameter("GlobalPos", pick.GlobalPos)); | 444 | cmd.Parameters.Add(m_database.CreateParameter("GlobalPos", pick.GlobalPos)); |
444 | cmd.Parameters.Add(m_database.CreateParameter("SortOrder", pick.SortOrder)); | 445 | cmd.Parameters.Add(m_database.CreateParameter("SortOrder", pick.SortOrder)); |
445 | cmd.Parameters.Add(m_database.CreateParameter("Enabled", pick.Enabled)); | 446 | cmd.Parameters.Add(m_database.CreateParameter("Enabled", pick.Enabled)); |
446 | 447 | ||
447 | cmd.ExecuteNonQuery(); | 448 | cmd.ExecuteNonQuery(); |
448 | } | 449 | } |
449 | } | 450 | } |
@@ -456,24 +457,24 @@ namespace OpenSim.Data.PGSQL | |||
456 | 457 | ||
457 | return true; | 458 | return true; |
458 | } | 459 | } |
459 | 460 | ||
460 | public bool DeletePicksRecord(UUID pickId) | 461 | public bool DeletePicksRecord(UUID pickId) |
461 | { | 462 | { |
462 | string query = string.Empty; | 463 | string query = string.Empty; |
463 | 464 | ||
464 | query += "DELETE FROM userpicks WHERE "; | 465 | query += "DELETE FROM userpicks WHERE "; |
465 | query += "pickuuid = :PickId"; | 466 | query += "pickuuid = :PickId"; |
466 | 467 | ||
467 | try | 468 | try |
468 | { | 469 | { |
469 | using (NpgsqlConnection dbcon = new NpgsqlConnection(ConnectionString)) | 470 | using (NpgsqlConnection dbcon = new NpgsqlConnection(ConnectionString)) |
470 | { | 471 | { |
471 | dbcon.Open(); | 472 | dbcon.Open(); |
472 | 473 | ||
473 | using (NpgsqlCommand cmd = new NpgsqlCommand(query, dbcon)) | 474 | using (NpgsqlCommand cmd = new NpgsqlCommand(query, dbcon)) |
474 | { | 475 | { |
475 | cmd.Parameters.Add(m_database.CreateParameter("PickId", pickId)); | 476 | cmd.Parameters.Add(m_database.CreateParameter("PickId", pickId)); |
476 | 477 | ||
477 | cmd.ExecuteNonQuery(); | 478 | cmd.ExecuteNonQuery(); |
478 | } | 479 | } |
479 | } | 480 | } |
@@ -488,18 +489,18 @@ namespace OpenSim.Data.PGSQL | |||
488 | } | 489 | } |
489 | 490 | ||
490 | #endregion Picks Queries | 491 | #endregion Picks Queries |
491 | 492 | ||
492 | #region Avatar Notes Queries | 493 | #region Avatar Notes Queries |
493 | 494 | ||
494 | public bool GetAvatarNotes(ref UserProfileNotes notes) | 495 | public bool GetAvatarNotes(ref UserProfileNotes notes) |
495 | { // WIP | 496 | { // WIP |
496 | string query = string.Empty; | 497 | string query = string.Empty; |
497 | 498 | ||
498 | query += "SELECT notes FROM usernotes WHERE "; | 499 | query += "SELECT notes FROM usernotes WHERE "; |
499 | query += "useruuid = :Id AND "; | 500 | query += "useruuid = :Id AND "; |
500 | query += "targetuuid = :TargetId"; | 501 | query += "targetuuid = :TargetId"; |
501 | OSDArray data = new OSDArray(); | 502 | OSDArray data = new OSDArray(); |
502 | 503 | ||
503 | try | 504 | try |
504 | { | 505 | { |
505 | using (NpgsqlConnection dbcon = new NpgsqlConnection(ConnectionString)) | 506 | using (NpgsqlConnection dbcon = new NpgsqlConnection(ConnectionString)) |
@@ -509,10 +510,10 @@ namespace OpenSim.Data.PGSQL | |||
509 | { | 510 | { |
510 | cmd.Parameters.Add(m_database.CreateParameter("Id", notes.UserId)); | 511 | cmd.Parameters.Add(m_database.CreateParameter("Id", notes.UserId)); |
511 | cmd.Parameters.Add(m_database.CreateParameter("TargetId", notes.TargetId)); | 512 | cmd.Parameters.Add(m_database.CreateParameter("TargetId", notes.TargetId)); |
512 | 513 | ||
513 | using (NpgsqlDataReader reader = cmd.ExecuteReader(CommandBehavior.SingleRow)) | 514 | using (NpgsqlDataReader reader = cmd.ExecuteReader(CommandBehavior.SingleRow)) |
514 | { | 515 | { |
515 | if(reader.HasRows) | 516 | if (reader.HasRows) |
516 | { | 517 | { |
517 | reader.Read(); | 518 | reader.Read(); |
518 | notes.Notes = OSD.FromString((string)reader["notes"]); | 519 | notes.Notes = OSD.FromString((string)reader["notes"]); |
@@ -528,12 +529,12 @@ namespace OpenSim.Data.PGSQL | |||
528 | 529 | ||
529 | return true; | 530 | return true; |
530 | } | 531 | } |
531 | 532 | ||
532 | public bool UpdateAvatarNotes(ref UserProfileNotes note, ref string result) | 533 | public bool UpdateAvatarNotes(ref UserProfileNotes note, ref string result) |
533 | { | 534 | { |
534 | string query = string.Empty; | 535 | string query = string.Empty; |
535 | bool remove; | 536 | bool remove; |
536 | 537 | ||
537 | if (string.IsNullOrEmpty(note.Notes)) | 538 | if (string.IsNullOrEmpty(note.Notes)) |
538 | { | 539 | { |
539 | remove = true; | 540 | remove = true; |
@@ -553,7 +554,7 @@ namespace OpenSim.Data.PGSQL | |||
553 | SELECT * FROM upsert | 554 | SELECT * FROM upsert |
554 | )"; | 555 | )"; |
555 | } | 556 | } |
556 | 557 | ||
557 | try | 558 | try |
558 | { | 559 | { |
559 | using (NpgsqlConnection dbcon = new NpgsqlConnection(ConnectionString)) | 560 | using (NpgsqlConnection dbcon = new NpgsqlConnection(ConnectionString)) |
@@ -561,12 +562,12 @@ namespace OpenSim.Data.PGSQL | |||
561 | dbcon.Open(); | 562 | dbcon.Open(); |
562 | using (NpgsqlCommand cmd = new NpgsqlCommand(query, dbcon)) | 563 | using (NpgsqlCommand cmd = new NpgsqlCommand(query, dbcon)) |
563 | { | 564 | { |
564 | if(!remove) | 565 | if (!remove) |
565 | cmd.Parameters.Add(m_database.CreateParameter("Notes", note.Notes)); | 566 | cmd.Parameters.Add(m_database.CreateParameter("Notes", note.Notes)); |
566 | 567 | ||
567 | cmd.Parameters.Add(m_database.CreateParameter("TargetId", note.TargetId)); | 568 | cmd.Parameters.Add(m_database.CreateParameter("TargetId", note.TargetId)); |
568 | cmd.Parameters.Add(m_database.CreateParameter("UserId", note.UserId)); | 569 | cmd.Parameters.Add(m_database.CreateParameter("UserId", note.UserId)); |
569 | 570 | ||
570 | cmd.ExecuteNonQuery(); | 571 | cmd.ExecuteNonQuery(); |
571 | } | 572 | } |
572 | } | 573 | } |
@@ -577,20 +578,20 @@ namespace OpenSim.Data.PGSQL | |||
577 | return false; | 578 | return false; |
578 | } | 579 | } |
579 | 580 | ||
580 | return true; | 581 | return true; |
581 | } | 582 | } |
582 | 583 | ||
583 | #endregion Avatar Notes Queries | 584 | #endregion Avatar Notes Queries |
584 | 585 | ||
585 | #region Avatar Properties | 586 | #region Avatar Properties |
586 | 587 | ||
587 | public bool GetAvatarProperties(ref UserProfileProperties props, ref string result) | 588 | public bool GetAvatarProperties(ref UserProfileProperties props, ref string result) |
588 | { | 589 | { |
589 | string query = string.Empty; | 590 | string query = string.Empty; |
590 | 591 | ||
591 | query += "SELECT * FROM userprofile WHERE "; | 592 | query += "SELECT * FROM userprofile WHERE "; |
592 | query += "useruuid = :Id"; | 593 | query += "useruuid = :Id"; |
593 | 594 | ||
594 | try | 595 | try |
595 | { | 596 | { |
596 | using (NpgsqlConnection dbcon = new NpgsqlConnection(ConnectionString)) | 597 | using (NpgsqlConnection dbcon = new NpgsqlConnection(ConnectionString)) |
@@ -599,10 +600,10 @@ namespace OpenSim.Data.PGSQL | |||
599 | using (NpgsqlCommand cmd = new NpgsqlCommand(query, dbcon)) | 600 | using (NpgsqlCommand cmd = new NpgsqlCommand(query, dbcon)) |
600 | { | 601 | { |
601 | cmd.Parameters.Add(m_database.CreateParameter("Id", props.UserId)); | 602 | cmd.Parameters.Add(m_database.CreateParameter("Id", props.UserId)); |
602 | 603 | ||
603 | using (NpgsqlDataReader reader = cmd.ExecuteReader(CommandBehavior.SingleRow)) | 604 | using (NpgsqlDataReader reader = cmd.ExecuteReader(CommandBehavior.SingleRow)) |
604 | { | 605 | { |
605 | if(reader.HasRows) | 606 | if (reader.HasRows) |
606 | { | 607 | { |
607 | // m_log.DebugFormat("[PROFILES_DATA]" + | 608 | // m_log.DebugFormat("[PROFILES_DATA]" + |
608 | // ": Getting data for {0}.", props.UserId); | 609 | // ": Getting data for {0}.", props.UserId); |
@@ -623,7 +624,7 @@ namespace OpenSim.Data.PGSQL | |||
623 | { | 624 | { |
624 | //m_log.DebugFormat("[PROFILES_DATA]" + | 625 | //m_log.DebugFormat("[PROFILES_DATA]" + |
625 | // ": No data for {0}", props.UserId); | 626 | // ": No data for {0}", props.UserId); |
626 | 627 | ||
627 | props.WebUrl = string.Empty; | 628 | props.WebUrl = string.Empty; |
628 | props.ImageId = UUID.Zero; | 629 | props.ImageId = UUID.Zero; |
629 | props.AboutText = string.Empty; | 630 | props.AboutText = string.Empty; |
@@ -707,11 +708,11 @@ namespace OpenSim.Data.PGSQL | |||
707 | 708 | ||
708 | return true; | 709 | return true; |
709 | } | 710 | } |
710 | 711 | ||
711 | public bool UpdateAvatarProperties(ref UserProfileProperties props, ref string result) | 712 | public bool UpdateAvatarProperties(ref UserProfileProperties props, ref string result) |
712 | { | 713 | { |
713 | string query = string.Empty; | 714 | string query = string.Empty; |
714 | 715 | ||
715 | query += "UPDATE userprofile SET "; | 716 | query += "UPDATE userprofile SET "; |
716 | query += "\"profileURL\"=:profileURL, "; | 717 | query += "\"profileURL\"=:profileURL, "; |
717 | query += "\"profileImage\"=:image, "; | 718 | query += "\"profileImage\"=:image, "; |
@@ -719,7 +720,7 @@ namespace OpenSim.Data.PGSQL | |||
719 | query += "\"profileFirstImage\"=:firstlifeimage,"; | 720 | query += "\"profileFirstImage\"=:firstlifeimage,"; |
720 | query += "\"profileFirstText\"=:firstlifetext "; | 721 | query += "\"profileFirstText\"=:firstlifetext "; |
721 | query += "WHERE \"useruuid\"=:uuid"; | 722 | query += "WHERE \"useruuid\"=:uuid"; |
722 | 723 | ||
723 | try | 724 | try |
724 | { | 725 | { |
725 | using (NpgsqlConnection dbcon = new NpgsqlConnection(ConnectionString)) | 726 | using (NpgsqlConnection dbcon = new NpgsqlConnection(ConnectionString)) |
@@ -733,14 +734,14 @@ namespace OpenSim.Data.PGSQL | |||
733 | cmd.Parameters.Add(m_database.CreateParameter("firstlifeimage", props.FirstLifeImageId)); | 734 | cmd.Parameters.Add(m_database.CreateParameter("firstlifeimage", props.FirstLifeImageId)); |
734 | cmd.Parameters.Add(m_database.CreateParameter("firstlifetext", props.FirstLifeText)); | 735 | cmd.Parameters.Add(m_database.CreateParameter("firstlifetext", props.FirstLifeText)); |
735 | cmd.Parameters.Add(m_database.CreateParameter("uuid", props.UserId)); | 736 | cmd.Parameters.Add(m_database.CreateParameter("uuid", props.UserId)); |
736 | 737 | ||
737 | cmd.ExecuteNonQuery(); | 738 | cmd.ExecuteNonQuery(); |
738 | } | 739 | } |
739 | } | 740 | } |
740 | } | 741 | } |
741 | catch (Exception e) | 742 | catch (Exception e) |
742 | { | 743 | { |
743 | m_log.Error("[PROFILES_DATA]: AgentPropertiesUpdate exception ", e); | 744 | m_log.Error("[PROFILES_DATA]: AgentPropertiesUpdate exception ", e); |
744 | return false; | 745 | return false; |
745 | } | 746 | } |
746 | 747 | ||
@@ -748,13 +749,13 @@ namespace OpenSim.Data.PGSQL | |||
748 | } | 749 | } |
749 | 750 | ||
750 | #endregion Avatar Properties | 751 | #endregion Avatar Properties |
751 | 752 | ||
752 | #region Avatar Interests | 753 | #region Avatar Interests |
753 | 754 | ||
754 | public bool UpdateAvatarInterests(UserProfileProperties up, ref string result) | 755 | public bool UpdateAvatarInterests(UserProfileProperties up, ref string result) |
755 | { | 756 | { |
756 | string query = string.Empty; | 757 | string query = string.Empty; |
757 | 758 | ||
758 | query += "UPDATE userprofile SET "; | 759 | query += "UPDATE userprofile SET "; |
759 | query += "\"profileWantToMask\"=:WantMask, "; | 760 | query += "\"profileWantToMask\"=:WantMask, "; |
760 | query += "\"profileWantToText\"=:WantText,"; | 761 | query += "\"profileWantToText\"=:WantText,"; |
@@ -762,7 +763,7 @@ namespace OpenSim.Data.PGSQL | |||
762 | query += "\"profileSkillsText\"=:SkillsText, "; | 763 | query += "\"profileSkillsText\"=:SkillsText, "; |
763 | query += "\"profileLanguages\"=:Languages "; | 764 | query += "\"profileLanguages\"=:Languages "; |
764 | query += "WHERE \"useruuid\"=:uuid"; | 765 | query += "WHERE \"useruuid\"=:uuid"; |
765 | 766 | ||
766 | try | 767 | try |
767 | { | 768 | { |
768 | using (NpgsqlConnection dbcon = new NpgsqlConnection(ConnectionString)) | 769 | using (NpgsqlConnection dbcon = new NpgsqlConnection(ConnectionString)) |
@@ -776,7 +777,7 @@ namespace OpenSim.Data.PGSQL | |||
776 | cmd.Parameters.Add(m_database.CreateParameter("SkillsText", up.SkillsText)); | 777 | cmd.Parameters.Add(m_database.CreateParameter("SkillsText", up.SkillsText)); |
777 | cmd.Parameters.Add(m_database.CreateParameter("Languages", up.Language)); | 778 | cmd.Parameters.Add(m_database.CreateParameter("Languages", up.Language)); |
778 | cmd.Parameters.Add(m_database.CreateParameter("uuid", up.UserId)); | 779 | cmd.Parameters.Add(m_database.CreateParameter("uuid", up.UserId)); |
779 | 780 | ||
780 | cmd.ExecuteNonQuery(); | 781 | cmd.ExecuteNonQuery(); |
781 | } | 782 | } |
782 | } | 783 | } |
@@ -804,13 +805,13 @@ namespace OpenSim.Data.PGSQL | |||
804 | { | 805 | { |
805 | dbcon.Open(); | 806 | dbcon.Open(); |
806 | 807 | ||
807 | using (NpgsqlCommand cmd = new NpgsqlCommand(string.Format (query,"\"classifieds\""), dbcon)) | 808 | using (NpgsqlCommand cmd = new NpgsqlCommand(string.Format(query, "\"classifieds\""), dbcon)) |
808 | { | 809 | { |
809 | cmd.Parameters.Add(m_database.CreateParameter("Id", avatarId)); | 810 | cmd.Parameters.Add(m_database.CreateParameter("Id", avatarId)); |
810 | 811 | ||
811 | using (NpgsqlDataReader reader = cmd.ExecuteReader(CommandBehavior.SingleRow)) | 812 | using (NpgsqlDataReader reader = cmd.ExecuteReader(CommandBehavior.SingleRow)) |
812 | { | 813 | { |
813 | if(reader.HasRows) | 814 | if (reader.HasRows) |
814 | { | 815 | { |
815 | while (reader.Read()) | 816 | while (reader.Read()) |
816 | { | 817 | { |
@@ -823,13 +824,13 @@ namespace OpenSim.Data.PGSQL | |||
823 | dbcon.Close(); | 824 | dbcon.Close(); |
824 | dbcon.Open(); | 825 | dbcon.Open(); |
825 | 826 | ||
826 | using (NpgsqlCommand cmd = new NpgsqlCommand(string.Format (query,"\"userpicks\""), dbcon)) | 827 | using (NpgsqlCommand cmd = new NpgsqlCommand(string.Format(query, "\"userpicks\""), dbcon)) |
827 | { | 828 | { |
828 | cmd.Parameters.Add(m_database.CreateParameter("Id", avatarId)); | 829 | cmd.Parameters.Add(m_database.CreateParameter("Id", avatarId)); |
829 | 830 | ||
830 | using (NpgsqlDataReader reader = cmd.ExecuteReader(CommandBehavior.SingleRow)) | 831 | using (NpgsqlDataReader reader = cmd.ExecuteReader(CommandBehavior.SingleRow)) |
831 | { | 832 | { |
832 | if(reader.HasRows) | 833 | if (reader.HasRows) |
833 | { | 834 | { |
834 | while (reader.Read()) | 835 | while (reader.Read()) |
835 | { | 836 | { |
@@ -838,19 +839,19 @@ namespace OpenSim.Data.PGSQL | |||
838 | } | 839 | } |
839 | } | 840 | } |
840 | } | 841 | } |
841 | 842 | ||
842 | dbcon.Close(); | 843 | dbcon.Close(); |
843 | dbcon.Open(); | 844 | dbcon.Open(); |
844 | 845 | ||
845 | query = "SELECT \"profileImage\", \"profileFirstImage\" FROM \"userprofile\" WHERE \"useruuid\" = :Id"; | 846 | query = "SELECT \"profileImage\", \"profileFirstImage\" FROM \"userprofile\" WHERE \"useruuid\" = :Id"; |
846 | 847 | ||
847 | using (NpgsqlCommand cmd = new NpgsqlCommand(string.Format (query,"\"userpicks\""), dbcon)) | 848 | using (NpgsqlCommand cmd = new NpgsqlCommand(string.Format(query, "\"userpicks\""), dbcon)) |
848 | { | 849 | { |
849 | cmd.Parameters.Add(m_database.CreateParameter("Id", avatarId)); | 850 | cmd.Parameters.Add(m_database.CreateParameter("Id", avatarId)); |
850 | 851 | ||
851 | using (NpgsqlDataReader reader = cmd.ExecuteReader(CommandBehavior.SingleRow)) | 852 | using (NpgsqlDataReader reader = cmd.ExecuteReader(CommandBehavior.SingleRow)) |
852 | { | 853 | { |
853 | if(reader.HasRows) | 854 | if (reader.HasRows) |
854 | { | 855 | { |
855 | while (reader.Read()) | 856 | while (reader.Read()) |
856 | { | 857 | { |
@@ -869,19 +870,19 @@ namespace OpenSim.Data.PGSQL | |||
869 | 870 | ||
870 | return data; | 871 | return data; |
871 | } | 872 | } |
872 | 873 | ||
873 | #region User Preferences | 874 | #region User Preferences |
874 | 875 | ||
875 | public bool GetUserPreferences(ref UserPreferences pref, ref string result) | 876 | public bool GetUserPreferences(ref UserPreferences pref, ref string result) |
876 | { | 877 | { |
877 | string query = string.Empty; | 878 | string query = string.Empty; |
878 | 879 | ||
879 | query += "SELECT imviaemail,visible,email FROM "; | 880 | query += "SELECT imviaemail,visible,email FROM "; |
880 | query += "usersettings WHERE "; | 881 | query += "usersettings WHERE "; |
881 | query += "useruuid = :Id"; | 882 | query += "useruuid = :Id"; |
882 | 883 | ||
883 | OSDArray data = new OSDArray(); | 884 | OSDArray data = new OSDArray(); |
884 | 885 | ||
885 | try | 886 | try |
886 | { | 887 | { |
887 | using (NpgsqlConnection dbcon = new NpgsqlConnection(ConnectionString)) | 888 | using (NpgsqlConnection dbcon = new NpgsqlConnection(ConnectionString)) |
@@ -890,10 +891,10 @@ namespace OpenSim.Data.PGSQL | |||
890 | using (NpgsqlCommand cmd = new NpgsqlCommand(query, dbcon)) | 891 | using (NpgsqlCommand cmd = new NpgsqlCommand(query, dbcon)) |
891 | { | 892 | { |
892 | cmd.Parameters.Add(m_database.CreateParameter("Id", pref.UserId)); | 893 | cmd.Parameters.Add(m_database.CreateParameter("Id", pref.UserId)); |
893 | 894 | ||
894 | using (NpgsqlDataReader reader = cmd.ExecuteReader()) | 895 | using (NpgsqlDataReader reader = cmd.ExecuteReader()) |
895 | { | 896 | { |
896 | if(reader.HasRows) | 897 | if (reader.HasRows) |
897 | { | 898 | { |
898 | reader.Read(); | 899 | reader.Read(); |
899 | bool.TryParse((string)reader["imviaemail"], out pref.IMViaEmail); | 900 | bool.TryParse((string)reader["imviaemail"], out pref.IMViaEmail); |
@@ -924,16 +925,16 @@ namespace OpenSim.Data.PGSQL | |||
924 | return true; | 925 | return true; |
925 | } | 926 | } |
926 | 927 | ||
927 | public bool UpdateUserPreferences(ref UserPreferences pref, ref string result) | 928 | public bool UpdateUserPreferences(ref UserPreferences pref, ref string result) |
928 | { | 929 | { |
929 | string query = string.Empty; | 930 | string query = string.Empty; |
930 | 931 | ||
931 | query += "UPDATE usersettings SET "; | 932 | query += "UPDATE usersettings SET "; |
932 | query += "imviaemail=:ImViaEmail, "; | 933 | query += "imviaemail=:ImViaEmail, "; |
933 | query += "visible=:Visible, "; | 934 | query += "visible=:Visible, "; |
934 | query += "email=:Email "; | 935 | query += "email=:Email "; |
935 | query += "WHERE useruuid=:uuid"; | 936 | query += "WHERE useruuid=:uuid"; |
936 | 937 | ||
937 | try | 938 | try |
938 | { | 939 | { |
939 | using (NpgsqlConnection dbcon = new NpgsqlConnection(ConnectionString)) | 940 | using (NpgsqlConnection dbcon = new NpgsqlConnection(ConnectionString)) |
@@ -961,17 +962,17 @@ namespace OpenSim.Data.PGSQL | |||
961 | } | 962 | } |
962 | 963 | ||
963 | #endregion User Preferences | 964 | #endregion User Preferences |
964 | 965 | ||
965 | #region Integration | 966 | #region Integration |
966 | 967 | ||
967 | public bool GetUserAppData(ref UserAppData props, ref string result) | 968 | public bool GetUserAppData(ref UserAppData props, ref string result) |
968 | { | 969 | { |
969 | string query = string.Empty; | 970 | string query = string.Empty; |
970 | 971 | ||
971 | query += "SELECT * FROM userdata WHERE "; | 972 | query += "SELECT * FROM userdata WHERE "; |
972 | query += "\"UserId\" = :Id AND "; | 973 | query += "\"UserId\" = :Id AND "; |
973 | query += "\"TagId\" = :TagId"; | 974 | query += "\"TagId\" = :TagId"; |
974 | 975 | ||
975 | try | 976 | try |
976 | { | 977 | { |
977 | using (NpgsqlConnection dbcon = new NpgsqlConnection(ConnectionString)) | 978 | using (NpgsqlConnection dbcon = new NpgsqlConnection(ConnectionString)) |
@@ -981,10 +982,10 @@ namespace OpenSim.Data.PGSQL | |||
981 | { | 982 | { |
982 | cmd.Parameters.Add(m_database.CreateParameter("Id", props.UserId)); | 983 | cmd.Parameters.Add(m_database.CreateParameter("Id", props.UserId)); |
983 | cmd.Parameters.Add(m_database.CreateParameter("TagId", props.TagId)); | 984 | cmd.Parameters.Add(m_database.CreateParameter("TagId", props.TagId)); |
984 | 985 | ||
985 | using (NpgsqlDataReader reader = cmd.ExecuteReader(CommandBehavior.SingleRow)) | 986 | using (NpgsqlDataReader reader = cmd.ExecuteReader(CommandBehavior.SingleRow)) |
986 | { | 987 | { |
987 | if(reader.HasRows) | 988 | if (reader.HasRows) |
988 | { | 989 | { |
989 | reader.Read(); | 990 | reader.Read(); |
990 | props.DataKey = (string)reader["DataKey"]; | 991 | props.DataKey = (string)reader["DataKey"]; |
@@ -996,8 +997,8 @@ namespace OpenSim.Data.PGSQL | |||
996 | query += ":UserId,"; | 997 | query += ":UserId,"; |
997 | query += ":TagId,"; | 998 | query += ":TagId,"; |
998 | query += ":DataKey,"; | 999 | query += ":DataKey,"; |
999 | query += ":DataVal) "; | 1000 | query += ":DataVal) "; |
1000 | 1001 | ||
1001 | using (NpgsqlCommand put = new NpgsqlCommand(query, dbcon)) | 1002 | using (NpgsqlCommand put = new NpgsqlCommand(query, dbcon)) |
1002 | { | 1003 | { |
1003 | put.Parameters.Add(m_database.CreateParameter("UserId", props.UserId)); | 1004 | put.Parameters.Add(m_database.CreateParameter("UserId", props.UserId)); |
@@ -1023,16 +1024,16 @@ namespace OpenSim.Data.PGSQL | |||
1023 | } | 1024 | } |
1024 | 1025 | ||
1025 | public bool SetUserAppData(UserAppData props, ref string result) | 1026 | public bool SetUserAppData(UserAppData props, ref string result) |
1026 | { | 1027 | { |
1027 | string query = string.Empty; | 1028 | string query = string.Empty; |
1028 | 1029 | ||
1029 | query += "UPDATE userdata SET "; | 1030 | query += "UPDATE userdata SET "; |
1030 | query += "\"TagId\" = :TagId, "; | 1031 | query += "\"TagId\" = :TagId, "; |
1031 | query += "\"DataKey\" = :DataKey, "; | 1032 | query += "\"DataKey\" = :DataKey, "; |
1032 | query += "\"DataVal\" = :DataVal WHERE "; | 1033 | query += "\"DataVal\" = :DataVal WHERE "; |
1033 | query += "\"UserId\" = :UserId AND "; | 1034 | query += "\"UserId\" = :UserId AND "; |
1034 | query += "\"TagId\" = :TagId"; | 1035 | query += "\"TagId\" = :TagId"; |
1035 | 1036 | ||
1036 | try | 1037 | try |
1037 | { | 1038 | { |
1038 | using (NpgsqlConnection dbcon = new NpgsqlConnection(ConnectionString)) | 1039 | using (NpgsqlConnection dbcon = new NpgsqlConnection(ConnectionString)) |
@@ -1041,9 +1042,9 @@ namespace OpenSim.Data.PGSQL | |||
1041 | using (NpgsqlCommand cmd = new NpgsqlCommand(query, dbcon)) | 1042 | using (NpgsqlCommand cmd = new NpgsqlCommand(query, dbcon)) |
1042 | { | 1043 | { |
1043 | cmd.Parameters.Add(m_database.CreateParameter("UserId", props.UserId.ToString())); | 1044 | cmd.Parameters.Add(m_database.CreateParameter("UserId", props.UserId.ToString())); |
1044 | cmd.Parameters.Add(m_database.CreateParameter("TagId", props.TagId.ToString ())); | 1045 | cmd.Parameters.Add(m_database.CreateParameter("TagId", props.TagId.ToString())); |
1045 | cmd.Parameters.Add(m_database.CreateParameter("DataKey", props.DataKey.ToString ())); | 1046 | cmd.Parameters.Add(m_database.CreateParameter("DataKey", props.DataKey.ToString())); |
1046 | cmd.Parameters.Add(m_database.CreateParameter("DataVal", props.DataKey.ToString ())); | 1047 | cmd.Parameters.Add(m_database.CreateParameter("DataVal", props.DataKey.ToString())); |
1047 | 1048 | ||
1048 | cmd.ExecuteNonQuery(); | 1049 | cmd.ExecuteNonQuery(); |
1049 | } | 1050 | } |