DECS (Domino enterprise connectivity services) is a real-time activity to push/pull data from external sources ie.,data on lotus and external source are always in sync at any given point of time. To achieve this, the DECS activities should be running non-stop. But there might be need to start the activity, pull/push data and stop the activity on a scheduled basis. Though there is a schedule feature in DECS, any updates to the documents prior to the start of the activity would not be pushed to the external source. The below code copied into a scheduled agent would overcome this problem. It starts the DECS activity, recalculates each documents (so push/pulls data to/from external source), and then stops the activity.
Code
Dim session As New notessession
Dim db As notesdatabase
Dim decsdb As notesdatabase
Dim acitivityview As notesview
Dim activitydoc As notesdocument
Dim doccoll As notesdocumentcollection
Dim doc As notesdocument
Dim query As String
Set db=session.currentdatabase
Set decsdb =
session.getdatabase(db.server,"decsadm.nsf")
Set activityview = decsdb.getview("(Nav Activities)")
Set activitydoc = activityview.getfirstdocument
'Start the activity
If activitydoc.Type(0) = "Activity" Then
If activitydoc.Lock(0)=0 Then
activitydoc.RunASAP = 1
Call activitydoc.save(True,True)
End If
End If
query = {(select form="testForm"}
'Refresh all documents,
so that data is pulled/pushed to oracle
Set doccoll = db.search(query,Nothing,0)
If doccoll.count > 0 Then
Set doc = doccoll.getfirstdocument
While Not doc Is Nothing
Call doc.computewithform(False,False)
Call doc.save(True,True)
Set doc = doccoll.getnextdocument(doc)
Wend
End If
'Stop the activity
If activitydoc.Type(0)="Activity" Then
If activitydoc.Lock(0) <> 0 Then
activitydoc.SystemAction = 21
End If
If activitydoc.RunASAP(0) <> 0 Then
activitydoc.RunASAP = 0
End If
Call activitydoc.save(True,True)
End If