Sys.Services.ProfileService クラス
更新 : 2007 年 11 月
プロファイル サービスのクライアント プロキシ クラスを提供します。
名前空間 :Sys.Services
継承 : なし
メンバ
名前 |
説明 |
---|---|
Sys.Services.ProfileService クラスの新しいインスタンスを初期化します。 |
|
既定のプロファイル サービスへのパスを指定します。 |
|
プロファイル情報を格納します。 |
|
指定したプロファイル プロパティを読み込みます。 |
|
指定したプロファイル プロパティを保存します。 |
|
既定の失敗コールバック関数を取得または設定します。 |
|
Sys.Services の ProfileService の defaultLoadCompletedCallback プロパティ |
既定の読み込み完了コールバック関数を取得または設定します。 |
Sys.Services の ProfileService の defaultSaveCompletedCallback プロパティ |
既定の保存完了コールバック関数の名前を取得または設定します。 |
Sys.Services の ProfileService の defaultSucceededCallback プロパティ |
サービスの既定の成功コールバック関数を取得または設定します。 |
サービスの既定のユーザー コンテキストを取得または設定します。 |
|
プロファイル サービス パスを取得または設定します。 |
|
プロファイル サービスのタイムアウト値を取得または設定します。 |
解説
ProfileService クラスは、ユーザーのプロファイル情報へのスクリプト アクセスを提供します。プロファイル サービスのメソッドを、他の Web サービス メソッドを呼び出す場合と同じインフラストラクチャを介して呼び出します。
メモ : |
---|
組み込みのプロファイル サービスは、サーバー上の定義済みの場所にあります。 |
Profile クラスはシングルトンで、アクセスのグローバル ポイントを提供するインスタンスを 1 つだけ持ちます。アプリケーションでいつでも使用でき、インスタンス化する必要はありません。
例
説明
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 クラス