Rev 4482 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed
<%@LANGUAGE="VBSCRIPT"%><%'=====================================================' Release Manager Admin Tests' Designed to be called via AJAX and to return' JSON formatted data to dynamic page'=====================================================%><%Option explicit' Good idea to set when using redirectResponse.Expires = 0 ' always load the page, dont store%><!--#include file="common/conf.asp"--><!--#include file="common/globals.asp"--><!--#include file="common/qstr.asp"--><!--#include file="common/common_subs.asp"--><!--#include file="common/formating.asp"--><SCRIPT LANGUAGE="VBScript" RUNAT=SERVER SRC="common/base64encode.vbs"></SCRIPT><SCRIPT LANGUAGE="VBScript" RUNAT=SERVER SRC="class/classaspJSON.vbs"></SCRIPT><%'------------ Variable Definition -------------Dim parOpr, newitemDim result' Basic ParametersparOpr = QStrPar("Opr")result = -1' Init the output JSON class' Operations can add data' Default data will be added at the endDim oJSONSet oJSON = New aspJSON'' Determine the operation to be performed'If (parOpr = "zipTest") Then'' Create a test file in a known directory'Dim objZIPObject, ZipFileDim outFile, objFSO, LocalDir, objFileSet objFSO=CreateObject("Scripting.FileSystemObject")LocalDir = Request.ServerVariables("APPL_PHYSICAL_PATH") & "release_manager\temp\"If NOT objFSO.FolderExists( LocalDir ) Thenresult = 1oJSON.data("emsgSummary") = "Folder not found:" & LocalDirElse' Create a known file to zip up'outFile = LocalDir & "zipTestFile.txt"Set objFile = objFSO.CreateTextFile(outFile,True)objFile.Write "test string" & vbCrLfobjFile.Close' Zip up a test file'ZipFile = LocalDir & "zipTest.zip"If objFSO.FileExists(ZipFile) ThenobjFSO.DeleteFile ZipFile, TRUEEnd IfOn Error Resume NextSet objZIPObject = Server.CreateObject("XStandard.Zip")If Err.Number <> 0 thenresult = 1oJSON.data("emsgSummary") = "Create XStandard.Zip:" & Err.DescriptionElseobjZIPObject.Pack outFile, ZipFileIf objZIPObject.ErrorCode <> 0 thenresult = 1oJSON.data("emsgSummary") = "Zip Error XStandard:" & objZIPObject.ErrorCode & ":" & objZIPObject.ErrorDescriptionElse' All done - must have passedresult = 0End IfEnd If'' Clean upIf objFSO.FileExists(outFile) ThenobjFSO.DeleteFile outFile, TRUEEnd IfIf objFSO.FileExists(ZipFile) ThenobjFSO.DeleteFile ZipFile, TRUEEnd IfobjZIPObject = NothingEnd Ifset objFSO = NothingElseoJSON.data("emsgSummary") = "Unknown operation requested:" & parOprEnd If'' Create JSON data for the user' Important fields' result'' Debug fields' Request (Array)''Write single valueoJSON.data("result") = result' DEBUG: An array of the user provided requestsSet oJSON.data("Request") = oJSON.Collection()Set newitem = oJSON.AddToCollection(oJSON.data("Request"))Dim variableNamefor each variableName in Request.QueryStringnewitem.add variableName, Request.QueryString(variableName)next'Return the objectResponse.Write oJSON.JSONoutput()%>