Search DominoPower's 11,441 Lotus-related article archive 
Home
EasyPrint
News details Click here for the RSS feed's XML code. This is not a browser URL.
Articles-only Click here for the RSS feed's XML code. This is not a browser URL.
Twitter Feed Click here for the Twitter feed.
Control your application's agents with this Agent Launchers tool (continued)

Launching agents on the specified schedule
Having a nice interface for specifying schedules is important, but it's useless without a mechanism to actually make the agents run on schedule. Essentially, this mechanism needs to be a server task that periodically checks to see which enabled agents are new or scheduled to run, runs them, and then marks them so that they won't run again before the next scheduled time. Instead of a true server task, however, it is sufficient to use a scheduled agent that runs more frequently than the smallest schedulable interval; that is, a launcher agent that runs more than once per hour. To use a round number, I chose to make this agent (agtschAGTLauncher) run every 30 minutes.

Note: When one scheduled agent launches another agent, the second agent runs under its own authority--that is, with whatever permissions its signer has. You should make sure that both the launcher and all schedulable agents are signed appropriately.

The code for the launcher agent is contained in the slAGTLauncher script library, in the subLaunch routine. Essentially, it loops through all enabled agent schedules, checks each one's schedule, and launches the ones whose schedules currently allow them to be launched. The code for subLaunch is straightforward and is omitted here.

To check a given agent schedule, the subLaunch routine calls the fnIsScheduled function, which is the core piece of the whole auto-launch mechanism. Instead of listing out the code or explaining the functionality in prose, I think the function's process can best be understood through pseudocode:

fnIsScheduled (Schedule As Document)
bRunAgent = False 'Assume the worst
dtLastRan = Schedule.LastLaunched 'the last time the agent was launched
If (dtLastRan = "") Then bRunAgent = True
If (dtLastRan = Today) Then bRanToday = True
If Not(bRunAgent) and (Now > Schedule.ScheduledTime) then
'We don't yet know whether to run the agent, but the designated time has arrived.
If Not (bRanToday) Then
'The agent has not yet been launched today.
Select Case Schedule.Frequency
Case "monthly"
If (the agent hasn't been run in 31 days) Then
bRunAgent = True
Else
If Schedule.MonthDay = "Last" Then
If (Today is last day of the month) Then bRunAgent = True
Else
If (Today = Schedule.MonthDay) Then bRunAgent = True
End If
End If
Case "weekly"
If (the agent hasn't been run in a week) Then
bRunAgent = True
Else
If (Today is the scheduled day) Then bRunAgent = True
End If
Case "daily"
'It's time, and the agent hasn't been run yet today
bRunAgent = True
Case "hourly"
'It's time, and the agent hasn't been run yet today
bRunAgent = True
End Select
Else
'The agent has already been run today.

If (Schedule.Frequency = "hourly") Then
TimeDifference = Now - dtLastRan
If (TimeDifference > Schedule.SpecifiedInterval) Then bRunAgent = True
End If
End If
End If
Return bRunAgent
End Function 'fnIsScheduled


« Previous  ·  1  ·  2  ·  3  ·  4  ·  5  ·  6  ·  7  ·  Next »
Other articles you might like
Home > Lotus Technologies > LotusScript (64 articles)
   When the debugger won't debug hidden code that isn't hidden
   What to do if the LotusScript debugger won't single-step over code
   Little known traps about Lotus Notes fields
Home > Lotus Technologies > Application Development (48 articles)
   An application for scanning physical mail and distributing it virtually
   How hide-whens in Rich Text can ruin your whole day (and what to do about it)
   Little known traps about Lotus Notes fields
Get Weekly Email Updates
Subscribe to our regular weekly email newsletter. It's packed with tips, reviews, deep analysis, and the latest news.
 
Recent DominoPower Articles
Application development, William Shatner, and the origin of the universe
Learn Domino Designer 8.5 for free
The (near) future of Sametime, Quickr, Connections, and Symphony
Inside the IBM Innovations lab
Lotusphere 2010: Hot fixes and cool news for Notes, Domino, and LotusLive
Lotusphere 2010: mobility and collaboration
2010: A Lotusphere of change
Latest Lotus Headlines
Xpages not loading? JVM errors? - Solution
How to implement an iCalendar feed into your Notes calendar with XPages
DWA Hotfixes for Domino 8.5.1FP1 - A Gotcha
IBM Adds DB2 to Lotus Foundations SMB Package
SNTT : XPages onclick Ghosts in the machine
Ports used by Lotus Sametime 8.5 servers
Exploring a Domino Date Bug
>> Read all the news
More from the ZATZ journals
Computing Unplugged: The iPad defenders have spoken
David Gewirtz Online: CNN commentary and analysis
OutlookPower: More about disappearing text
-- Advertisement --

Sophisticated Meets Simple For Document Management
Share. Control. Manage.
Documents, emails, and content in the context of how work is done. Native to Lotus Domino. The User Experience unseen for Lotus Domino. Do more with less. Really.

See the possibilities Docova unleashes for Lotus Domino.
-- Advertisement --

Mark your calendar for in-depth Lotus training, May 12-14, Boston
Join experts and peers May 12-14 in Boston for educational and networking events that deliver real-world Lotus training so you can increase productivity and efficiency in your company, advance your skills, and squeeze the most from your current environment. One registration gets you into THE VIEW's Admin2010 and Lotus Developer2010.

Register by April 10 to save $200.
ZATZ Home  ·  News  ·  Back Issues  ·  Credits/Trademarks ·  Link To Us
Copyright © 1998-2010, ZATZ Publishing. All rights reserved worldwide.
Editor's Login