project BLF > class BBaseDaemonQueue > method ApiResetDaemonQueueStatus
Description
Method used to reset the status of daemon queue records from "Processed-Error" of "In Process" to "Waiting".
Parameters
iiDaemonId | input | integer | |
icDaemonName | input | character | |
iiDaemonQueueId | input | integer | |
ilResetProcessedError | input | logical | |
ilResetInProcess | input | logical | |
oiReturnStatus | output | integer | Return status of the method. |
Internal usage
unused
program code (program3/bbasedaemonqueue.p)
If oiReturnStatus = 0
Then Assign oiReturnStatus = -98.
assign vcMessage = "":U.
if iiDaemonID = ? then assign iiDaemonID = 0.
if icDaemonName = ? then assign icDaemonName = "":U.
if iiDaemonQueueId = ? then assign iiDaemonQueueId = 0.
/* - If DaemonID = ? then DaemonName should be filled */
if iiDaemonID = 0
then do:
if icDaemonName = "":U
then assign vcMessage = trim(#T-9'Daemon-Id or DaemonName should be filled for the clean-up of a DaemonQueue.':255(5058)T-9#).
else do:
<Q-1 run DaemonPrim (all) (Read) (NoCache)
(input icdaemonname, (DaemonName)
input iidaemonid, (DaemonId)
output dataset tqDaemonPrim) in BBaseDaemon >
find tqDaemonPrim where
tqDaemonPrim.tcDaemonName = icDaemonName
no-lock no-error.
if not available tqDaemonPrim
then assign vcMessage = trim(substitute(#T-91'Unable to find the daemon based on its name (&1).':255(33)T-91#,icDaemonName)).
else assign iiDaemonID = tqDaemonPrim.tiDaemonId.
end. /* if icDaemonName <> "":U */
end. /* if iiDaemonID = 0 */
if vcMessage <> "":U
then do:
assign oiReturnStatus = -1.
<M-12 run SetMessage
(input vcMessage (icMessage),
input '' (icArguments),
input '' (icFieldName),
input '' (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input '' (icRowid),
input 'BLF-42':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BBaseDaemonQueue>
return.
end. /* if vcMessage <> "":U */
if iiDaemonQueueId <> 0 And
ilResetInProcess = true
Then Do:
<Q-16 assign vlFcQueryRecordsAvailable = DaemonInfoLimited (NoCache)
(input iiDaemonId, (DaemonId)
input ?, (DaemonName)
input {&DAEMONSTATUS-INACTIVE}, (DaemonStatus)
input ?, (DaemonStatusDiffersFrom)) in BBaseDaemon >
If vlFcQueryRecordsAvailable = no
Then Do:
assign vcMessage = Trim(#T-13'You can not reset the 'In Process' daemon queues to 'Waiting' because the daemon is not inactive.':255(5106)T-13#)
oiReturnStatus = -1.
<M-14 run SetMessage
(input vcMessage (icMessage),
input '' (icArguments),
input '' (icFieldName),
input '' (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input '' (icRowid),
input 'BLF-43':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BBaseDaemonQueue>
return.
End.
End.
<M-3 run ClearData
(output viFcReturnSuper (oiReturnStatus)) in BBaseDaemonQueue>
if viFcReturnSuper <> 0
then Assign oiReturnStatus = viFcReturnSuper.
If viFcReturnSuper < 0
Then Return.
If iiDaemonQueueId = 0 And
ilResetInProcess = True And
ilResetProcessedError = True
Then Assign vcFreeForm = "for each fcDaemonQueue where fcDaemonQueue.DaemonID = ":U +
string (iiDaemonID) +
" and (fcDaemonQueue.DaemonQueueStatus = ":U + "'":U + {&DAEMONQUEUESTATUS-PROCESSEDERR} + "'":U +
" Or fcDaemonQueue.DaemonQueueStatus = ":U + "'":U + {&DAEMONQUEUESTATUS-INPROCESS} + "')":U.
Else If iiDaemonQueueId = 0 And
ilResetProcessedError = True
Then Assign vcFreeForm = "for each fcDaemonQueue where fcDaemonQueue.DaemonID = ":U +
string (iiDaemonID) +
" and fcDaemonQueue.DaemonQueueStatus = ":U + "'":U + {&DAEMONQUEUESTATUS-PROCESSEDERR} + "'":U.
Else If iiDaemonQueueId = 0 And
ilResetInProcess = True
Then Assign vcFreeForm = "for each fcDaemonQueue where fcDaemonQueue.DaemonID = ":U +
string (iiDaemonID) +
" and fcDaemonQueue.DaemonQueueStatus = ":U + "'":U + {&DAEMONQUEUESTATUS-INPROCESS} + "'":U.
Else Assign vcFreeForm = "for each fcDaemonQueue where fcDaemonQueue.DaemonQueueID = ":U +
string (iiDaemonQueueId).
<M-4 run DataLoad
(input '' (icRowids),
input '' (icPkeys),
input '' (icObjectIds),
input vcFreeForm (icFreeform),
input False (ilKeepPrevious),
output viFcReturnSuper (oiReturnStatus)) in BBaseDaemonQueue>
If viFcReturnSuper = -4
Then do :
Assign viFcReturnSuper = 0
oiReturnStatus = 0.
return.
end.
if viFcReturnSuper <> 0
then do :
assign oiReturnStatus = viFcReturnSuper
vcMessage = trim(#T-11'An error occured while Loading the instances from the Database.':255(5060)T-11#).
<M-5 run SetMessage
(input vcMessage (icMessage),
input '' (icArguments),
input '' (icFieldName),
input '' (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input '' (icRowid),
input 'BLF-41':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BBaseDaemonQueue>
return.
end. /* if viFcReturnSuper <> 0 */
for each tfcDaemonQueue :
assign tfcDaemonQueue.DaemonQueueStatus = {&DAEMONQUEUESTATUS-WAITING}
tfcDaemonQueue.DaemonQueueLockedProcess = 0
tfcDaemonQueue.tc_Status = 'C':U.
end. /* for each */
/* ======================================== */
/* Validate, AdditionalUpdates and DataSave */
/* ======================================== */
<M-6 run ValidateBC
(output viFcReturnSuper (oiReturnStatus)) in BBaseDaemonQueue>
if viFcReturnSuper <> 0
then Assign oiReturnStatus = viFcReturnSuper.
If viFcReturnSuper < 0
Then Return.
<M-7 run AdditionalUpdates
(output viFcReturnSuper (oiReturnStatus)) in BBaseDaemonQueue>
if viFcReturnSuper <> 0
then Assign oiReturnStatus = viFcReturnSuper.
If viFcReturnSuper < 0
Then Return.
<M-8 run DataSave
(output viFcReturnSuper (oiReturnStatus)) in BBaseDaemonQueue>
if viFcReturnSuper <> 0
then Assign oiReturnStatus = viFcReturnSuper.
If viFcReturnSuper < 0
Then Return.
empty temp-table tqDaemonPrim.
If oiReturnStatus = -98
Then Assign oiReturnStatus = 0.
Sample code: how to call this method through RPCRequestService (QXtend Inbound)
define temp-table ttContext no-undo
field propertyQualifier as character
field propertyName as character
field propertyValue as character
index entityContext is primary unique
propertyQualifier
propertyName
index propertyQualifier
propertyQualifier.
define dataset dsContext for ttContext.
define variable vhContextDS as handle no-undo.
define variable vhExceptionDS as handle no-undo.
define variable vhServer as handle no-undo.
define variable vhInputDS as handle no-undo.
define variable vhInputOutputDS as handle no-undo.
define variable vhOutputDS as handle no-undo.
define variable vhParameter as handle no-undo.
/* Create context */
create ttContext.
assign ttContext.propertyName = "programName"
ttContext.propertyValue = "BBaseDaemonQueue".
create ttContext.
assign ttContext.propertyName = "methodName"
ttContext.propertyValue = "ApiResetDaemonQueueStatus".
create ttContext.
assign ttContext.propertyName = "applicationId"
ttContext.propertyValue = "fin".
create ttContext.
assign ttContext.propertyName = "entity"
ttContext.propertyValue = "1000".
create ttContext.
assign ttContext.propertyName = "userName"
ttContext.propertyValue = "mfg".
create ttContext.
assign ttContext.propertyName = "password"
ttContext.propertyValue = "".
/* Create input dataset */
create dataset vhInputDS.
vhInputDS:read-xmlschema("file", "xml/bbasedaemonqueue.apiresetdaemonqueuestatus.i.xsd", ?).
vhParameter = vhInputDS:get-buffer-handle("tParameterI").
vhParameter:buffer-create().
assign vhParameter::iiDaemonId = <parameter value>
vhParameter::icDaemonName = <parameter value>
vhParameter::iiDaemonQueueId = <parameter value>
vhParameter::ilResetProcessedError = <parameter value>
vhParameter::ilResetInProcess = <parameter value>.
/* Connect the AppServer */
create server vhServer.
vhServer:connect("-URL <appserver-url>").
if not vhServer:connected()
then do:
message "Could not connect AppServer" view-as alert-box error title "Error".
return.
end.
/* Run */
assign vhContextDS = dataset dsContext:handle.
run program/rpcrequestservice.p on vhServer
(input-output dataset-handle vhContextDS by-reference,
output dataset-handle vhExceptionDS,
input dataset-handle vhInputDS by-reference,
input-output dataset-handle vhInputOutputDS by-reference,
output dataset-handle vhOutputDS).
/* Handle output however you want, in this example, we dump it to xml */
if valid-handle(vhExceptionDS)
then vhExceptionDS:write-xml("file", "Exceptions.xml", true).
if valid-handle(vhOutputDS)
then vhOutputDS:write-xml("file", "Output.xml", true).
/* Cleanup */
vhServer:disconnect().
assign vhServer = ?.
if valid-handle(vhInputDS)
then delete object vhInputDS.
if valid-handle(vhOutputDS)
then delete object vhOutputDS.
if valid-handle(vhExceptionDS)
then delete object vhExceptionDS.