project BLF > class BXmlDaemonProcessor > method PerformWorkItem

Description

This is the method that contains the call to the specific method in the appropriate class to perform the request.
This method should be extended on the specific daemon level.
In order to have a proper logging of the errors/warnings you get from the business method that is used for processing the work, you need to fill in tPassMessages temp-table parameter, as a copy of tFcMessages from the called business component.


Parameters


iiDaemonQueueIdinputintegerID of the daemon queue record that indicates the work that needs to be done.
olSuccessoutputlogicalWas the operation successful?
oiReturnStatusoutputintegerReturn status of the method.


Internal usage


unused


program code (program1/bxmldaemonprocessor.p)

<Q-21 run GetXmlDaemonQueueInfo (all) (Read) (NoCache)
   (input iiDaemonQueueId, (DaemonQueueId)
    output dataset tqGetXmlDaemonQueueInfo) in BXmlDaemonQueue >

find first tqGetXmlDaemonQueueInfo no-error.

if not available tqGetXmlDaemonQueueInfo
then do:
    <M-22 run SetMessage
       (input  trim(#T-23'Work item (with daemon queue ID = $1) cannot be read.':120(370)T-23#) (icMessage), 
        input  string(iidaemonQueueId) (icArguments), 
        input  '' (icFieldName), 
        input  '' (icFieldValue), 
        input  'S':U (icType), 
        input  2 (iiSeverity), 
        input  '' (icRowid), 
        input  'BLF-292':U (icFcMsgNumber), 
        input  '' (icFcExplanation), 
        input  '' (icFcIdentification), 
        input  '' (icFcContext), 
        output viFcReturnSuper (oiReturnStatus)) in BXmlDaemonProcessor>

    assign olSuccess      = false
           oiReturnStatus = 0.

    return.
end.

<M-1 run GetDocument
   (input  iiDaemonQueueId (iiDaemonQueueId), 
    output vmDocument (omDocument), 
    output viFcReturnSuper (oiReturnStatus)) in BXmlDaemonQueue>

if viFcReturnSuper <> 0
then assign oiReturnStatus = viFcReturnSuper.

if viFcReturnSuper < 0
then return.

create x-document vhDocument in widget-pool "non-persistent".
vhDocument:load("memptr":U, vmDocument, no) no-error.

if error-status:num-messages > 0
then do viCnt1 = 1 to error-status:num-messages:
    assign vcErrors = vcErrors + chr(2) + error-status:get-message(viCnt1).
end.

if vcErrors <> ""
then do:
    <M-17 run SetMessage
       (input  trim(#T-24'The XML document could not be read.':100(371)T-24#) (icMessage), 
        input  '' (icArguments), 
        input  '' (icFieldName), 
        input  '' (icFieldValue), 
        input  'D':U (icType), 
        input  3 (iiSeverity), 
        input  '' (icRowid), 
        input  'BLF-291':U (icFcMsgNumber), 
        input  '' (icFcExplanation), 
        input  '' (icFcIdentification), 
        input  '' (icFcContext), 
        output viFcReturnSuper (oiReturnStatus)) in BXmlDaemonProcessor>

    do viCnt1 = 1 to num-entries(vcErrors, chr(2)):
        <M-2 run SetMessage
           (input  entry (viCnt1,vcErrors,chr(2)) (icMessage), 
            input  '' (icArguments), 
            input  '' (icFieldName), 
            input  '' (icFieldValue), 
            input  'S':U (icType), 
            input  3 (iiSeverity), 
            input  '' (icRowid), 
            input  'BLF-290':U (icFcMsgNumber), 
            input  '' (icFcExplanation), 
            input  '' (icFcIdentification), 
            input  '' (icFcContext), 
            output viFcReturnSuper (oiReturnStatus)) in BXmlDaemonProcessor>
    end.

    assign oiReturnStatus = -3.
    return.
end.

<M-19 run GetActionForOriginator
   (input  tqGetXmlDaemonQueueInfo.tcXmlDaemonQueueXmlOrigin (icOriginator), 
    output vcOriginatorAction (ocAction), 
    output viFcReturnSuper (oiReturnStatus)) in BXmlDaemon>

<M-18 run LoadXmlDocument
   (input  vhDocument (ihDocument), 
    input  tqGetXmlDaemonQueueInfo.tcXmlDaemonQueueXmlClassName (icClassName), 
    input  vcOriginatorAction (icOverrideAction), 
    output tXmlObjectsLoaded (tXmlObjectsLoaded), 
    output olSuccess (olSuccess), 
    output viFcReturnSuper (oiReturnStatus)) in BXmlDaemonProcessor>

if viFcReturnSuper <> 0
then assign oiReturnStatus = viFcReturnSuper.

if viFcReturnSuper < 0
then return.

if can-find (first tXmlObjectsLoaded)
then do:
    <M-13 run SetXmlQueueStatus
       (input  tXmlObjectsLoaded (tXmlObjects), 
        input  tqGetXmlDaemonQueueInfo.tcXmlDaemonQueueXmlFreeText (icComment), 
        input  tqGetXmlDaemonQueueInfo.tcXmlDaemonQueueXmlCyCode (icCompanyCode), 
        input  tqGetXmlDaemonQueueInfo.tcXmlDaemonQueueXmlClassName (icClassName), 
        input  tqGetXmlDaemonQueueInfo.tcXmlDaemonQueueXmlOrigin (icOriginator), 
        output viFcReturnSuper (oiReturnStatus)) in BXmlDaemonQueue>

    if viFcReturnSuper <> 0
    then assign oiReturnStatus = viFcReturnSuper.

    if viFcReturnSuper < 0
    then return.
end.

finally:
    set-size (vmDocument) = 0.
    if vhDocument <> ?
    then delete object vhDocument.
end finally.