aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenGrid.Framework.Data.DB4o/DB4oManager.cs
diff options
context:
space:
mode:
authorgareth2007-05-07 16:32:30 +0000
committergareth2007-05-07 16:32:30 +0000
commit3de3d8bb3ba9b0781a2078c8698816ae5b72f7b1 (patch)
tree5d6b1009685278b214100a7901bd4feaeed584da /OpenGrid.Framework.Data.DB4o/DB4oManager.cs
parentUpdated to have uniform build number (diff)
downloadopensim-SC-3de3d8bb3ba9b0781a2078c8698816ae5b72f7b1.zip
opensim-SC-3de3d8bb3ba9b0781a2078c8698816ae5b72f7b1.tar.gz
opensim-SC-3de3d8bb3ba9b0781a2078c8698816ae5b72f7b1.tar.bz2
opensim-SC-3de3d8bb3ba9b0781a2078c8698816ae5b72f7b1.tar.xz
Merged 0.1-prestable back into trunk :(
Diffstat (limited to 'OpenGrid.Framework.Data.DB4o/DB4oManager.cs')
-rw-r--r--OpenGrid.Framework.Data.DB4o/DB4oManager.cs68
1 files changed, 63 insertions, 5 deletions
diff --git a/OpenGrid.Framework.Data.DB4o/DB4oManager.cs b/OpenGrid.Framework.Data.DB4o/DB4oManager.cs
index 3ebcee2..aaa6e91 100644
--- a/OpenGrid.Framework.Data.DB4o/DB4oManager.cs
+++ b/OpenGrid.Framework.Data.DB4o/DB4oManager.cs
@@ -7,19 +7,19 @@ using libsecondlife;
7 7
8namespace OpenGrid.Framework.Data.DB4o 8namespace OpenGrid.Framework.Data.DB4o
9{ 9{
10 class DB4oManager 10 class DB4oGridManager
11 { 11 {
12 public Dictionary<LLUUID, SimProfileData> profiles = new Dictionary<LLUUID, SimProfileData>(); 12 public Dictionary<LLUUID, SimProfileData> simProfiles = new Dictionary<LLUUID, SimProfileData>();
13 string dbfl; 13 string dbfl;
14 14
15 public DB4oManager(string db4odb) 15 public DB4oGridManager(string db4odb)
16 { 16 {
17 dbfl = db4odb; 17 dbfl = db4odb;
18 IObjectContainer database; 18 IObjectContainer database;
19 database = Db4oFactory.OpenFile(dbfl); 19 database = Db4oFactory.OpenFile(dbfl);
20 IObjectSet result = database.Get(typeof(SimProfileData)); 20 IObjectSet result = database.Get(typeof(SimProfileData));
21 foreach(SimProfileData row in result) { 21 foreach(SimProfileData row in result) {
22 profiles.Add(row.UUID, row); 22 simProfiles.Add(row.UUID, row);
23 } 23 }
24 database.Close(); 24 database.Close();
25 } 25 }
@@ -31,7 +31,65 @@ namespace OpenGrid.Framework.Data.DB4o
31 /// <returns>Successful?</returns> 31 /// <returns>Successful?</returns>
32 public bool AddRow(SimProfileData row) 32 public bool AddRow(SimProfileData row)
33 { 33 {
34 profiles.Add(row.UUID, row); 34 if (simProfiles.ContainsKey(row.UUID))
35 {
36 simProfiles[row.UUID] = row;
37 }
38 else
39 {
40 simProfiles.Add(row.UUID, row);
41 }
42
43 try
44 {
45 IObjectContainer database;
46 database = Db4oFactory.OpenFile(dbfl);
47 database.Set(row);
48 database.Close();
49 return true;
50 }
51 catch (Exception e)
52 {
53 return false;
54 }
55 }
56
57
58 }
59
60 class DB4oUserManager
61 {
62 public Dictionary<LLUUID, UserProfileData> userProfiles = new Dictionary<LLUUID, UserProfileData>();
63 string dbfl;
64
65 public DB4oUserManager(string db4odb)
66 {
67 dbfl = db4odb;
68 IObjectContainer database;
69 database = Db4oFactory.OpenFile(dbfl);
70 IObjectSet result = database.Get(typeof(UserProfileData));
71 foreach (UserProfileData row in result)
72 {
73 userProfiles.Add(row.UUID, row);
74 }
75 database.Close();
76 }
77
78 /// <summary>
79 /// Adds a new profile to the database (Warning: Probably slow.)
80 /// </summary>
81 /// <param name="row">The profile to add</param>
82 /// <returns>Successful?</returns>
83 public bool AddRow(UserProfileData row)
84 {
85 if (userProfiles.ContainsKey(row.UUID))
86 {
87 userProfiles[row.UUID] = row;
88 }
89 else
90 {
91 userProfiles.Add(row.UUID, row);
92 }
35 93
36 try 94 try
37 { 95 {