project BLF > class Database Component > method EventPublishing

Description

Wrapper for method PublishEvent, loop through all database objects in memory.


Parameters


ilForcePublishinputlogical
oiReturnStatusoutputintegerReturn status of the method.


Internal usage


BLF
method database.AdditionalUpdates
method database.ApiForcePublish


program code (program1/database.p)

<M-1 run DataDescription
   (input  '' (icRowids), 
    input  '' (icPkey), 
    input  '' (icObjectIds), 
    input  no (ilAllTables), 
    output viFcReturnSuper (oiReturnStatus)) in database>
if viFcReturnSuper <> 0
then oiReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0
then return.

find first tFcDynRel where tFcDynRel.tcFcFrom = "" no-error.
if available tFcDynRel
then do:
    assign vcTable    = tFcDynRel.tcFcTo
           vhBuffer   = tFcDynRel.thFcBuffer.
    <M-2 run GetKeyFields (input-output tFcDynRel.tcFcTo (bcTableName), 
                       output vcDummy (ocPrimaryKey), 
                       output vcDummy (ocAlternateKey), 
                       output vcObjectName (ocObjectID), 
                       output vcDummy (ocObjectStatus), 
                       output viFcReturnSuper (oiReturnStatus)) in database>
    if viFcReturnSuper <> 0
    then oiReturnStatus = viFcReturnSuper.
    if viFcReturnSuper < 0
    then return.
    
    create query vhQuery in widget-pool "non-persistent".
    vhQuery:forward-only = yes.
    vhQuery:set-buffers(vhBuffer).
    vhQuery:query-prepare("for each t_o":U + vcTable).
    vhQuery:query-open().
    vhQuery:get-first().
    
    do while not vhQuery:query-off-end:

        if vhBuffer::tc_Status = "" and
           not ilForcePublish
        then do:
            <M-4 run EventPublishingLookForUpdates
               (input  vcTable (icParentTable), 
                input  vhBuffer::tc_Rowid (icParentRowid), 
                input-output vcQueryNames (bcQueryNames), 
                input-output vcQueryHandles (bcQueryHandles), 
                output vlFcOk (olUpdateFound), 
                output viFcReturnSuper (oiReturnStatus)) in database>
            if viFcReturnSuper <> 0
            then oiReturnStatus = viFcReturnSuper.
            if viFcReturnSuper < 0
            then return.
        end.
        else vlFcOk = yes.
        
        if vlFcOk
        then do:
            /* get object ID value */
            if vcObjectName <> ""
            then assign vhField    = vhBuffer:buffer-field(vcObjectName)
                        viObjectId = vhField:buffer-value.
            <M-3 run PublishEvent
               (input  yes (ilAllChanges), 
                input  '' (icStatusFieldName), 
                input  '' (icOldStatus), 
                input  '' (icNewStatus), 
                input  viObjectId (iiObjectID), 
                input  vhBuffer::tc_Rowid (icObjectRowid), 
                output viFcReturnSuper (oiReturnStatus)) in database>
            if viFcReturnSuper <> 0
            then oiReturnStatus = viFcReturnSuper.
            if viFcReturnSuper < 0
            then leave.
        end.
        
        vhQuery:get-next().
    end.
    
    vhQuery:query-close().
    delete object vhQuery.
    
    do viFcCount1 = 2 to num-entries(vcQueryHandles):
        vhFcComponent = widget-handle(entry(viFcCount1,vcQueryHandles)).
        delete object vhFcComponent.
    end.
end.