Compartilhar via


Classe sys.Services.ProfileService

Fornece a classe de proxy do cliente para o serviço de analisar.

Namespace: Sys.Services

Herda: Nenhum

Membros

Nome

Descrição

Construtor sys.Services.ProfileService

Inicializa uma nova instância da classe Sys.Services.ProfileService.

Sys.Services ProfileService DefaultWebServicePath campo

Especifica o caminho do serviço de analisar padrão.

Propriedades de Sys.Services ProfileService campo

Contém as informações de analisar.

Carga Sys.Services ProfileService método

Carrega as propriedades de analisar especificado.

Sys.Services ProfileService Salvar método

Salva as propriedades de analisar especificado.

Sys.Services ProfileService defaultFailedCallback propriedade

Obtém ou define a função de retorno de chamada de falha padrão.

Sys.Services ProfileService defaultLoadCompletedCallback propriedade

Obtém ou define a função de retorno de chamada concluída carga padrão.

Sys.Services ProfileService defaultSaveCompletedCallback propriedade

Obtém ou define o nome da função de retorno de chamada salvar foi concluído padrão.

Sys.Services ProfileService defaultSucceededCallback propriedade

Obtém ou define a função de retorno de chamada padrão bem-sucedida para o serviço.

Sys.Services ProfileService defaultUserContext propriedade

Obtém ou define o contexto de usuário padrão para o serviço.

Caminho Sys.Services ProfileService propriedade

Obtém ou define o caminho do analisar de serviço.

Tempo limite Sys.Services ProfileService propriedade

Obtém ou define o valor de time limite do analisar de serviço.

Comentários

The ProfileService classe fornece acesso de script para as informações de analisar do usuário. Ela chama métodos do serviço de analisar usando a mesma infra-estrutura usada para chamar qualquer Outros método de serviço Web.

ObservaçãoObservação:

O analisar interno serviço está localizado no servidor em um local predefinido.

The Profile classe é um singleton; ele possui apenas uma instância que fornece um ponto de acesso global. Está sempre disponível para seu aplicativo e não é necessário que instanciar a ele.

Exemplo

Descrição

O exemplo a seguir mostra como usar o ProfileService classe para obter informações de analisar do usuário autenticado no momento. Para obter mais informações, consulte Usando Perfis de Informações com AJAX do ASP.NET.

Código

// The OnClickLogin function is called when 
// the user clicks the Login button. 
// It calls the AuthenticationService.login to
// authenticates the user.
function OnClickLogin()
{
    Sys.Services.AuthenticationService.login(
        document.form1.userId.value,
        document.form1.userPwd.value,false,null,null,
        OnLoginComplete, AuthenticationFailedCallback,
        "User context information.");
}


// The OnClickLogout function is called when 
// the user clicks the Logout button. 
// It logs out the current authenticated user.
function OnClickLogout()
{
    Sys.Services.AuthenticationService.logout(
        null, OnLogoutComplete, AuthenticationFailedCallback,null);
}


function OnLogoutComplete(result, 
    userContext, methodName)
{
    // Code that performs logout 
    // housekeeping goes here.          
}       

// This function is called after the user is
// authenticated. It loads the user's profile.
// This is the callback function called 
// if the authentication completed successfully.
function OnLoginComplete(validCredentials, 
    userContext, methodName)
{
    if(validCredentials == true)
    {
        DisplayInformation("Welcome " + document.form1.userId.value);
    
        // Set the default failed callback function.
        DefaultFailedCallback();
        
        // Set the default load callback function.
        DefaultLoadCompletedCallback();
        
        // Set the default save callback function.
        DefaultSaveCompletedCallback();
        
        // Get path and timeout
        GetPathAndTimeout();
        
        
        LoadProfile();
        
    
        // Hide or make visible page display elements.
        GetElementById("loginId").style.visibility = "hidden";
        GetElementById("setProfProps").style.visibility = "visible";
        GetElementById("logoutId").style.visibility = "visible";
    
    }
    else
    {
        DisplayInformation("Could not login");
    }
}


