Subversion Repositories DevTools

Rev

Rev 6953 | Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
6952 dpurdie 1
<%@LANGUAGE="VBSCRIPT"%>
2
<%
3
'=====================================================
4
'   rep_new_versions_json.asp
5
'   Ajax support for various operations
6
'       getData
7
'
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
<!--#include file="_access_control_general.asp"-->
23
<SCRIPT LANGUAGE="VBScript" RUNAT=SERVER SRC="class/classaspJSON.vbs"></SCRIPT> 
24
<%
25
'------------ Variable Definition -------------
26
Dim parOpr, parRtagId
27
Dim result
28
Dim SqlQry
29
Dim rsQry
30
 
31
parOpr = QStrPar("action")
32
parRtagId = QStrPar("rtag_id")
33
result = -1
34
 
35
' Init the output JSON class
36
'   Operations can add data
37
'   Default data will be added at the end
38
Dim oJSON
39
Set oJSON = New aspJSON
40
Dim newitem
41
 
42
'   
43
'   Perform the body of the operations within a Sub and use
44
'   On Error Resule Next to catch errors that accur in the code
45
'
46
On Error Resume Next
47
If (parOpr = "getData") Then
48
    getData
49
 
50
Else
51
    oJSON.data("error") = 1
52
    oJSON.data("emsgSummary") = "Unknown JSON Operation"
53
    oJSON.data("emsgDetails") = "The Requested JSON operation is not supported: " & parOpr
54
End If
55
 
56
 
57
' SQL error detection and reporting
58
If objEH.LastOraFailed Then
59
    oJSON.data("error") = 1
60
    result = -1
61
 
62
    oJSON.data("emsgSummary") = objEH.MessageSummary
63
    oJSON.data("emsgDetails") = objEH.MessageDetails
64
    oJSON.data("SqlQry") = SqlQry
65
'
66
'   Detect program errors
67
ElseIf Err.number <> 0 Then
68
    result = -3
69
    oJSON.data("error") = 2
70
    oJSON.data("errnum") = Err.number
71
    oJSON.data("errtxt") = Err.description
72
    oJSON.data("errsrc") = Err.source
73
    oJSON.data("emsgSummary") = "Internal VBScript Error:" & Err.number &  ":" & Err.description
74
End If
75
On error goto 0
76
'Write single value
77
oJSON.data("result") = result
78
 
79
'function Sleep(seconds)
80
'    dim oshell, cmd
81
'    set oShell = CreateObject("Wscript.Shell")
82
'    cmd = "cmd.exe /c timeout " & seconds & " /nobreak"
83
'    oShell.Run cmd,0,1
84
'End function
85
'
86
'Sleep(2)
87
 
88
 
89
' DEBUG: A Hash of the user provided requests
90
<!--oJSON.data("QueryString") = Request.QueryString       -->
91
<!--                                                      -->
92
<!--Dim requestSet : Set requestSet = oJSON.Collection()  -->
93
<!--Set oJSON.data("Request") = requestSet                -->
94
<!--Dim variableName                                      -->
95
<!--for each variableName in Request.QueryString          -->
96
<!--    requestSet.add variableName, Request(variableName)-->
97
<!--next                                                  -->
98
<!--for each variableName in Request.Form                 -->
99
<!--    requestSet.add variableName, Request(variableName)-->
100
<!--next                                                  -->
101
 
102
'Return the object
103
Response.Write oJSON.JSONoutput()
104
Set oJSON = Nothing
105
Call Destroy_All_Objects
106
%>
107
<%
108
'-------------------------------------------------
109
' Function:    getData
110
' Description: Get the data for the page - as jason
111
'              Not used directly by datatables
112
'              The format is special. Its not a direct result of the sql query
113
'              Group multiple version-information as an array
114
'              ie: [ a,b,c,d,e,f, [[ a,b,c],[a,b,c]]
115
'
116
Sub getData
117
 
118
    OraDatabase.Parameters.Add "RTAG_ID", parRtagId, ORAPARM_INPUT, ORATYPE_NUMBER
119
 
120
    SqlQry = GetQuery("rep_new_versions.sql")
121
    objEH.ErrorRedirect = FALSE
122
    objEH.TryORA ( OraSession )
123
    On Error Resume Next
124
    Set rsQry = OraDatabase.DbCreateDynaset( SqlQry, ORADYN_DEFAULT )
125
    objEH.CatchORA ( OraSession )
126
    On Error GoTo 0
127
 
128
	OraDatabase.Parameters.Remove "RTAG_ID"
129
 
130
    ' Things for oJSON object
131
    '   Set someVar  = oJSON.Collection()       (Will create an empty collection)
132
    '   obj(field) = data                       (Will create a hash entry)
133
    '   newObj = oJSON.AddToCollection( obj )   (Will create an array)
134
 
135
    Dim lastPvid : lastPvid = 0
136
    Dim extraData
137
    Dim extraIdx
138
    Dim pvid
139
    Set oJSON.data("aaData") = oJSON.Collection()
140
 
141
    While (NOT rsQry.BOF) AND (NOT rsQry.EOF)
142
        pvid = rsQry("PV_ID") 
143
        If pvid <> lastPvid Then
144
            ' This is a new entry
145
            lastPvid = pvid
146
            Set newitem = oJSON.AddToCollection(oJSON.data("aaData"))
147
            newitem(0)= rsQry("PV_ID") 
148
            newitem(1)= rsQry("VIEW_NAME")
149
            newitem(2)= rsQry("PKG_ID")
150
            newitem(3)= rsQry("PKG_NAME")
151
            newitem(4)= rsQry("PKG_VERSION") 
152
            newitem(5)= rsQry("V_EXT")
153
            newitem(6)= rsQry("CREATED_STAMP") 
154
            newitem(7)= rsQry("NEW_PV_ID")
155
            newitem(8)= rsQry("NEW_PKG_VERSION")
156
            newitem(9)= rsQry("NEW_CREATED_STAMP")
157
            extraIdx = 0
158
 
159
        Else
160
            ' Additional Data to be added
161
            '   May need to add an array, before adding entries to the array
162
            If extraIdx = 0 Then
163
                Set extraData = oJSON.Collection()
164
                newitem.Add 10 ,extraData
165
            End If
166
 
167
            Dim entry: Set entry = oJSON.Collection()
168
            entry(0)= rsQry("NEW_PV_ID")
169
            entry(1)= rsQry("NEW_PKG_VERSION")
170
            entry(2)= rsQry("NEW_CREATED_STAMP")
171
            extraData.Add extraIdx, entry
172
            extraIdx = extraIdx + 1
173
        End If
174
 
175
       rsQry.MoveNext
176
    Wend
177
 
178
End Sub
179
 
180
%>