| 5050 |
dpurdie |
1 |
<%@LANGUAGE="VBSCRIPT"%>
|
|
|
2 |
<%
|
|
|
3 |
'=====================================================
|
|
|
4 |
' sdk_content_json.asp
|
|
|
5 |
' Ajax support for table of SDK Content
|
|
|
6 |
' Designed to be driven by the jquery tablescroller
|
| 5054 |
dpurdie |
7 |
' Uses DataTables 1.10 format data
|
| 5050 |
dpurdie |
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 |
<SCRIPT LANGUAGE="VBScript" RUNAT=SERVER SRC="class/classaspJSON.vbs"></SCRIPT>
|
|
|
23 |
<%
|
|
|
24 |
'------------ Variable Definition -------------
|
|
|
25 |
Dim result : result = -1
|
|
|
26 |
Dim SqlQry
|
|
|
27 |
Dim rsQry
|
|
|
28 |
Dim sdktag_id : sdktag_id = Request("sdktag_id")
|
| 5052 |
dpurdie |
29 |
Dim sdk_statefilter : sdk_statefilter = Request("sdk_statefilter")
|
| 5050 |
dpurdie |
30 |
|
|
|
31 |
' Init the output JSON class
|
|
|
32 |
' Operations can add data
|
|
|
33 |
' Default data will be added at the end
|
|
|
34 |
Dim oJSON :Set oJSON = New aspJSON
|
|
|
35 |
Dim newitem
|
|
|
36 |
|
|
|
37 |
'
|
|
|
38 |
' Determine the size of the record set
|
|
|
39 |
' Gives bad results when searching
|
|
|
40 |
Dim MaxCount : MaxCount = 0
|
|
|
41 |
|
|
|
42 |
SqlQry = "select count(*) as count from SDK_CONTENT skc where SDKTAG_ID = '" & sdktag_id &"'"
|
| 5053 |
dpurdie |
43 |
If sdk_statefilter Then
|
|
|
44 |
SqlQry = SqlQry & " AND skc.sdkpkg_state in ('E')"
|
|
|
45 |
End If
|
| 5050 |
dpurdie |
46 |
|
|
|
47 |
On Error Resume Next
|
|
|
48 |
objEH.ErrorRedirect = FALSE
|
|
|
49 |
objEH.TryORA ( OraSession )
|
|
|
50 |
Set rsQry = OraDatabase.DbCreateDynaset( SqlQry, ORADYN_DEFAULT )
|
|
|
51 |
objEH.CatchORA ( OraSession )
|
|
|
52 |
If ((NOT rsQry.BOF) AND (NOT rsQry.EOF)) Then
|
|
|
53 |
MaxCount = rsQry("COUNT")
|
|
|
54 |
End If
|
|
|
55 |
rsQry.Close
|
|
|
56 |
Set rsQry = Nothing
|
|
|
57 |
|
|
|
58 |
' Basic Header
|
|
|
59 |
' iTotalRecords = total records without any filtering/limits
|
|
|
60 |
' iTotalDisplayRecords = filtered result count
|
|
|
61 |
|
| 5054 |
dpurdie |
62 |
oJSON.data("draw") = CInt(Request.QueryString("draw"))
|
|
|
63 |
oJSON.data("recordsTotal") = MaxCount
|
|
|
64 |
oJSON.data("recordsFiltered") = MaxCount
|
| 5050 |
dpurdie |
65 |
|
|
|
66 |
Dim vName
|
|
|
67 |
for each vName in Request.QueryString
|
|
|
68 |
oJSON.data("sReq_" & vName) = Request.QueryString(vName)
|
|
|
69 |
next
|
|
|
70 |
|
|
|
71 |
' Extract selected range
|
|
|
72 |
result = 0
|
|
|
73 |
dim firstRow,lastRow
|
| 5054 |
dpurdie |
74 |
firstRow = CInt(Request.QueryString("start"))
|
|
|
75 |
lastRow = firstRow + CInt(Request.QueryString("length"))
|
| 5050 |
dpurdie |
76 |
|
|
|
77 |
' Define the data items to extract from the database
|
|
|
78 |
' An array of items to extract
|
|
|
79 |
'
|
|
|
80 |
Dim dataCols: dataCols = Array ( _
|
|
|
81 |
"sc.pv_id", _
|
|
|
82 |
"p.pkg_name", _
|
|
|
83 |
"pv.pkg_version", _
|
|
|
84 |
"sc.sdkpkg_state" )
|
|
|
85 |
|
|
|
86 |
' Define array of colums to sort by
|
|
|
87 |
' Must match user sort column request
|
|
|
88 |
Dim sortCols: sortCols = Array ( _
|
|
|
89 |
"sc.pv_id", _
|
|
|
90 |
"UPPER(p.pkg_name)", _
|
|
|
91 |
"UPPER(pv.pkg_version)", _
|
|
|
92 |
"UPPER(sc.sdkpkg_state)" )
|
|
|
93 |
|
|
|
94 |
' Dim determine sorting options
|
|
|
95 |
'On Error goto 0
|
|
|
96 |
'Response.Write "<pre>"
|
|
|
97 |
Dim sortString
|
| 5054 |
dpurdie |
98 |
If Request.QueryString("order[0][column]") <> "" Then
|
|
|
99 |
sortString = " ORDER BY " & sortCols(CInt(Request.QueryString("order[0][column]")))
|
|
|
100 |
sortString = sortString & " " & Request.QueryString("order[0][dir]")
|
| 5052 |
dpurdie |
101 |
sortString = sortString & "," & sortCols(CInt(1)) & " asc"
|
| 5050 |
dpurdie |
102 |
Else
|
|
|
103 |
sortString = " ORDER BY " & sortCols(CInt(1)) & " asc"
|
|
|
104 |
End If
|
|
|
105 |
|
|
|
106 |
' Filter (search )
|
| 5052 |
dpurdie |
107 |
Dim searchString : searchString = ""
|
| 5054 |
dpurdie |
108 |
If Request.QueryString("search[value]") <> "" Then
|
|
|
109 |
searchString = " AND upper(pkg_name) || '_' || UPPER(pv.pkg_version) LIKE upper('%" & Request.QueryString("search[value]") & "%')"
|
| 5050 |
dpurdie |
110 |
End If
|
|
|
111 |
|
| 5052 |
dpurdie |
112 |
If sdk_statefilter Then
|
|
|
113 |
searchString = searchString & " AND sc.sdkpkg_state in ('E')"
|
|
|
114 |
End If
|
|
|
115 |
|
| 5050 |
dpurdie |
116 |
' Create a list of cols that we need. Avoids ambiguity in selections
|
|
|
117 |
Dim x,colList,colListJoin
|
|
|
118 |
For x = Lbound(dataCols) to Ubound(dataCols)
|
|
|
119 |
colList = colList & colListJoin & dataCols(x)
|
|
|
120 |
colListJoin = ","
|
|
|
121 |
Next
|
|
|
122 |
|
|
|
123 |
Dim whereString
|
|
|
124 |
Dim BasicSql
|
|
|
125 |
BasicSql = "select " & colList &_
|
|
|
126 |
" FROM SDK_CONTENT SC , PACKAGE_VERSIONS pv, PACKAGES p " &_
|
|
|
127 |
" where sc.sdktag_id = "&sdktag_id&" AND pv.pv_id = sc.pv_id AND p.pkg_id = pv.pkg_id " &_
|
|
|
128 |
whereString &_
|
|
|
129 |
searchString &_
|
|
|
130 |
sortString
|
|
|
131 |
|
|
|
132 |
SqlQry = "select * from ( "&_
|
|
|
133 |
"select a.*, ROWNUM rnum from (" & BasicSql &_
|
|
|
134 |
") a where ROWNUM <= " & lastRow &_
|
|
|
135 |
") where rnum >= " & firstRow
|
|
|
136 |
|
|
|
137 |
' Assist in debug
|
|
|
138 |
oJSON.data("BasicSql") = BasicSql
|
|
|
139 |
'oJSON.data("SqlQry") = SqlQry
|
|
|
140 |
|
|
|
141 |
' Perform the database query
|
|
|
142 |
Set oJSON.data("aaData") = oJSON.Collection()
|
|
|
143 |
On Error Resume Next
|
|
|
144 |
objEH.ErrorRedirect = FALSE
|
|
|
145 |
objEH.TryORA ( OraSession )
|
|
|
146 |
Set rsQry = OraDatabase.DbCreateDynaset( SqlQry, ORADYN_DEFAULT )
|
|
|
147 |
objEH.CatchORA ( OraSession )
|
|
|
148 |
' Process each row and return required fields to the user
|
|
|
149 |
If objEH.Finally Then
|
|
|
150 |
On Error goto 0
|
|
|
151 |
|
|
|
152 |
While (NOT rsQry.BOF) AND (NOT rsQry.EOF)
|
|
|
153 |
Set newitem = oJSON.AddToCollection(oJSON.data("aaData"))
|
|
|
154 |
Dim ii
|
|
|
155 |
for ii = 0 to rsQry.Fields.Count - 2
|
|
|
156 |
newitem (rsQry.FieldName(ii)) = rsQry.Fields(ii)
|
|
|
157 |
'newitem (ii) = rsQry.Fields(ii)
|
|
|
158 |
Next
|
|
|
159 |
rsQry.MoveNext
|
|
|
160 |
Wend
|
|
|
161 |
End IF
|
|
|
162 |
|
|
|
163 |
rsQry.Close
|
|
|
164 |
Set rsQry = Nothing
|
|
|
165 |
|
|
|
166 |
'
|
|
|
167 |
' SQL error detection and reporting
|
| 5054 |
dpurdie |
168 |
' The content of 'error' will be dsplayed to the user.
|
| 5050 |
dpurdie |
169 |
If objEH.LastOraFailed Then
|
| 5054 |
dpurdie |
170 |
oJSON.data("error") = objEH.MessageSummary
|
| 5050 |
dpurdie |
171 |
oJSON.data("emsgDetails") = objEH.MessageDetails
|
|
|
172 |
oJSON.data("SqlQry") = SqlQry
|
|
|
173 |
End If
|
|
|
174 |
|
|
|
175 |
'Return the object
|
|
|
176 |
Response.Write oJSON.JSONoutput()
|
|
|
177 |
'OraSession.Dispose()
|
|
|
178 |
%>
|