다음을 통해 공유


Sys.Services.ProfileService 클래스

업데이트: 2007년 11월

프로필 서비스에 클라이언트 프록시 클래스를 제공합니다.

네임스페이스:Sys.Services

상속: 없음

멤버

이름

설명

Sys.Services.ProfileService 생성자

Sys.Services.ProfileService 클래스의 새 인스턴스를 초기화합니다.

Sys.Services ProfileService DefaultWebServicePath 필드

기본 프로필 서비스의 경로를 지정합니다.

Sys.Services ProfileService properties 필드

프로필 정보를 포함합니다.

Sys.Services ProfileService load 메서드

지정된 프로필 속성을 로드합니다.

Sys.Services ProfileService save 메서드

지정된 프로필 속성을 저장합니다.

Sys.Services ProfileService defaultFailedCallback 속성

기본 실패 콜백 함수를 가져오거나 설정합니다.

Sys.Services ProfileService defaultLoadCompletedCallback 속성

로드 완료 기본 콜백 함수를 가져오거나 설정합니다.

Sys.Services ProfileService defaultSaveCompletedCallback 속성

저장 완료 기본 콜백 함수의 이름을 가져오거나 설정합니다.

Sys.Services ProfileService defaultSucceededCallback 속성

서비스에 대한 기본 성공 콜백 함수를 가져오거나 설정합니다.

Sys.Services ProfileService defaultUserContext 속성

서비스에 대한 기본 사용자 컨텍스트를 가져오거나 설정합니다.

Sys.Services ProfileService path 속성

프로필 서비스 경로를 가져오거나 설정합니다.

Sys.Services ProfileService timeout 속성

프로필 서비스 제한 시간 값을 가져오거나 설정합니다.

설명

ProfileService 클래스를 사용하면 스크립트를 통해 사용자의 프로필 정보에 액세스할 수 있습니다. 이 클래스는 다른 모든 웹 서비스 메서드를 호출하는 데 사용되는 것과 같은 인프라를 통해 프로필 서비스의 메서드를 호출합니다.

참고

기본 제공되는 프로필 서비스는 서버에서 미리 정의된 위치에 있습니다.

Profile 클래스는 전역 액세스 지점을 제공하는 하나의 인스턴스만 포함된 singleton 개체입니다. 이 클래스는 응용 프로그램에서 항상 사용할 수 있으므로 인스턴스화할 필요가 없습니다.

예제

설명

다음 예제에서는 ProfileService 클래스를 사용하여 현재 인증된 사용자의 프로필 정보를 가져오는 방법을 보여 줍니다. 자세한 내용은 ASP.NET AJAX에서 프로필 정보 사용을 참조하십시오.

코드

// 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;
}

참고 항목

개념

Sys.Services.AuthenticationService 클래스

Sys.Net.WebServiceProxy 클래스

ASP.NET AJAX에서 프로필 정보 사용

참조

Sys.Services.ProfileGroup 클래스