' Arguments: None ' ' Returns : None ' '---------------------------------------------------------------------------- Sub ServeClose %>   <% End Sub '---------------------------------------------------------------------------- ' ' Function SA_ExecuteTask ' ' Synopsis Executes an Appliance Task backend object. Normally, backend Tasks ' are executed synchronously. The bExecuteAsync parameter allows overriding ' the default behavior. ' ' If the oTaskContext object has not been created and initialized, this function ' will create a default oTaskContext and will initialize it by creating task ' parameters using all input form fields from the current Request object. This ' makes it easy to pass an HTML form to the appliance task. ' ' If an error is encountered the really is no reasonable recovery that a ' scripting client can make. ' ' Arguments [in] TaskName Name of task to execute ' ' [in] bExecuteAsync Flag indicating if Task should be executed ' synchronisly (default, FALSE) or async (TRUE). ' ' [in/out] oTaskContext TaskContext object for the appliance task. The TaskContext ' object can be used to pass input arguments to the Task. ' ' Returns: ' SA_NO_ERROR ' The call succeeded, no errors occured ' ' SA_ERROR_CREATE_OBJECT_FAILED ' Unable to create one of the required backend objects, this indicates that either the ' components were not installed correctly or that the Appliance Manager service ' is not running. ' ' SA_ERROR_INITIALIZE_OBJECT_FAILED ' The Task object encountered an unrecoverable error during it's internal initialization. ' This is probably not recoverable and likely indicates a problem with either the expected ' inputs or the current state of the Appliance task. ' ' All other cases ' The HRESULT return value recieved from the Task ' ' ' Example 1 - Create TaskContext and set input parameters: ' Dim oTaskContext ' Dim rc ' ' Set oTaskContext = CreateObject("Taskctx.TaskContext") ' If Err.Number <> 0 Then ' ' Handle the error ' Exit Function ' End If ' ' Call oTaskContext.SetParameter("Method Name", strMethodName) ' Call oTaskContext.SetParameter("LanguageID", strLANGID) ' Call oTaskContext.SetParameter("AutoConfig", "y") ' ' rc = SA_ExecuteTask("ChangeLanguage", FALSE, oTaskContext) ' If ( rc <> SA_NO_ERROR ) Then ' ' Handle the error ' End If ' ' Example 2 - Use the current input form (Request object) as input to the task ' Dim rc ' Dim oTaskContext ' Set oTaskContext = nothing ' rc = SA_ExecuteTask("MyApplianceTask", FALSE, oTaskContext) ' If ( rc <> SA_NO_ERROR ) Then ' ' Handle the error ' End If '---------------------------------------------------------------------------- ' ' Following signature has been deprecated in SAK 2.0 - See SA_ExecuteTask Private Function ExecuteTask(ByVal TaskName, ByRef oTaskContext) ExecuteTask = SA_ExecuteTask(TaskName, FALSE, oTaskContext) End Function Public Function SA_ExecuteTask(ByVal TaskName, ByVal bExecuteAsync, ByRef oTaskContext) on error resume next Err.Clear Dim objAS Dim objValue Dim objElementCol Dim objElement Dim oField Dim rc SA_ExecuteTask = SA_NO_ERROR ' ' Create default TaskContext object if necessary ' If (NOT IsObject(oTaskContext)) Then Call SA_TraceOut("SH_TASK", "SA_ExecuteTask - Creating default TaskContext") Set oTaskContext = Server.CreateObject("Taskctx.TaskContext") If (Err.Number <> 0) Then Call SA_TraceErrorOut(SA_GetScriptFileName(), "Server.CreateObject(Taskctx.TaskContext) failed: " + CStr(Hex(Err.Number)) + " " + Err.Description) SA_ExecuteTask = SA_ERROR_CREATE_OBJECT_FAILED Exit Function End If ' ' Set default value of parameters For Each oField in Request.Form oTaskContext.SetParameter oField, CStr(Request.Form(oField)) Next End If ' ' Get interface to ApplianceServices interface, the object that allows us to invoke tasks Set objAS = Server.CreateObject("Appsrvcs.ApplianceServices") If (Err.Number <> 0) Then Call SA_TraceErrorOut(SA_GetScriptFileName(), "Server.CreateObject(Appsrvcs.ApplianceServices) failed: " + CStr(Hex(Err.Number)) + " " + Err.Description) SA_ExecuteTask = SA_ERROR_CREATE_OBJECT_FAILED Exit Function End If ' ' Initialize ApplianceServices object objAS.Initialize() If (Err.Number <> 0) Then Call SA_TraceErrorOut(SA_GetScriptFileName(), "objAS.Initialize() for object Appsrvcs.ApplianceServices failed: " + CStr(Hex(Err.Number)) + " " + Err.Description) SA_ExecuteTask = SA_ERROR_INITIALIZE_OBJECT_FAILED Exit Function End If ' ' Initialize context parameters oTaskContext.SetParameter PROPERTY_TASK_NICE_NAME, mstrTaskTitle oTaskContext.SetParameter PROPERTY_TASK_URL, m_VirtualRoot + GetScriptPath() Err.Clear If ( TRUE = bExecuteAsync ) Then 'Call SA_TraceOut("SH_TASK", "Calling objAS.ExecuteTaskAsync("+TaskName+", oTaskContext)") Call objAS.ExecuteTaskAsync(TaskName, oTaskContext) Else 'Call SA_TraceOut("SH_TASK", "Calling objAS.ExecuteTask("+TaskName+", oTaskContext)") Call objAS.ExecuteTask(TaskName, oTaskContext) End If If ( Err.Number <> 0 ) Then SA_ExecuteTask = Err.Number Call SA_TraceErrorOut(SA_GetScriptFileName(), "Task execution returned failure code: " + CStr(Hex(Err.Number)) + " " + Err.Description) End If objAS.Shutdown() Err.Clear Set objAS = Nothing End Function Private Function SA_TaskToPageType() If ( mstrTaskType = "prop" ) Then SA_TaskToPageType = "Property Page" ElseIf ( mstrTaskType = TAB_PROPSHEET) Then SA_TaskToPageType = "Tabbed Property Page" ElseIf ( mstrTaskType = "wizard") Then SA_TaskToPageType = "Wizard Page" Else SA_TaskToPageType = "Unknown Page Type" End If End Function %>