sibon1
25th April 2003, 09:10
I have written my own program using native baan. you can see all active baan user by company; you can sort them by processID, UserID, LogonDate and Company; you also can kill a specific process or send a notice to a active user; if you wish, you can see the open sessions of a user.
enclosed pls. find a hardcopy of the session and the program script.
it works good and fast for me on Windows 2000 Server; i never tested it on Unix.
Josef N.
|******************************************************************************
|* tccom9590 0 VRC B40C c4 wuh1
|* *Aktive User abfragen
|* Nobis Josef
|* 2002-10-08
|******************************************************************************
|* Main table tccom990 Aktive User, Form Type 2
|* All Rights Reserved
|*
|* Permission to use, copy, modify, and distribute this software and its
|* documentation for any purpose and without fee is hereby granted,
|* provided that the above copyright notice appear in all copies and that
|* both that copyright notice and this permission notice appear in
|* supporting documentation.
|*
|* Josef N. and Baanboard.com DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
|* SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|* AND FITNESS, IN NO EVENT SHALL Norbert Wimmer nor Baanboard.com BE LIABLE FOR ANY
|* SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|* WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
|* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE
|* OR PERFORMANCE OF THIS SOFTWARE.
|******************************************************************************
|****************************** declaration section ***************************
declaration:
#pragma used dll ottdllbw
table ttccom990 | Aktive User
table tttaad200 | User
extern domain tcemno emno.f
extern domain tcemno emno.t
extern domain tcitem cprj.f fixed
extern domain tcitem cprj.t fixed
extern domain tcyrno year.f
extern domain tcyrno year.t
extern domain tcpern pern.f
extern domain tcpern pern.t
extern domain tcitem item.f fixed
extern domain tcitem item.t fixed
extern domain tcmcs.str30 filename
extern domain tcmcs.str50 filenamepath
extern domain tcmcs.str215 stringline
extern long ret
extern long file.pointer
extern long i
extern long fieldcounter
extern long item.exist
extern long rec.good
extern long rec.bad
extern domain tcmcs.str50 tempstr
extern domain tcitem item.i
extern domain tcqsl1 quan.i
extern domain tcmcs.str10 server.i
extern domain tcmcs.str15 user.pid
extern domain tcmcs.str12 user.i
extern domain tcmcs.long pid.i
extern domain tcmcs.str15 system.i
extern domain tcmcs.str10 date.i
extern domain tcmcs.str5 time.i
extern domain tcmcs.str16 date.time
extern domain tcqiv1 user.f1
extern domain tcqiv1 user.f2
extern domain tcqiv1 user.f3
extern domain tcqiv1 user.all
extern domain tcmcs.str50 i.file
extern domain tcmcs.str50 baan.message
extern domain tcmcs.str1 qm | Quotation Mark = "
|****************************** form section **********************************
form.1:
init.form:
daten.aktualisieren()
|# Schaltfläche Daten aktualisieren
choice.user.0:
before.choice:
daten.aktualisieren()
message("Daten aktualisiert")
|# Schaltfläche Key 1 (PID)
choice.user.1:
before.choice:
to.key(1)
daten.aktualisieren()
|# Schaltfläche Key 2 (User)
choice.user.2:
before.choice:
to.key(2)
daten.aktualisieren()
|# Schaltfläche Print Prozessliste pro PID
choice.user.3:
before.choice:
ret = run.prog("cmd.exe", "cmd /c r:\apps\baan\bin\bshcmd.exe -p " & str$(tccom990.pid) & " > r:\apps\baan\tmp\bshcmd.txt", RP_WAIT)
if ret = 0 then
| message("Prozessliste in bshcmd.txt ausgegeben")
else
message("Fehler Nr. " & str$(ret) & " beim Erstellen der Prozessliste")
endif
ret = server2client("r:\apps\baan\tmp\bshcmd.txt", "d:\bshcmd.txt",1)
if ret = 0 then
| message("Datei erfolgreich kopiert!")
else
message("Fehler Nr. " & str$(ret) & " beim Kopieren der Datei")
endif
i.file = "d:\bshcmd.txt"
| message(i.file)
ret = app_start(strip$(i.file), "", "", "", "")
|# Schaltfläche KILL PID
choice.user.4:
before.choice:
message("Prozess " & str$(tccom990.pid) & " wird gelöscht!")
ret = run.prog("cmd.exe", "cmd /c r:\apps\baan\bin\bshcmd.exe -e " & str$(tccom990.pid), RP_WAIT)
| message(str$(ret))
if ret = 0 then
message("Prozess wurde gelöscht!")
else
message("Fehler Nr. " & str$(ret) & " beim Löschen")
endif
daten.aktualisieren()
|# Schaltfläche Show Message
choice.user.5:
before.choice:
zoom.to$("tccom9591s000", z.session, "dummy", "", 0)
|# Schaltfläche Key 6 (Sort. Datum)
choice.user.6:
before.choice:
to.key(3)
daten.aktualisieren()
|# Schaltfläche Key 7 (Sort. Company#)
choice.user.7:
before.choice:
to.key(4)
daten.aktualisieren()
|****************************** function section ******************************
functions:
function create.active.userfile()
{
ret = run.prog("cmd.exe", "cmd /c r:\apps\baan\bin\licmon.exe -w > r:\apps\baan\tmp\user.txt", RP_WAIT)
}
function open.userfile()
{
filenamepath = "r:/apps/baan/tmp/user.txt"
file.pointer = seq.open(strip$(filenamepath), "r") | open for reading
if file.pointer < 1 then
mess("tccom90001",1,strip$(filename)) | Datei kann nicht geöffnet werden
choice.again()
endif
}
function delete.working.table()
{
db.retry.point()
select tccom990.*
from tccom990 for update
selectdo
db.delete(ttccom990, db.retry)
endselect
commit.transaction()
}
function fill.working.table()
{
if file.pointer = 0 then
open.userfile()
endif
while ret = 0
ret = seq.gets(stringline, 215, file.pointer)
if ret = 0 then
if stringline(1;6)<>"SERVER" then
separate.string.into.fields()
write.table()
endif
endif
endwhile
}
function separate.string.into.fields()
{
server.i = stringline(1;10)
user.pid = stringline(24;15)
system.i = stringline(39;15)
date.i = stringline(54;10)
time.i = stringline(65;5)
date.time = date.i(7;4) & "-" & date.i(4;2) & "-" & date.i(1;2) & " " & time.i
for i = 2 to 14
if user.pid(i;1)="." then
user.i = user.pid(1;i-1) & " "
user.i = tolower$(user.i) | Umwandeln in Kleinbuchstaben
pid.i = lval(user.pid(i+1;15-i))
endif
endfor
tccom990.pid = pid.i | ProzessID
tccom990.user = user.i | UserID
tccom990.serv = server.i | Servername
tccom990.sysm = system.i | Systemname
tccom990.date = date.time | Datum und Uhrzeit
userstamm.lesen()
}
function write.table()
{
db.retry.point()
select tccom990.*
from tccom990 for update
where tccom990._index1 = {:pid.i}
selectdo
| update set
db.update(ttccom990, db.retry)
selectempty
db.insert(ttccom990, db.retry)
endselect
commit.transaction()
}
function close.userfile()
{
ret = seq.close(file.pointer)
if ret <> 0 then
mess("tccom90002",1,strip$(filename)) | Datei kann nicht geschlossen werden
endif
}
function userstamm.lesen()
{
user.all = user.all + 1
select ttaad200.*
from ttaad200
where ttaad200._index1 = {:user.i}
| where ttaad200.uusr = :user.i
and ttaad200._compnr = 0
selectdo
if ttaad200.comp = 1 then
user.f1 = user.f1 +1
endif
if ttaad200.comp = 2 then
user.f2 = user.f2 +1
endif
if ttaad200.comp = 3 then
user.f3 = user.f3 +1
endif
tccom990.comp = ttaad200.comp
selectempty
message("User " & user.i & " not found in Userstamm!")
tccom990.comp = 0
endselect
}
function daten.aktualisieren()
{
user.f1 = 0
user.f2 = 0
user.f3 = 0
user.all = 0
create.active.userfile()
open.userfile()
delete.working.table()
fill.working.table()
close.userfile()
execute(find.data) | Anzeige aktualisieren
}
enclosed pls. find a hardcopy of the session and the program script.
it works good and fast for me on Windows 2000 Server; i never tested it on Unix.
Josef N.
|******************************************************************************
|* tccom9590 0 VRC B40C c4 wuh1
|* *Aktive User abfragen
|* Nobis Josef
|* 2002-10-08
|******************************************************************************
|* Main table tccom990 Aktive User, Form Type 2
|* All Rights Reserved
|*
|* Permission to use, copy, modify, and distribute this software and its
|* documentation for any purpose and without fee is hereby granted,
|* provided that the above copyright notice appear in all copies and that
|* both that copyright notice and this permission notice appear in
|* supporting documentation.
|*
|* Josef N. and Baanboard.com DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
|* SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|* AND FITNESS, IN NO EVENT SHALL Norbert Wimmer nor Baanboard.com BE LIABLE FOR ANY
|* SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|* WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
|* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE
|* OR PERFORMANCE OF THIS SOFTWARE.
|******************************************************************************
|****************************** declaration section ***************************
declaration:
#pragma used dll ottdllbw
table ttccom990 | Aktive User
table tttaad200 | User
extern domain tcemno emno.f
extern domain tcemno emno.t
extern domain tcitem cprj.f fixed
extern domain tcitem cprj.t fixed
extern domain tcyrno year.f
extern domain tcyrno year.t
extern domain tcpern pern.f
extern domain tcpern pern.t
extern domain tcitem item.f fixed
extern domain tcitem item.t fixed
extern domain tcmcs.str30 filename
extern domain tcmcs.str50 filenamepath
extern domain tcmcs.str215 stringline
extern long ret
extern long file.pointer
extern long i
extern long fieldcounter
extern long item.exist
extern long rec.good
extern long rec.bad
extern domain tcmcs.str50 tempstr
extern domain tcitem item.i
extern domain tcqsl1 quan.i
extern domain tcmcs.str10 server.i
extern domain tcmcs.str15 user.pid
extern domain tcmcs.str12 user.i
extern domain tcmcs.long pid.i
extern domain tcmcs.str15 system.i
extern domain tcmcs.str10 date.i
extern domain tcmcs.str5 time.i
extern domain tcmcs.str16 date.time
extern domain tcqiv1 user.f1
extern domain tcqiv1 user.f2
extern domain tcqiv1 user.f3
extern domain tcqiv1 user.all
extern domain tcmcs.str50 i.file
extern domain tcmcs.str50 baan.message
extern domain tcmcs.str1 qm | Quotation Mark = "
|****************************** form section **********************************
form.1:
init.form:
daten.aktualisieren()
|# Schaltfläche Daten aktualisieren
choice.user.0:
before.choice:
daten.aktualisieren()
message("Daten aktualisiert")
|# Schaltfläche Key 1 (PID)
choice.user.1:
before.choice:
to.key(1)
daten.aktualisieren()
|# Schaltfläche Key 2 (User)
choice.user.2:
before.choice:
to.key(2)
daten.aktualisieren()
|# Schaltfläche Print Prozessliste pro PID
choice.user.3:
before.choice:
ret = run.prog("cmd.exe", "cmd /c r:\apps\baan\bin\bshcmd.exe -p " & str$(tccom990.pid) & " > r:\apps\baan\tmp\bshcmd.txt", RP_WAIT)
if ret = 0 then
| message("Prozessliste in bshcmd.txt ausgegeben")
else
message("Fehler Nr. " & str$(ret) & " beim Erstellen der Prozessliste")
endif
ret = server2client("r:\apps\baan\tmp\bshcmd.txt", "d:\bshcmd.txt",1)
if ret = 0 then
| message("Datei erfolgreich kopiert!")
else
message("Fehler Nr. " & str$(ret) & " beim Kopieren der Datei")
endif
i.file = "d:\bshcmd.txt"
| message(i.file)
ret = app_start(strip$(i.file), "", "", "", "")
|# Schaltfläche KILL PID
choice.user.4:
before.choice:
message("Prozess " & str$(tccom990.pid) & " wird gelöscht!")
ret = run.prog("cmd.exe", "cmd /c r:\apps\baan\bin\bshcmd.exe -e " & str$(tccom990.pid), RP_WAIT)
| message(str$(ret))
if ret = 0 then
message("Prozess wurde gelöscht!")
else
message("Fehler Nr. " & str$(ret) & " beim Löschen")
endif
daten.aktualisieren()
|# Schaltfläche Show Message
choice.user.5:
before.choice:
zoom.to$("tccom9591s000", z.session, "dummy", "", 0)
|# Schaltfläche Key 6 (Sort. Datum)
choice.user.6:
before.choice:
to.key(3)
daten.aktualisieren()
|# Schaltfläche Key 7 (Sort. Company#)
choice.user.7:
before.choice:
to.key(4)
daten.aktualisieren()
|****************************** function section ******************************
functions:
function create.active.userfile()
{
ret = run.prog("cmd.exe", "cmd /c r:\apps\baan\bin\licmon.exe -w > r:\apps\baan\tmp\user.txt", RP_WAIT)
}
function open.userfile()
{
filenamepath = "r:/apps/baan/tmp/user.txt"
file.pointer = seq.open(strip$(filenamepath), "r") | open for reading
if file.pointer < 1 then
mess("tccom90001",1,strip$(filename)) | Datei kann nicht geöffnet werden
choice.again()
endif
}
function delete.working.table()
{
db.retry.point()
select tccom990.*
from tccom990 for update
selectdo
db.delete(ttccom990, db.retry)
endselect
commit.transaction()
}
function fill.working.table()
{
if file.pointer = 0 then
open.userfile()
endif
while ret = 0
ret = seq.gets(stringline, 215, file.pointer)
if ret = 0 then
if stringline(1;6)<>"SERVER" then
separate.string.into.fields()
write.table()
endif
endif
endwhile
}
function separate.string.into.fields()
{
server.i = stringline(1;10)
user.pid = stringline(24;15)
system.i = stringline(39;15)
date.i = stringline(54;10)
time.i = stringline(65;5)
date.time = date.i(7;4) & "-" & date.i(4;2) & "-" & date.i(1;2) & " " & time.i
for i = 2 to 14
if user.pid(i;1)="." then
user.i = user.pid(1;i-1) & " "
user.i = tolower$(user.i) | Umwandeln in Kleinbuchstaben
pid.i = lval(user.pid(i+1;15-i))
endif
endfor
tccom990.pid = pid.i | ProzessID
tccom990.user = user.i | UserID
tccom990.serv = server.i | Servername
tccom990.sysm = system.i | Systemname
tccom990.date = date.time | Datum und Uhrzeit
userstamm.lesen()
}
function write.table()
{
db.retry.point()
select tccom990.*
from tccom990 for update
where tccom990._index1 = {:pid.i}
selectdo
| update set
db.update(ttccom990, db.retry)
selectempty
db.insert(ttccom990, db.retry)
endselect
commit.transaction()
}
function close.userfile()
{
ret = seq.close(file.pointer)
if ret <> 0 then
mess("tccom90002",1,strip$(filename)) | Datei kann nicht geschlossen werden
endif
}
function userstamm.lesen()
{
user.all = user.all + 1
select ttaad200.*
from ttaad200
where ttaad200._index1 = {:user.i}
| where ttaad200.uusr = :user.i
and ttaad200._compnr = 0
selectdo
if ttaad200.comp = 1 then
user.f1 = user.f1 +1
endif
if ttaad200.comp = 2 then
user.f2 = user.f2 +1
endif
if ttaad200.comp = 3 then
user.f3 = user.f3 +1
endif
tccom990.comp = ttaad200.comp
selectempty
message("User " & user.i & " not found in Userstamm!")
tccom990.comp = 0
endselect
}
function daten.aktualisieren()
{
user.f1 = 0
user.f2 = 0
user.f3 = 0
user.all = 0
create.active.userfile()
open.userfile()
delete.working.table()
fill.working.table()
close.userfile()
execute(find.data) | Anzeige aktualisieren
}