diff options
Diffstat (limited to 'OpenGridServices/OpenGrid.Framework.Data.DB4o/DB4oUserData.cs')
-rw-r--r-- | OpenGridServices/OpenGrid.Framework.Data.DB4o/DB4oUserData.cs | 100 |
1 files changed, 100 insertions, 0 deletions
diff --git a/OpenGridServices/OpenGrid.Framework.Data.DB4o/DB4oUserData.cs b/OpenGridServices/OpenGrid.Framework.Data.DB4o/DB4oUserData.cs new file mode 100644 index 0000000..b95219c --- /dev/null +++ b/OpenGridServices/OpenGrid.Framework.Data.DB4o/DB4oUserData.cs | |||
@@ -0,0 +1,100 @@ | |||
1 | using System; | ||
2 | using System.Collections.Generic; | ||
3 | using System.Text; | ||
4 | using OpenGrid.Framework.Data; | ||
5 | using libsecondlife; | ||
6 | |||
7 | namespace OpenGrid.Framework.Data.DB4o | ||
8 | { | ||
9 | public class DB4oUserData : IUserData | ||
10 | { | ||
11 | DB4oUserManager manager; | ||
12 | |||
13 | public void Initialise() | ||
14 | { | ||
15 | manager = new DB4oUserManager("userprofiles.yap"); | ||
16 | } | ||
17 | |||
18 | public UserProfileData getUserByUUID(LLUUID uuid) | ||
19 | { | ||
20 | if(manager.userProfiles.ContainsKey(uuid)) | ||
21 | return manager.userProfiles[uuid]; | ||
22 | return null; | ||
23 | } | ||
24 | |||
25 | public UserProfileData getUserByName(string name) | ||
26 | { | ||
27 | return getUserByName(name.Split(' ')[0], name.Split(' ')[1]); | ||
28 | } | ||
29 | |||
30 | public UserProfileData getUserByName(string fname, string lname) | ||
31 | { | ||
32 | foreach (UserProfileData profile in manager.userProfiles.Values) | ||
33 | { | ||
34 | if (profile.username == fname && profile.surname == lname) | ||
35 | return profile; | ||
36 | } | ||
37 | return null; | ||
38 | } | ||
39 | |||
40 | public UserAgentData getAgentByUUID(LLUUID uuid) | ||
41 | { | ||
42 | try | ||
43 | { | ||
44 | return getUserByUUID(uuid).currentAgent; | ||
45 | } | ||
46 | catch (Exception e) | ||
47 | { | ||
48 | return null; | ||
49 | } | ||
50 | } | ||
51 | |||
52 | public UserAgentData getAgentByName(string name) | ||
53 | { | ||
54 | return getAgentByName(name.Split(' ')[0], name.Split(' ')[1]); | ||
55 | } | ||
56 | |||
57 | public UserAgentData getAgentByName(string fname, string lname) | ||
58 | { | ||
59 | try | ||
60 | { | ||
61 | return getUserByName(fname,lname).currentAgent; | ||
62 | } | ||
63 | catch (Exception e) | ||
64 | { | ||
65 | return null; | ||
66 | } | ||
67 | } | ||
68 | |||
69 | public void addNewUserProfile(UserProfileData user) | ||
70 | { | ||
71 | manager.AddRow(user); | ||
72 | } | ||
73 | |||
74 | public void addNewUserAgent(UserAgentData agent) | ||
75 | { | ||
76 | // Do nothing. yet. | ||
77 | } | ||
78 | |||
79 | public bool moneyTransferRequest(LLUUID from, LLUUID to, uint amount) | ||
80 | { | ||
81 | return true; | ||
82 | } | ||
83 | |||
84 | public bool inventoryTransferRequest(LLUUID from, LLUUID to, LLUUID item) | ||
85 | { | ||
86 | return true; | ||
87 | } | ||
88 | |||
89 | |||
90 | public string getName() | ||
91 | { | ||
92 | return "DB4o Userdata"; | ||
93 | } | ||
94 | |||
95 | public string getVersion() | ||
96 | { | ||
97 | return "0.1"; | ||
98 | } | ||
99 | } | ||
100 | } | ||