| 5098 |
dpurdie |
1 |
<%@LANGUAGE="VBSCRIPT"%>
|
|
|
2 |
<%
|
|
|
3 |
'=====================================================
|
|
|
4 |
' Build Daemon enquiries
|
|
|
5 |
' Designed to be called via AJAX and to return
|
|
|
6 |
' JSON formatted data to dynamic page
|
|
|
7 |
'=====================================================
|
|
|
8 |
%>
|
|
|
9 |
<%
|
|
|
10 |
Option explicit
|
|
|
11 |
' Essential to get UTF through all the hoops. ie: VÄSTTRAFIK (VTK)
|
|
|
12 |
Response.ContentType = "text/html"
|
|
|
13 |
Response.AddHeader "Content-Type", "text/html;charset=UTF-8"
|
|
|
14 |
Response.CodePage = 65001
|
|
|
15 |
Response.CharSet = "UTF-8"
|
|
|
16 |
%>
|
|
|
17 |
<!--#include file="common/conf.asp"-->
|
|
|
18 |
<!--#include file="common/globals.asp"-->
|
|
|
19 |
<!--#include file="common/qstr.asp"-->
|
|
|
20 |
<!--#include file="common/common_subs.asp"-->
|
|
|
21 |
<SCRIPT LANGUAGE="VBScript" RUNAT=SERVER SRC="class/classaspJSON.vbs"></SCRIPT>
|
|
|
22 |
<%
|
|
|
23 |
'------------ Variable Definition -------------
|
|
|
24 |
Dim parOpr
|
|
|
25 |
Dim result
|
|
|
26 |
Dim SqlQry
|
|
|
27 |
Dim rsQry
|
|
|
28 |
|
|
|
29 |
parOpr = QStrPar("opr")
|
|
|
30 |
result = -1
|
|
|
31 |
|
|
|
32 |
' Init the output JSON class
|
|
|
33 |
' Operations can add data
|
|
|
34 |
' Default data will be added at the end
|
|
|
35 |
Dim oJSON
|
|
|
36 |
Set oJSON = New aspJSON
|
|
|
37 |
Dim newitem
|
|
|
38 |
|
|
|
39 |
'
|
|
|
40 |
' Perform the body of the operations within a Sub and use
|
|
|
41 |
' On Error Resule Next to catch errors that accur in the code
|
|
|
42 |
'
|
|
|
43 |
On Error Resume Next
|
| 7063 |
dpurdie |
44 |
If (parOpr = "dynaHead") Then
|
|
|
45 |
dynaHead
|
| 5098 |
dpurdie |
46 |
|
|
|
47 |
Else
|
|
|
48 |
oJSON.data("error") = 1
|
|
|
49 |
oJSON.data("emsgSummary") = "Unknown JSON Operation"
|
|
|
50 |
oJSON.data("emsgDetails") = "The Requested JSON operation is not supported: " & parOpr
|
|
|
51 |
End If
|
|
|
52 |
|
|
|
53 |
|
|
|
54 |
' SQL error detection and reporting
|
|
|
55 |
If objEH.LastOraFailed Then
|
|
|
56 |
oJSON.data("error") = 1
|
|
|
57 |
result = -1
|
|
|
58 |
|
|
|
59 |
oJSON.data("emsgSummary") = objEH.MessageSummary
|
|
|
60 |
oJSON.data("emsgDetails") = objEH.MessageDetails
|
|
|
61 |
oJSON.data("SqlQry") = SqlQry
|
|
|
62 |
'
|
|
|
63 |
' Detect program errors
|
|
|
64 |
ElseIf Err.number <> 0 Then
|
|
|
65 |
result = -3
|
|
|
66 |
oJSON.data("error") = 2
|
|
|
67 |
oJSON.data("errnum") = Err.number
|
|
|
68 |
oJSON.data("errtxt") = Err.description
|
|
|
69 |
oJSON.data("errsrc") = Err.source
|
|
|
70 |
oJSON.data("emsgSummary") = "Internal VBScript Error:" & Err.number & ":" & Err.description
|
|
|
71 |
End If
|
|
|
72 |
On error goto 0
|
|
|
73 |
'Write single value
|
|
|
74 |
oJSON.data("result") = result
|
|
|
75 |
|
|
|
76 |
'function Sleep(seconds)
|
|
|
77 |
' dim oshell, cmd
|
|
|
78 |
' set oShell = CreateObject("Wscript.Shell")
|
|
|
79 |
' cmd = "cmd.exe /c timeout " & seconds & " /nobreak"
|
|
|
80 |
' oShell.Run cmd,0,1
|
|
|
81 |
'End function
|
|
|
82 |
'
|
|
|
83 |
'Sleep(2)
|
|
|
84 |
|
|
|
85 |
|
|
|
86 |
' DEBUG: A Hash of the user provided requests
|
|
|
87 |
<!--oJSON.data("QueryString") = Request.QueryString -->
|
|
|
88 |
<!-- -->
|
|
|
89 |
<!--Dim requestSet : Set requestSet = oJSON.Collection() -->
|
|
|
90 |
<!--Set oJSON.data("Request") = requestSet -->
|
|
|
91 |
<!--Dim variableName -->
|
|
|
92 |
<!--for each variableName in Request.QueryString -->
|
|
|
93 |
<!-- requestSet.add variableName, Request(variableName)-->
|
|
|
94 |
<!--next -->
|
|
|
95 |
<!--for each variableName in Request.Form -->
|
|
|
96 |
<!-- requestSet.add variableName, Request(variableName)-->
|
|
|
97 |
<!--next -->
|
|
|
98 |
|
|
|
99 |
|
|
|
100 |
'Return the object
|
|
|
101 |
Response.Write oJSON.JSONoutput()
|
| 5957 |
dpurdie |
102 |
Set oJSON = Nothing
|
|
|
103 |
Call Destroy_All_Objects
|
| 5098 |
dpurdie |
104 |
%>
|
|
|
105 |
<%
|
|
|
106 |
'-------------------------------------------------
|
| 7063 |
dpurdie |
107 |
' Function: dynaHead
|
|
|
108 |
' Description: Return data to update the dynamic header
|
|
|
109 |
' Indef paused, user logged out, current (Perth Time)
|
|
|
110 |
Sub dynaHead
|
| 5098 |
dpurdie |
111 |
|
| 7063 |
dpurdie |
112 |
objAccessControl.objOraSession = OraSession ' Create database link for orasession
|
|
|
113 |
objAccessControl.objOraDatabase = OraDatabase ' Create database link for oradatabase
|
| 5098 |
dpurdie |
114 |
|
| 7063 |
dpurdie |
115 |
oJSON.data("indefPause") = IndefPause
|
| 7065 |
dpurdie |
116 |
oJSON.data("now") = "Updated: " & Now & " (AWST)"
|
| 7063 |
dpurdie |
117 |
oJSON.data("loggedIn") = objAccessControl.UserLogedIn
|
| 5098 |
dpurdie |
118 |
result = 0
|
|
|
119 |
|
|
|
120 |
End Sub
|
|
|
121 |
%>
|