public GroupMembersData GetAgentGroupMemberData(UUID requestingAgentID, UUID GroupID, UUID AgentID)
        {
            object remoteValue = DoRemote(requestingAgentID, GroupID, AgentID);
            if (remoteValue != null || m_doRemoteOnly)
                return (GroupMembersData)remoteValue;


            QueryFilter filter = new QueryFilter();
            filter.andFilters["GroupID"] = GroupID;
            filter.andFilters["AgentID"] = requestingAgentID;

            //Permissions
            List<string> OtherPermiss = data.Query(new string[4] { 
                "AcceptNotices",
                "Contribution",
                "ListInProfile", 
                "SelectedRoleID"
            }, "osgroupmembership", filter, null, null, null);

            if (OtherPermiss.Count == 0)
            {
                return null;
            }

            filter.andFilters["AgentID"] = AgentID;

            List<string> Membership = data.Query(new string[4] { 
                "AcceptNotices",
                "Contribution",
                "ListInProfile", 
                "SelectedRoleID"
            }, "osgroupmembership", filter, null, null, null);

            if (Membership.Count != 4)
            {
                return null;
            }

            filter.andFilters.Remove("AgentID");
            filter.andFilters["RoleID"] = Membership[3];

            List<string> GroupRole = data.Query(new string[2] { 
                "Title",
                "Powers"
            }, "osrole", filter, null, null, null);

            if (GroupRole.Count != 2)
            {
                return null;
            }

            filter.andFilters.Remove("RoleID");

            List<string> OwnerRoleID = data.Query(new string[1] { 
                "OwnerRoleID"
            }, "osgroup", filter, null, null, null);

            filter.andFilters["RoleID"] = OwnerRoleID[0];
            filter.andFilters["AgentID"] = AgentID;

            bool IsOwner = uint.Parse(data.Query(new string[1] { 
                "COUNT(AgentID)"
            }, "osgrouprolemembership", filter, null, null, null)[0]) == 1;

            GroupMembersData GMD = new GroupMembersData
            {
                AcceptNotices = (Membership[0]) == "1",
                AgentID = AgentID,
                Contribution = int.Parse(Membership[1]),
                IsOwner = IsOwner,
                ListInProfile = (Membership[2]) == "1",
                AgentPowers = ulong.Parse(GroupRole[1]),
                Title = GroupRole[0],
                OnlineStatus = "(Online)"
            };

            return GMD;
        }
        public List<GroupMembersData> GetGroupMembers(UUID requestingAgentID, UUID GroupID)
        {
            if (m_debugEnabled)
                MainConsole.Instance.InfoFormat("[SIMIAN-GROUPS-CONNECTOR]  {0} called", MethodBase.GetCurrentMethod().Name);

            List<GroupMembersData> members = new List<GroupMembersData>();

            OSDMap GroupInfo;
            string GroupName;
            UUID GroupOwnerRoleID = UUID.Zero;
            if (!SimianGetFirstGenericEntry(GroupID, "Group", out GroupName, out GroupInfo))
            {
                return members;
            }
            GroupOwnerRoleID = GroupInfo["OwnerRoleID"].AsUUID();

            // Locally cache group roles, since we'll be needing this data for each member
            Dictionary<string, OSDMap> GroupRoles;
            SimianGetGenericEntries(GroupID, "GroupRole", out GroupRoles);

            // Locally cache list of group owners
            Dictionary<UUID, OSDMap> GroupOwners;
            SimianGetGenericEntries("GroupRole" + GroupID.ToString(), GroupOwnerRoleID.ToString(), out GroupOwners);

            Dictionary<UUID, OSDMap> GroupMembers;
            if (SimianGetGenericEntries("GroupMember", GroupID.ToString(), out GroupMembers))
            {
                foreach (KeyValuePair<UUID, OSDMap> member in GroupMembers)
                {
                    GroupMembersData data = new GroupMembersData {AgentID = member.Key};

                    UUID SelectedRoleID = member.Value["SelectedRoleID"].AsUUID();

                    data.AcceptNotices = member.Value["AcceptNotices"].AsBoolean();
                    data.ListInProfile = member.Value["ListInProfile"].AsBoolean();
                    data.Contribution = member.Value["Contribution"].AsInteger();

                    data.IsOwner = GroupOwners.ContainsKey(member.Key);

                    OSDMap GroupRoleInfo = GroupRoles[SelectedRoleID.ToString()];
                    data.Title = GroupRoleInfo["Title"].AsString();
                    data.AgentPowers = GroupRoleInfo["Powers"].AsULong();

                    members.Add(data);
                }
            }

            return members;
        }
        public GroupMembersData GetAgentGroupMemberData(UUID requestingAgentID, UUID GroupID, UUID AgentID)
        {
            Dictionary<string, object> sendData = new Dictionary<string, object>();

            sendData["METHOD"] = "GetAgentGroupMemberData";
            sendData["requestingAgentID"] = requestingAgentID;
            sendData["GroupID"] = GroupID;
            sendData["AgentID"] = AgentID;

            string reqString = WebUtils.BuildXmlResponse(sendData);

            try
            {
                List<string> m_ServerURIs =
                    m_registry.RequestModuleInterface<IConfigurationService>().FindValueOf(
                        requestingAgentID.ToString(), "RemoteServerURI", false);
                foreach (string m_ServerURI in m_ServerURIs)
                {
                    string reply = SynchronousRestFormsRequester.MakeRequest("POST",
                                                                             m_ServerURI,
                                                                             reqString);
                    if (reply != string.Empty)
                    {
                        Dictionary<string, object> replyData = WebUtils.ParseXmlResponse(reply);

                        if (replyData != null)
                        {
                            Dictionary<string, object>.ValueCollection replyvalues = replyData.Values;
                            GroupMembersData group = null;
#if (!ISWIN)
                            foreach (object replyvalue in replyvalues)
                            {
                                Dictionary<string, object> f = replyvalue as Dictionary<string, object>;
                                if (f != null)
                                {
                                    group = new GroupMembersData(f);
                                }
                            }
#else
                            foreach (Dictionary<string, object> f in replyvalues.OfType<Dictionary<string, object>>())
                            {
                                group = new GroupMembersData(f);
                            }
#endif
                            // Success
                            return group;
                        }
                    }
                }
            }
            catch (Exception e)
            {
                MainConsole.Instance.DebugFormat("[AuroraRemoteGroupsServiceConnector]: Exception when contacting server: {0}", e);
            }

            return null;
        }
        public GroupMembersData GetAgentGroupMemberData(UUID requestingAgentID, UUID GroupID, UUID AgentID)
        {

            Dictionary<string, object> where = new Dictionary<string, object>(2);
            where["GroupID"] = GroupID;
            where["AgentID"] = requestingAgentID;

            //Permissions
            List<string> OtherPermiss = data.Query(new string[4] { 
                "AcceptNotices",
                "Contribution",
                "ListInProfile", 
                "SelectedRoleID"
            }, "osgroupmembership", new QueryFilter
            {
                andFilters = where
            }, null, null, null);

            if (OtherPermiss.Count == 0)
            {
                return null;
            }

            where["AgentID"] = AgentID;

            List<string> Membership = data.Query(new string[4] { 
                "AcceptNotices",
                "Contribution",
                "ListInProfile", 
                "SelectedRoleID"
            }, "osgroupmembership", new QueryFilter
            {
                andFilters = where
            }, null, null, null);

            if (Membership.Count != 4)
            {
                return null;
            }

            where.Remove("AgentID");
            where["RoleID"] = Membership[3];

            List<string> GroupRole = data.Query(new string[2] { 
                "Title",
                "Powers"
            }, "osrole", new QueryFilter
            {
                andFilters = where
            }, null, null, null);

            if (GroupRole.Count != 2)
            {
                return null;
            }

            where.Remove("RoleID");

            List<string> OwnerRoleID = data.Query(new string[1] { 
                "OwnerRoleID"
            }, "osgroup", new QueryFilter
            {
                andFilters = where
            }, null, null, null);

            where["RoleID"] = OwnerRoleID[0];
            where["AgentID"] = AgentID;

            bool IsOwner = uint.Parse(data.Query(new string[1] { 
                "COUNT(AgentID)"
            }, "osgrouprolemembership", new QueryFilter
            {
                andFilters = where
            }, null, null, null)[0]) == 1;

            GroupMembersData GMD = new GroupMembersData
            {
                AcceptNotices = (Membership[0]) == "1",
                AgentID = AgentID,
                Contribution = int.Parse(Membership[1]),
                IsOwner = IsOwner,
                ListInProfile = (Membership[2]) == "1",
                AgentPowers = ulong.Parse(GroupRole[1]),
                Title = GroupRole[0],
                OnlineStatus = "(Online)"
            };

            return GMD;
        }