// This is the callback function called 
// if the authentication failed.
function AuthenticationFailedCallback(error_object, 
    userContext, methodName)
{   
    DisplayInformation("Authentication failed with this error: " +
        error_object.get_message());
}



// Gets the profile service path and timeout.
function GetPathAndTimeout()
{
    // Get the profile service path
    var path = Sys.Services.ProfileService.get_path();

    if (path == "")
        path = "standard default path";

    alert("The profile service path is: " + path);

    // Get the profile service timeout
    var timeout = Sys.Services.ProfileService.get_timeout();

    alert("The profile service timeout is: " + timeout);

}

// Sets and gets the default load completed callback function.
function DefaultLoadCompletedCallback()
{
       

    // Set default load completed callback function.
    Sys.Services.ProfileService.set_defaultLoadCompletedCallback(LoadCompletedCallback);

     // Get default load completed callback function.
    var defaultLoadCompletedCallback =
        Sys.Services.ProfileService.get_defaultLoadCompletedCallback();
           

    alert("The default load completed callback is: " + 
        defaultLoadCompletedCallback);

}

// Sets and gets the default save completed callback function.
function DefaultSaveCompletedCallback()
{

    // Set default load completed callback function.
    Sys.Services.ProfileService.set_defaultSaveCompletedCallback(SaveCompletedCallback);

     // Get default save completed callback function.
    var defaultSaveCompletedCallback =
        Sys.Services.ProfileService.get_defaultSaveCompletedCallback();


    alert("The default save completed callback is: " + 
        defaultSaveCompletedCallback);

}
// Sets and gets the default failed callback function.
function DefaultFailedCallback()
{
       
    // Set default failed callback function.
    Sys.Services.ProfileService.set_defaultFailedCallback(ProfileFailedCallback);

     // Get default failed callback function.
    var defaultFailedCallback =
        Sys.Services.ProfileService.get_defaultFailedCallback();       


    alert("The default failed callback is: " + defaultFailedCallback);

}


// Loads the profile of the current
// authenticated user.
function LoadProfile()
{
    Sys.Services.ProfileService.load(null, 
        LoadCompletedCallback, ProfileFailedCallback, null);

}

// Saves the new profile
// information entered by the user.
function SaveProfile()
{
       
    Sys.Services.ProfileService.properties.Backgroundcolor = 
        GetElementById("bgcolor").value;
    
    Sys.Services.ProfileService.properties.Foregroundcolor =
        GetElementById("fgcolor").value; 

       
    Sys.Services.ProfileService.save(null, 
        SaveCompletedCallback, ProfileFailedCallback, null);

}

// Reads the profile information and displays it.
function LoadCompletedCallback(numProperties, userContext, methodName)
{
    document.bgColor = 
        Sys.Services.ProfileService.properties.Backgroundcolor;

    document.fgColor =   
        Sys.Services.ProfileService.properties.Foregroundcolor;         
}



// This is the callback function called 
// if the profile was saved successfully.
function SaveCompletedCallback(numProperties, userContext, methodName)
{
    LoadProfile();
    // Hide the area that contains 
    // the controls to set the profile properties.
    SetProfileControlsVisibility("hidden");
}

// This is the callback function called 
// if the profile load or save operations failed.
function ProfileFailedCallback(error_object, userContext, methodName)
{
    alert("Profile service failed with message: " + 
            error_object.get_message());
}


// Utility functions.

// This function sets the visibilty for the
// area containing the page elements for settings
// profiles.
function SetProfileControlsVisibility(currentVisibility)
{
    GetElementById("setProfileProps").style.visibility = 
        currentVisibility; 
}

// Utility function to display user's information.
function DisplayInformation(text)
{
    document.getElementById('placeHolder').innerHTML += 
    "<br/>"+ text;
}


function GetElementById(elementId)
{
    var element = document.getElementById(elementId);
    return element;
}

Consulte também

Conceitos

Classe Sys.Services.AuthenticationService

Classe Sys.Net.WebServiceProxy

Usando Perfis de Informações com AJAX do ASP.NET

Referência

Classe Sys.Services.ProfileGroup