diff options
Diffstat (limited to 'OpenGridServices/OpenGrid.Framework.Data.DB4o/DB4oUserData.cs')
-rw-r--r-- | OpenGridServices/OpenGrid.Framework.Data.DB4o/DB4oUserData.cs | 90 |
1 files changed, 90 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..7dd4c51 --- /dev/null +++ b/OpenGridServices/OpenGrid.Framework.Data.DB4o/DB4oUserData.cs | |||
@@ -0,0 +1,90 @@ | |||
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 bool moneyTransferRequest(LLUUID from, LLUUID to, uint amount) | ||
70 | { | ||
71 | return true; | ||
72 | } | ||
73 | |||
74 | public bool inventoryTransferRequest(LLUUID from, LLUUID to, LLUUID item) | ||
75 | { | ||
76 | return true; | ||
77 | } | ||
78 | |||
79 | |||
80 | public string getName() | ||
81 | { | ||
82 | return "DB4o Userdata"; | ||
83 | } | ||
84 | |||
85 | public string getVersion() | ||
86 | { | ||
87 | return "0.1"; | ||
88 | } | ||
89 | } | ||
90 | } | ||