aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenGridServices/OpenGrid.Framework.Data.DB4o/DB4oManager.cs
diff options
context:
space:
mode:
authorMW2007-05-26 13:40:19 +0000
committerMW2007-05-26 13:40:19 +0000
commit3436961bb5c01d659d09be134368f4f69460cef9 (patch)
tree3753ba4d7818df2a6bce0bbe863ff033cdfd568a /OpenGridServices/OpenGrid.Framework.Data.DB4o/DB4oManager.cs
downloadopensim-SC-3436961bb5c01d659d09be134368f4f69460cef9.zip
opensim-SC-3436961bb5c01d659d09be134368f4f69460cef9.tar.gz
opensim-SC-3436961bb5c01d659d09be134368f4f69460cef9.tar.bz2
opensim-SC-3436961bb5c01d659d09be134368f4f69460cef9.tar.xz
Start of rewrite 5279!
Diffstat (limited to '')
-rw-r--r--OpenGridServices/OpenGrid.Framework.Data.DB4o/DB4oManager.cs111
1 files changed, 111 insertions, 0 deletions
diff --git a/OpenGridServices/OpenGrid.Framework.Data.DB4o/DB4oManager.cs b/OpenGridServices/OpenGrid.Framework.Data.DB4o/DB4oManager.cs
new file mode 100644
index 0000000..1606765
--- /dev/null
+++ b/OpenGridServices/OpenGrid.Framework.Data.DB4o/DB4oManager.cs
@@ -0,0 +1,111 @@
1using System;
2using System.Collections.Generic;
3using System.Text;
4using Db4objects.Db4o;
5using OpenGrid.Framework.Data;
6using libsecondlife;
7
8namespace OpenGrid.Framework.Data.DB4o
9{
10 class DB4oGridManager
11 {
12 public Dictionary<LLUUID, SimProfileData> simProfiles = new Dictionary<LLUUID, SimProfileData>();
13 string dbfl;
14
15 public DB4oGridManager(string db4odb)
16 {
17 dbfl = db4odb;
18 IObjectContainer database;
19 database = Db4oFactory.OpenFile(dbfl);
20 IObjectSet result = database.Get(typeof(SimProfileData));
21 foreach(SimProfileData row in result) {
22 simProfiles.Add(row.UUID, row);
23 }
24 database.Close();
25 }
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 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 Console.WriteLine("adding profile to database" + row.username);
86 if (userProfiles.ContainsKey(row.UUID))
87 {
88 userProfiles[row.UUID] = row;
89 }
90 else
91 {
92 userProfiles.Add(row.UUID, row);
93 }
94
95 try
96 {
97 IObjectContainer database;
98 database = Db4oFactory.OpenFile(dbfl);
99 database.Set(row);
100 database.Close();
101 return true;
102 }
103 catch (Exception e)
104 {
105 return false;
106 }
107 }
108
109
110 }
111}