############################################################################################# # 1. init export parameters (as needed), create logging window and global DEBUG procedure ############################################################################################# SETG sDebug:0 # create the dockable window for the output stream IF (sDebug) { CC "AdoScript" CREATE_OUTPUT_WIN winid:"DEBUG_LOG" title:"Logging" } # establish a global procedure as a helper implementation for timestamped logging PROCEDURE global DEBUG msgType:string message:string { IF (sDebug) { CC "Application" GET_DATE_TIME date-format:"dd/mm/yyyy" time-format:"hh:mm:ss" SET currentDateTime: ((date) + " " + (time)) CC "AdoScript" OUT winid:"DEBUG_LOG" text: ("[" + (msgType) + "@" + currentDateTime + "]: " + (message) + "\n") } } # Initial event log message for the "AppInitialized" event DEBUG msgType:"INFO" message: ("Export triggered") ############################################################################################# # 2. read available remote documentation formats and serializers, provide UI and store selected settings # - modeltype # - format/extension # - multiple single # - "report selection" ############################################################################################# CC "AdoScript" HTTP_REQUEST (sRemoteDocumentationURL + "transformationRegistry") SETL sReports:(response) CC "AdoScript" LISTBOX entries:(sReports) toksep:";" title:"Select format" oktext:"OK" boxtext:"Report formats:" IF (endbutton != "ok") { EXIT } SETL sReportType:(selection) CC "AdoScript" HTTP_REQUEST (sRemoteDocumentationURL + "transformationRegistry/" + sReportType) SETL sReportDetails:(response) ############################################################################################# # 3. model selection and export location ############################################################################################# # re-run the dialog until an empty directory is selected SET bIsEmpty:0 WHILE (bIsEmpty = 0) { CC "ImportExport" SHOW_EXPORT_DLG title:"Remote Documentation" multi-select:(VAL token(sReportDetails, 3, ";")) model-groups-selectable:0 filedescription:(token(sReportDetails, 2, ";")) fileextension:(token(sReportDetails, 1, ";")) mode:"xml" IF (LEN(filename) = 0) { DEBUG msgType:"INFO" message:"Dialog canceled" EXIT } SET lExportModelIDs:(modelids) SET sExportFile:(filename) CC "Application" GET_PATH (sExportFile) path-only append-delimiter SET sExportLocation:(path) CC "AdoScript" IS_DIR_EMPTY path:(sExportLocation) SET bIsEmpty:(isempty) IF (bIsEmpty = 0) { CC "AdoScript" ERRORBOX "Directory is not empty, select an empty directory or create a new one!" } } #--- give a helpful information DEBUG msgType:"INFO" message:("Models which are going to be exported: " + lExportModelIDs) DEBUG msgType:"INFO" message:("Exported to file: " + sExportFile) DEBUG msgType:"INFO" message:("Exported to: " + sExportLocation) ############################################################################################# # 4. export to temp location ############################################################################################# CC "Documentation" XML_MODELS modelids:(lExportModelIDs) mgroupids:("") attrprofs:("") apgroups:("") CC "AdoScript" FWRITE file:(sExportLocation + "models.xml") text:(xml) binary:0 FOR sModelID in:(lExportModelIDs) { SET nModelID:(VAL sModelID) CC "Core" IS_MODEL_LOADED modelid:(nModelID) SET bLoaded:(isloaded) IF (bLoaded = 0) { CC "Core" LOAD_MODEL modelid:(nModelID) } CC "Drawing" GEN_GFX_FILE modelid:(nModelID) scale:1.0 filename:(sExportLocation + sModelID +".png") gfx-format:"png" CC "Drawing" GEN_GFX_FILE modelid:(nModelID) scale:1.0 filename:(sExportLocation + sModelID +".jpg") gfx-format:"jpg" CC "Drawing" COMPUTE_REGION_IMAGE_MAP modelid:(nModelID) scale:100 CC "AdoScript" FWRITE file:(sExportLocation + sModelID + "_map.xml") text:(imgmap) binary:0 CC "Documentation" XML_MODEL_DOCU modelid:(nModelID) CC "AdoScript" FWRITE file:(sExportLocation + sModelID + "_docu.xml") text:(xml) binary:0 IF (bLoaded = 0) { CC "Core" DISCARD_MODEL modelid:(nModelID) } } # export TOC, important to filter this TOC afterwards CC "Documentation" XML_TOC_FOR_USER_ID update-toc:(1) CC "AdoScript" FWRITE file:(sExportLocation + "toc.xml") text:(xml) binary:0 ############################################################################################# # 5. upload input files to server ############################################################################################# CC "Application" GET_DATE_TIME date-format:"DDMMYYYY" time-format:"HHMMSS" SET sUniqueID:(date+time) CC "AdoScript" DIR_LIST path:(sExportLocation) SET lUploadFileList:(files) CC "AdoScript" GET_CWD SET oldCwd:(cwd) CC "AdoScript" SET_CWD path:(sExportLocation) CC "AdoScript" FILE_COPY from:"db:\\curl.exe" to:(sExportLocation + "curl.exe") SET nStep:0 SET nNumberOfSteps:(tokcnt(lUploadFileList, "*")) CC "AdoScript" PERCWIN_CREATE title:"My percentage window" FOR sUploadFile in:(lUploadFileList) sep:"*" { SET nStep:(nStep + 1) CC "AdoScript" PERCWIN_SET percentage:(nStep/nNumberOfSteps*100) text:(STR nStep + ": Uploading file to server: " + sUploadFile) DEBUG msgType:"INFO" message:("Uploading file: " + sUploadFile) DEBUG msgType:"INFO" message:("curl --form \"uploaded_file=@"+sUploadFile+";filename="+sUploadFile+"\" --form userDir="+sUniqueID+" " +sRemoteDocumentationURL + "upload") SYSTEM ("curl -k --form \"uploaded_file=@"+sUploadFile+";filename="+sUploadFile+"\" --form userDir="+sUniqueID+" "+sRemoteDocumentationURL + "/upload") # FIXME read return an provide result CC "AdoScript" FILE_DELETE file:(sExportLocation + sUploadFile) } CC "AdoScript" PERCWIN_DESTROY ############################################################################################# # 6. transform, download result and store at location ############################################################################################# SET sPipeline:(token(sReportDetails, 4, ";")) SET sPipeline:(replall(sPipeline, "MODELID", lExportModelIDs)) IF (sReportType = "HTML (Online)") { CC "AdoScript" FWRITE file:(sExportFile) text:("
This page has moved to a ADOxxWeb Remote Documentation.
") } ELSIF (sReportType = "HTML (Offline)") { CC "AdoScript" FILE_COPY from:"db:\\wget.exe" to:(sExportLocation + "wget.exe") SYSTEM ("wget --no-check-certificate --recursive --html-extension --page-requisites --convert-links "+sRemoteDocumentationURL +sUniqueID+"/modelContentHTML/") SETL sOfflineLink:(replall(replall(sRemoteDocumentationURL +sUniqueID+"/modelContentHTML/", "http://", ""), ":", "+") + "index.html") CC "AdoScript" FWRITE file:(sExportFile) text:("This page has moved to a ADOxxWeb Remote Documentation.
") } ELSE { DEBUG msgType:"INFO" message:("curl -o "+sExportFile+" "+sRemoteDocumentationURL + sUniqueID + "/" + sPipeline) SYSTEM ("curl -k -o \""+sExportFile+"\" "+sRemoteDocumentationURL + sUniqueID + "/" + sPipeline) } CC "AdoScript" FILE_DELETE file:(sExportLocation + "curl.exe") CC "AdoScript" FILE_DELETE file:(sExportLocation + "wget.exe") CC "AdoScript" QUERYBOX "The documentation export completed successfully. Open the result document?" title:"Remote Documentation" yes-no def-no IF (endbutton = "yes") { DEBUG msgType:"INFO" message:("Starting docmentation: " + sExportFile) START ("\"" + sExportFile + "\"") cmdshow:showmaximized }