| 4477 |
dpurdie |
1 |
<%@LANGUAGE="VBSCRIPT"%>
|
|
|
2 |
<%
|
|
|
3 |
'=====================================================
|
|
|
4 |
' Release Manager Admin Tests
|
|
|
5 |
' Designed to be called via AJAX and to return
|
|
|
6 |
' JSON formatted data to dynamic page
|
|
|
7 |
'=====================================================
|
|
|
8 |
%>
|
|
|
9 |
<%
|
|
|
10 |
Option explicit
|
|
|
11 |
' Good idea to set when using redirect
|
|
|
12 |
Response.Expires = 0 ' always load the page, dont store
|
|
|
13 |
%>
|
|
|
14 |
<!--#include file="common/conf.asp"-->
|
|
|
15 |
<!--#include file="common/globals.asp"-->
|
|
|
16 |
<!--#include file="common/qstr.asp"-->
|
|
|
17 |
<!--#include file="common/common_subs.asp"-->
|
|
|
18 |
<!--#include file="common/formating.asp"-->
|
|
|
19 |
<SCRIPT LANGUAGE="VBScript" RUNAT=SERVER SRC="common/base64encode.vbs"></SCRIPT>
|
|
|
20 |
<SCRIPT LANGUAGE="VBScript" RUNAT=SERVER SRC="class/classaspJSON.vbs"></SCRIPT>
|
|
|
21 |
<%
|
|
|
22 |
'------------ Variable Definition -------------
|
|
|
23 |
Dim parOpr, newitem
|
|
|
24 |
Dim result
|
|
|
25 |
|
|
|
26 |
' Basic Parameters
|
|
|
27 |
parOpr = QStrPar("Opr")
|
|
|
28 |
result = -1
|
|
|
29 |
|
|
|
30 |
' Init the output JSON class
|
|
|
31 |
' Operations can add data
|
|
|
32 |
' Default data will be added at the end
|
|
|
33 |
Dim oJSON
|
|
|
34 |
Set oJSON = New aspJSON
|
|
|
35 |
|
|
|
36 |
'
|
|
|
37 |
' Determine the operation to be performed
|
|
|
38 |
'
|
|
|
39 |
If (parOpr = "zipTest") Then
|
|
|
40 |
|
|
|
41 |
'
|
|
|
42 |
' Create a test file in a known directory
|
|
|
43 |
'
|
|
|
44 |
Dim objZIPObject, ZipFile
|
|
|
45 |
Dim outFile, objFSO, LocalDir, objFile
|
|
|
46 |
Set objFSO=CreateObject("Scripting.FileSystemObject")
|
|
|
47 |
LocalDir = Request.ServerVariables("APPL_PHYSICAL_PATH") & "release_manager\temp\"
|
|
|
48 |
|
|
|
49 |
If NOT objFSO.FolderExists( LocalDir ) Then
|
|
|
50 |
result = 1
|
|
|
51 |
oJSON.data("emsgSummary") = "Folder not found:" & LocalDir
|
|
|
52 |
Else
|
|
|
53 |
' Create a known file to zip up
|
|
|
54 |
'
|
|
|
55 |
outFile = LocalDir & "zipTestFile.txt"
|
|
|
56 |
Set objFile = objFSO.CreateTextFile(outFile,True)
|
|
|
57 |
objFile.Write "test string" & vbCrLf
|
|
|
58 |
objFile.Close
|
|
|
59 |
|
|
|
60 |
' Zip up a test file
|
|
|
61 |
'
|
|
|
62 |
ZipFile = LocalDir & "zipTest.zip"
|
|
|
63 |
If objFSO.FileExists(ZipFile) Then
|
|
|
64 |
objFSO.DeleteFile ZipFile, TRUE
|
|
|
65 |
End If
|
|
|
66 |
|
|
|
67 |
On Error Resume Next
|
|
|
68 |
Set objZIPObject = Server.CreateObject("XStandard.Zip")
|
|
|
69 |
If Err.Number <> 0 then
|
|
|
70 |
result = 1
|
|
|
71 |
oJSON.data("emsgSummary") = "Create XStandard.Zip:" & Err.Description
|
|
|
72 |
Else
|
|
|
73 |
objZIPObject.Pack outFile, ZipFile
|
|
|
74 |
|
|
|
75 |
If objZIPObject.ErrorCode <> 0 then
|
|
|
76 |
result = 1
|
|
|
77 |
oJSON.data("emsgSummary") = "Zip Error XStandard:" & objZIPObject.ErrorCode & ":" & objZIPObject.ErrorDescription
|
|
|
78 |
Else
|
|
|
79 |
' All done - must have passed
|
|
|
80 |
result = 0
|
|
|
81 |
|
|
|
82 |
End If
|
|
|
83 |
End If
|
|
|
84 |
|
|
|
85 |
'
|
|
|
86 |
' Clean up
|
|
|
87 |
If objFSO.FileExists(outFile) Then
|
|
|
88 |
objFSO.DeleteFile outFile, TRUE
|
|
|
89 |
End If
|
|
|
90 |
|
|
|
91 |
If objFSO.FileExists(ZipFile) Then
|
|
|
92 |
objFSO.DeleteFile ZipFile, TRUE
|
|
|
93 |
End If
|
|
|
94 |
|
|
|
95 |
objZIPObject = Nothing
|
|
|
96 |
|
|
|
97 |
End If
|
|
|
98 |
set objFSO = Nothing
|
|
|
99 |
|
|
|
100 |
Else
|
|
|
101 |
oJSON.data("emsgSummary") = "Unknown operation requested:" & parOpr
|
|
|
102 |
End If
|
|
|
103 |
|
|
|
104 |
'
|
|
|
105 |
' Create JSON data for the user
|
|
|
106 |
' Important fields
|
|
|
107 |
' result
|
|
|
108 |
'
|
|
|
109 |
' Debug fields
|
|
|
110 |
' Request (Array)
|
|
|
111 |
'
|
|
|
112 |
'Write single value
|
|
|
113 |
oJSON.data("result") = result
|
|
|
114 |
|
|
|
115 |
' DEBUG: An array of the user provided requests
|
|
|
116 |
Set oJSON.data("Request") = oJSON.Collection()
|
|
|
117 |
Set newitem = oJSON.AddToCollection(oJSON.data("Request"))
|
|
|
118 |
Dim variableName
|
|
|
119 |
for each variableName in Request.QueryString
|
|
|
120 |
newitem.add variableName, Request.QueryString(variableName)
|
|
|
121 |
next
|
|
|
122 |
|
|
|
123 |
'Return the object
|
|
|
124 |
Response.Write oJSON.JSONoutput()
|
|
|
125 |
%>
|