Consultor Eletrônico



Kbase 21135: How To Do a Remote proshut Using Virtual System Tables (VST)
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   7/16/2009
Status: Verified

GOAL:

How to proshut a user remotely using the Virtual System Tables (VST).

GOAL:

How to remote disconnect a user from the database using VST

FACT(s) (Environment):

Progress 8.X
Progress 9.X
Windows

FIX:

The code example below consists of one table definition 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.

The five steps to implement this remote proshut are as follows:

1) If you are using Version 8 of Progress you need to enable the VST using: proutil sports -C enablevst

2) Load the following table definition for the 'shut' table. Ensure you are using the correct startup parameters when doing this, particularly when loading the .d file. See the .d file trailer for more information. The parameters to think about are -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
o"
INITIAL "no"
LABEL "Shut user ? (yes
o)"
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) At the Server, execute in batch mode the following program using the command: mbpro sports -p shut.p
***NOTE: REPLACE THE DBNAME IN THE PROSHUT COMMAND WITH YOUR DBASE NAME****

/* shut.p */
/* Daemon that will monitor the table SHUT */
/* This table must be loaded in the Database you want to control */
/* This program uses the sports database as an example. Insert */
/* the desired 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 program:

/* shutr.p */
/* This program will run on the client side and will browse a Promon like a user list */
/* If you press the shut button 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.
.