project BLF > class TApplication > method ExecuteAction
Description
Execute a certain action.
This method is called upon by ApplicationControl component.
In this method, for every possible action, code should be put for execution.
Supported actions are "Stop", "Start" and "ResetConfigurations".
Parameters
icAction | input | character | Action to be executed |
ocMessage | output | character | Message coming back from the execution. |
oiReturnStatus | output | integer | Return status of the method. |
Internal usage
BLF
program code (program1/tapplication.p)
case icAction:
when "StartApplication":U
THEN do:
assign vlActionExists = yes.
<M-1 run StartApplication (input true (ilPerformHousekeeping),
output ocMessage (ocMessage),
output oiReturnStatus (oiReturnStatus)) in TApplication>
end.
when "StartApplication_no_housekeeping":U
THEN do:
assign vlActionExists = yes.
<M-4 run StartApplication (input false (ilPerformHousekeeping),
output ocMessage (ocMessage),
output oiReturnStatus (oiReturnStatus)) in TApplication>
end.
when "StopApplication":U
then do:
assign vlActionExists = yes.
<M-25 run StopApplication
(input true (ilWait),
output ocMessage (ocMessage),
output oiReturnStatus (oiReturnStatus)) in TApplication>
end.
when "StopApplication_no_wait":U
then do:
assign vlActionExists = yes.
<M-5 run StopApplication (input false (ilWait),
output ocMessage (ocMessage),
output oiReturnStatus (oiReturnStatus)) in TApplication>
end.
when "OnlineHousekeeping":U
then do :
assign vlActionExists = yes.
<M-24 run MainBlock (input yes (ilRunOnline)) in Housekeeping>
run gipr_DeleteProcedure in vhFcComponent.
delete procedure vhFcComponent.
/* pick up housekeeping output */
file-info:file-name = session:temp-dir + "Housekeeping-errors.txt".
if file-info:file-type begins "F"
then do:
copy-lob from file (session:temp-dir + "Housekeeping-errors.txt":U) to vpHouseKeeping.
ocMessage = substring(vpHouseKeeping,1,20000,"CHARACTER").
ocMessage = trim(ocMessage).
os-delete value (session:temp-dir + "Housekeeping-errors.txt":U).
end.
end.
when "ActivateSOD"
then do:
assign vlActionExists = yes.
<M-74 run ActivateSOD
(output ocMessage (ocMessage),
output oiReturnStatus (oiReturnStatus)) in TApplication>
end.
when "DeactivateSOD"
then do:
assign vlActionExists = yes.
<M-37 run DeactivateSOD
(output ocMessage (ocMessage),
output oiReturnStatus (oiReturnStatus)) in TApplication>
end.
otherwise do:
case entry(1,icAction," "):
when "StartDaemon":U or
when "StartDaemons":U or
when "StopDaemon":U or
when "StopDaemons":U or
when "DaemonStatus":U or
when "ResetDaemonConfiguration":U or
when "UnconditionalStopDaemon":U or
when "ClearDaemonQueue":U
then do:
assign vlActionExists = yes
vcDaemonName = if num-entries (icAction, " ") > 1
then entry(2,icAction," ")
else "".
/* IF a daemonname is supplied, then it should exist and be configured in the system */
if vcDaemonName <> ""
then do:
<Q-15 assign vlFcQueryRecordsAvailable = DaemonLoginInfo (NoCache) (input vcDaemonName, (DaemonName)) in BBaseDaemon >
if not vlFcQueryRecordsAvailable
then do:
assign ocMessage = substitute("Daemon '(&1)' non existent or not configured properly":U,vcDaemonName)
oiReturnStatus = -1.
return.
end.
/* The Report Daemon can not be started or stopped using ApplicationControl */
if (icAction begins 'StartDaemon' or icAction begins 'StopDaemon') and
vcDaemonName = {&REPORTDAEMON}
then do :
assign ocMessage = 'The REPORTDAEMON can not be started or stopped using ApplicationControl':U
oiReturnStatus = -1.
return.
end.
end.
if icAction begins "StartDaemon":U
then do:
<M-13 run StartDaemonAction
(input vcDaemonName (icDaemonName),
output ocMessage (ocMessage),
output oiReturnStatus (oiReturnStatus)) in TApplication>
end.
if icAction begins "StopDaemon":U
then do:
<M-60 run StopDaemonAction
(input vcDaemonName (icDaemonName),
output ocMessage (ocMessage),
output viFcReturnSuper (oiReturnStatus)) in TApplication>
end.
if icAction begins "UnconditionalStopDaemon":U
then do:
if vcDaemonName = ""
then do:
assign ocMessage = "The daemon name should be specified":U
oiReturnStatus = -1.
end.
else do :
<M-23 run CallUnconditionalStopDaemon
(input vcDaemonName (icDaemonName),
output ocMessage (ocMessage),
output oiReturnStatus (oiReturnStatus)) in TApplication>
end.
end.
if icAction begins "DaemonStatus":U
then do:
<M-18 run Main (input viSessionId (iiSessionId)) in TDaemonUtility>
<M-20 run GetDaemonStatus
(input vcDaemonName (icDaemonName),
output tDaemonStatusReturn (tDaemonStatus),
output oiReturnStatus (oiReturnStatus)) in TDaemonUtility>
run gipr_DeleteProcedure in vhFcComponent.
delete procedure vhFcComponent.
end.
if icAction begins "ResetDaemonConfiguration":U
then do:
<M-14 run ResetConfigurations
(input vcDaemonName (icDaemonName),
output ocMessage (ocMessage),
output oiReturnStatus (oiReturnStatus)) in TApplication>
end.
if icAction begins "ClearDaemonQueue"
then do:
<M-47 run ClearDaemonQueue
(input vcDaemonName (icDaemonName),
output ocMessage (ocMessage),
output oiReturnStatus (oiReturnStatus)) in TApplication>
end.
end.
otherwise do:
assign vlActionExists = no
ocMessage = subst ('The supplied action (&1) is not supported by TApplication.ExecuteAction.':U,icAction)
oiReturnStatus = -1.
end.
end case.
end.
end case.
if vlActionExists
then return.
if icAction begins "Synchronize":U
then do:
if num-entries(icAction," ") > 1
then do:
assign vcSynchType = entry(2,icAction," ").
if vcSynchType = "Full":U then assign vcAction = {&SYNCHRONIZETYPE-FULL}.
if vcSynchType = "Limited":U then assign vcAction = {&SYNCHRONIZETYPE-LIMITED}.
if vcSynchType begins "Topic":U then assign vcAction = {&SYNCHRONIZETYPE-TOPIC} + substring(vcSynchType,6,-1,"CHARACTER":U).
if vcAction = "" or vcAction = ?
then do:
assign ocMessage = "The synchronize type is not recognized. It should be 'Full', 'Limited' or 'Topic<NR>'.":U
oiReturnStatus = -1.
end.
else do:
<M-26 run Synchronize
(input vcAction (icType),
output ocMessage (ocMessage),
output oiReturnStatus (oiReturnStatus)) in TApplication>
end.
end.
else assign ocMessage = "The synchronize action should always be qualified with the type. It should be 'Full', 'Limited' or 'Topic<NR>'.":U
oiReturnStatus = -1.
end.
else do :
assign vlActionExists = no
ocMessage = subst ('The supplied action (&1) is not supported by TApplication.ExecuteAction.':U,icAction)
oiReturnStatus = -1.
end.
catch syster as progress.lang.error:
oiReturnStatus = -98.
do viFcCount4 = 1 to syster:NumMessages:
create tFcMessages.
assign tFcMessages.tcFcMessage = syster:GetMessage (viFcCount4)
tFcMessages.tcFcBusMethod = (if session:error-stack-trace
then syster:CallStack
else program-name(2))
tFcMessages.tcFcContext = syster:ToString() /* contains root cause for com.qad.lang.apperror */
tFcMessages.tiFcSeverity = syster:severity
tFcMessages.tcFcType = "S".
end.
end catch.
finally:
for each tFcMessages:
ocMessage = ocMessage + chr(10) + tFcMessages.tcFcMessage + " (" + tFcMessages.tcFcMsgNumber + ")".
end.
end finally.