示例#1
0
        List <DirGroupInfo> IGroupsInterface.GetGroupsByName(UUI requestingAgent, string query)
        {
            var groups = new List <DirGroupInfo>();

            using (var conn = new MySqlConnection(m_ConnectionString))
            {
                conn.Open();
                using (var cmd = new MySqlCommand("SELECT g.GroupID, g.`Name`, g.Location, " + GCountQuery + " FROM groups AS g WHERE g.Name LIKE @value", conn))
                {
                    cmd.Parameters.AddParameter("@value", "%" + query + "%");
                    using (MySqlDataReader reader = cmd.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            DirGroupInfo info = new DirGroupInfo();
                            info.ID.ID        = reader.GetUUID("GroupID");
                            info.ID.GroupName = reader.GetString("Name");
                            string uri = reader.GetString("Location");
                            if (!string.IsNullOrEmpty(uri))
                            {
                                info.ID.HomeURI = new Uri(uri, UriKind.Absolute);
                            }
                            info.MemberCount = reader.GetInt32("MemberCount");
                            groups.Add(info);
                        }
                    }
                }
            }
            return(groups);
        }
        List <DirGroupInfo> IGroupsInterface.GetGroupsByName(UGUI requestingAgent, string query)
        {
            var groups = new List <DirGroupInfo>();

            using (var conn = new NpgsqlConnection(m_ConnectionString))
            {
                conn.Open();
                using (var cmd = new NpgsqlCommand("SELECT g.\"GroupID\", g.\"Name\", g.\"Location\", " + GCountQuery + " FROM groups AS g WHERE g.\"Name\" LIKE @value", conn))
                {
                    cmd.Parameters.AddParameter("@value", "%" + query + "%");
                    using (NpgsqlDataReader reader = cmd.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            var info = new DirGroupInfo();
                            info.ID.ID        = reader.GetUUID("GroupID");
                            info.ID.GroupName = (string)reader["Name"];
                            string uri = (string)reader["Location"];
                            if (!string.IsNullOrEmpty(uri))
                            {
                                info.ID.HomeURI = new Uri(uri, UriKind.Absolute);
                            }
                            info.MemberCount = (int)(long)reader["MemberCount"];
                            groups.Add(info);
                        }
                    }
                }
            }
            return(groups);
        }