%@ LANGUAGE="VBSCRIPT"%>
<%Response.Expires = 0%>
Set HostName Page
<%
Dim strStatus
Dim strHostName
Dim objSaHelper
Dim objTaskContext
Dim objAS
Dim rc
Dim objLocMgr
Dim varReplacementStrings
Dim strUnknownErrorText
Dim strRebootErrorText
Dim strShuttingDownText
Const UNKNOWN_ERROR_TEXT = "&H40020004"
Const REBOOT_ERROR_TEXT = "&H4002000E"
Const SHUTTINGDOWN_TEXT = "&H40020011"
On Error Resume Next
Err.Clear
Set objLocMgr = Server.CreateObject("ServerAppliance.LocalizationManager")
If Err.number = 0 Then
strUnknownErrorText = objLocMgr.GetString("salocaluimsg.dll",UNKNOWN_ERROR_TEXT,varReplacementStrings)
strRebootErrorText = objLocMgr.GetString("salocaluimsg.dll",REBOOT_ERROR_TEXT,varReplacementStrings)
strShuttingDownText = objLocMgr.GetString("salocaluimsg.dll",SHUTTINGDOWN_TEXT,varReplacementStrings)
Set objLocMgr = Nothing
End If
If strUnknownErrorText = "" Then
strUnknownErrorText = "Encountered problem in setting host name. The change has been canceled."
End If
If strRebootErrorText = "" Then
strRebootErrorText = "Changing host name requires reboot. Do you want to continue?"
End If
Err.Clear
Const strMethodName = "ShutdownAppliance"
strHostName = Session("Hostname_Hostname")
Set objSaHelper = Server.CreateObject("ServerAppliance.SAHelper")
If Err.Number <> 0 Then
strStatus = strUnknownErrorText
Else
objSaHelper.HostName = strHostName
If Err.Number <> 0 Then
strStatus = strUnknownErrorText
Else
Set objTaskContext = CreateObject("Taskctx.TaskContext")
If Err.Number <> 0 Then
strStatus = strRebootErrorText
Else
Set objAS = CreateObject("Appsrvcs.ApplianceServices")
If Err.Number <> 0 Then
strStatus = strRebootErrorText
Set objTaskContext = Nothing
Else
objTaskContext.SetParameter "Method Name", strMethodName
objTaskContext.SetParameter "SleepDuration", 1000
objTaskContext.SetParameter "PowerOff", "0"
If Err.Number <> 0 Then
strStatus = strRebootErrorText
Set objAS = Nothing
Set objTaskContext = Nothing
Else
objAS.Initialize()
If Err.Number <> 0 Then
strStatus = strRebootErrorText
Set objAS = Nothing
Set objTaskContext = Nothing
Else
rc = objAS.ExecuteTaskAsync("ApplianceShutdownTask", objTaskContext)
If Err.Number <> 0 Then
strStatus = strRebootErrorText
Else
strStatus = "Success"
End If
Set objAS = Nothing
Set objTaskContext = Nothing
End If
End If
End If
End If
End If
End If
Set objSaHelper = Nothing
%>
<%=strStatus%>
<%=strShuttingDownText%>