| 7168 |
dpurdie |
1 |
<%@LANGUAGE="VBSCRIPT"%>
|
|
|
2 |
<%
|
|
|
3 |
'=====================================================
|
|
|
4 |
' Daemon Plan control interface
|
|
|
5 |
' _json_plan_control.asp
|
|
|
6 |
' Designed to be called via AJAX and to return
|
|
|
7 |
' JSON formatted data to dynamic page
|
|
|
8 |
'=====================================================
|
|
|
9 |
%>
|
|
|
10 |
<%
|
|
|
11 |
Option explicit
|
|
|
12 |
' Essential to get UTF through all the hoops. ie: VÄSTTRAFIK (VTK)
|
|
|
13 |
Response.ContentType = "text/html"
|
|
|
14 |
Response.AddHeader "Content-Type", "text/html;charset=UTF-8"
|
|
|
15 |
Response.CodePage = 65001
|
|
|
16 |
Response.CharSet = "UTF-8"
|
|
|
17 |
%>
|
|
|
18 |
<!--#include file="common/conf.asp"-->
|
|
|
19 |
<!--#include file="common/globals.asp"-->
|
|
|
20 |
<!--#include file="common/qstr.asp"-->
|
|
|
21 |
<!--#include file="common/common_subs.asp"-->
|
|
|
22 |
<% '------------ ACCESS CONTROL ------------------ %>
|
|
|
23 |
<!--#include file="_access_control_login_optional.asp"-->
|
|
|
24 |
<!--#include file="_access_control_general.asp"-->
|
|
|
25 |
<!--#include file="_access_control_project.asp"-->
|
|
|
26 |
<SCRIPT LANGUAGE="VBScript" RUNAT=SERVER SRC="class/classaspJSON.vbs"></SCRIPT>
|
|
|
27 |
<%
|
|
|
28 |
'------------ Variable Definition -------------
|
|
|
29 |
Dim parOpr
|
|
|
30 |
Dim result
|
|
|
31 |
Dim SqlQry
|
|
|
32 |
Dim rsQry
|
|
|
33 |
Dim canControl
|
|
|
34 |
|
|
|
35 |
|
|
|
36 |
parOpr = QStrPar("opr")
|
|
|
37 |
result = -1
|
|
|
38 |
|
|
|
39 |
' Init the output JSON class
|
|
|
40 |
' Operations can add data
|
|
|
41 |
' Default data will be added at the end
|
|
|
42 |
Dim oJSON
|
|
|
43 |
Set oJSON = New aspJSON
|
|
|
44 |
Dim newitem
|
|
|
45 |
|
|
|
46 |
'
|
|
|
47 |
' Perform the body of the operations within a Sub and use
|
|
|
48 |
' On Error Resule Next to catch errors that accur in the code
|
|
|
49 |
'
|
|
|
50 |
On Error Resume Next
|
|
|
51 |
If (parOpr = "setThreshold") Then
|
|
|
52 |
setThreshold
|
|
|
53 |
|
|
|
54 |
ElseIf (parOpr = "setDrop") Then
|
|
|
55 |
setDrop
|
|
|
56 |
|
|
|
57 |
Else
|
|
|
58 |
oJSON.data("error") = 1
|
|
|
59 |
oJSON.data("emsgSummary") = "Unknown JSON Operation"
|
|
|
60 |
oJSON.data("emsgDetails") = "The Requested JSON operation is not supported: " & parOpr
|
|
|
61 |
End If
|
|
|
62 |
|
|
|
63 |
|
|
|
64 |
' SQL error detection and reporting
|
|
|
65 |
If objEH.LastOraFailed Then
|
|
|
66 |
oJSON.data("error") = 1
|
|
|
67 |
result = -1
|
|
|
68 |
|
|
|
69 |
oJSON.data("emsgSummary") = objEH.MessageSummary
|
|
|
70 |
oJSON.data("emsgDetails") = objEH.MessageDetails
|
|
|
71 |
oJSON.data("SqlQry") = SqlQry
|
|
|
72 |
'
|
|
|
73 |
' Detect program errors
|
|
|
74 |
ElseIf Err.number <> 0 Then
|
|
|
75 |
result = -3
|
|
|
76 |
oJSON.data("error") = 2
|
|
|
77 |
oJSON.data("errnum") = Err.number
|
|
|
78 |
oJSON.data("errtxt") = Err.description
|
|
|
79 |
oJSON.data("errsrc") = Err.source
|
|
|
80 |
oJSON.data("emsgSummary") = "Internal VBScript Error:" & Err.number & ":" & Err.description
|
|
|
81 |
End If
|
|
|
82 |
On error goto 0
|
|
|
83 |
'Write single value
|
|
|
84 |
oJSON.data("result") = result
|
|
|
85 |
|
|
|
86 |
'function Sleep(seconds)
|
|
|
87 |
' dim oshell, cmd
|
|
|
88 |
' set oShell = CreateObject("Wscript.Shell")
|
|
|
89 |
' cmd = "cmd.exe /c timeout " & seconds & " /nobreak"
|
|
|
90 |
' oShell.Run cmd,0,1
|
|
|
91 |
'End function
|
|
|
92 |
'
|
|
|
93 |
'Sleep(2)
|
|
|
94 |
|
|
|
95 |
|
|
|
96 |
' DEBUG: A Hash of the user provided requests
|
|
|
97 |
<!--oJSON.data("QueryString") = Request.QueryString -->
|
|
|
98 |
<!-- -->
|
|
|
99 |
<!--Dim requestSet : Set requestSet = oJSON.Collection() -->
|
|
|
100 |
<!--Set oJSON.data("Request") = requestSet -->
|
|
|
101 |
<!--Dim variableName -->
|
|
|
102 |
<!--for each variableName in Request.QueryString -->
|
|
|
103 |
<!-- requestSet.add variableName, Request(variableName)-->
|
|
|
104 |
<!--next -->
|
|
|
105 |
<!--for each variableName in Request.Form -->
|
|
|
106 |
<!-- requestSet.add variableName, Request(variableName)-->
|
|
|
107 |
<!--next -->
|
|
|
108 |
|
|
|
109 |
|
|
|
110 |
'Return the object
|
|
|
111 |
Response.Write oJSON.JSONoutput()
|
|
|
112 |
Set oJSON = Nothing
|
|
|
113 |
Call Destroy_All_Objects
|
|
|
114 |
%>
|
|
|
115 |
<%
|
|
|
116 |
'-------------------------------------------------
|
|
|
117 |
' Function: setThreshold
|
|
|
118 |
' Description: Set the PLAN_THRESHOLD indication on the RELEASE
|
|
|
119 |
Function canAccess
|
|
|
120 |
canAccess = canActionControlInProject("BuildControl")
|
|
|
121 |
If NOT canAccess Then
|
|
|
122 |
oJSON.data("error") = 1
|
|
|
123 |
oJSON.data("emsgSummary") = "User does not have access to this function"
|
|
|
124 |
oJSON.data("emsgDetails") = "User does not have access to this function : " & parOpr
|
|
|
125 |
|
|
|
126 |
result = -2
|
|
|
127 |
End If
|
|
|
128 |
End Function
|
|
|
129 |
|
|
|
130 |
'-------------------------------------------------
|
|
|
131 |
' Function: setThreshold
|
|
|
132 |
' Description: Set the PLAN_THRESHOLD indication on the RELEASE
|
|
|
133 |
Sub setThreshold
|
|
|
134 |
|
|
|
135 |
If canAccess() Then
|
|
|
136 |
Dim parRtagId : parRtagId = QStrPar("rtag_id")
|
|
|
137 |
Dim parThreshold : parThreshold = QStrPar("threshold")
|
|
|
138 |
|
|
|
139 |
objEH.ErrorRedirect = FALSE
|
|
|
140 |
objEH.TryORA ( OraSession )
|
|
|
141 |
On Error Resume Next
|
|
|
142 |
|
|
|
143 |
OraDatabase.Parameters.Add "RTAG_ID", parRtagId, ORAPARM_INPUT, ORATYPE_NUMBER
|
|
|
144 |
OraDatabase.Parameters.Add "THRESHOLD", parThreshold, ORAPARM_INPUT, ORATYPE_NUMBER
|
|
|
145 |
|
|
|
146 |
SqlQry = "UPDATE RELEASE_TAGS SET PLAN_THRESHOLD = :THRESHOLD where RTAG_ID = :RTAG_ID"
|
|
|
147 |
OraDatabase.ExecuteSQL SqlQry
|
|
|
148 |
|
|
|
149 |
OraDatabase.Parameters.Remove "RTAG_ID"
|
|
|
150 |
OraDatabase.Parameters.Remove "THRESHOLD"
|
|
|
151 |
|
|
|
152 |
objEH.CatchORA ( OraSession )
|
|
|
153 |
|
|
|
154 |
result = 0
|
|
|
155 |
End If
|
|
|
156 |
End Sub
|
|
|
157 |
|
|
|
158 |
'-------------------------------------------------
|
|
|
159 |
' Function: setDrop
|
|
|
160 |
' Description: Set the PLAN_DROP indication on the RELEASE
|
|
|
161 |
Sub setDrop
|
|
|
162 |
If canAccess() Then
|
|
|
163 |
Dim parRtagId : parRtagId = QStrPar("rtag_id")
|
|
|
164 |
Dim parMode : parMode = IIF(RequestBool("mode", False), "Y", "N")
|
|
|
165 |
|
|
|
166 |
objEH.ErrorRedirect = FALSE
|
|
|
167 |
objEH.TryORA ( OraSession )
|
|
|
168 |
On Error Resume Next
|
|
|
169 |
|
|
|
170 |
OraDatabase.Parameters.Add "RTAG_ID", parRtagId, ORAPARM_INPUT, ORATYPE_NUMBER
|
|
|
171 |
OraDatabase.Parameters.Add "PMODE", parMode, ORAPARM_INPUT, ORATYPE_CHAR
|
|
|
172 |
|
|
|
173 |
SqlQry = "UPDATE RELEASE_TAGS SET PLAN_DROP = :PMODE where RTAG_ID = :RTAG_ID"
|
|
|
174 |
OraDatabase.ExecuteSQL SqlQry
|
|
|
175 |
|
|
|
176 |
OraDatabase.Parameters.Remove "RTAG_ID"
|
|
|
177 |
OraDatabase.Parameters.Remove "PMODE"
|
|
|
178 |
|
|
|
179 |
objEH.CatchORA ( OraSession )
|
|
|
180 |
|
|
|
181 |
result = 0
|
|
|
182 |
End If
|
|
|
183 |
End Sub
|
|
|
184 |
%>
|