Rev 5098 | Rev 7063 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed
<%@LANGUAGE="VBSCRIPT"%><%'=====================================================' NEW VERSION' Build Daemon enquiries' Designed to be called via AJAX and to return' JSON formatted data to dynamic page'=====================================================%><%Option explicit' Essential to get UTF through all the hoops. ie: VÄSTTRAFIK (VTK)Response.ContentType = "text/html"Response.AddHeader "Content-Type", "text/html;charset=UTF-8"Response.CodePage = 65001Response.CharSet = "UTF-8"%><!--#include file="common/conf.asp"--><!--#include file="common/globals.asp"--><!--#include file="common/qstr.asp"--><!--#include file="common/common_subs.asp"--><SCRIPT LANGUAGE="VBScript" RUNAT=SERVER SRC="class/classaspJSON.vbs"></SCRIPT><%'------------ Variable Definition -------------Dim parOprDim resultDim SqlQryDim rsQryparOpr = QStrPar("opr")result = -1' Init the output JSON class' Operations can add data' Default data will be added at the endDim oJSONSet oJSON = New aspJSONDim newitem'' Perform the body of the operations within a Sub and use' On Error Resule Next to catch errors that accur in the code'On Error Resume NextIf (parOpr = "indefPause") ThenindefPauseElseoJSON.data("error") = 1oJSON.data("emsgSummary") = "Unknown JSON Operation"oJSON.data("emsgDetails") = "The Requested JSON operation is not supported: " & parOprEnd If' SQL error detection and reportingIf objEH.LastOraFailed ThenoJSON.data("error") = 1result = -1oJSON.data("emsgSummary") = objEH.MessageSummaryoJSON.data("emsgDetails") = objEH.MessageDetailsoJSON.data("SqlQry") = SqlQry'' Detect program errorsElseIf Err.number <> 0 Thenresult = -3oJSON.data("error") = 2oJSON.data("errnum") = Err.numberoJSON.data("errtxt") = Err.descriptionoJSON.data("errsrc") = Err.sourceoJSON.data("emsgSummary") = "Internal VBScript Error:" & Err.number & ":" & Err.descriptionEnd IfOn error goto 0'Write single valueoJSON.data("result") = result'function Sleep(seconds)' dim oshell, cmd' set oShell = CreateObject("Wscript.Shell")' cmd = "cmd.exe /c timeout " & seconds & " /nobreak"' oShell.Run cmd,0,1'End function''Sleep(2)' DEBUG: A Hash of the user provided requests<!--oJSON.data("QueryString") = Request.QueryString --><!-- --><!--Dim requestSet : Set requestSet = oJSON.Collection() --><!--Set oJSON.data("Request") = requestSet --><!--Dim variableName --><!--for each variableName in Request.QueryString --><!-- requestSet.add variableName, Request(variableName)--><!--next --><!--for each variableName in Request.Form --><!-- requestSet.add variableName, Request(variableName)--><!--next -->'Return the objectResponse.Write oJSON.JSONoutput()%><%'-------------------------------------------------' Function: indefPause' Description: Determine if daemons are pausedSub indefPause' Get Data for an existing entry' Setup for the database accessSqlQry = "select * from run_level_schedule rls where rls.indefinite_pause = 'P'"objEH.ErrorRedirect = FALSEobjEH.TryORA ( OraSession )On Error Resume NextSet rsQry = OraDatabase.DbCreateDynaset( SqlQry, ORADYN_DEFAULT )objEH.CatchORA ( OraSession )oJSON.data("indefPause") = rsQry.RecordCountresult = 0rsQry.CloseSet rsQry = NothingEnd Sub%>