private GridUserData GetGridUserData(string userID) { GridUserData d = null; if (userID.Length > 36) // it's a UUI { d = m_Database.Get(userID); } else // it's a UUID { GridUserData[] ds = m_Database.GetAll(userID); if (ds == null) { return(null); } if (ds.Length > 0) { d = ds[0]; foreach (GridUserData dd in ds) { if (dd.UserID.Length > d.UserID.Length) // find the longest { d = dd; } } } } return(d); }
public bool LoggedOut(string userID, UUID sessionID, UUID regionID, Vector3 lastPosition, Vector3 lastLookAt) { m_log.DebugFormat("[GRID USER SERVICE]: User {0} is offline", userID); GridUserData d = GetGridUserData(userID); if (d == null) { d = new GridUserData(); d.UserID = userID; } d.Data["Online"] = false.ToString(); d.Data["Logout"] = Util.UnixTimeSinceEpoch().ToString(); d.Data["LastRegionID"] = regionID.ToString(); d.Data["LastPosition"] = lastPosition.ToString(); d.Data["LastLookAt"] = lastLookAt.ToString(); bool ret = m_Database.Store(d); if (ret && userID.Length >= 36) { cache.Add(userID.Substring(0, 36), d, 300000); } return(ret); }
public virtual GridUserInfo GetGridUserInfo(string userID) { GridUserData d = GetGridUserData(userID); if (d == null) { return(null); } GridUserInfo info = new GridUserInfo(); info.UserID = d.UserID; info.HomeRegionID = new UUID(d.Data["HomeRegionID"]); info.HomePosition = Vector3.Parse(d.Data["HomePosition"]); info.HomeLookAt = Vector3.Parse(d.Data["HomeLookAt"]); info.LastRegionID = new UUID(d.Data["LastRegionID"]); info.LastPosition = Vector3.Parse(d.Data["LastPosition"]); info.LastLookAt = Vector3.Parse(d.Data["LastLookAt"]); info.Online = bool.Parse(d.Data["Online"]); info.Login = Util.ToDateTime(Convert.ToInt32(d.Data["Login"])); info.Logout = Util.ToDateTime(Convert.ToInt32(d.Data["Logout"])); return(info); }
protected DGridUserInfo ToGridUserInfo(GridUserData d) { DGridUserInfo info = new DGridUserInfo(); info.UserID = d.UserID; info.HomeRegionID = new UUID(d.Data["HomeRegionID"]); info.HomePosition = Vector3.Parse(d.Data["HomePosition"]); info.HomeLookAt = Vector3.Parse(d.Data["HomeLookAt"]); info.LastRegionID = new UUID(d.Data["LastRegionID"]); info.LastPosition = Vector3.Parse(d.Data["LastPosition"]); info.LastLookAt = Vector3.Parse(d.Data["LastLookAt"]); info.Online = bool.Parse(d.Data["Online"]); info.Login = Util.ToDateTime(Convert.ToInt32(d.Data["Login"])); info.Logout = Util.ToDateTime(Convert.ToInt32(d.Data["Logout"])); if (d.Data.ContainsKey("TOS") && d.Data["TOS"] != null) { info.TOS = d.Data["TOS"]; } else { info.TOS = string.Empty; } return(info); }
protected bool StoreGridUserInfo(GridUserInfo info) { GridUserData d = new GridUserData(); d.Data["HomeRegionID"] = info.HomeRegionID.ToString(); d.Data["HomePosition"] = info.HomePosition.ToString(); d.Data["HomeLookAt"] = info.HomeLookAt.ToString(); return(m_Database.Store(d)); }
public virtual GridUserInfo GetGridUserInfo(string userID) { GridUserData d = GetGridUserData(userID); if (d == null) { return(null); } return(ToInfo(d)); }
public virtual GridUserInfo GetGridUserInfo(string userID) { GridUserData d = null; if (userID.Length > 36) // it's a UUI { d = m_Database.Get(userID); } else // it's a UUID { GridUserData[] ds = m_Database.GetAll(userID); if (ds == null) { return(null); } if (ds.Length > 0) { d = ds[0]; foreach (GridUserData dd in ds) { if (dd.UserID.Length > d.UserID.Length) // find the longest { d = dd; } } } } if (d == null) { return(null); } GridUserInfo info = new GridUserInfo(); info.UserID = d.UserID; info.HomeRegionID = new UUID(d.Data["HomeRegionID"]); info.HomePosition = Vector3.Parse(d.Data["HomePosition"]); info.HomeLookAt = Vector3.Parse(d.Data["HomeLookAt"]); info.LastRegionID = new UUID(d.Data["LastRegionID"]); info.LastPosition = Vector3.Parse(d.Data["LastPosition"]); info.LastLookAt = Vector3.Parse(d.Data["LastLookAt"]); info.Online = bool.Parse(d.Data["Online"]); info.Login = Util.ToDateTime(Convert.ToInt32(d.Data["Login"])); info.Logout = Util.ToDateTime(Convert.ToInt32(d.Data["Logout"])); return(info); }
private GridUserData GetGridUserData(string userID) { if (userID.Length > 36) { userID = userID.Substring(0, 36); } if (cache.TryGetValue(userID, out GridUserData d)) { return(d); } GridUserData[] ds = m_Database.GetAll(userID); if (ds == null || ds.Length == 0) { cache.Add(userID, null, 300000); return(null); } d = ds[0]; if (ds.Length > 1) { // try find most recent record try { int tsta = int.Parse(d.Data["Login"]); int tstb = int.Parse(d.Data["Logout"]); int cur = tstb > tsta? tstb : tsta; for (int i = 1; i < ds.Length; ++i) { GridUserData dd = ds[i]; tsta = int.Parse(dd.Data["Login"]); tstb = int.Parse(dd.Data["Logout"]); if (tsta > tstb) { tstb = tsta; } if (tstb > cur) { cur = tstb; d = dd; } } } catch { } } cache.Add(userID, d, 300000); return(d); }
public bool SetLangCode(string userID, string langCode) { GridUserData d = GetGridUserData(userID); if (d == null) { d = new GridUserData(); d.UserID = userID; } d.Data["LangCode"] = langCode; return(m_Database.Store(d)); }
public bool StoreTOS(DGridUserInfo info) { GridUserData d = m_Database.Get(info.UserID); if (d != null) { if (d.Data.ContainsKey("TOS")) { d.Data["TOS"] = info.TOS; return(m_Database.Store(d)); } } return(false); }
public bool SetHome(string userID, UUID homeID, Vector3 homePosition, Vector3 homeLookAt) { GridUserData d = GetGridUserData(userID); if (d == null) { d = new GridUserData(); d.UserID = userID; } d.Data["HomeRegionID"] = homeID.ToString(); d.Data["HomePosition"] = homePosition.ToString(); d.Data["HomeLookAt"] = homeLookAt.ToString(); return(m_Database.Store(d)); }
public bool SetLastPosition(string userID, UUID sessionID, UUID regionID, Vector3 lastPosition, Vector3 lastLookAt) { m_log.DebugFormat("[GRID USER SERVICE]: SetLastPosition for {0}", userID); GridUserData d = m_Database.Get(userID); if (d == null) { d = new GridUserData(); d.UserID = userID; } d.Data["LastRegionID"] = regionID.ToString(); d.Data["LastPosition"] = lastPosition.ToString(); d.Data["LastLookAt"] = lastLookAt.ToString(); return(m_Database.Store(d)); }
public bool SetDisplayName(string userID, string displayName) { // m_log.InfoFormat("[GRID USER SERVICE]: SetDisplayName for {0} to {1}", userID, displayName); GridUserData d = GetGridUserData(userID); if (d == null) { d = new GridUserData(); d.UserID = userID; } d.Data["DisplayName"] = displayName; d.Data["NameCached"] = Util.UnixTimeSinceEpoch().ToString(); return(m_Database.Store(d)); }
public GridUserInfo LoggedIn(string userID) { m_log.DebugFormat("[GRID USER SERVICE]: User {0} is online", userID); GridUserData d = m_Database.Get(userID); if (d == null) { d = new GridUserData(); d.UserID = userID; } d.Data["Online"] = true.ToString(); d.Data["Login"] = Util.UnixTimeSinceEpoch().ToString(); m_Database.Store(d); return(GetGridUserInfo(userID)); }
public virtual GridUserInfo GetGridUserInfo(string userID) { GridUserData d = GetGridUserData(userID); if (d == null) { return(null); } GridUserInfo info = new GridUserInfo(); info.UserID = d.UserID; info.HomeRegionID = new UUID(d.Data["HomeRegionID"]); info.HomePosition = Vector3.Parse(d.Data["HomePosition"]); info.HomeLookAt = Vector3.Parse(d.Data["HomeLookAt"]); info.LastRegionID = new UUID(d.Data["LastRegionID"]); info.LastPosition = Vector3.Parse(d.Data["LastPosition"]); info.LastLookAt = Vector3.Parse(d.Data["LastLookAt"]); info.Online = bool.Parse(d.Data["Online"]); info.Login = Util.ToDateTime(Convert.ToInt32(d.Data["Login"])); info.Logout = Util.ToDateTime(Convert.ToInt32(d.Data["Logout"])); info.DisplayName = d.Data.ContainsKey("DisplayName") ? d.Data["DisplayName"] : string.Empty; if (d.Data.ContainsKey("NameCached")) { if (d.Data["NameCached"] != null) { if (!string.IsNullOrWhiteSpace(d.Data["NameCached"])) { info.NameCached = Util.ToDateTime(Convert.ToInt32(d.Data["NameCached"])); } } } if (info.NameCached == null) { info.NameCached = DateTime.MinValue; } return(info); }
protected GridUserInfo ToGridUserInfo(GridUserData d) { GridUserInfo info = new GridUserInfo(); info.UserID = d.UserID; info.HomeRegionID = new UUID(d.Data["HomeRegionID"]); info.HomePosition = Vector3.Parse(d.Data["HomePosition"]); info.HomeLookAt = Vector3.Parse(d.Data["HomeLookAt"]); info.LastRegionID = new UUID(d.Data["LastRegionID"]); info.LastPosition = Vector3.Parse(d.Data["LastPosition"]); info.LastLookAt = Vector3.Parse(d.Data["LastLookAt"]); info.Online = bool.Parse(d.Data["Online"]); info.Login = Util.ToDateTime(Convert.ToInt32(d.Data["Login"])); info.Logout = Util.ToDateTime(Convert.ToInt32(d.Data["Logout"])); return(info); }
public bool LoggedOut(string userID, UUID sessionID, UUID regionID, Vector3 lastPosition, Vector3 lastLookAt) { m_log.DebugFormat("[GRID USER SERVICE]: User {0} is offline", userID); GridUserData d = m_Database.Get(userID); if (d == null) { d = new GridUserData(); d.UserID = userID; } d.Data["Online"] = false.ToString(); d.Data["Logout"] = Util.UnixTimeSinceEpoch().ToString(); d.Data["LastRegionID"] = regionID.ToString(); d.Data["LastPosition"] = lastPosition.ToString(); d.Data["LastLookAt"] = lastLookAt.ToString(); return(m_Database.Store(d)); }
private GridUserData GetGridUserData(string userID) { GridUserData d = null; if (userID.Length > 36) // it's a UUI { d = m_Database.Get(userID); } else // it's a UUID { GridUserData[] ds = m_Database.GetAll(userID); if (ds == null) { return(null); } if (ds.Length > 0) { d = ds[0]; foreach (GridUserData dd in ds) { if (dd.UserID == userID) // test for exact match { d = dd; break; } else if (dd.UserID.Length > d.UserID.Length) // find the longest { d = dd; } } if (d.UserID != userID) { // this seems like it warrants a WARN, but will set at INFO for now m_log.InfoFormat("[GRID USER SERVICE]: No exact match found for User ID {0}. Returning {1}.", userID, d.UserID); } } } return(d); }
public bool SetHome(string userID, UUID homeID, Vector3 homePosition, Vector3 homeLookAt) { GridUserData d = GetGridUserData(userID); if (d == null) { d = new GridUserData(); d.UserID = userID; } d.Data["HomeRegionID"] = homeID.ToString(); d.Data["HomePosition"] = homePosition.ToString(); d.Data["HomeLookAt"] = homeLookAt.ToString(); bool ret = m_Database.Store(d); if (ret && userID.Length >= 36) { cache.Add(userID.Substring(0, 36), d, 300000); } return(ret); }
public override GridUserInfo GetGridUserInfo(string userID) { GridUserData d = null; if (userID.Length > 36) // it's a UUI { d = m_Database.Get(userID); } else // it's a UUID { GridUserData[] ds = m_Database.GetAll(userID); if (ds == null) { return(null); } if (ds.Length > 0) { d = ds[0]; foreach (GridUserData dd in ds) { if (dd.UserID.Length > d.UserID.Length) // find the longest { d = dd; } } } } if (d == null) { return(null); } DGridUserInfo info = ToGridUserInfo(d); return(info); }
// </test updater> public GridUserInfo LoggedIn(string userID) { m_log.DebugFormat("[GRID USER SERVICE]: User {0} is online", userID); GridUserData d = GetGridUserData(userID); if (d == null) { d = new GridUserData(); d.UserID = userID; } d.Data["Online"] = true.ToString(); d.Data["Login"] = Util.UnixTimeSinceEpoch().ToString(); m_Database.Store(d); if (userID.Length >= 36) { cache.Add(userID.Substring(0, 36), d, 300000); } return(ToInfo(d)); }
public bool SetLastPosition(string userID, UUID sessionID, UUID regionID, Vector3 lastPosition, Vector3 lastLookAt) { // m_log.DebugFormat("[GRID USER SERVICE]: SetLastPosition for {0}", userID); GridUserData d = GetGridUserData(userID); if (d == null) { d = new GridUserData(); d.UserID = userID; } d.Data["LastRegionID"] = regionID.ToString(); d.Data["LastPosition"] = lastPosition.ToString(); d.Data["LastLookAt"] = lastLookAt.ToString(); bool ret = m_Database.Store(d); if (ret && userID.Length >= 36) { cache.Add(userID.Substring(0, 36), d, 300000); } return(ret); }
private GridUserInfo ToInfo(GridUserData d) { GridUserInfo info = new GridUserInfo(); info.UserID = d.UserID; Dictionary <string, string> kvp = d.Data; string tmpstr; if (kvp.TryGetValue("HomeRegionID", out tmpstr)) { info.HomeRegionID = new UUID(tmpstr); } else { info.HomeRegionID = UUID.Zero; } if (kvp.TryGetValue("HomePosition", out tmpstr)) { info.HomePosition = Vector3.Parse(tmpstr); } else { info.HomePosition = Vector3.Zero; } if (kvp.TryGetValue("HomeLookAt", out tmpstr)) { info.HomeLookAt = Vector3.Parse(tmpstr); } else { info.HomeLookAt = Vector3.Zero; } if (kvp.TryGetValue("LastRegionID", out tmpstr)) { info.LastRegionID = new UUID(tmpstr); } else { info.LastRegionID = UUID.Zero; } if (kvp.TryGetValue("LastPosition", out tmpstr)) { info.LastPosition = Vector3.Parse(tmpstr); } else { info.LastPosition = Vector3.Zero; } if (kvp.TryGetValue("LastLookAt", out tmpstr)) { info.LastLookAt = Vector3.Parse(tmpstr); } else { info.LastLookAt = Vector3.Zero; } if (kvp.TryGetValue("Online", out tmpstr)) { info.Online = bool.Parse(tmpstr); } else { info.Online = false; } if (kvp.TryGetValue("Login", out tmpstr)) { info.Login = Util.ToDateTime(Convert.ToInt32(tmpstr)); } else { info.Login = Util.UnixEpoch; } if (kvp.TryGetValue("Logout", out tmpstr)) { info.Logout = Util.ToDateTime(Convert.ToInt32(tmpstr)); } else { info.Logout = Util.UnixEpoch; } return(info); }
private GridUserInfo ToInfo(GridUserData d) { GridUserInfo info = new GridUserInfo(); info.UserID = d.UserID; Dictionary <string, string> kvp = d.Data; string tmpstr; if (kvp.TryGetValue("HomeRegionID", out tmpstr)) { info.HomeRegionID = new UUID(tmpstr); } else { info.HomeRegionID = UUID.Zero; } if (kvp.TryGetValue("HomePosition", out tmpstr)) { info.HomePosition = Vector3.Parse(tmpstr); } else { info.HomePosition = Vector3.Zero; } if (kvp.TryGetValue("HomeLookAt", out tmpstr)) { info.HomeLookAt = Vector3.Parse(tmpstr); } else { info.HomeLookAt = Vector3.Zero; } if (kvp.TryGetValue("LastRegionID", out tmpstr)) { info.LastRegionID = new UUID(tmpstr); } else { info.LastRegionID = UUID.Zero; } if (kvp.TryGetValue("LastPosition", out tmpstr)) { info.LastPosition = Vector3.Parse(tmpstr); } else { info.LastPosition = Vector3.Zero; } if (kvp.TryGetValue("LastLookAt", out tmpstr)) { info.LastLookAt = Vector3.Parse(tmpstr); } else { info.LastLookAt = Vector3.Zero; } if (kvp.TryGetValue("Online", out tmpstr)) { info.Online = bool.Parse(tmpstr); } else { info.Online = false; } if (kvp.TryGetValue("Login", out tmpstr)) { info.Login = Util.ToDateTime(Convert.ToInt32(tmpstr)); } else { info.Login = Util.UnixEpoch; } if (kvp.TryGetValue("Logout", out tmpstr)) { info.Logout = Util.ToDateTime(Convert.ToInt32(tmpstr)); } else { info.Logout = Util.UnixEpoch; } info.DisplayName = d.Data.ContainsKey("DisplayName") ? d.Data["DisplayName"] : string.Empty; if (d.Data.ContainsKey("NameCached")) { if (d.Data["NameCached"] != null) { if (!string.IsNullOrWhiteSpace(d.Data["NameCached"])) { info.NameCached = Util.ToDateTime(Convert.ToInt32(d.Data["NameCached"])); } } } if (info.NameCached == null) { info.NameCached = DateTime.MinValue; } return(info); }
public List <ExtendedGroupMembersData> GetGroupMembers(string RequestingAgentID, UUID GroupID) { List <ExtendedGroupMembersData> members = new List <ExtendedGroupMembersData>(); GroupData group = m_Database.RetrieveGroup(GroupID); if (group == null) { return(members); } // Unfortunately this doesn't quite work on legacy group data because of a bug // that's also being fixed here on CreateGroup. The OwnerRoleID sent to the DB was wrong. // See how to find the ownerRoleID a few lines below. UUID ownerRoleID = new UUID(group.Data["OwnerRoleID"]); RoleData[] roles = m_Database.RetrieveRoles(GroupID); if (roles == null) { // something wrong with this group return(members); } List <RoleData> rolesList = new List <RoleData>(roles); // Let's find the "real" ownerRoleID RoleData ownerRole = rolesList.Find(r => r.Data["Powers"] == ((long)OwnerPowers).ToString()); if (ownerRole != null) { ownerRoleID = ownerRole.RoleID; } // Check visibility? // When we don't want to check visibility, we pass it "all" as the requestingAgentID bool checkVisibility = !RequestingAgentID.Equals(UUID.Zero.ToString()); if (checkVisibility) { // Is the requester a member of the group? bool isInGroup = false; if (m_Database.RetrieveMember(GroupID, RequestingAgentID) != null) { isInGroup = true; } if (!isInGroup) // reduce the roles to the visible ones { rolesList = rolesList.FindAll(r => (UInt64.Parse(r.Data["Powers"]) & (ulong)GroupPowers.MemberVisible) != 0); } } MembershipData[] datas = m_Database.RetrieveMembers(GroupID); if (datas == null || (datas != null && datas.Length == 0)) { return(members); } // OK, we have everything we need foreach (MembershipData d in datas) { RoleMembershipData[] rolememberships = m_Database.RetrieveMemberRoles(GroupID, d.PrincipalID); List <RoleMembershipData> rolemembershipsList = new List <RoleMembershipData>(rolememberships); ExtendedGroupMembersData m = new ExtendedGroupMembersData(); // What's this person's current role in the group? UUID selectedRole = new UUID(d.Data["SelectedRoleID"]); RoleData selected = rolesList.Find(r => r.RoleID == selectedRole); if (selected != null) { m.Title = selected.Data["Title"]; m.AgentPowers = UInt64.Parse(selected.Data["Powers"]); } m.AgentID = d.PrincipalID; m.AcceptNotices = d.Data["AcceptNotices"] == "1" ? true : false; m.Contribution = Int32.Parse(d.Data["Contribution"]); m.ListInProfile = d.Data["ListInProfile"] == "1" ? true : false; GridUserData gud = m_GridUserService.Get(d.PrincipalID); if (gud != null) { if (bool.Parse(gud.Data["Online"])) { m.OnlineStatus = @"Online"; } else { int unixtime = int.Parse(gud.Data["Login"]); // The viewer is very picky about how these strings are formed. Eg. it will crash on malformed dates! m.OnlineStatus = (unixtime == 0) ? @"unknown" : Util.ToDateTime(unixtime).ToString("MM/dd/yyyy"); } } // Is this person an owner of the group? m.IsOwner = (rolemembershipsList.Find(r => r.RoleID == ownerRoleID) != null) ? true : false; members.Add(m); } return(members); }