Subversion Repositories DevTools

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
7570 dpurdie 1
<%@LANGUAGE="VBSCRIPT"%>
2
<%
3
'=====================================================
4
'       view_snapshots_json.asp
5
'=====================================================
6
%>
7
<%
8
Option explicit
9
' Essential to get UTF through all the hoops. ie: VÄSTTRAFIK (VTK)
10
Response.ContentType = "text/html"
11
Response.AddHeader "Content-Type", "text/html;charset=UTF-8"
12
Response.CodePage = 65001
13
Response.CharSet = "UTF-8"
14
%>
15
<!--#include file="common/conf.asp"-->
16
<!--#include file="common/globals.asp"-->
17
<!--#include file="common/qstr.asp"-->
18
<!--#include file="common/common_subs.asp"-->
19
<SCRIPT LANGUAGE="VBScript" RUNAT=SERVER SRC="class/classaspJSON.vbs"></SCRIPT> 
20
<%
21
'------------ Variable Definition -------------
22
Dim result : result = -1
23
Dim SqlQry
24
Dim rsQry
25
Dim parRtagId : parRtagId = Request("rtag_id")
26
 
27
' Init the output JSON class
28
'   Operations can add data
29
'   Default data will be added at the end
30
Dim oJSON :Set oJSON = New aspJSON
31
Dim newitem
32
 
33
'
34
'   Global Filter
35
'
36
Dim showHideFilter : showHideFilter = ""
37
 
38
' Filter (search )
39
Dim searchString
40
If Request.QueryString("search[value]") <> "" Then
41
    searchString = " AND upper(rt.rtag_name || '_' || TO_CHAR(rt.created_stamp,'DD-Mon-YYYY hh24:mi:ss') || '_' ||  rt.description) LIKE upper('%" & Request.QueryString("search[value]") & "%')" 
42
End If
43
 
44
'
45
' Determine the size of the record set
46
'   Gives bad results when searching
47
Dim MaxCount : MaxCount = 0
48
 
49
SqlQry =  "select  count(*) as count " &_ 
50
            " FROM RELEASE_TAGS rt " &_
51
            " WHERE rt.parent_rtag_id = " & parRtagId &_
52
            " AND OFFICIAL = 'S'" &_
53
            searchString &_
54
            showHideFilter
55
 
56
oJSON.data("CountSqlQry") = SqlQry
57
On Error Resume Next
58
objEH.ErrorRedirect = FALSE
59
objEH.TryORA ( OraSession )
60
Set rsQry = OraDatabase.DbCreateDynaset( SqlQry, ORADYN_DEFAULT )
61
objEH.CatchORA ( OraSession )
62
    If ((NOT rsQry.BOF) AND (NOT rsQry.EOF)) Then
63
        MaxCount = rsQry("COUNT")
64
    End If
65
rsQry.Close
66
Set rsQry = Nothing
67
 
68
' Basic Header
69
'   iTotalRecords = total records without any filtering/limits
70
'   iTotalDisplayRecords = filtered result count
71
 
72
oJSON.data("draw") = CLng(Request.QueryString("draw"))
73
oJSON.data("recordsTotal") = MaxCount
74
oJSON.data("recordsFiltered") = MaxCount
75
 
76
Dim vName
77
for each vName in Request.QueryString
78
    oJSON.data("sReq_" & vName) = Request.QueryString(vName)
79
next
80
 
81
' Extract selected range
82
result = 0
83
dim firstRow,lastRow
84
firstRow = CLng(Request.QueryString("start"))
85
lastRow = firstRow + CLng(Request.QueryString("length"))
86
 
87
' Define the data items to extract from the database
88
' An array of items to extract
89
'
90
Dim dataCols: dataCols = Array ( _
91
        "rt.rtag_id", _
92
        "rt.rtag_name", _
93
        "TO_CHAR(rt.created_stamp,'DD-Mon-YYYY hh24:mi:ss') AS created_stamp", _
94
        "rt.description", _
95
        "rt.s3Manifest", _
96
        "rt.s3Manifest_Done" )
97
 
