| icType | input | character | Supported types: LIMITED -> Will perform limited synchronization FULL -> Will perform full synchronization |
| ocMessage | output | character | |
| oiReturnStatus | output | integer | Return status of the method. |
BLF
/* ================================================================================ */
/* Log the Synchronisation in vcLogFile */
/* ================================================================================ */
<M-44 run GetLogFileLocation (output vcLogFile (ocLogFile)) in TApplication>
output to value (vcLogFile) append.
put '':U skip.
put unformatted string (now) '> ':U
'TApplication.Synchronize: started (type = ':U icType ').' skip.
output close.
/* Check the Synchronize.config file. This file indicates to start ctlog tracing or not. */
assign vcSynchronizeConfig = search("Synchronize.config":U).
if vcSynchronizeConfig <> ?
then do:
input from value(vcSynchronizeConfig).
repeat:
import unformatted vcSynchronizeConfigLine no-error.
if vcSynchronizeConfigLine begins "BLDebugLevel=":U
then viDebugLevel = integer(substring(vcSynchronizeConfigLine, length("BLDebugLevel=":U, "CHARACTER":U) + 1, -1, "CHARACTER":U)) no-error.
end.
input close.
end.
else do:
/* Create the config file at the same location as the server.xml */
assign vcSynchronizeConfig = search("server.xml":U).
if vcSynchronizeConfig <> ?
then do:
assign vcSynchronizeConfig = replace(vcSynchronizeConfig, "server.xml":U, "Synchronize.config":U).
output to value(vcSynchronizeConfig).
put "BLDebugLevel=0":U skip.
output close.
end.
end.
Assign vcSyncLogin = 'mfg':U
vcSyncPwd = '':U.
<Q-10 assign vlFcQueryRecordsAvailable = UserPrim (NoCache)
(input 0, (UsrId)
input 0, (UsrLogin)) in BUser >
If vlFcQueryRecordsAvailable <> False
Then Do:
<Q-11 run SystBySystAdminUser (all) (Read) (NoCache)
(output dataset tqSystBySystAdminUser) in BSystem >
Find First tqSystBySystAdminUser No-error.
If Available tqSystBySystAdminUser
Then Do:
Assign vcSyncLogin = tqSystBySystAdminUser.tcUsrLogin.
assign vhFcComponent = ?.
<M-12 run MainBlock
() in TCrypt>
assign vhCrypthandle = vhFcComponent.
<M-13 run DecryptString
(input tqSystBySystAdminUser.tcSystAdminUserPwd (icInputString),
output vcSyncPwd (ocOutputString),
output viFcReturnSuper (oiReturnStatus)) in TCrypt>
run gipr_DeleteProcedure in vhCrypthandle.
delete procedure vhCrypthandle.
End.
End.
/* ================================================================================ */
/* Logging */
/* ================================================================================ */
output to value (vcLogFile) append.
put unformatted string (now) '> ':U
'TApplication.Synchronize: Starting session and establishing a login for ':U vcSyncLogin skip.
output close.
/* Start and Open Session, login as mfg */
<I-1 {tFcStartAndOpenInstance
&CLASS = "Session"
&SESSIONID = "0"}>
if viDebugLevel > 0
then do:
<M-15 run SetDebugLevel (input viDebugLevel (iiDebugLevel)) in Session>
end.
<M-3 run Login
(input vcSyncLogin (icLogin),
input vcSyncPwd (icPassword),
input '' (icExtra),
output vlValid (olValid),
output viFcReturnSuper (oiReturnStatus)) in Session>
/* ================================================================================ */
/* Logging */
/* ================================================================================ */
output to value (vcLogFile) append.
put unformatted string (now) '> ':U
'TApplication.Synchronize: Login executed (viFcReturnSuper=' viFcReturnSuper ', vlValid=' vlValid ').' skip.
output close.
if viFcReturnSuper < 0 or
not vlValid
then do:
assign oiReturnStatus = viFcReturnSuper
ocMessage = trim( #T-14'Session.Login failed:':255(8914)T-14#) +
' vcSyncLogin=' + vcSyncLogin +
', ReturnStatus=' + string (viFcReturnSuper) +
', vlValid=' + string (vlValid).
<I-16 {tFcCloseAndStopInstance
&CLASS = "Session"}>
return.
end.
/* ================================================================================ */
/* Logging */
/* ================================================================================ */
output to value (vcLogFile) append.
put unformatted string (now) '> ':U
'TApplication.Synchronize: Starting BSystem and running ApiGetSynchronisationTopics and ApiSynchronise.' skip.
output close.
/* Start and Open BSystem */
<I-5 {tFcStartAndOpenInstance
&CLASS = "BSystem"
&SESSIONID = "viSessionTAppID"}>
/* Get the Synchronization topics */
<M-6 run ApiGetSynchronisationTopics
(output tTopicTApp (tTopic),
output viFcReturnSuper (oiReturnStatus)) in BSystem>
/* For Single Topic Synchronization modify the topic temp-table record for the requested
topic and deselect all other topics from being synchronized */
if icType begins {&SYNCHRONIZETYPE-TOPIC}
then do:
assign viTopicNumber = integer(substring(icType,index(icType,"TOPIC":U) + 5,-1,"CHARACTER":U)) no-error.
if error-status:error
then do:
assign ocMessage = substitute(#T-17'Invalid synchronization topic number (&1).':50(9204)T-17#,substring(icType,index(icType,"TOPIC":U) + 5,-1,"CHARACTER":U))
oiReturnStatus = -3.
end.
else do :
for each tTopicTApp:
if tTopicTApp.tiTopicNumber = viTopicNumber
then assign tTopicTApp.tcSynchronizeType = icType
tTopicTApp.tlSelected = true.
else assign tTopicTApp.tlSelected = false.
end.
end.
end.
/* Run the synchronize method */
if viFcReturnSuper >= 0
then do:
<M-7 run ApiSynchronise
(input icType (icSynchronizeType),
input-output tTopicTApp (tTopic),
output viFcReturnSuper (oiReturnStatus)) in BSystem>
if viFcReturnSuper <> 0
then oiReturnStatus = viFcReturnSuper.
end.
/* Close BSystem and Session */
<I-8 {tFcCloseAndStopInstance
&CLASS = "BSystem"}>
<I-9 {tFcCloseAndStopInstance
&CLASS = "Session"}>
/* ================================================================================ */
/* Logging */
/* ================================================================================ */
output to value (vcLogFile) append.
put unformatted string (now) '> ':U
'TApplication.Synchronize: ended (Returnstatus= ':U oiReturnStatus ').' skip.
output close.