Lotusscript统计在线用户数
使用notessession的SendConsoleCommand方法向服务器控制台发送“show inetusers”命令,该命令返回一个结果(字符串),字符串类似如下:
admin 192.168.0.50 HTTP 20100910T114142,37+08 admin 192.168.0.43 HTTP 20100910T114345,34+08
用户与用户之间使用回车符Chr(13)分隔,用户的相关信息用Chr(9)字符分隔。
把返回得到的字符串再根据这一规则保存到数组中,即可得到在线用户信息。
1 Set session = New NotesSession 2 Set cdb = session.CurrentDatabase 3 commandStr$="show inetusers" 4 onlineUsers$ = session.SendConsoleCommand(cdb.Server,commandStr$) 5 onlineUsersArray = Split(onlineUsers$,Chr(13)&Chr(10)) 6 usersStr = "" 7 For i =0 To Ubound(onlineUsersArray) 8 If onlineUsersArray(i) <> "" Then 9 If usersStr = "" Then 10 usersStr = Lcase(Strleft(onlineUsersArray(i),Chr(9))) 11 Else 12 usersStr = usersStr & ";" & Lcase(Strleft(onlineUsersArray(i),Chr(9))) 13 End If 14 End If 15 Next 16
附:chr参数对应键盘字符表
NUL[000] DLE[016] SPC[032] 0[048] @[064] P[080] `[096] p [112] SOH[001] DC1[017] ! [033] 1[049] A[065] Q[081] a[097] q [113] STX[002] DC2[018] " [034] 2[050] B[066] R[082] b[098] r [114] ETX[003] DC3[019] # [035] 3[051] C[067] S[083] c[099] s [115] EOT[004] DC4[020] $ [036] 4[052] D[068] T[084] d[100] t [116] ENQ[005] NAK[021] % [037] 5[053] E[069] U[085] e[101] u [117] ACK[006] SYN[022] & [038] 6[054] F[070] V[086] f[102] v [118] BEL[007] ETB[023] ' [039] 7[055] G[071] W[087] g[103] w [119] BS [008] CAN[024] ( [040] 8[056] H[072] X[088] h[104] x [120] TAB[009] EM [025] ) [041] 9[057] I[073] Y[089] i[105] y [121] LF [010] SUB[026] * [042] :[058] J[074] Z[090] j[106] z [122] VT [011] ESC[027] + [043] ;[059] K[075] [[091] k[107] { [123] FF [012] FS [028] , [044] <[060] L[076] \[092] l[108] | [124] CR [013] GS [029] - [045] =[061] M[077] ][093] m[109] } [125] SO [014] RS [030] . [046] >[062] N[078] ^[094] n[110] ~ [126] SI [015] US [031] / [047] ?[063] O[079] _[095] o[111] DEL[127]