Using A Timer In Lotusscript

There are a number of things that the code below accomplishes. It runs as a
scheduled agent, reading in a flat file for purposes of creating IDs/PWs for
access to Domino databases. It determines if a person doc already exists in
the NAB for the requested ID, and if not creates a person doc for that ID,
saving multiple items of information contained in the file for the ID to that
doc (including both saving and encrypting the requested password for that ID).
It also inserts the ID into the appropriate group for access (the ACLs use
group names for access, not individual names). But perhaps the highlight of
the code is the timer that I have implemented. The timer checks the time when
the agent started running, and at the point when the agent has been running for
9 minutes and 50 seconds or more, stops execution (by preventing the agent from
reading the next line of the file). Whatever line of the file the agent
stopped at is recorded in a database document, enabling the agent to pick up
where it left off n
ext time it runs. (The reason for implementation of the timer was that the
server doc. settings in our environment limit LotusScript agent execution time
to a maximum of 10 minutes, and the timer stops execution before that limit is
hit to prevent a hard stop caused by the server that would result in one or
more errors in the log.)
Sub Initialize
Dim aSess As New NotesSession
Dim aDB As NotesDatabase
Dim bView As NotesView
Dim cView As NotesView
Dim trackerView As NotesView
Dim allDocs As NotesDocumentCollection
Dim sameDocs As NotesDocumentCollection
Dim aDoc As NotesDocument
Dim bDoc As NotesDocument
Dim cDoc As NotesDocument
Dim nextDoc As NotesDocument
Dim trackerDoc As NotesDocument
Dim newMember As NotesItem
Dim dummyDate As New NotesDateTime("01/01/1990")
Dim encryptPW As Variant
Dim currLine$, userID$, userPW$, userName$, groupName$, fileName$,
groupCode$
Dim fileNum%, procCount%
Dim timeOn!, timeRan!
Dim fileLine&
timeOn = Timer
Set aDB = aSess.CurrentDatabase
Set allDocs = aDB.UnprocessedDocuments
Set nextDoc = allDocs.GetFirstDocument
While Not (nextDoc Is Nothing) 'Mark all documents as processed
Call aSess.UpdateProcessedDoc(nextDoc)
Set nextDoc = allDocs.GetNextDocument(nextDoc)
Wend
Set trackerView = aDB.GetView("Counter")
Set trackerDoc = trackerView.GetFirstDocument
procCount = trackerDoc.LineNumber(0)
fileName = "ustrade/passwords/pw.lena"
Set cView = aDB.GetView("Admin \ Country \ US LENA People")
Set bView = aDB.GetView("Groups")
fileNum = Freefile
Open ("/home/www/webpub/" & fileName) For Input Access Read As fileNum
Err = 0
For fileLine = 1 To procCount
Input #fileNum, currLine
Next
If Eof(fileNum) Or Err Then
trackerDoc.LineNumber = 1
Call trackerDoc.Save(False, True)
End If
On Error Resume Next
Do While Not Eof(fileNum) And timeRan < 590
Input #fileNum, currLine
userID = Left(currLine, 14)
If procCount < 10 Then
groupCode = "0" + Cstr(procCount)
Else
groupCode = Left(Right(Cstr(procCount), 4), 2)
End If
groupName = "PSG US Users " & groupCode
Set cDoc = cView.GetDocumentByKey(userID, True)
If cDoc Is Nothing Then
userPW = Mid(currLine, 16, 4)
userName = Mid(currLine, 21, 5)
Set aDoc = aDB.CreateDocument
aDoc.Form = "Person"
aDoc.Type = "Person"
aDoc.LastName = userID
aDoc.FullName = userID
aDoc.ShortName = userID
aDoc.UserPW = userPW
aDoc.HTTPPassword = userPW
encryptPW = Evaluate("@Password(HTTPPassword)", aDoc)
aDoc.HTTPPassword = encryptPW
aDoc.CompanyName = userName
aDoc.GroupName = groupName
aDoc.Comment = "US LENA"
Call aDoc.Save(False, True)
Set bDoc = bView.GetDocumentByKey(groupName, True)
Set newMember = bDoc.GetFirstItem("Members")
Call newMember.AppendToTextList(userID)
Call bDoc.Save(False, True)
End If
procCount = procCount + 1
timeRan = Timer - timeOn
Loop
trackerDoc.LineNumber = procCount
Call trackerDoc.Save(False, True)
Close fileNum
End Sub

Dig Deeper on Domino Resources

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.

-ADS BY GOOGLE

SearchWindowsServer

Search400

  • iSeries tutorials

    Search400.com's tutorials provide in-depth information on the iSeries. Our iSeries tutorials address areas you need to know about...

  • V6R1 upgrade planning checklist

    When upgrading to V6R1, make sure your software will be supported, your programs will function and the correct PTFs have been ...

  • Connecting multiple iSeries systems through DDM

    Working with databases over multiple iSeries systems can be simple when remotely connecting logical partitions with distributed ...

SearchDataCenter

SearchContentManagement

Close