aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenGrid.Framework.Data.DB4o/DB4oManager.cs
diff options
context:
space:
mode:
authorAdam Frisby2007-05-05 23:04:47 +0000
committerAdam Frisby2007-05-05 23:04:47 +0000
commit6d6117e0196e8aabccee2a8879b0b6ad950ab3ab (patch)
tree61d8e736ebd1a407010900d2839fbfdf83ea37d7 /OpenGrid.Framework.Data.DB4o/DB4oManager.cs
parentGrid Framework for DB4o - supports all framework.data interfaces. (diff)
downloadopensim-SC_OLD-6d6117e0196e8aabccee2a8879b0b6ad950ab3ab.zip
opensim-SC_OLD-6d6117e0196e8aabccee2a8879b0b6ad950ab3ab.tar.gz
opensim-SC_OLD-6d6117e0196e8aabccee2a8879b0b6ad950ab3ab.tar.bz2
opensim-SC_OLD-6d6117e0196e8aabccee2a8879b0b6ad950ab3ab.tar.xz
You can now save profiles to a database. (Zomg!)
Diffstat (limited to 'OpenGrid.Framework.Data.DB4o/DB4oManager.cs')
-rw-r--r--OpenGrid.Framework.Data.DB4o/DB4oManager.cs29
1 files changed, 27 insertions, 2 deletions
diff --git a/OpenGrid.Framework.Data.DB4o/DB4oManager.cs b/OpenGrid.Framework.Data.DB4o/DB4oManager.cs
index f889636..3ebcee2 100644
--- a/OpenGrid.Framework.Data.DB4o/DB4oManager.cs
+++ b/OpenGrid.Framework.Data.DB4o/DB4oManager.cs
@@ -10,11 +10,13 @@ namespace OpenGrid.Framework.Data.DB4o
10 class DB4oManager 10 class DB4oManager
11 { 11 {
12 public Dictionary<LLUUID, SimProfileData> profiles = new Dictionary<LLUUID, SimProfileData>(); 12 public Dictionary<LLUUID, SimProfileData> profiles = new Dictionary<LLUUID, SimProfileData>();
13 13 string dbfl;
14
14 public DB4oManager(string db4odb) 15 public DB4oManager(string db4odb)
15 { 16 {
17 dbfl = db4odb;
16 IObjectContainer database; 18 IObjectContainer database;
17 database = Db4oFactory.OpenFile(db4odb); 19 database = Db4oFactory.OpenFile(dbfl);
18 IObjectSet result = database.Get(typeof(SimProfileData)); 20 IObjectSet result = database.Get(typeof(SimProfileData));
19 foreach(SimProfileData row in result) { 21 foreach(SimProfileData row in result) {
20 profiles.Add(row.UUID, row); 22 profiles.Add(row.UUID, row);
@@ -22,6 +24,29 @@ namespace OpenGrid.Framework.Data.DB4o
22 database.Close(); 24 database.Close();
23 } 25 }
24 26
27 /// <summary>
28 /// Adds a new profile to the database (Warning: Probably slow.)
29 /// </summary>
30 /// <param name="row">The profile to add</param>
31 /// <returns>Successful?</returns>
32 public bool AddRow(SimProfileData row)
33 {
34 profiles.Add(row.UUID, row);
35
36 try
37 {
38 IObjectContainer database;
39 database = Db4oFactory.OpenFile(dbfl);
40 database.Set(row);
41 database.Close();
42 return true;
43 }
44 catch (Exception e)
45 {
46 return false;
47 }
48 }
49
25 50
26 } 51 }
27} 52}