project BLF > class Session > method AppServerInfo
Description
return info on appserver
(this method can be run without a valid login)
Parameters
ocText | output | character | Returns all server settings in one text |
oiReturnStatus | output | integer | |
Internal usage
unused
program code (program3/session.p)
input through ("hostname":U).
import vcHost.
input close.
if opsys = "UNIX":U
then do:
assign vcUser = os-getenv ("LOGNAME":U).
input through "echo $PPID".
import viProcessId.
input close.
if viProcessId = 0
then do:
create buffer vhConnBuffer for table "_MyConnection" in widget-pool "non-persistent" no-error.
if vhConnBuffer <> ?
then do:
vhConnBuffer:find-first ("",no-lock).
if vhConnBuffer:available
then viProcessId = vhConnBuffer::_MyConn-Pid.
delete object vhConnBuffer.
end.
end.
end.
if opsys = "WIN32":U
then do:
assign vcUser = os-getenv ("USERNAME":U).
<M-1 run Main () in Win32Lib>
assign viProcessId = <M-2 GetCurrentProcess () in Win32Lib>.
run gipr_DeleteProcedure in vhFcComponent.
delete procedure vhFcComponent.
end.
if vcHost = ? then vcHost = "".
if vcUser = ? then vcUser = "".
assign ocText = ocText + trim (#T-3'Host name':40(18)t-3#) + " : ":U + chr(10) + vcHost + chr(10) + chr(10)
+ trim (#T-4'Logged in as':40(19)t-4#) + " : ":U + chr(10) + vcUser + chr(10) + chr(10)
+ trim (#T-5'Operating system':40(20)t-5#) + " : ":U + chr(10) + opsys + chr(10) + chr(10)
+ "PROPATH :":U + chr(10) + replace (propath, ",":U, chr(10)) + chr(10) + chr(10).
if num-dbs > 0
then do:
assign ocText = ocText + trim (#T-6'Connected databases':40(21)t-6#) + " : ":U + chr(10).
do viFcCount1 = 1 to num-dbs:
assign ocText = ocText + pdbname(viFcCount1)
+ (if pdbname(viFcCount1) = ldbname(viFcCount1)
then ""
else " (":U + ldbname(viFcCount1) + ")":U)
+ " : ":U + dbtype(viFcCount1) + chr(10).
if not can-do (vcpages,dbcodepage(viFcCount1))
then vcpages = vcpages + ",":U + dbcodepage(viFcCount1).
end.
assign ocText = ocText + chr(10).
end.
assign ocText = ocText + trim (#T-7'Code Pages':40(22)T-7#) + " : ":U + chr(10)
+ trim (#T-8'Internal':40(23)t-8#) + " = ":U + session:cpinternal + chr(10)
+ trim (#T-9'Input/Output':40(24)t-9#) + " = ":U + session:cpstream + chr(10).
if vcpages <> ""
then assign ocText = ocText + trim (#T-10'Database':12(7170)T-10#) + " = ":U + substring(vcPages,2,-1,"CHARACTER":U) + chr(10).
empty temp-table tProcList.
assign vhFcComponent = session:first-procedure.
do while valid-handle (vhFcComponent):
find first tProcList where
tProcList.tcName = vhFcComponent:file-name no-error.
if not available tProcList
then do:
create tProcList.
assign tProcList.tcName = vhFcComponent:file-name
tProcList.tcClassName = entry(1,vhFcComponent:file-name,".":U).
assign tProcList.tcClassName = entry(num-entries(tProcList.tcClassName,"/":U),tProcList.tcClassName,"/":U).
assign tProcList.tcClassName = entry(num-entries(tProcList.tcClassName,"_":U),tProcList.tcClassName,"_":U).
end.
assign tProcList.tiSequence = tProcList.tiSequence + 1
vhFcComponent = vhFcComponent:next-sibling.
end.
assign ocText = ocText + chr(10)
+ trim (#T-11'Procedure list':40(26)t-11#) + " : ":U + chr(10).
for each tProcList by tProcList.tcClassName by tProcList.tcName:
assign ocText = ocText + tProcList.tcName
+ (if tProcList.tiSequence = 1
then ""
else " (":U + string(tProcList.tiSequence) + ")":U)
+ chr(10).
end.
assign ocText = ocText + chr(10)
+ trim (#T-12'Process ID':40(27)t-12#) + " : ":U + chr(10) + string(viProcessId) + chr(10) + chr(10).
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 = "Session".
create ttContext.
assign ttContext.propertyName = "methodName"
ttContext.propertyValue = "AppServerInfo".
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 = "".
/* 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.