Platform SDK: Exchange 2000 Server |
[This is preliminary documentation and subject to change.]
Rules for registering an event sink (registration fails otherwise):
The following code registers your workflow application folder for the OnTimer system event, the OnSyncSave store event, and the OnSyncDelete store event. In this example the OnTimer event will cause the Workflow Event Sink to run every 15 minutes. This interval should not be any smaller than necessary, because the OnTimer event fires for every workflow folder on your server. The store event registrations will cause the Workflow Event Sink to run any time a document is saved to or deleted from the workflow folder. You should register these events in the following order for workflow:
See Event Sink Registration for more information on using event registrations.
Note
The store event registrations set the criteria field with a SQL WHERE clause to prevent other registrations, ProcessDefinitions, and CommonScripts from firing events in the folder.
Dim EventRuleItem As String Dim sEvtRegURL As String Dim ProcessDefinitionURL As String '''''''''''''''''''''Register OnTimer Event EventRuleItem = "OnTimerRule" sEvtRegURL = sFolderURL & EventRuleItem 'The event registration item (sEvtRegURL) must be saved 'in the folder for which you want to register 'the workflow sink. Dim Rec As ADODB.Record Set Rec = New ADODB.Record Rec.Open sEvtRegURL, , adModeReadWrite, _ adCreateNonCollection Or adCreateOverwrite, _ adDelayFetchFields If Err.Number <> 0 Then Debug.Print "Failed to open event registration record." & Err.Description End If Dim Flds As ADODB.Fields With Rec Set Flds = .Fields Flds("DAV:contentclass") = "urn:content-class:storeeventreg" Flds("http://schemas.microsoft.com/exchange/events/EventMethod") = "OnTimer" Flds("http://schemas.microsoft.com/exchange/events/SinkClass") = "CdoWfEvt.EventSink.1" Flds("http://schemas.microsoft.com/exchange/events/TimerStartTime") = #5/1/1999# Flds("http://schemas.microsoft.com/exchange/events/TimerInterval") = 15 Flds("http://schemas.microsoft.com/exchange/events/TimerExpiryTime") = #8/4/2000# Flds.Update .Close End With '''''''''''''''''''''Register OnSyncSave and OnSyncDelete Events EventRuleItem = "OnSyncSave_OnSyncDelete_Rule" sEvtRegURL = sFolderURL & EventRuleItem ProcessDefinitionURL = sProcDefURL Rec.Open sEvtRegURL, , adModeReadWrite, _ adCreateNonCollection Or adCreateOverwrite, _ adDelayFetchFields If Err.Number <> 0 Then Debug.Print "Failed to open event registration record." & Err.Description End If With Rec Set Flds = .Fields Flds("DAV:contentclass") = "urn:content-class:storeeventreg" Flds("http://schemas.microsoft.com/exchange/events/EventMethod") = "OnSyncSave;OnSyncDelete" Flds("http://schemas.microsoft.com/exchange/events/SinkClass") = "CdoWfEvt.EventSink.1" Flds("http://schemas.microsoft.com/exchange/events/Criteria") = "WHERE $DAV:ishidden$ = FALSE" Flds("http://schemas.microsoft.com/cdo/workflow/defaultprocdefinition") = ProcessDefinitionURL Flds("http://schemas.microsoft.com/cdo/workflow/adhocflows") = 0 Flds("http://schemas.microsoft.com/cdo/workflow/enabledebug") = True Flds("http://schemas.microsoft.com/cdo/workflow/disablesuccessentries") = False Flds.Update .Close End With