project BLF > class BStoredSearch > method ApiSynchronise
Description
Load the XML file with the factory default stored searches.
Parameters
olUpdatesDone | output | logical | UpdatesDone |
oiReturnStatus | output | integer | Return status of the method. |
Internal usage
BLF
program code (program9/bstoredsearch.p)
if oiReturnStatus = 0
then oiReturnStatus = -98.
/* ============ */
/* Get Filename */
/* ============ */
<M-81 run Main (input viSessionID (iiSessionId)) in TApplication>
<M-85 run GetDefaultsFolder (output vcFilePath (ocFolder)) in TApplication>
run gipr_DeleteProcedure in vhFcComponent.
delete procedure vhFcComponent.
assign vcFileName = "factorydefaults.xml":U
vcFile = trim(vcFilePath) + trim(vcFileName).
/* ======================================== */
/* Check if the file realy exists as a file */
/* ======================================== */
assign FILE-INFO:FILE-NAME = vcFile no-error.
if error-status:error or
FILE-INFO:FILE-NAME = ? or
FILE-INFO:FILE-TYPE = ? or
INDEX(FILE-INFO:FILE-TYPE,"F":U) = 0
then do :
assign olUpdatesDone = false
vcMsgSS = trim(#T-6'No proper XML file was found by the stored searches.':150(427)T-6#) + chr(10) +
trim(substitute(#T-7'File name: &1.':255(428)T-7#,FILE-INFO:FILE-NAME)) + chr(10) +
trim(substitute(#T-8'File type: &1.':255(429)T-8#,FILE-INFO:FILE-type)) + chr(10) +
trim(substitute(#T-9'Internal error number: &1.':255(433)T-9#,(if error-status:error then #T-10'yes':4(431)t-10# else #T-11'no':4(432)t-11#))) + chr(10) +
(if error-status:error = true
then trim(substitute(#T-12'Internal error number: &1.':255(433)T-12#,string(ERROR-STATUS:GET-NUMBER(1)))) + chr(10)
else "":U)
oiReturnStatus = +1.
<M-3 run SetMessage
(input vcMsgSS (icMessage),
input '':U (icArguments),
input '':U (icFieldName),
input '':U (icFieldValue),
input 'W':U (icType),
input 4 (iiSeverity),
input '':U (icRowid),
input 'BLF-213':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BStoredSearch>
return.
end. /* if error-status:error or */
/* ============================================ */
/* Import the FactoryDefaults from the XML-file */
/* ============================================ */
<M-4 run apiMaintainByXml
(input ? (imDocument),
input vcFile (icFileName),
output olUpdatesDone (olSuccess),
output tXmlObjects (tXmlObjects),
output viFcReturnSuper (oiReturnStatus)) in BStoredSearch>
if viFcReturnSuper <> 0
then oiReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0
then return.
/* ================================================================= */
/* olsuccess = no does not mean 'no updates required' */
/* create an error messages */
/* ================================================================= */
if not olUpdatesDone
then do:
<M-5 run SetMessage
(input #T-13'Synchronization of the factory defaults failed.':100(434)t-13# (icMessage),
input '' (icArguments),
input '' (icFieldName),
input '' (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input '' (icRowid),
input 'BLF-214':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BStoredSearch>
assign oiReturnStatus = -3.
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 = "BStoredSearch".
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.