Event Log |
Scroll |
Creating an event log is easy. The provided example shows you how to.
Thereforeā¢ Capture Thereforeā¢ Navigator Thereforeā¢ Viewer Extension for Windows Explorer (Save documents to Thereforeā¢ from Windows Explorer). Add-in for Microsoft Office (Save documents to Thereforeā¢ from Microsoft Office applications). |
Requirements and Assumptions: AddIn project configured and registered as described in "AddIn Creation in C#" or "Add In Creation in VB .NET". Visual Basic Imports System.Runtime.InteropServices Imports System.IO Imports Therefore.API
<Guid("471A456A-AB1D-4af0-AF1F-53F0F0FB672C"), ComVisible(True), ClassInterface(ClassInterfaceType.None)> _ Public Class EventLogAddIn Implements ITheAddIn
Private eventLog As String = ""
Public Sub GetHandledEvents(ByVal client As TheClientType, ByVal eventSet As TheEventSet) _ Implements ITheAddIn.GetHandledEvents
' Register for all events eventSet.AddAll()
End Sub
Public Function HandleEvent(ByVal e As TheEvent) As Integer _ Implements ITheAddIn.HandleEvent
' Append the current event to a string eventLog += DateTime.Now.ToString() + " ... " + e.ToString() + vbNewLine
' Write the event log to a file when the application exits If e.EventType = TheEventType.ExitApplication Then Dim writer As New StreamWriter("c:/eventLog.txt") writer.WriteLine(eventLog) writer.Flush() End If
Return 0 End Function
End Class
C# using System; using System.Collections.Generic; using System.IO; using System.Runtime.InteropServices; using System.Text; using Therefore.API;
namespace AddInSamples { [Guid("F72A6BF3-6A97-4236-96F3-A57C23110F31"), ComVisible(true), ClassInterface(ClassInterfaceType.None)] class EventLogAddIn : ITheAddIn { private string eventLog;
public void GetHandledEvents(TheClientType client, TheEventSet eventSet) { // Register for all events eventSet.AddAll(); }
public int HandleEvent(TheEvent e) { // Append the current event to a string eventLog += DateTime.Now.ToString() + " ... " + e.ToString() + "\r\n";
// Write the event log to a file when the application exits if (e.EventType == TheEventType.ExitApplication) { StreamWriter writer = new StreamWriter("eventLog.txt"); writer.WriteLine(eventLog); writer.Flush(); }
return 0; } } } |