ExportAssetsAndUploadToCloud
Structure
ExportAssetsAndUploadToCloud(sSQL, sEventFilter, sService, sFolder, sLocalArchiveFolder: Text; bOverwrite, bAllowAuth: Boolean): Text
Type
Function
Description
This function will export all the assets matching the sSQL (sql for a WHERE clause in GAGES table) and upload them the cloud service given in sService. If the sFolder parameter is set then the resulting zips will be uploaded into this folder in the cloud (must be one level above root directory). If sFolder is empty then the files will be uploaded to the root directory. If only a sub-set of events are desired then sEventFilter can be specified (sql for a WHERE clause in EVENTS tabls). sLocalArchiveFolder can be set with an optional local directory where the zips should be copied before upload. Set bOverwrite if you would like the file to be first deleted from the cloud before upload if the file already exists in the cloud by this name. The function will return a summary of completed actions. Search on the text 'ERROR' to confirm if any errors occurred during download or import. Upon execution, if no token exists for the cloud service AND the bAuth parameter is True then the service's login screen will be shown in a browser window. This token will be remembered for future sessions.
Parameters: 7
sSQL = sql for a WHERE clause in the GAGES table for all the assets that should be exported. This sql should NOT begin with the word WHERE (this will be automatically added by IndySoft)
sEventFilter = If you would like only a subset of events exported with the assets then input sql here for WHERE clause in the EVENTS table. This sql should NOT begin with the word WHERE (this will be automatically added by IndySoft.
sService = the name of the online cloud service. Acceptable values are: 'BOX' (box.com) and 'DROPBOX' (dropbox.com)
sFolder = Optional online folder where the files should be uploaded. This folder should exist one level above the root directory. If this parameter is empty then all zips will be uploaded to the root directory in the cloud service.
sLocalArchiveFolder = Set this optional parameter to the name of a local directory where the zips should be copied before upload.
bOverwrite = If TRUE and a zip file of the same name already exists in the Cloud location then it will be first deleted before the newer zip is uploaded.
bAllowAuth = If previous tokens saved to the database are not found and/or do not allow access to the online service, this parameter determines if a browser window should be shown to allow for credentials to be entered. If this script is intended to be run in an automated/unattended setup, then this parameter should be set to False.
Return Value
Text
Examples
sService = "DROPBOX" sCompany = "TEST COMPANY"
sArchiveDirectory = "C:\Temp\Uploaded" & sCompany
if tdDoSQLRecords(1, "SELECT VARIABLE_DATE FROM COMPANY_VARS WHERE COMPANY = '" & sCompany &
"' AND VARIABLE_NAME = 'LAST EXPORT DATE'") then
dtCompanyLastExport = tdFieldByNameAsDateTime(1, "VARIABLE_DATE")
Else
dtCompanyLastExport = 0 RunSQL("INSERT INTO COMPANY_VARS (COMPANY, VARIABLE_NAME) VALUES ('" & sCompany & "', 'LAST EXPORT DATE')") End If
dtExport = Now
sResult = ExportAssetsAndUploadToCloud("COMPANY = '" & sCompany & "' AND LAST_MODIFIED_DATE >= '" &
FormatDateTimeForSQL(dtCompanyLastExport) & "'", "(EVENTS.EVENT_DATE > '01/01/2013 12:00:00 AM')", sService,
sCompany, sArchiveDirectory, True, True)
DebugLog(sResult)
SendEMail("myemail@notreal.com", "", "", "Export and Upload Results", "", "CLOUD", sResult, False, False)
if Pos("ERROR:", sResult) = 0 then
RunSQL("UPDATE COMPANY_VARS SET VARIABLE_DATE = '" & FormatDateTimeForSQL(dtExport) & "' WHERE COMPANY = '" &
sCompany & "' AND " & "VARIABLE_NAME = 'LAST EXPORT DATE'")
End If |