Monitoring event sink # 26 - Implementing onTimer Event sink


                    Le Café Central de
Deva              

                                 
                                 ..... Deva blogs!!




 

 

Monitoring event sink # 26 - Implementing onTimer Event sink

  • Comments 1

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

OnTimer method:

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)
Here, bstrURLItem - refers URL to the event registration item; lFlags - Get more information as specified in the article or refer this blog post or you can refer the EVT_INITNEW event sink flag. This flag is set at the first firing of the event. (Useful for initialization purposes. It is set only once during the lifetime of a created event sink.)

Note The bit flags are implemented in EXEVTSNK.TLB, which is installed with the Exchange Software Development Kit (SDK), and are passed through the LFLAGS parameter of the any one of the Exchange store event interface method.

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
   7:  
   8: 'Specify the custom event log file
   9:     eventLog = Environ("SystemDrive") & "\Customlog.log"
  10:  
  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)
  14:  
  15: 'Now append incoming event info into log file
  16:     evtFile.WriteLine (" Event Sink logged : OnTimer()")
  17:     evtFile.WriteLine (" lFlags: " & "0x" & Hex(lFlags))
  18:  
  19:     evtFile.WriteBlankLines (1)
  20:  
  21: 'Clean the variables & object before we Quit
  22:     evtFile.Close
  23:     Set FileSys = Nothing
  24:  
  25: End Sub

Registering Event sink:

Syntax:

   1: cscript RegEvent.vbs add ontimer "Event Sink" "path" "Start time" interval -e "End time"

Usage:

   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"
Blog - Post Feedback Form(CAPTCHA)
Leave a Comment
  • Post