SqlProfileProvider.GetAllProfiles Método

Definición

Recupera datos de perfil de usuario de los perfiles en el origen de datos.

public:
 override System::Web::Profile::ProfileInfoCollection ^ GetAllProfiles(System::Web::Profile::ProfileAuthenticationOption authenticationOption, int pageIndex, int pageSize, [Runtime::InteropServices::Out] int % totalRecords);
public override System.Web.Profile.ProfileInfoCollection GetAllProfiles (System.Web.Profile.ProfileAuthenticationOption authenticationOption, int pageIndex, int pageSize, out int totalRecords);
override this.GetAllProfiles : System.Web.Profile.ProfileAuthenticationOption * int * int * int -> System.Web.Profile.ProfileInfoCollection
Public Overrides Function GetAllProfiles (authenticationOption As ProfileAuthenticationOption, pageIndex As Integer, pageSize As Integer, ByRef totalRecords As Integer) As ProfileInfoCollection

Parámetros

authenticationOption
ProfileAuthenticationOption

Uno de los valores de la enumeración ProfileAuthenticationOption, que especifica si se devuelven perfiles anónimos, autenticados o de ambos tipos.

pageIndex
Int32

El índice de la página de resultados que se va a devolver. pageIndex es de base cero.

pageSize
Int32

Tamaño de la página de resultados que se va a devolver.

totalRecords
Int32

El resultado que devuelve este método contiene un entero que identifica el número total de perfiles. Este parámetro se pasa sin inicializar.

Devoluciones

Colección ProfileInfoCollection que contiene información de perfil de usuario de todos perfiles en el origen de datos.

Excepciones

pageIndex es menor que cero.

o bien

pageSize es menor que uno.

o bien

pageIndex multiplicado por pageSize es mayor que Int32.MaxValue.

Ejemplos

En el ejemplo de código siguiente se muestra información de perfil para todos los perfiles de los configurados applicationName en páginas de datos.

<%@ 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()
{
  SqlProfileProvider p = (SqlProfileProvider)Profile.Providers["SqlProvider"]; 
  ProfileGrid.DataSource = p.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()

  Dim p As SqlProfileProvider = CType(Profile.Providers("SqlProvider"), SqlProfileProvider) 
  ProfileGrid.DataSource = p.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>

Comentarios

El GetAllProfiles método se usa para recuperar información de perfil de los perfiles del origen de datos de la aplicación especificada por el applicationName atributo en el archivo de configuración. Use el authenticationOption parámetro para especificar si solo desea perfiles anónimos, solo perfiles autenticados o todos los perfiles que se van a buscar.

Los resultados devueltos por GetAllInactiveProfiles están restringidos por los pageIndex parámetros y pageSize . El pageSize parámetro identifica el número máximo de ProfileInfo objetos que se van a devolver en ProfileInfoCollection. El pageIndex parámetro identifica la página de resultados que se va a devolver; 0 identifica la primera página. El totalRecords parámetro es un out parámetro que se establece en el número total de perfiles de usuario inactivos para el configurado applicationName, en función de los authenticationOption parámetros y userInactiveSinceDate . Por ejemplo, si hay 13 usuarios para el configurado applicationNamey el pageIndex valor es 1 con un pageSize de 5, el ProfileInfoCollection devuelto contendrá el sexto a los décimo perfiles. El totalRecords parámetro se establecerá en 13.

Se aplica a

Consulte también