Le Café Central de Deva
let.us.share.develop.more... Deva blogs!!
Timers & Events:
Whenever we talk about the event sink and we plan to implement the event sink that should trigger within a specified time or interval, then we will go for onTimer Event sink.
Basically Timers have scope, in the same way as other events. With timers, however, no event occurs in that location to cause the specified event to occur (such as a save event or a delete event).
Note Scope does define a specific location for the registration event item, which can affect the security context of the event sink, and guarantees that the event will be deleted if the folder containing the timer event registration is deleted
The OnTimer method will be called after a specific interval of time. It can be called by using the IExStoreSystemEvents Interface, which is the part of EXOLEDB type library.
This method is called for the time or time interval specified in the registration item.
Note The store may not invoke this sink if the server is not running when the specified time elapses. For example, if a sink registers for notification at 11:00 A.M. and the service goes down at 10:55 A.M. and comes back up at 11:05 A.M., the sink may not be called.
Creating sample Event sink (Visual Basic):
In order to create the Event sink with the OnTimer method, we need to make use of IEXStoreSystemEvents Interface like,
1: Sub OnTimer(bstrURLItem As String,lFlags As LONG)
Code Snippet(Visual Basic):
1: 'Using OnTimer Method
2: Private Sub IExStoreSystemEvents_OnTimer(ByVal bstrURLItem As String, ByVal lFlags As Long)
3: ' Declare the variable
4: Dim FileSys As Object
5: Dim eventLog As String
6: Dim evtFile
8: 'Specify the custom event log file
9: eventLog = Environ("SystemDrive") & "\Customlog.log"
11: 'Creates new log file %SystemDrive%\Customlog.log or opens it if exists
12: Set FileSys = CreateObject("Scripting.FileSystemObject")
13: Set evtFile = FileSys.OpenTextFile(eventLog, 8, True)
15: 'Now append incoming event info into log file
16: evtFile.WriteLine (" Event Sink logged : OnTimer()")
17: evtFile.WriteLine (" lFlags: " & "0x" & Hex(lFlags))
19: evtFile.WriteBlankLines (1)
21: 'Clean the variables & object before we Quit
23: Set FileSys = Nothing
25: End Sub
Registering Event sink:
1: cscript RegEvent.vbs add ontimer "Event Sink" "path" "Start time" interval -e "End time"
1: 'Registering Event sink to execute for every one hour in between specific time duration for the specific public folder
2: cscript RegEvent.vbs add ontimer sink1.sink1.1 file://./backofficestorage/mydomain/public%20folders/events/EventRegTimerItem1 "8/4/98 01:50:00 AM" 1 -e "8/4/98 02:50:00 AM"
PingBack from http://mstechnews.info/2008/11/monitoring-event-sink-26-implementing-ontimer-event-sink/