Subversion Repositories DevTools

Rev

Rev 7168 | Details | Compare with Previous | Last modification | View Log | RSS feed

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