Autor Thema: force exiting from a db with a schedu LS agent ?  (Gelesen 1221 mal)

Offline Toma Bogdan

  • Aktives Mitglied
  • ***
  • Beiträge: 146
  • Geschlecht: Männlich
  • That's me ...
    • A nice site !
force exiting from a db with a schedu LS agent ?
« 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 !  ???
« Letzte Änderung: 01.01.70 - 01:00:00 von 1034200800 »

Offline eknori

  • @Notes Preisträger
  • Moderator
  • Gold Platin u.s.w. member:)
  • *****
  • Beiträge: 11.728
  • Geschlecht: Männlich
Re: force exiting from a db with a schedu LS agent
« Antwort #1 am: 18.06.02 - 10:44:52 »
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
« Letzte Änderung: 01.01.70 - 01:00:00 von 1034200800 »
Egal wie tief man die Messlatte für den menschlichen Verstand auch ansetzt: jeden Tag kommt jemand und marschiert erhobenen Hauptes drunter her!

Offline Toma Bogdan

  • Aktives Mitglied
  • ***
  • Beiträge: 146
  • Geschlecht: Männlich
  • That's me ...
    • A nice site !
Re: force exiting from a db with a schedu LS agent
« Antwort #2 am: 19.06.02 - 14:27:41 »
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 ....
« Letzte Änderung: 01.01.70 - 01:00:00 von 1034200800 »

Offline eknori

  • @Notes Preisträger
  • Moderator
  • Gold Platin u.s.w. member:)
  • *****
  • Beiträge: 11.728
  • Geschlecht: Männlich
Re: force exiting from a db with a schedu LS agent
« Antwort #3 am: 20.06.02 - 11:01:30 »
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
« Letzte Änderung: 01.01.70 - 01:00:00 von 1034200800 »
Egal wie tief man die Messlatte für den menschlichen Verstand auch ansetzt: jeden Tag kommt jemand und marschiert erhobenen Hauptes drunter her!

 

Impressum Atnotes.de  -  Powered by Syslords Solutions  -  Datenschutz