| 5853 |
dpurdie |
1 |
<%@LANGUAGE="VBSCRIPT"%>
|
|
|
2 |
<%
|
|
|
3 |
'=====================================================
|
|
|
4 |
' project_log_json.asp
|
|
|
5 |
'
|
|
|
6 |
' AJAX SUpport for project_log.asp
|
|
|
7 |
'=====================================================
|
|
|
8 |
%>
|
|
|
9 |
<%
|
|
|
10 |
Option explicit
|
|
|
11 |
Response.ContentType = "text/html"
|
|
|
12 |
Response.AddHeader "Content-Type", "text/html;charset=UTF-8"
|
|
|
13 |
Response.CodePage = 65001
|
|
|
14 |
Response.CharSet = "UTF-8"
|
|
|
15 |
%>
|
|
|
16 |
<!--#include file="common/conf.asp"-->
|
|
|
17 |
<!--#include file="common/globals.asp"-->
|
|
|
18 |
<!--#include file="common/qstr.asp"-->
|
|
|
19 |
<!--#include file="common/common_subs.asp"-->
|
|
|
20 |
<SCRIPT LANGUAGE="VBScript" RUNAT=SERVER SRC="class/classaspJSON.vbs"></SCRIPT>
|
|
|
21 |
<%
|
|
|
22 |
'------------ Variable Definition -------------
|
|
|
23 |
Dim result : result = -1
|
|
|
24 |
Dim SqlQry
|
|
|
25 |
Dim rsQry
|
|
|
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 |
' Determine the size of the record set
|
|
|
35 |
Dim MaxCount : MaxCount = 0
|
|
|
36 |
|
|
|
37 |
SqlQry = "select count(*) as count from PROJECT_ACTION_LOG"
|
|
|
38 |
On Error Resume Next
|
|
|
39 |
objEH.ErrorRedirect = FALSE
|
|
|
40 |
objEH.TryORA ( OraSession )
|
|
|
41 |
Set rsQry = OraDatabase.DbCreateDynaset( SqlQry, ORADYN_DEFAULT )
|
|
|
42 |
objEH.CatchORA ( OraSession )
|
|
|
43 |
If ((NOT rsQry.BOF) AND (NOT rsQry.EOF)) Then
|
|
|
44 |
MaxCount = rsQry("COUNT")
|
|
|
45 |
End If
|
|
|
46 |
rsQry.Close
|
|
|
47 |
Set rsQry = Nothing
|
|
|
48 |
|
|
|
49 |
' Basic Header
|
| 7250 |
dpurdie |
50 |
oJSON.data("draw") = CInt(Request.QueryString("draw"))
|
|
|
51 |
oJSON.data("recordsTotal") = MaxCount
|
|
|
52 |
oJSON.data("recordsFiltered") = MaxCount
|
| 5853 |
dpurdie |
53 |
|
|
|
54 |
' Assist in debug
|
| 7250 |
dpurdie |
55 |
oJSON.data("start") = CInt(Request.QueryString("start"))
|
|
|
56 |
oJSON.data("length") = CInt(Request.QueryString("length"))
|
| 5853 |
dpurdie |
57 |
|
|
|
58 |
Dim vName
|
|
|
59 |
for each vName in Request.QueryString
|
|
|
60 |
oJSON.data("sReq_" & vName) = Request.QueryString(vName)
|
|
|
61 |
next
|
|
|
62 |
|
|
|
63 |
' Extract selected range
|
|
|
64 |
result = 0
|
|
|
65 |
dim firstRow,lastRow
|
| 7250 |
dpurdie |
66 |
firstRow = CInt(Request.QueryString("start"))
|
|
|
67 |
lastRow = firstRow + CInt(Request.QueryString("length"))
|
| 5853 |
dpurdie |
68 |
|
|
|
69 |
' Define the data items to extract from the database
|
|
|
70 |
' Format is:
|
|
|
71 |
' 1) Name of Database column
|
|
|
72 |
' 2) Expression::Name of Database column
|
|
|
73 |
' Name will be used for sorting puposes
|
|
|
74 |
' Expression will be used for data retrieval
|
|
|
75 |
'
|
|
|
76 |
Dim dataCols: dataCols = Array ( _
|
|
|
77 |
"TO_CHAR(PL.ACTION_DATETIME, 'Dy DD-Mon-YYYY HH:MI:SS')::PL.ACTION_DATETIME", _
|
|
|
78 |
"PL.DESCRIPTION", _
|
|
|
79 |
"PROJ_ID", _
|
|
|
80 |
"RTAG_ID", _
|
|
|
81 |
"AT.DESCRIPTION", _
|
|
|
82 |
"FULL_NAME")
|
|
|
83 |
|
|
|
84 |
' Split dataCols into two parts based on ::
|
|
|
85 |
' FirstPart - Complex Expression
|
|
|
86 |
' SecondPart - Simple Name for Result
|
|
|
87 |
' If no '::' then Expression to be the simple bit
|
|
|
88 |
Dim x, pos
|
|
|
89 |
ReDim dataExt(Ubound(dataCols))
|
|
|
90 |
For x = Lbound(dataCols) to Ubound(dataCols)
|
|
|
91 |
pos = InStr( dataCols(x), "::" )
|
|
|
92 |
If pos > 0 Then
|
|
|
93 |
dataExt(x) = Mid( dataCols(x), 1, pos - 1 )
|
|
|
94 |
dataCols(x) = Mid(dataCols(x), pos + 2)
|
|
|
95 |
Else
|
|
|
96 |
dataExt(x) = dataCols(x)
|
|
|
97 |
End If
|
|
|
98 |
Next
|
|
|
99 |
|
|
|
100 |
|
|
|
101 |
' Dim determine sorting options
|
|
|
102 |
Dim sortString
|
| 7250 |
dpurdie |
103 |
If Request.QueryString("order[0][column]") <> "" Then
|
|
|
104 |
sortString = " ORDER BY " & dataCols(CInt(Request.QueryString("order[0][column]")))
|
|
|
105 |
sortString = sortString & " " & Request.QueryString("order[0][dir]")
|
| 5853 |
dpurdie |
106 |
End If
|
|
|
107 |
|
|
|
108 |
' Create a list of cols that we need. Avoids ambiguity in selections
|
|
|
109 |
Dim colList,colListJoin
|
|
|
110 |
For x = Lbound(dataCols) to Ubound(dataCols)
|
|
|
111 |
colList = colList & colListJoin & dataExt(x)
|
|
|
112 |
Dim asName
|
|
|
113 |
asName = Replace(dataCols(x) , "." , "_")
|
|
|
114 |
if dataCols(x) <> asName Then colList = colList & " as " & asName
|
|
|
115 |
colListJoin = ","
|
|
|
116 |
Next
|
|
|
117 |
|
|
|
118 |
Dim BasicSql
|
|
|
119 |
BasicSql = "select " & colList &_
|
|
|
120 |
" from PROJECT_ACTION_LOG pl,USERS u, ACTION_TYPE at" &_
|
|
|
121 |
" where pl.USER_ID = u.USER_ID and pl.acttype_id = at.acttype_id" &_
|
|
|
122 |
sortString
|
|
|
123 |
|
|
|
124 |
SqlQry = "select * from ( "&_
|
|
|
125 |
"select a.*, ROWNUM rnum from (" & BasicSql &_
|
|
|
126 |
") a where ROWNUM <= " & lastRow &_
|
|
|
127 |
") where rnum >= " & firstRow
|
|
|
128 |
|
|
|
129 |
' Assist in debug
|
|
|
130 |
oJSON.data("BasicSql") = BasicSql
|
|
|
131 |
'oJSON.data("SqlQry") = SqlQry
|
|
|
132 |
|
|
|
133 |
' Perform the database query
|
| 7250 |
dpurdie |
134 |
Set oJSON.data("data") = oJSON.Collection()
|
| 5853 |
dpurdie |
135 |
On Error Resume Next
|
|
|
136 |
objEH.ErrorRedirect = FALSE
|
|
|
137 |
objEH.TryORA ( OraSession )
|
|
|
138 |
Set rsQry = OraDatabase.DbCreateDynaset( SqlQry, ORADYN_DEFAULT )
|
|
|
139 |
objEH.CatchORA ( OraSession )
|
|
|
140 |
|
|
|
141 |
' Return all fields to the user as an array
|
|
|
142 |
If objEH.Finally Then
|
|
|
143 |
While (NOT rsQry.BOF) AND (NOT rsQry.EOF)
|
| 7250 |
dpurdie |
144 |
Set newitem = oJSON.AddToCollection(oJSON.data("data"))
|
| 5853 |
dpurdie |
145 |
Dim ii
|
|
|
146 |
for ii = 0 to rsQry.Fields.Count - 1
|
|
|
147 |
newitem(ii) = rsQry.Fields(ii)
|
|
|
148 |
Next
|
|
|
149 |
rsQry.MoveNext
|
|
|
150 |
Wend
|
|
|
151 |
End IF
|
|
|
152 |
|
|
|
153 |
rsQry.Close
|
|
|
154 |
Set rsQry = Nothing
|
|
|
155 |
|
|
|
156 |
'
|
|
|
157 |
' SQL error detection and reporting
|
|
|
158 |
If objEH.LastOraFailed Then
|
|
|
159 |
oJSON.data("error") = 1
|
|
|
160 |
|
|
|
161 |
oJSON.data("emsgSummary") = objEH.MessageSummary
|
|
|
162 |
oJSON.data("emsgDetails") = objEH.MessageDetails
|
|
|
163 |
oJSON.data("SqlQry") = SqlQry
|
|
|
164 |
End If
|
|
|
165 |
|
|
|
166 |
'Return the object
|
|
|
167 |
Response.Write oJSON.JSONoutput()
|
| 5957 |
dpurdie |
168 |
Set oJSON = Nothing
|
|
|
169 |
Call Destroy_All_Objects
|
| 5853 |
dpurdie |
170 |
%>
|