project BLF > class Cacher > method UpdateSessionData

Description

This method updates the data item values in the internal cache based on the sesion ID that is passed as input parameter. This update physically calls the session component to retrieve the values. This is only done when the current session ID for the cache is different than the one passed in as parameter.


Parameters


iiSessionIdinputintegerThe session ID that uniquely identifies the session for which the cache needs to be updated.
oiReturnStatusoutputintegerReturn status of the method.


Internal usage


BLF
method Cacher.GetCharacterValueFromSession
method Cacher.GetDateValueFromSession
method Cacher.GetDecimalValueFromSession
method Cacher.GetIntegerValueFromSession
method Cacher.GetLogicalValueFromSession
method Cacher.GetValuesFromSession


program code (program1/cacher.p)

if iiSessionId = 0
or iiSessionId = ?
then do:
    assign oiReturnStatus = -98.
    return.
end.

/* already up to date ? */
if iiSessionId = viCachedSessionId
then return.

/* Remove and reset the caching */
assign viCachedSessionID   = 0.
for each tCachedData where tCachedData.tlSessionData:
    delete tCachedData.
end.

assign viCacherSessionId   = iiSessionId
       vhCacherSessionInst = ?.

<I-1 {tFcOpenInstance
     &CLASS                = "session"
     &SESSIONID            = "0"}>
            
/* Get the session data */
<M-63 run GetSessionData
   (output tSessionData (tDataItems), 
    output viFcReturnSuper (oiReturnStatus)) in Session>

<I-3 {tFcCloseInstance
     &CLASS           = "Session"}>

/* return the session data */
for each tSessionData:

    find tCachedData where
         tCachedData.tcName = tSessionData.tcName and
         tCachedData.tcDataType = tSessionData.tcDataType
         /* and tCachedData.tlSessionData = no */
         no-error.

    if not available tCachedData
    then create tCachedData.

    buffer-copy tSessionData to tCachedData.
    assign tCachedData.tlSessionData = yes.

    delete tSessionData.

end. /* for each tSessionData */

assign viCachedSessionID = iiSessionId.