Exemplo n.º 1
0
 private static OSDMap GroupRecord2OSDMap(GroupRecord group)
 {
     OSDMap resp = new OSDMap();
     resp["GroupID"] = group.GroupID;
     resp["GroupName"] = group.GroupName;
     resp["AllowPublish"] = group.AllowPublish;
     resp["MaturePublish"] = group.MaturePublish;
     resp["Charter"] = group.Charter;
     resp["FounderID"] = group.FounderID;
     resp["GroupPicture"] = group.GroupPicture;
     resp["MembershipFee"] = group.MembershipFee;
     resp["OpenEnrollment"] = group.OpenEnrollment;
     resp["OwnerRoleID"] = group.OwnerRoleID;
     resp["ShowInList"] = group.ShowInList;
     return resp;
 }
        public GroupRecord GetGroupRecord(UUID requestingAgentID, UUID GroupID, string GroupName)
        {
            Dictionary<string, object> sendData = new Dictionary<string, object>();

            sendData["METHOD"] = "GetGroupRecord";
            sendData["requestingAgentID"] = requestingAgentID;
            sendData["GroupID"] = GroupID;
            sendData["GroupName"] = GroupName;

            string reqString = WebUtils.BuildXmlResponse(sendData);

            try
            {
                List<string> m_ServerURIs = m_registry.RequestModuleInterface<IConfigurationService>().FindValueOf(requestingAgentID.ToString(), "RemoteServerURI", true);
                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;
                            foreach (object f in replyvalues)
                            {
                                if (f is Dictionary<string, object>)
                                {
                                    GroupRecord group = new GroupRecord((Dictionary<string, object>)f);
                                    // Success
                                    return group;
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception e)
            {
                MainConsole.Instance.DebugFormat("[AuroraRemoteGroupsServiceConnector]: Exception when contacting server: {0}", e.ToString());
            }

            return null;
        }
        private GroupRecord GroupProfileHashtableToGroupRecord(Hashtable groupProfile)
        {
            GroupRecord group = new GroupRecord();
            group.GroupID = UUID.Parse((string) groupProfile["GroupID"]);
            group.GroupName = groupProfile["Name"].ToString();
            if (groupProfile["Charter"] != null)
            {
                group.Charter = (string) groupProfile["Charter"];
            }
            group.ShowInList = ((string) groupProfile["ShowInList"]) == "1";
            group.GroupPicture = UUID.Parse((string) groupProfile["InsigniaID"]);
            group.MembershipFee = int.Parse((string) groupProfile["MembershipFee"]);
            group.OpenEnrollment = ((string) groupProfile["OpenEnrollment"]) == "1";
            group.AllowPublish = ((string) groupProfile["AllowPublish"]) == "1";
            group.MaturePublish = ((string) groupProfile["MaturePublish"]) == "1";
            group.FounderID = UUID.Parse((string) groupProfile["FounderID"]);
            group.OwnerRoleID = UUID.Parse((string) groupProfile["OwnerRoleID"]);

            return group;
        }
        public GroupRecord GetGroupRecord(UUID requestingAgentID, UUID GroupID, string GroupName)
        {
            object remoteValue = DoRemote(requestingAgentID, GroupID, GroupName);
            if (remoteValue != null || m_doRemoteOnly)
                return (GroupRecord)remoteValue;

            GroupRecord record = new GroupRecord();

            QueryFilter filter = new QueryFilter();

            List<string> Keys = new List<string>();
            List<object> Values = new List<object>();
            if (GroupID != UUID.Zero)
            {
                filter.andFilters["GroupID"] = GroupID;
            }
            if (!string.IsNullOrEmpty(GroupName))
            {
                filter.andFilters["Name"] = GroupName.MySqlEscape(50);
            }
            if (filter.Count == 0)
            {
                return null;
            }
            List<string> osgroupsData = data.Query(new string[11]{
                "GroupID",
                "Name",
                "Charter",
                "InsigniaID",
                "FounderID",
                "MembershipFee",
                "OpenEnrollment",
                "ShowInList",
                "AllowPublish",
                "MaturePublish",
                "OwnerRoleID"
            }, "osgroup", filter, null, null, null);
            return (osgroupsData.Count == 0) ? null : GroupRecordQueryResult2GroupRecord(osgroupsData);
        }
        public GroupRecord GetGroupRecord(UUID requestingAgentID, UUID groupID, string groupName)
        {
            if (m_debugEnabled)
                MainConsole.Instance.InfoFormat("[SIMIAN-GROUPS-CONNECTOR]  {0} called", MethodBase.GetCurrentMethod().Name);

            OSDMap GroupInfoMap = null;
            if (groupID != UUID.Zero)
            {
                if (!SimianGetFirstGenericEntry(groupID, "Group", out groupName, out GroupInfoMap))
                {
                    return null;
                }
            }
            else if (!string.IsNullOrEmpty(groupName))
            {
                if (!SimianGetFirstGenericEntry("Group", groupName, out groupID, out GroupInfoMap))
                {
                    return null;
                }
            }

            GroupRecord GroupInfo = new GroupRecord
                                        {
                                            GroupID = groupID,
                                            GroupName = groupName,
                                            Charter = GroupInfoMap["Charter"].AsString(),
                                            ShowInList = GroupInfoMap["ShowInList"].AsBoolean(),
                                            GroupPicture = GroupInfoMap["InsigniaID"].AsUUID(),
                                            MembershipFee = GroupInfoMap["MembershipFee"].AsInteger(),
                                            OpenEnrollment = GroupInfoMap["OpenEnrollment"].AsBoolean(),
                                            AllowPublish = GroupInfoMap["AllowPublish"].AsBoolean(),
                                            MaturePublish = GroupInfoMap["MaturePublish"].AsBoolean(),
                                            FounderID = GroupInfoMap["FounderID"].AsUUID(),
                                            OwnerRoleID = GroupInfoMap["OwnerRoleID"].AsUUID()
                                        };

            return GroupInfo;
        }
        public GroupRecord GetGroupRecord(UUID requestingAgentID, UUID GroupID, string GroupName)
        {
            GroupRecord record = new GroupRecord();

            Dictionary<string, object> where = new Dictionary<string, object>();

            List<string> Keys = new List<string>();
            List<object> Values = new List<object>();
            if (GroupID != UUID.Zero)
            {
                where["GroupID"] = GroupID;
            }
            if (!string.IsNullOrEmpty(GroupName))
            {
                where["Name"] = GroupName.MySqlEscape(50);
            }
            if (where.Count == 0)
            {
                return null;
            }
            List<string> osgroupsData = data.Query(new string[11]{
                "GroupID",
                "Name",
                "Charter",
                "InsigniaID",
                "FounderID",
                "MembershipFee",
                "OpenEnrollment",
                "ShowInList",
                "AllowPublish",
                "MaturePublish",
                "OwnerRoleID"
            }, "osgroup", new QueryFilter
            {
                andFilters = where
            }, null, null, null);
            return (osgroupsData.Count == 0) ? null : GroupRecordQueryResult2GroupRecord(osgroupsData);
        }