1
0

DB4oUserData.cs 2.5 KB

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