Das Notes Forum
Domino 9 und frühere Versionen => Entwicklung => Thema gestartet von: Toma Bogdan am 18.06.02 - 10:38:55
-
How I can force exiting from a db with a scheduled Lotus Script agent ? Ex: to force the user next time when he use this db to open it again ! ???
-
Hi bog_tom
You have seen in secure web sites that if there is no activity on the form for certain time you are logged out.Similiar results can be acheived by using the following code below.
The code below shows how to Log out user's when there is no activity on a database?
---GLOBAL DECLARATIONS ------
Dim elapsedTime As Integer
Dim elapsedTimer As NotesTimer
%INCLUDE "lsconst.lss"
------POSTOPEN FORM EVENT ------
Sub Postopen(Source As Notesuidocument)
Dim session As New NotesSession
Set elapsedTimer = session.CreateTimer()
elapsedTimer.Interval = 1
elapsedTimer.Comment = "Elapsed time since opening document"
elapsedTime = 0
On Event Alarm From elapsedTimer Call elapsedTimerHandler
End Sub
-----ELAPSEDTIME SUBROUTINE-------
Sub elapsedTimerHandler(Source As NotesTimer)
Dim workspace As New NotesUIWorkspace
Dim uidoc As NotesUIDocument
Set uidoc = workspace.CurrentDocument
elapsedTime = elapsedTime + 1
Print elapsedtime
If elapsedtime=4 Then
If uidoc.EditMode Then
Call uidoc.FieldSetText( "SaveOptions", "0" )
uidoc.close
Messagebox ("Temp-1")
Else
uidoc.close
twoLiner = |This message is on two lines-2|
Messagebox twoLiner, MB_OK, "Demo"
End If
End If
End Sub
eknori
-
I think that this code will work if I am into a specific form which contains that code ! But supose that I am into a frameset of a database and I need to close this db if I pass into a new day (at 0 AM next day) ! How can I do that ? I think that I must put some code into the Database scripts ....
-
Hi bog_tom
sorry for the delay but this one was a bit tricky. Since note does not have a database close command in LS I had to use some Windows API to do the job.
Here's the code
This one goes into the declaration section of the database script
Dim elapsedTime As Integer
Dim elapsedTimer As NotesTimer
Declare Function NEMGetCurrentSubprogramWindow Lib "nnotesws.dll" () As Long
Declare Function NEMStopSubprogramWindow Lib "nnotesws.dll" (Byval hwnd As Long) As Integer
Copy the following function to the databasescript too
Sub elapsedTimerHandler(Source As NotesTimer)
Dim workspace As New NotesUIWorkspace
Dim uidoc As NotesUIDocument
Set uidoc = workspace.CurrentDocument
elapsedTime = elapsedTime + 1
If elapsedtime=3600 Then
Dim wHandle As Long
wHandle = NEMGetCurrentSubprogramWindow
Call NEMStopSubprogramWindow(wHandle)
End If
End Sub
Modify the elapsedtime variable to your own need.
Finally paste the following code into either the initialize or postopen event of the database Script
Dim session As New NotesSession
Set elapsedTimer = session.CreateTimer()
elapsedTimer.Interval = 1
elapsedTimer.Comment = "Elapsed time since opening document"
elapsedTime = 0
On Event Alarm From elapsedTimer Call elapsedTimerHandler
eknori