project BLF > class BLanguage > method ApiSynchronise
Description
ApiSynchronise; this method will do the synchronisation (=upload of the system languages).
Parameters
olUpdatesDone | output | logical | UpdatesDone; true in cases updates were done |
oiReturnStatus | output | integer | Return status of the method. |
Internal usage
BLF
program code (program9/blanguage.p)
/* ================================================================= */
/* Create a list of system languages. */
/* (warning, these are not the ISO codes) */
/* ================================================================= */
assign vcLngCode [01] = "bu":U
vcLngName [01] = "bulgarian":U
vcLngCode [02] = "ch":U
vcLngName [02] = "chinese":U
vcLngCode [03] = "cs":U
vcLngName [03] = "castilian spanish":U
vcLngCode [04] = "cz":U
vcLngName [04] = "czech":U
vcLngCode [05] = "da":U
vcLngName [05] = "danish":U
vcLngCode [06] = "du":U
vcLngName [06] = "dutch":U
vcLngCode [07] = "fi":U
vcLngName [07] = "finnish":U
vcLngCode [08] = "fr":U
vcLngName [08] = "french":U
vcLngCode [09] = "ge":U
vcLngName [09] = "german":U
vcLngCode [10] = "hu":U
vcLngName [10] = "hungarian":U
vcLngCode [11] = "it":U
vcLngName [11] = "italian":U
vcLngCode [12] = "jp":U
vcLngName [12] = "japanese":U
vcLngCode [13] = "ko":U
vcLngName [13] = "korean":U
vcLngCode [14] = "ls":U
vcLngName [14] = "latin spanish":U
vcLngCode [15] = "lt":U
vcLngName [15] = "lithuanian":U
vcLngCode [16] = "no":U
vcLngName [16] = "norwegian":U
vcLngCode [17] = "pl":U
vcLngName [17] = "polish":U
vcLngCode [18] = "po":U
vcLngName [18] = "portuguese":U
vcLngCode [19] = "ro":U
vcLngName [19] = "romanian":U
vcLngCode [20] = "ru":U
vcLngName [20] = "russian":U
vcLngCode [21] = "si":U
vcLngName [21] = "slovenian":U
vcLngCode [22] = "sk":U
vcLngName [22] = "slovak":U
vcLngCode [23] = "sw":U
vcLngName [23] = "swedish":U
vcLngCode [24] = "tu":U
vcLngName [24] = "turkish":U
vcLngCode [25] = "tw":U
vcLngName [25] = "traditional chinese":U
vcLngCode [26] = "ua":U
vcLngName [26] = "ukranian":U
vcLngCode [27] = "us":U
vcLngName [27] = "english (U.S.)":U
vcLngCode[28] = "gr":U
vcLngName[28] = "greek":U
vcLngCode[29] = "cr":U
vcLngName[29] = "Croatian":U.
if oiReturnStatus = 0
then oiReturnStatus = -98.
/* ================================================================= */
/* Load all language codes. */
/* ================================================================= */
<M-1 run DataLoad
(input '' (icRowids),
input '' (icPkeys),
input '' (icObjectIds),
input '' (icFreeform),
input no (ilKeepPrevious),
output viFcReturnSuper (oiReturnStatus)) in BLanguage>
if viFcReturnSuper = -4
then viFcReturnSuper = 0. /* no error if no language codes exist yet */
if viFcReturnSuper <> 0
then oiReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0
then return.
/* ================================================================= */
/* Create system languages if they do not exist. */
/* Set system flag if they do exist. */
/* ================================================================= */
do viLCO = 1 to 29:
find first tLng where
tLng.LngCode = vcLngCode[viLCO] no-error.
if available tLng
then do:
if tLng.LngDescription <> vcLngName[viLCO]
or tLng.LngIsSystemLanguage <> yes
then assign tLng.LngDescription = vcLngName[viLCO]
tLng.LngIsSystemLanguage = yes
tlng.tc_Status = "C":U
olUpdatesDone = yes.
else assign vcRowids = vcRowids + ",":U + tLng.tc_Rowid.
if tLng.LngCode = "us":U and tLng.LngIsInstalled = no
then assign tLng.LngIsInstalled = yes
tLng.tc_Status = "C":U
olUpdatesDone = yes.
end.
else do:
<M-2 run AddDetailLine
(input 'Lng':U (icTable),
input '' (icParentRowid),
output viFcReturnSuper (oiReturnStatus)) in BLanguage>
if viFcReturnSuper <> 0
then oiReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0
then return.
assign tLng.LngCode = vcLngCode[viLCO]
tLng.LngDescription = vcLngName[viLCO]
tLng.LngIsActive = (vcLngCode[viLCO] = "us":U)
tLng.LngIsSystemLanguage = yes
olUpdatesDone = yes.
if tLng.LngCode = "us":U and tLng.LngIsInstalled = no
then assign tLng.LngIsInstalled = yes.
end.
end.
/* ================================================================= */
/* Switch off system flag for all other language codes. */
/* ================================================================= */
for each tLng where
tLng.LngIsSystemLanguage and
tLng.tc_Status = "" and
not can-do(vcRowids,tLng.tc_Rowid):
assign tLng.LngIsSystemLanguage = no
tlng.tc_Status = "C":U
olUpdatesDone = yes.
end.
/* ================================================================= */
/* Validate & Save. */
/* ================================================================= */
if olUpdatesDone
then do:
<M-3 run ValidateBC
(output viFcReturnSuper (oiReturnStatus)) in BLanguage>
if viFcReturnSuper <> 0
then oiReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0
then return.
<M-4 run AdditionalUpdates
(output viFcReturnSuper (oiReturnStatus)) in BLanguage>
if viFcReturnSuper <> 0
then oiReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0
then return.
<M-5 run DataSave
(output viFcReturnSuper (oiReturnStatus)) in BLanguage>
if viFcReturnSuper <> 0
then oiReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0
then return.
end.
if oiReturnStatus = -98
then oiReturnStatus = 0.
Sample code: how to call this method through RPCRequestService (QXtend Inbound)
define temp-table ttContext no-undo
field propertyQualifier as character
field propertyName as character
field propertyValue as character
index entityContext is primary unique
propertyQualifier
propertyName
index propertyQualifier
propertyQualifier.
define dataset dsContext for ttContext.
define variable vhContextDS as handle no-undo.
define variable vhExceptionDS as handle no-undo.
define variable vhServer as handle no-undo.
define variable vhInputDS as handle no-undo.
define variable vhInputOutputDS as handle no-undo.
define variable vhOutputDS as handle no-undo.
define variable vhParameter as handle no-undo.
/* Create context */
create ttContext.
assign ttContext.propertyName = "programName"
ttContext.propertyValue = "BLanguage".
create ttContext.
assign ttContext.propertyName = "methodName"
ttContext.propertyValue = "ApiSynchronise".
create ttContext.
assign ttContext.propertyName = "applicationId"
ttContext.propertyValue = "fin".
create ttContext.
assign ttContext.propertyName = "entity"
ttContext.propertyValue = "1000".
create ttContext.
assign ttContext.propertyName = "userName"
ttContext.propertyValue = "mfg".
create ttContext.
assign ttContext.propertyName = "password"
ttContext.propertyValue = "".
/* Connect the AppServer */
create server vhServer.
vhServer:connect("-URL <appserver-url>").
if not vhServer:connected()
then do:
message "Could not connect AppServer" view-as alert-box error title "Error".
return.
end.
/* Run */
assign vhContextDS = dataset dsContext:handle.
run program/rpcrequestservice.p on vhServer
(input-output dataset-handle vhContextDS by-reference,
output dataset-handle vhExceptionDS,
input dataset-handle vhInputDS by-reference,
input-output dataset-handle vhInputOutputDS by-reference,
output dataset-handle vhOutputDS).
/* Handle output however you want, in this example, we dump it to xml */
if valid-handle(vhExceptionDS)
then vhExceptionDS:write-xml("file", "Exceptions.xml", true).
if valid-handle(vhOutputDS)
then vhOutputDS:write-xml("file", "Output.xml", true).
/* Cleanup */
vhServer:disconnect().
assign vhServer = ?.
if valid-handle(vhInputDS)
then delete object vhInputDS.
if valid-handle(vhOutputDS)
then delete object vhOutputDS.
if valid-handle(vhExceptionDS)
then delete object vhExceptionDS.