IPSentry Add-In SDK
Code Sample - VB.NET
Add-In SDK Index | Top
![]()
The following code sample represents a basic interface structure for the primary class allow IPSentry to interface with your add-in component as a COM visible class. This is intended for general reference purposes and is not intended for general usage.
| VB.NET |
|
Imports System.Runtime.InteropServices ' 'The following code represents the basic interface requirements for development 'of an IPSentry add-in in VB.NET ' 'Notes: ' Create a new Class Library ' You MUST define a guid for your class and apply it to the GuidAttribute. ' Your assembly must be configured as ComVisible ' Create a strong name key for your assembly. ' IPSentry creates an instance to the adding using CreateObject("app.class") ' and this will need to be provided to IPSentry using the Add-In Manager to ' install a new reference. ' 'Un-remark this section and replace with a new guid. '<GuidAttribute("xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx")> _ <ClassInterface(ClassInterfaceType.AutoDual)> _ Public Class MyAddinCTL '-----------------------------------------------------------------------------------''' <summary> ''' Enumeration to represent the abilities of the addin. ''' </summary> Enum EN_AddInUseType CIPS_ADDIN_NONE = 0 'No add-in usage type defined. CIPS_ADDIN_MONITOR = 1 'The add-in can be used as a monitoring entry. CIPS_ADDIN_ALERT = 2 'The add-in can be used as an alerting function. CIPS_ADDIN_CUSTOM_MONITOR = 8 'Monitoring configuration interface exists. CIPS_ADDIN_CUSTOM_ALERT = 16 'Alerting configuration interface exists. End Enum '-----------------------------------------------------------------------------------''' <summary> ''' Class instantiation required with no arguments for COM visible .NET ''' </summary> Public Sub New() End Sub '-----------------------------------------------------------------------------------''' <summary> ''' Caller is requesting information about the add-in. This procedure should ''' instantiate an 'about' dialogue for the user. ''' </summary> Public Sub About() MsgBox("This is my control.", _ MsgBoxStyle.OkOnly + MsgBoxStyle.Information, _ "My Add-In") End Sub '----------------------------------------------------------------------------------- ''' <summary> ''' Return the valid usage types available for this add-in based on ''' EN_AddInUseType values. ''' </summary> Public ReadOnly Property IPSUseType() As Integer Get Return EN_AddInUseType.CIPS_ADDIN_MONITOR + _ EN_AddInUseType.CIPS_ADDIN_CUSTOM_MONITOR End Get End Property '-----------------------------------------------------------------------------------''' <summary> ''' The title or friendly name of this add-in ''' </summary> Public ReadOnly Property IPSTitle() As String Get Return "My Add-in Control in .NET" End Get End Property '----------------------------------------------------------------------------------- ''' <summary> ''' The long description of this add-in ''' </summary> Public ReadOnly Property IPSDescription() As String Get Return "This add-in doesn't do anything, it is just an example." End Get End Property '-----------------------------------------------------------------------------------''' <summary> ''' Called to notify the add-in of the running context of the application. ''' </summary> Public WriteOnly Property IPSIsService() As Boolean Set(ByVal value As Boolean) 'Store the value passed for reference in your add-in code. End Set End Property '-----------------------------------------------------------------------------------''' <summary> ''' Called to perform the add-in monitoring task. ''' </summary> Public Function IPSMonitor(ByVal MUID As String, ByVal Args As String) As Integer Dim myResult As Integer = -1 'Perform whatever monitoring tasks are required after parsing the Args value. 'Return your result as 0=(OK) or -1=(Critical). Return myResult End Function '-----------------------------------------------------------------------------------''' <summary> ''' Called to configure add-in specifications. ''' </summary> Public Sub IPSMonitorConfig(ByVal MUID As String, ByRef Args As String) Dim newArgs As String = Args 'Perform necessary logic to obtain configuration data for this add-in. 'If user accepts the changes, return the configuration data. Args = newArgs End Sub '----------------------------------------------------------------------------------- ''' <summary> ''' Provides the caller with verbose description of the monitoring task. ''' </summary> Public ReadOnly Property IPSMonitorResult() As String Get Return "Information about the monitoring process results." End Get End Property '----------------------------------------------------------------------------------- ''' <summary> ''' Caller has requested that the add-in stop monitoring. ''' </summary> Public Sub IPSMonitorStop() 'Set a value noting that the monitoring task has been requested to stop. 'this value should be checked while performing monitoring. End Sub '----------------------------------------------------------------------------------- ''' <summary> ''' Returns the date/time associated with the graph enabled data values ''' </summary> Public ReadOnly Property GraphDate() As DateTime Get Return DateTime.Now End Get End Property '----------------------------------------------------------------------------------- ''' <summary> ''' Returns the total time (in ms) for the add-in to perform the monitoring process ''' </summary> Public ReadOnly Property GraphProcTime() As Integer Get 'Return the total time (in ms) for the add-in to 'perform the monitoring process. End Get End Property '----------------------------------------------------------------------------------- ''' <summary> ''' Returns the graph state result (absolute and reverse values of IPSMonitorResult. ''' </summary> Public ReadOnly Property GraphResult() As Integer Get 'If failed, return zero (0). 'If success, return one (1). Return 0 End Get End Property '----------------------------------------------------------------------------------- ''' <summary> ''' Return multiple graph value items in a collection of strings. ''' Each item contains XML gValue element of the graph enabled value: ''' <gValue Name=”” Value=”” Scale=”” Desc=”” State=”” IsGlobal=”0” /> ''' </summary> Public ReadOnly Property GraphItems() As Collection Get 'Return a collection of graph items. Dim myCollection As New Collection 'Add the graph items to the collection '(do something here to do this) Return myCollection End Get End Property '----------------------------------------------------------------------------------- ''' <summary> ''' Called to perform the add-in alerting task. ''' </summary> Public Function IPSAlert(ByVal MUID As String, _ ByVal AUID As String, _ ByVal Args As String) As Integer Dim myResult As Integer = -1 'Perform whatever alerting tasks are required after parsing the Args value. 'Return your result as 0=(OK) or -1=(Critical). Return myResult End Function '----------------------------------------------------------------------------------- ''' <summary> ''' Called to configure add-in alert specifications. ''' </summary> Public Sub IPSAlertConfig(ByVal MUID As String, _ ByVal AUID As String, _ ByVal Args As String) Dim newArgs As String = Args 'Perform necessary logic to obtain configuration data for this add-in. 'If user accepts the changes, return the configuration data. Args = newArgs End Sub '----------------------------------------------------------------------------------- ''' <summary> ''' Provides the caller with verbose description of the alerting task results. ''' </summary> Public ReadOnly Property IPSAlertResult() As String Get Return "Information about the alerting process results." End Get End Property '----------------------------------------------------------------------------------- ''' <summary> ''' Caller has requested that the add-in stop alerting process. ''' </summary> Public Sub IPSAlertStop() 'Set a value noting that the alerting task has been requested to stop. 'this value should be checked while performing alerting. End Sub End Class '(c)2008 - RGE, Inc. |
![]()
|
© 2008 by
RGE, Inc. (All Rights Reserved) |
http://www.ipsentry.com Support@ipsentry.com |