Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

document update not noticed from within agent

Status
Not open for further replies.

mberni

IS-IT--Management
Jul 25, 2001
197
DE
Hi!

We want to write an agent to start multiple LEI (Lotus Enterprise Integrator) activities in sequence.

Activity n+1 must not be started before activity n has finished.

So we wrote an agent, who sets RunASAP=1 for the first activity and then monitors within a loop, if RunASAP is set back to 0 (i.e. it was executed by the LEI server process) to start the next activity and so on.

Problem is: the agent does not notice the fieldchange within the loop. That means: LEI executes the first activity, resets RunASAP to 0, but within the agent the field still shows value 1.

We refresh the view within the loop, but this doesnt matter.

How can i accomplish a view refresh within notes script so that the valuechange can be seen?

 
You're talking about a field, which means that you are working on a document. Is the document saved after the field change ?

Pascal.
 
Hi!

When we set RunASAP = 1 we do a save.

This works and LEI executes the activity.

But when LEI resets the field to 0, i do not see that within my looping agent.

I guess LEI will save its changes cause i can see it, when i open the doc from another session.

This is what our agent looks like:

Sub Initialize

Dim sess As New NotesSession
Dim db As NotesDatabase
Dim view As NotesView
Dim doc As NotesDocument

Dim aname(4) As String

Dim firststart As Integer
Dim count As Integer
Dim abbruch As Long
Dim runActivity As Integer
Dim i As Integer

Set db = sess.CurrentDatabase
Set view = db.GetView("(All my Activities)")
Set doc = view.GetFirstDocument

count = 1
abbruch = 1

i=1

aname(1) = "1. Activity"
aname(2) = "2. Activity"
aname(3) = "3. Activity"
aname(4) = "4. Activity"

firststart = False

view.AutoUpdate=True

Do While (Not (doc Is Nothing) And abbruch < 10000)

If count = 1 And doc.Name(0) = aname( count ) And doc.RunASAP(0) = 0 And firststart = False Then

' If doc.Lock(0) = 0 Then
doc.RunASAP = 1
Call doc.Save( True, False, True )
' End If
firststart = True
End If

Print abbruch, aname(count),doc.runasap(0)

If doc.Name(0) = aname(count) And doc.RunASAP(0) = 1 Then

runActivity = count
Call view.Refresh
Set doc = view.GetFirstDocument

Elseif doc.Name(0) = aname(count) And doc.RunASAP(0) = 0 Then

Print 2,abbruch, aname(count),doc.runasap(0)

If (count = 2 And runActivity = 1) Or (count = 3 And runActivity = 2) Or (count = 4 And runActivity = 3) Then
If doc.Lock(0) = 0 Then
doc.RunASAP = 1
Call doc.Save( True, False, True )
End If
Else
count = count + 1
Call view.Refresh
Set doc = view.GetNextDocument( doc )
End If

Else
Set doc = view.GetNextDocument( doc )

Print 3,abbruch, aname(count),doc.runasap(0)

End If

If count > 4 Then Exit Sub ' count = Anzahl der insgesamt zu prüfenden Activities

abbruch = abbruch +1

If abbruch = 10000 Then
Print abbruch
End If

Loop

End Sub
 
Okay, lets try a different tack. Does LEI accept running an agent after the end of its job ?
If yes, all you need to do in the first agent is launch the first task.
Then the corresponding LEI task executes, and when its finished, it launches the second agent, which sets the second LEI task in motion, and so forth.

I suppose that LEI should be able to launch an agent after a task. A few years ago I worked on comparing various products of that type, and all the others could doit except LEI. I should think that gap has been closed by now.

Pascal.
 
Hi Pascal, thanks for your suggestions.

Yes, LEI can execute an activity or agent after execution of an activity.

The problem is, i want to run four certain activities in sequence, but the first one must not be started again, before the last has finished.

The first activity is started via a LEI-polling activity, i.e. LEI checks whether a certain condition is met and if true starts the activity. Furhermore i can make this activity beeing executed synchronously by LEI, i.e. the poll will not fire again, until my activity has finished.

Now i could tell my first activity to start the second after it has finished and so on ... but ...

LEI WILL NOT NOTICE THE SECOND AND FOLLOWING ACTITVITIES CONCERNING SYNCHRONOUS EXECUTION.

That means: when the first activity has finished, my polling activity will happily fire again, when its starting condition is met, cause LEI doesnt "know" of the other still running activities.

So my first thought was to write an agent, beeing a single activity to LEI, which runs all my activities in sequence and then exits. So LEI wont fire again while my agent is running.

Now this seems to be a rather difficult way to achieve this ...
 
So the polling starts again. Fine. But if you can control the polling to look for a value on a document, then the polling will just see that it should not start yet. And the next activity in sequence will poll and see that it should start - because the agent that runs after the first activity set up the documents for that.

Is that the idea ? Or are you saying that it doesn't work ?

Pascal.
 
It seems i will end up with redesigning my activities so every sigle activity can decide for itself, if it may run or not.

Or maybe i will decrease the polling intervall so all the activities will have enough time to comlete.

I simply didnt know that synchronous executing does not include followup-activities.

Too bad.

Thanks for your ideas, but since i have to solve that problem during this week i will have to work around that.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top