ProfileManager.GetAllProfiles Método
Definição
Importante
Algumas informações dizem respeito a um produto pré-lançado que pode ser substancialmente modificado antes de ser lançado. A Microsoft não faz garantias, de forma expressa ou implícita, em relação à informação aqui apresentada.
Recupera dados de perfil de utilizador para perfis na fonte de dados.
Sobrecargas
| Name | Description |
|---|---|
| GetAllProfiles(ProfileAuthenticationOption) |
Recupera dados de perfil de utilizador para perfis na fonte de dados. |
| GetAllProfiles(ProfileAuthenticationOption, Int32, Int32, Int32) |
Recupera páginas de dados de perfil de utilizador. |
GetAllProfiles(ProfileAuthenticationOption)
Recupera dados de perfil de utilizador para perfis na fonte de dados.
public:
static System::Web::Profile::ProfileInfoCollection ^ GetAllProfiles(System::Web::Profile::ProfileAuthenticationOption authenticationOption);
public static System.Web.Profile.ProfileInfoCollection GetAllProfiles(System.Web.Profile.ProfileAuthenticationOption authenticationOption);
static member GetAllProfiles : System.Web.Profile.ProfileAuthenticationOption -> System.Web.Profile.ProfileInfoCollection
Public Shared Function GetAllProfiles (authenticationOption As ProfileAuthenticationOption) As ProfileInfoCollection
Parâmetros
- authenticationOption
- ProfileAuthenticationOption
Um dos ProfileAuthenticationOption valores de enumeração, que especifica se perfis são anónimos, autenticados ou ambos os tipos de perfis, é devolvido.
Devoluções
A ProfileInfoCollection contendo informações de perfil de utilizador para todos os perfis na fonte de dados.
Exemplos
O exemplo de código seguinte apresenta informação de perfil para todos os perfis do .applicationName
<%@ Page Language="C#" %>
<%@ Import Namespace="System.Web.Profile" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
public void Page_Load()
{
TotalLabel.Text = ProfileManager.GetNumberOfProfiles(ProfileAuthenticationOption.All).ToString();
GetProfiles();
}
private void GetProfiles()
{
ProfileGrid.DataSource = ProfileManager.GetAllProfiles(ProfileAuthenticationOption.All);
ProfileGrid.DataBind();
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>Sample: Find Profiles</title>
</head>
<body>
<form id="form1" runat="server">
<h3>Profile List</h3>
<asp:Label id="TotalLabel" runat="server" text="0" /> Profiles found.<br />
<asp:GridView id="ProfileGrid" runat="server"
CellPadding="2" CellSpacing="1" Gridlines="Both">
<HeaderStyle BackColor="darkblue" ForeColor="white" />
</asp:GridView>
</form>
</body>
</html>
<%@ Page Language="VB" %>
<%@ Import Namespace="System.Web.Profile" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
Public Sub Page_Load()
TotalLabel.Text = ProfileManager.GetNumberOfProfiles(ProfileAuthenticationOption.All).ToString()
GetProfiles()
End Sub
Private Sub GetProfiles()
ProfileGrid.DataSource = ProfileManager.GetAllProfiles(ProfileAuthenticationOption.All)
ProfileGrid.DataBind()
End Sub
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>Sample: Find Profiles</title>
</head>
<body>
<form id="form1" runat="server">
<h3>Profile List</h3>
<asp:Label id="TotalLabel" runat="server" text="0" /> Profiles found.<br />
<asp:GridView id="ProfileGrid" runat="server"
CellPadding="2" CellSpacing="1" Gridlines="Both">
<HeaderStyle BackColor="darkblue" ForeColor="white" />
</asp:GridView>
</form>
</body>
</html>
Observações
O GetAllProfiles método é usado para recuperar informação de perfil da fonte de dados da aplicação especificada pelo applicationName atributo no ficheiro de configuração. Use o authenticationOption parâmetro para especificar se quer que sejam pesquisados apenas perfis anónimos, apenas perfis autenticados ou todos os perfis.
Podes recuperar páginas de ProfileInfo objetos para perfis de utilizador usando o overload para o GetAllProfiles método que requer parâmetros adicionais pageIndex e pageSize de .
O GetAllProfiles método chama o GetAllProfiles método do fornecedor de perfil padrão. O fornecedor de perfil por defeito é especificado usando o defaultProvider atributo do elemento de configuração do perfil . Se o perfil de utilizador contiver propriedades geridas por um fornecedor de perfil diferente do fornecedor padrão, a fonte de dados do outro fornecedor de perfil não é pesquisada. Para encontrar perfis geridos por um fornecedor de perfis diferente do fornecedor padrão, obtenha uma referência ao fornecedor de perfil que utiliza a Providers propriedade e contacte diretamente o GetAllProfiles método desse fornecedor.
Ver também
Aplica-se a
GetAllProfiles(ProfileAuthenticationOption, Int32, Int32, Int32)
Recupera páginas de dados de perfil de utilizador.
public:
static System::Web::Profile::ProfileInfoCollection ^ GetAllProfiles(System::Web::Profile::ProfileAuthenticationOption authenticationOption, int pageIndex, int pageSize, [Runtime::InteropServices::Out] int % totalRecords);
public static System.Web.Profile.ProfileInfoCollection GetAllProfiles(System.Web.Profile.ProfileAuthenticationOption authenticationOption, int pageIndex, int pageSize, out int totalRecords);
static member GetAllProfiles : System.Web.Profile.ProfileAuthenticationOption * int * int * int -> System.Web.Profile.ProfileInfoCollection
Public Shared Function GetAllProfiles (authenticationOption As ProfileAuthenticationOption, pageIndex As Integer, pageSize As Integer, ByRef totalRecords As Integer) As ProfileInfoCollection
Parâmetros
- authenticationOption
- ProfileAuthenticationOption
Um dos ProfileAuthenticationOption valores de enumeração, que especifica se perfis são anónimos, autenticados ou ambos os tipos de perfis, é devolvido.
- pageIndex
- Int32
O índice da página de resultados para devolver.
pageIndex é baseado em zero.
- pageSize
- Int32
O tamanho da página de resultados para devolver.
- totalRecords
- Int32
Quando este método retorna, contém um inteiro que identifica o número total de perfis. Este parâmetro é passado sem inicializar.
Devoluções
A ProfileInfoCollection contendo informações de perfil de utilizador para todos os perfis na fonte de dados.
Exemplos
O exemplo de código seguinte apresenta informações de perfil para todos os perfis das páginas de dados configuradas applicationName in.
<%@ Page Language="C#" %>
<%@ Import Namespace="System.Web.Profile" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
int pageSize = 5;
int totalProfiles;
int totalPages;
int currentPage = 1;
public void Page_Load()
{
if (!IsPostBack)
{
GetProfiles();
}
}
private void GetProfiles()
{
ProfileGrid.DataSource = ProfileManager.GetAllProfiles(
ProfileAuthenticationOption.All,
currentPage - 1, pageSize, out totalProfiles);
totalPages = ((totalProfiles - 1) / pageSize) + 1;
// Ensure that we do not navigate past the last page of Profiles.
if (currentPage > totalPages)
{
currentPage = totalPages;
GetProfiles();
return;
}
ProfileGrid.DataBind();
CurrentPageLabel.Text = currentPage.ToString();
TotalPagesLabel.Text = totalPages.ToString();
if (currentPage == totalPages)
NextButton.Visible = false;
else
NextButton.Visible = true;
if (currentPage == 1)
PreviousButton.Visible = false;
else
PreviousButton.Visible = true;
if (totalProfiles <= 0)
NavigationPanel.Visible = false;
else
NavigationPanel.Visible = true;
}
public void NextButton_OnClick(object sender, EventArgs args)
{
currentPage = Convert.ToInt32(CurrentPageLabel.Text);
currentPage++;
GetProfiles();
}
public void PreviousButton_OnClick(object sender, EventArgs args)
{
currentPage = Convert.ToInt32(CurrentPageLabel.Text);
currentPage--;
GetProfiles();
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>Sample: Find Profiles</title>
</head>
<body>
<form id="form1" runat="server">
<h3>Profile List</h3>
<asp:Panel id="NavigationPanel" Visible="false" runat="server">
<table border="0" cellpadding="3" cellspacing="3">
<tr>
<td style="width:100">Page <asp:Label id="CurrentPageLabel" runat="server" />
of <asp:Label id="TotalPagesLabel" runat="server" /></td>
<td style="width:60"><asp:LinkButton id="PreviousButton" Text="< Prev"
OnClick="PreviousButton_OnClick" runat="server" /></td>
<td style="width:60"><asp:LinkButton id="NextButton" Text="Next >"
OnClick="NextButton_OnClick" runat="server" /></td>
</tr>
</table>
</asp:Panel>
<asp:GridView id="ProfileGrid" runat="server"
CellPadding="2" CellSpacing="1" Gridlines="Both">
<HeaderStyle BackColor="darkblue" ForeColor="white" />
</asp:GridView>
</form>
</body>
</html>
<%@ Page Language="VB" %>
<%@ Import Namespace="System.Web.Profile" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
Dim pageSize As Integer = 5
Dim totalProfiles As Integer
Dim totalPages As Integer
Dim currentPage As Integer = 1
Public Sub Page_Load()
If Not IsPostBack Then
GetProfiles()
End If
End Sub
Private Sub GetProfiles()
ProfileGrid.DataSource = ProfileManager.GetAllProfiles( _
ProfileAuthenticationOption.All, _
currentPage - 1, pageSize, totalProfiles)
totalPages = ((totalProfiles - 1) \ pageSize) + 1
' Ensure that we do not navigate past the last page of Profiles.
If currentPage > totalPages Then
currentPage = totalPages
GetProfiles()
Return
End If
ProfileGrid.DataBind()
CurrentPageLabel.Text = currentPage.ToString()
TotalPagesLabel.Text = totalPages.ToString()
If currentPage = totalPages Then
NextButton.Visible = False
Else
NextButton.Visible = True
End If
If currentPage = 1 Then
PreviousButton.Visible = False
Else
PreviousButton.Visible = True
End If
If totalProfiles <= 0 Then
NavigationPanel.Visible = False
Else
NavigationPanel.Visible = True
End If
End Sub
Public Sub NextButton_OnClick(sender As Object, args As EventArgs)
currentPage = Convert.ToInt32(CurrentPageLabel.Text)
currentPage += 1
GetProfiles()
End SUb
Public Sub PreviousButton_OnClick(sender As Object, args As EventArgs)
currentPage = Convert.ToInt32(CurrentPageLabel.Text)
currentPage -= 1
GetProfiles()
End Sub
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>Sample: Find Profiles</title>
</head>
<body>
<form id="form1" runat="server">
<h3>Profile List</h3>
<asp:Panel id="NavigationPanel" Visible="False" runat="server">
<table border="0" cellpadding="3" cellspacing="3">
<tr>
<td style="width:100">Page <asp:Label id="CurrentPageLabel" runat="server" />
of <asp:Label id="TotalPagesLabel" runat="server" /></td>
<td style="width:60"><asp:LinkButton id="PreviousButton" Text="< Prev"
OnClick="PreviousButton_OnClick" runat="server" /></td>
<td style="width:60"><asp:LinkButton id="NextButton" Text="Next >"
OnClick="NextButton_OnClick" runat="server" /></td>
</tr>
</table>
</asp:Panel>
<asp:GridView id="ProfileGrid" runat="server"
CellPadding="2" CellSpacing="1" Gridlines="Both">
<HeaderStyle BackColor="darkblue" ForeColor="white" />
</asp:GridView>
</form>
</body>
</html>
Observações
O GetAllProfiles método é usado para recuperar informação de perfil da fonte de dados da aplicação especificada pelo applicationName atributo no ficheiro de configuração. Use o authenticationOption parâmetro para especificar se quer que sejam pesquisados apenas perfis anónimos, apenas perfis autenticados ou todos os perfis.
Os resultados devolvidos por GetAllInactiveProfiles são limitados pelos pageIndex parâmetros e.pageSize O pageSize parâmetro identifica o número máximo de ProfileInfo objetos a devolver no ProfileInfoCollection. O pageIndex parâmetro identifica qual página de resultados devolver; zero identifica a primeira página. O totalRecords parâmetro é um out parâmetro definido para o número total de perfis de utilizador inativos para o configurado applicationName, com base no .authenticationOption Por exemplo, se houver 13 utilizadores para o configurado applicationName, e o pageIndex valor for um com a pageSize de 5, os ProfileInfoCollection devolvidos conterão os perfis do sexto ao décimo. O totalRecords parâmetro será definido para 13.
O GetAllProfiles método chama o GetAllProfiles método do fornecedor de perfil padrão. O fornecedor de perfil por defeito é especificado usando o defaultProvider atributo do elemento de configuração do perfil . Se o perfil de utilizador contiver propriedades geridas por um fornecedor de perfil diferente do fornecedor padrão, a fonte de dados do outro fornecedor de perfil não é pesquisada. Para encontrar perfis geridos por um fornecedor de perfis diferente do fornecedor padrão, obtenha uma referência ao fornecedor de perfil que utiliza a Providers propriedade e contacte diretamente o GetAllProfiles método desse fornecedor.