98
'   Define array of colums to sort by
99
'       Must match user sort column request
100
Dim sortCols: sortCols = Array ( _
101
        "rt.rtag_id",_
102
        "UPPER(rt.rtag_name)",_
103
        "rt.created_stamp",_
104
        "UPPER(rt.description)",_
105
        "rt.s3Manifest",_
106
        "rt.s3Manifest_Done" )
107
 
108
' Dim determine sorting options
109
'On Error goto 0
110
'Response.Write "<pre>"
111
 
112
' Dim determine sorting options
113
'   Secondary sort by package name Entry(1)
114
Dim sortString
115
Dim sortColumn : sortColumn = CInt(Request.QueryString("order[0][column]"))
116
Dim sortDir    : sortDir = Request.QueryString("order[0][dir]")
117
 
118
If sortColumn <> "" Then
119
    sortString = " ORDER BY " & sortCols(sortColumn) & " " & sortDir
120
    If sortColumn <> "1" Then
121
        sortString = sortString & ", " & sortCols(CInt(1)) & " " & sortDir
122
    End If
123
Else
124
    sortString = " ORDER BY " & sortCols(CInt(1)) & " asc"
125
End If
126
 
127
' Create a list of cols that we need. Avoids ambiguity in selections
128
Dim x,colList,colListJoin
129
For x = Lbound(dataCols) to Ubound(dataCols)
130
    colList = colList & colListJoin & dataCols(x)
131
    colListJoin = ","
132
Next
133
 
134
Dim BasicSql
135
BasicSql =  "select " & colList &_ 
136
            " FROM RELEASE_TAGS rt " &_
137
            " WHERE rt.parent_rtag_id = " & parRtagId &_
138
            " AND OFFICIAL = 'S'" &_
139
            searchString &_
140
            showHideFilter &_
141
            sortString
142
 
143
SqlQry = "select * from ( "&_
144
            "select a.*, ROWNUM rnum from (" & BasicSql &_
145
                ") a where ROWNUM <= " & lastRow &_
146
            ") where rnum >= " & firstRow
147
 
148
' Assist in debug
149
oJSON.data("BasicSql") = BasicSql
150
oJSON.data("SqlQry") = SqlQry
151
 
152
' Perform the database query
153
Set oJSON.data("data") = oJSON.Collection()
154
On Error Resume Next
155
objEH.ErrorRedirect = FALSE
156
objEH.TryORA ( OraSession )
157
Set rsQry = OraDatabase.DbCreateDynaset( SqlQry, ORADYN_DEFAULT )
158
objEH.CatchORA ( OraSession )
159
' Process each row and return required fields to the user
160
If objEH.Finally Then
161
   While (NOT rsQry.BOF) AND (NOT rsQry.EOF)
162
        Set newitem = oJSON.AddToCollection(oJSON.data("data"))
163
 
164
        ' Attempt to speed up access to the data
165
        '    Extract all fields for the row
166
        '    Access fields by index
167
        Dim fields
168
        Set fields = rsQry.Fields
169
 
170
        Dim rtag_id         : rtag_id = fields(0)
171
        Dim rtag_name       : rtag_name = fields(1)
172
        Dim created_stamp   : created_stamp = fields(2)
173
        Dim description     : description = CleanUpJson(Server.HTMLEncode(fields(3)))
174
        Dim s3Manifest      : s3Manifest = fields(4)
175
        Dim s3Manifest_Done : s3Manifest_Done = fields(5)
176
 
177
        Set fields = nothing
178
 
179
        newitem(0) = rtag_id
180
        newitem(1) = rtag_name
181
        newitem(2) = created_stamp
182
        newitem(3) = description
183
        newitem(4) = s3Manifest
184
        newitem(5) = s3Manifest_Done
185
 
186
        rsQry.MoveNext
187
   Wend
188
End IF
189
 
190
rsQry.Close
191
Set rsQry = Nothing
192
 
193
'
194
' SQL error detection and reporting
195
If objEH.LastOraFailed Then
196
    oJSON.data("error") = 1
197
 
198
    oJSON.data("emsgSummary") = objEH.MessageSummary
199
    oJSON.data("emsgDetails") = objEH.MessageDetails
200
    oJSON.data("SqlQry") = SqlQry
201
End If
202
 
203
'Return the object
204
Response.Write oJSON.JSONoutput()
205
Set oJSON = Nothing
206
Call Destroy_All_Objects
207
%>