|
<< Click to Display Table of Contents >> Navigation: Programming Mechworks PDM > DBWCommandShell > Event Scripts > RemoteAccess > OnRemoteAccessFileTransfer.LST script file |
The script is executed every time a file transfer from the remote site to the local site is needed by DBWorks/DBInventor.
Not only the main document files, but also the .GZ or .JPG files must be managed by this script.
Options→Environment→Remote Access
@DOCUMENT_UNIQUE_ID |
the document unique id |
|---|---|
@FROM_FILE |
the origin of the file transfer |
@TO_FILE |
destination of the file transfer |
@EVENT_TYPE |
0:download |
@EVENT_TYPE=0 |
@OK_REMOTE_ACCESS_FILE_TRANSFER |
0: transfer unsuccessfull |
|---|---|---|
@EVENT_TYPE=1 |
@OK_REMOTE_ACCESS_FILE_TRANSFER |
0: transfer unsuccessfull |
@EVENT_TYPE=2 |
@OK_REMOTE_ACCESS_FILE_IS_NEWER |
1: if the @FROM_FILE is newer than the @TO_FILE |
@REMOTE_ACCESS_FROM_FILE_SIZE |
The size in bytes of the @FROM_FILE file |
|
@REMOTE_ACCESS_TO_FILE_SIZE |
The size in bytes of the @TO_FILE file |
The script is now supported by the DBWorks Standalone running as a server for the Server Side File Transfer requests.
In such way, the FileCopy commands, issued by the DBWorks client to the DBWorks Standalone server, are converted in calls to the OnRemoteAccessFileTransfer.LST script, that may be able, for example, to download/upload files from/to an FTP site or sites with a different file transfer protocol (HTTP, etc.).
OnRemoteAccessAction.LST script
.VBSCRIPT
sub main()
DBWInit(TRUE)
docUid = DBWInput("@DOCUMENT_UNIQUE_ID")
fromFile = DBWInput("@FROM_FILE")
toFile = DBWInput("@TO_FILE")
eventType = DBWInput("@EVENT_TYPE")
if eventType = "0" then
action = "Download"
elseif eventType = "1" then
action = "Upload"
else
action = "Check date/time and size"
end if
DBWMsgBox "OnRemoteAccessFileTransfer.LST" & vbcrlf & _
"document unique id = " & docUid & vbcrlf & _
"transfer from = " & fromFile & vbcrlf & _
"to = " & toFile & vbcrlf & _
"action = " & action
if eventType = "0" or eventType = "1" then
'
' manage the transfer from->to
'
' for this example, we'll use local file operations
'
DBWCopyFileToDir fromFile, toFile
'
' output the result for DBWorks
'
trasferIsSuccessful = "1"
DBWOutput "@OK_REMOTE_ACCESS_FILE_TRANSFER",trasferIsSuccessful,ForWriting
else
'
' check if from is newer than to, and get their file size
'
' for this example, we'll use the local file informations
'
Set fso = CreateObject("Scripting.FileSystemObject")
fileSizeFrom = 0
if fso.FileExists(fromFile) then
Set fFrom = fso.GetFile(fromFile)
fileSizeFrom = fFrom.size
end if
fileSizeTo = 0
if fso.FileExists(toFile) then
Set fTo = fso.GetFile(toFile)
fileSizeTo = fTo.size
end if
fromFileIsNewerThanToFile = "0"
if fileSizeFrom>0 and fileSizeTo>0 then
if fFrom.DateLastModified > fTo.DateLastModified then
fromFileIsNewerThanToFile = "1"
end if
end if
'
' output the result for DBWorks
'
DBWOutput "@OK_REMOTE_ACCESS_FILE_IS_NEWER",fromFileIsNewerThanToFile,ForWriting
DBWOutput "@REMOTE_ACCESS_FROM_FILE_SIZE",fileSizeFrom,ForAppending
DBWOutput "@REMOTE_ACCESS_TO_FILE_SIZE",fileSizeTo,ForAppending
end if
end sub