variables.version = "1.1";
variables.svnBuild = "35";
application.ptSync.version = variables.version;
application.ptSync.svnBuild = variables.svnBuild;
// Load the app config
application.ptSync.appConfig = getAppConfig(getAppBeanName());
validateAppConfig();
// Build cache variables
buildCache();
// Init the logging variables
initLogs();
// Validate if the MULTI SERVER variable is in the config,
// otherwise set to false
if ( NOT StructKeyExists(application.ptSync.appConfig,"multiserver") OR NOT LEN(application.ptSync.appConfig.multiserver) ){
application.ptSync.appConfig.multiserver = false;
}
// Validate if the LOGGING variables is in the config
if ( NOT StructKeyExists(application.ptSync.appConfig,"enableLogs") OR NOT LEN(application.ptSync.appConfig.enableLogs) ){
application.ptSync.appConfig.enableLogs = false;
}
if ( NOT StructKeyExists(application.ptSync.appConfig,"logHistory") OR NOT LEN(application.ptSync.appConfig.logHistory) ){
application.ptSync.appConfig.logHistory = 10;
}
// Validate if the Enable Run Time Sync is in the config
if ( NOT StructKeyExists(application.ptSync.appConfig,"runTimeSync") OR NOT LEN(application.ptSync.appConfig.runTimeSync) ){
application.ptSync.appConfig.runTimeSync = false;
}
/* COMPLEX FIELDS */
/* Validate if the Complex Image field is in the config
* Set a numeric value for the operation:
* 0 - Do Nothing
* 1 - Copy Image
* 2 - Store Text
*/
if ( StructKeyExists(application.ptSync.appConfig,"complexImage") AND LEN(application.ptSync.appConfig.complexImage) ){
// Set the text to the numeric value
if ( application.ptSync.appConfig.complexImage EQ "Copy Image to Destination Site" )
application.ptSync.appConfig.complexImage = 1;
else if ( application.ptSync.appConfig.complexImage EQ "Text Field with Image Path to Source Site" )
application.ptSync.appConfig.complexImage = 2;
else
application.ptSync.appConfig.complexImage = 0;
}
else {
application.ptSync.appConfig.complexImage = 0;
}
/* Validate if the CS Page URL field is in the config
* Set a numeric value for the operation:
* 0 - Do Nothing
* 1 - Copy Document
* 2 - Store Text
*/
if ( StructKeyExists(application.ptSync.appConfig,"complexDocument") AND LEN(application.ptSync.appConfig.complexDocument) ){
// Set the text to the numeric value
if ( application.ptSync.appConfig.complexDocument EQ "Copy Document to Destination Site" )
application.ptSync.appConfig.complexDocument = 1;
else if ( application.ptSync.appConfig.complexDocument EQ "Text Field with URL Path to Source Site" )
application.ptSync.appConfig.complexDocument = 2;
else
application.ptSync.appConfig.complexDocument = 0;
}
else {
application.ptSync.appConfig.complexDocument = 0;
}
var i = 1;
var mappingDataArray = "";
// Set the cache variables
application.ptSync.cache = StructNew();
application.ptSync.cache.mapSrcFormIDList = "";
application.ptSync.cache.mappingData = StructNew();
application.ptSync.cache.multiServer = StructNew();
application.ptSync.cache.siteData = StructNew();
// Build the Multi Server Config Cache
// Check if the Multi Server is ENABLED
if ( application.ptSync.appConfig.multiserver EQ TRUE ) {
application.ptSync.cache.multiServer = application.ptSync.syncService.buildMultiServerConfigQuery();
}
// Check if the app is configured to run on this server
if ( StructKeyExists(application.ptSync.appConfig, "sourceSite")
AND LEN(application.ptSync.appConfig.sourceSite)
AND StructKeyExists(application.ptSync.appConfig, "destinationSite")
AND LEN(application.ptSync.appConfig.destinationSite) ) {
// Get the Active Sync Mappings
mappingDataArray = application.ptSync.syncDAO.getSyncMapping();
// Validate if we have mapping data
if ( ArrayLen(mappingDataArray) ){
// Loop over the mapping data and load into cache.
for ( i=1; i LTE ArrayLen(mappingDataArray); i=i+1 ){
// Insert the mapping data based on the source form id
StructInsert(application.ptSync.cache.mappingData, mappingDataArray[i].values.sourceCE, mappingDataArray[i]);
}
// Get a list of the source Forms IDs and set into cache
application.ptSync.cache.mapSrcFormIDList = StructKeyList(application.ptSync.cache.mappingData);
}
// Build the Source and Destination Site Data
// Get the CS site data for the source and destination site
application.ptSync.cache.siteData = application.ptSync.syncService.getSiteConfigData();
}
// Init the variables for the logs
application.ptSync.logs = StructNew();
application.ptSync.logs.fail = ArrayNew(1);
application.ptSync.logs.success = ArrayNew(1);
application.ptSync.logs.errors = ArrayNew(1);