project BLF > class PMfgPro > method StartQadAppServiceCaller

Description

Start the QadAppServiceCaller.p persistently if not yet started before


Parameters


oiReturnStatusoutputintegerReturn status of the method.


Internal usage


BLF
method PMfgPro.InitInstance


program code (program1/pmfgpro.p)

assign oiReturnStatus = -98.

if not valid-handle (vhServiceCaller)
then vhServiceCaller = ?.

/* First, check whether the ExceptionManager.p procedure is running persistently.  If not, start it */
assign vhProc = session:first-procedure.
do while vhProc <> ?:
    if vhProc:name begins "com/qad/qra/si/ExceptionManager.":U
    then vhExceptionManager = vhProc.
    if vhServiceCaller = ?
    then if vhProc:name begins "com/qad/qra/si/QADAppServiceCaller.":U                               
         then vhServiceCaller = vhProc.
    assign vhProc = vhProc:next-sibling.
end.

if vhExceptionManager = ?
then do:
    /* Check the propath */    
    if search("com/qad/qra/si/ExceptionManager.r":U) = ? and
       search("com/qad/qra/si/ExceptionManager.p":U) = ?
    then do:
        <M-4 run SetMessage
          (input  #T-6'The Exception Manager for the MFG/PRO service interface is not reachable':100(8068)T-6# (icMessage), 
           input  '' (icArguments), 
           input  '' (icFieldName), 
           input  '' (icFieldValue), 
           input  'S':U (icType), 
           input  1 (iiSeverity), 
           input  '' (icRowid), 
           input  'BLF-384':U (icFcMsgNumber), 
           input  'The com/qad/qra/si/exceptionManager.p cannot be found.  The appserver propath is not set correctly on the installed product.  It should include the com/qad/qra/si/exceptionManager.p':U (icFcExplanation), 
           input  '' (icFcIdentification), 
           input  '' (icFcContext), 
           output viFcReturnSuper (oiReturnStatus)) in PMfgPro>
        assign oiReturnStatus = -5.
        return.
    end.

    run value("com/qad/qra/si/ExceptionManager.p":U) persistent no-error.
    if error-status:error
    then do :
        assign vcError = error-status:get-message(1) + chr(10) +
                         error-status:get-message(2) + chr(10) +
                         error-status:get-message(3).
        <M-5 run SetMessage (input  'A problem occured when starting the ExceptionManager.p':U (icMessage), 
                     input  '' (icArguments), 
                     input  '' (icFieldName), 
                     input  '' (icFieldValue), 
                     input  'S':U (icType), 
                     input  1 (iiSeverity), 
                     input  '' (icRowid), 
                     input  'BLF-385':U (icFcMsgNumber), 
                     input  'The ExceptionManager.p is found in the propath, but it gives errors when it is run.  The following error is returned:' + chr(10) + vcError (icFcExplanation), 
                     input  '' (icFcIdentification), 
                     input  '' (icFcContext), 
                     output viFcReturnSuper (oiReturnStatus)) in PMfgPro>
        assign oiReturnStatus = -5.
        return.
    end.
end.

/* We only have to start the QADAppServiceCaller.p only if it's not yet active */
if vhServiceCaller = ?
then do :
    /* Check the propath */
    if search("com/qad/qra/si/QADAppServiceCaller.r":U) = ? and
       search("com/qad/qra/si/QADAppServiceCaller.p":U) = ?
    then do:
        <M-1 run SetMessage
          (input  #T-2'The MFG/PRO service is not reachable':100(8067)t-2# (icMessage), 
           input  '' (icArguments), 
           input  '' (icFieldName), 
           input  '' (icFieldValue), 
           input  'S':U (icType), 
           input  1 (iiSeverity), 
           input  '' (icRowid), 
           input  'BLF-383':U (icFcMsgNumber), 
           input  'The com/qad/qra/si/QADAppServiceCaller.p cannot be found.  The appserver propath is not set correctly on the installed product.  It should include the com/qad/qra/si/QadAppServiceCaller.p':U (icFcExplanation), 
           input  '' (icFcIdentification), 
           input  '' (icFcContext), 
           output viFcReturnSuper (oiReturnStatus)) in PMfgPro>
        assign oiReturnStatus = -5.
        return.
    end.
    
    run value("com/qad/qra/si/QADAppServiceCaller.p":U) persistent set vhServiceCaller 
        ( input "APPSERVICE":U,
          input "MfgPro":U,
          input "server.xml":U)
        no-error.

    if error-status:error or
       not valid-handle(vhServiceCaller)
    then do :
        /* Reset the error-status by adding no-error */
        assign oiReturnStatus = -5 no-error.
        /* Call the exception manager to retrieve all exceptions.  The exception manager is run as a session super procedure */
              
        run getAllExceptions (output dataset-handle vhExceptionDS).
        <M-7 run StoreSIExceptions
           (input  vhExceptionDS by-reference (izExceptionDS), 
            output viReturnSI (oiReturnFromService), 
            output viFcReturnSuper (oiReturnStatus)) in PMfgPro>
        /*delete dataset vhExceptionDS to avoid that temp_err_msg keeps living in memory*/
        delete object vhExceptionDS no-error.
        return.
    end.
end.

assign oiReturnStatus = 0.