<%@LANGUAGE="VBSCRIPT"%> <% '===================================================== ' Daemon Plan control interface ' _json_plan_control.asp ' 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 = 65001 Response.CharSet = "UTF-8" %> <% '------------ ACCESS CONTROL ------------------ %> <% '------------ Variable Definition ------------- Dim parOpr Dim result Dim SqlQry Dim rsQry Dim canControl parOpr = QStrPar("opr") result = -1 ' Init the output JSON class ' Operations can add data ' Default data will be added at the end Dim oJSON Set oJSON = New aspJSON Dim 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 Next If (parOpr = "setThreshold") Then setThreshold ElseIf (parOpr = "setDrop") Then setDrop Else oJSON.data("error") = 1 oJSON.data("emsgSummary") = "Unknown JSON Operation" oJSON.data("emsgDetails") = "The Requested JSON operation is not supported: " & parOpr End If ' SQL error detection and reporting If objEH.LastOraFailed Then oJSON.data("error") = 1 result = -1 oJSON.data("emsgSummary") = objEH.MessageSummary oJSON.data("emsgDetails") = objEH.MessageDetails oJSON.data("SqlQry") = SqlQry ' ' Detect program errors ElseIf Err.number <> 0 Then result = -3 oJSON.data("error") = 2 oJSON.data("errnum") = Err.number oJSON.data("errtxt") = Err.description oJSON.data("errsrc") = Err.source oJSON.data("emsgSummary") = "Internal VBScript Error:" & Err.number & ":" & Err.description End If On error goto 0 'Write single value oJSON.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 'Return the object Response.Write oJSON.JSONoutput() Set oJSON = Nothing Call Destroy_All_Objects %> <% '------------------------------------------------- ' Function: setThreshold ' Description: Set the PLAN_THRESHOLD indication on the RELEASE Function canAccess canAccess = canActionControlInProject("BuildControl") If NOT canAccess Then oJSON.data("error") = 1 oJSON.data("emsgSummary") = "User does not have access to this function" oJSON.data("emsgDetails") = "User does not have access to this function : " & parOpr result = -2 End If End Function '------------------------------------------------- ' Function: setThreshold ' Description: Set the PLAN_THRESHOLD indication on the RELEASE Sub setThreshold If canAccess() Then Dim parRtagId : parRtagId = QStrPar("rtag_id") Dim parThreshold : parThreshold = QStrPar("threshold") objEH.ErrorRedirect = FALSE objEH.TryORA ( OraSession ) On Error Resume Next OraDatabase.Parameters.Add "RTAG_ID", parRtagId, ORAPARM_INPUT, ORATYPE_NUMBER OraDatabase.Parameters.Add "THRESHOLD", parThreshold, ORAPARM_INPUT, ORATYPE_NUMBER SqlQry = "UPDATE RELEASE_TAGS SET PLAN_THRESHOLD = :THRESHOLD where RTAG_ID = :RTAG_ID" OraDatabase.ExecuteSQL SqlQry OraDatabase.Parameters.Remove "RTAG_ID" OraDatabase.Parameters.Remove "THRESHOLD" objEH.CatchORA ( OraSession ) result = 0 End If End Sub '------------------------------------------------- ' Function: setDrop ' Description: Set the PLAN_DROP indication on the RELEASE Sub setDrop If canAccess() Then Dim parRtagId : parRtagId = QStrPar("rtag_id") Dim parMode : parMode = IIF(RequestBool("mode", False), "Y", "N") objEH.ErrorRedirect = FALSE objEH.TryORA ( OraSession ) On Error Resume Next OraDatabase.Parameters.Add "RTAG_ID", parRtagId, ORAPARM_INPUT, ORATYPE_NUMBER OraDatabase.Parameters.Add "PMODE", parMode, ORAPARM_INPUT, ORATYPE_CHAR SqlQry = "UPDATE RELEASE_TAGS SET PLAN_DROP = :PMODE where RTAG_ID = :RTAG_ID" OraDatabase.ExecuteSQL SqlQry OraDatabase.Parameters.Remove "RTAG_ID" OraDatabase.Parameters.Remove "PMODE" objEH.CatchORA ( OraSession ) result = 0 End If End Sub %>