project BLF > class BBaseDaemon > method PreSave

Description

Actions to take before writing current instance to the database (inside the db transaction!).
Use the field tc_status to test the status of the updated records:
'' = unchanged
'N' = new
'C' = changed
'D' = deleted


Parameters


oiReturnStatusoutputintegerReturn status of the method.


Internal usage


unused


program code (program/bbasedaemon.p)

<ANCESTOR-CODE>

/* In ValidateDirectories, we give warnings if directories don't exist and create a record for them in tDirectoryToCreate. */
/* If there are only warnings, the UI will ask to save changes anyway.                                                     */
/* If the user answers yes, we actually create the folders here                                                            */
if can-find(first tDirectoryToCreate)
then do:
    <M-1 run Main  (input  viSessionId (iiSessionId)) in TDaemonUtility>
    vhDU = vhFcComponent.

    for each tDirectoryToCreate on error undo, throw:
        vhFcComponent = vhDU.
        <M-2 run CreateDirectory
           (input  tDirectoryToCreate.tcDaemonName (icDaemonName), 
            input  tDirectoryToCreate.tcDaemonAppserver (icDaemonAppServerURL), 
            input  tDirectoryToCreate.tcDirectoryName (icDirectoryName), 
            output vcMessage (ocMessage), 
            output viFcReturnSuper (oiReturnStatus)) in TDaemonUtility>

        if viFcReturnSuper < 0
        then do:
            <M-3 run SetMessage
               (input  trim(#T-1'The following error occurred while creating directory $1: $2.':255(998716603)T-1#) (icMessage), 
                input  tDirectoryToCreate.tcDirectoryName + chr(2) + vcMessage (icArguments), 
                input  '' (icFieldName), 
                input  '' (icFieldValue), 
                input  'E' (icType), 
                input  3 (iiSeverity), 
                input  '' (icRowid), 
                input  'BLF-232':U (icFcMsgNumber), 
                input  '' (icFcExplanation), 
                input  '' (icFcIdentification), 
                input  '' (icFcContext), 
                output viFcReturnSuper (oiReturnStatus)) in BBaseDaemon>

            assign oiReturnStatus = -3.
        end.
    end.
end.

finally:
    empty temp-table tDirectoryToCreate.
    if vhDU <> ?
    then do:
        run gipr_DeleteProcedure in vhDU.
        delete procedure vhDU.
    end.
end finally.