project BLF > class Database Component > method PublishEvent

Description

Check if any event publishing is active for current class and publish (= create a request for the event daemon) the update if there is.


Parameters


ilAllChangesinputlogical
icStatusFieldNameinputcharacter
icOldStatusinputcharacter
icNewStatusinputcharacter
iiObjectIDinputinteger
icObjectRowidinputcharacter
oiReturnStatusoutputintegerReturn status of the method.


Internal usage


BLF
method database.EventPublishing
method database.ObjectStatusUpdate


program code (program1/database.p)

<Q-5 run LookupDestinations (all) (Read) (Cache)
   (input viCompanyId, (CompanyId)
    input vcFcComponentName, (BusComponentName)
    input ilAllChanges, (AllChanges)
    output dataset tqDestinations) in BEventConfig>

for each tqDestinations where
        (tqDestinations.tcEventConfigStatusFieldName = icStatusFieldName or
         tqDestinations.tlEventConfigAllUpdates) and
        (tqDestinations.tcEventConfigStatusValue = icNewStatus or
         tqDestinations.tcEventConfigStatusValue = "" or
         tqDestinations.tcEventconfigStatusValue = ?) on error undo, throw:

    if not vlEventsPublished
    then do:
        <I-7 {bFcAddToTransaction
             &CLASS           = "BEventDaemonQueue"}>
        vlEventsPublished = yes.
    end.
    
    <M-3 run CreateEvent
       (input  vcFcComponentName (icClassName), 
        input  iiObjectId (iiObjectId), 
        input  icObjectRowid (icObjectRowId), 
        input  tqDestinations.tiEventDestination_ID (iiEventDestinationID), 
        input  tqDestinations.tcEventDestinationType (icEventDestinationType), 
        input  {&TARGETPROCEDURE} (ihParentClass), 
        input  tqDestinations.tlEventConfigOnlyHeader (ilHeaderOnly), 
        input  tqDestinations.tlEventConfigSuppressEmpty (ilSuppressEmptyFields), 
        output viFcReturnSuper (oiReturnStatus)) in BEventDaemonQueue>
    if viFcReturnSuper <> 0
    then oiReturnStatus = viFcReturnSuper.
    if viFcReturnSuper < 0
    then do:
        vlEventsPublished = no.
        <I-6 {bFcCloseAndStopInstance
            &CLASS           = "BEventDaemonQueue"}>
        return.
    end.

    if tqDestinations.tlEventConfigLockRequired
    then vlLock = yes.
end.

if vlLock
then if vcExternalControlItems = ""
     then assign vcExternalControlItems = string(iiObjectId).
     else assign vcExternalControlItems = vcExternalControlItems
                                        + ",":U + string(iiObjectId).

finally:
    empty temp-table tqDestinations.
end finally.