The code example below consists of one table definition (.df) and two programs:
- The first program is shut.p. This is a daemon that needs to be executed in batch mode inside the Server using a self-service client connection. Shut.p will poll a record from the table 'shut'. Whenever there is a change in the field shut_status to true, it will shut the process with the number contained in shut_id.
- The second program is shutr.p and it must run on the Client side. Using the VST table _connect, it detects the users that are connected remotely and lists them in a browser. To disconnect a user, select the user and press the "shut" button.
Five steps to implement this remote PROSHUT are as follows:1. For Progress 8x VST's need to be enabled using:
proutil sports -C enablevstFor Progress 9 and later, VST's are enabled by default and it is advisable to update VSTs with:
proutil dbname -C updateVST2. Load the following table definition for the '
shut' table. Ensure the correct startup parameters are used when doing this, particularly when loading the
.d file. See the .d file trailer for more information. The parameters in particular are the: -d, -yy and numeric format:
UPDATE DATABASE "?"
ADD TABLE "Shut"
AREA "Schema Area"
DUMP-NAME "shut"
ADD FIELD "shut_status" OF "Shut" AS logical
DESCRIPTION "When changed to ""yes"" a daemon process will proceed to disconnect the remote user."
FORMAT "yes/no"
INITIAL "no"
LABEL "Shut user ? (yes/no)"
POSITION 2
SQL-WIDTH 1
ORDER 10
ADD FIELD "shut_id" OF "Shut" AS integer
DESCRIPTION "Id of the user to be disconnected."
FORMAT "->,>>>,>>9"
INITIAL "0"
POSITION 4
SQL-WIDTH 4
ORDER 20
.
PSC
cpstream=ISO8859-1
.
0000000523
3. Load the following record (shut.d) into the 'shut' table:
no 0
.
PSC
filename=Shut
records=0000000000001
ldbname=Shut
timestamp=2001/06/29-13:20:32
numformat=44,46
dateformat=mdy-1950
map=NO-MAP
cpstream=ISO8859-1
.
0000000009
4. On the Server, execute in batch mode the following
shut.p program using the command:
mbpro dbname -p shut.pReplace the
DBNAME in the PROSHUT COMMAND with the database name.
/* shut.p */
/* Daemon that will monitor the table SHUT */
/* This table must be loaded in the Database you want to control */
/* Insert the required database name after the PROSHUT command */
REPEAT:
FIND FIRST shut NO-LOCK.
IF shut.shut_status THEN
DO:
OS-COMMAND SILENT VALUE("proshut <DBNAME> -C disconnect " +
TRIM(STRING(shut.shut_id,">>9"))).
FIND FIRST shut SHARE-LOCK.
ASSIGN shut.shut_status = NO
shut.shut_id = 0.
RELEASE shut.
END.
PAUSE 1.
END.
5. On the client side, execute the following
shutr.p program:
/* shutr.p */
/* This program will run on the client side and will browse the user list with _Connect */
/* When the shut button is Selected it will disconnect the selected user and exit*/
DEFINE VARIABLE shut_w AS WIDGET NO-UNDO.
DEFINE BUTTON but_shut LABEL "&Shut User".
DEFINE BUTTON but_exit LABEL "&Exit".
DEFINE BUTTON but_refr LABEL "&Refresh".
DEFINE QUERY shut_q FOR _Connect.
DEFINE BROWSE shut_b QUERY shut_q
DISPLAY _Connect._Connect-Usr
_Connect._Connect-Name
_Connect._Connect-Type
_Connect._Connect-Wait
_Connect._Connect-Wait1
_Connect._Connect-TransID
_Connect._Connect-PID
_Connect._Connect-Server
_Connect._Connect-Time
WITH 15 DOWN.
FORM shut_b
but_shut AT 1
but_refr AT 20
but_exit AT 110
WITH FRAME shut_f
1 DOWN NO-BOX KEEP-TAB-ORDER OVERLAY
SIDE-LABELS NO-UNDERLINE THREE-D
AT COL 1 ROW 1 SIZE 120 BY 14.50
CANCEL-BUTTON but_exit.
ON CHOOSE OF but_shut
DO:
IF AVAILABLE _Connect THEN DO TRANSACTION:
FIND FIRST shut.
ASSIGN shut.shut_status = YES
shut.shut_id = _Connect._Connect-Usr.
RELEASE shut.
END.
END.
ON CHOOSE OF but_refr
DO:
RUN open_query IN THIS-PROCEDURE.
END.
CREATE WINDOW shut_w
ASSIGN
HEIGHT = 14.50
WIDTH = 120
STATUS-AREA = NO
MESSAGE-AREA = NO.
DO TRANSACTION:
FIND FIRST shut.
ASSIGN shut.shut_status = NO
shut.shut_id = 0.
RELEASE shut.
END.
RUN open_query IN THIS-PROCEDURE.
VIEW FRAME shut_f IN WINDOW shut_w.
ENABLE ALL WITH FRAME shut_f.
APPLY "cursor-down" TO shut_b.
WAIT-FOR WINDOW-CLOSE OF shut_w OR CHOOSE OF but_exit
FOCUS shut_b.
DELETE WIDGET shut_w.
QUIT.
PROCEDURE open_query:
OPEN QUERY shut_q FOR EACH _Connect WHERE _Connect._Connect-Type = "REMC".
END.