IPSentry Add-In SDK
Code Sample - VB.NET
Add-In SDK Index | Top
sep

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.

Imports System.Runtime.InteropServices
'
'The following code represents the basic interface requirements for development
'of an IPSentry add-in in VB.NET (.NET 40)
'
'Notes:
' Create a new Class Library
' You MUST guids for Class, Interface and Events apply them appropriately.
' Your assembly must be configured as ComVisible
' Create a strong name key for your assembly.
' IPSentry creates an instance of the add-in using CreateObject("app.class")
' and this will need to be provided to IPSentry using the Add-In Manager to
' install a new reference.

'
<Microsoft.VisualBasic.ComClass(IPSentryAddIn.ClassId, IPSentryAddIn.InterfaceId, IPSentryAddIn.EventsId)> _
Public Class IPSentryAddIn

#Region "COM GUIDs"
' These GUIDs provide the COM identity for this class
' and its COM interfaces.
' Do not use the GUID's provided as they are invalid.


Public Const ClassId As String = "create a new GUID and insert here"
Public Const InterfaceId As String = "create a new GUID and insert here"
Public Const EventsId As String = "create a new GUID and insert here"
#End Region


'-----------------------------------------------------------------------------------
''' <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()
    MyBase.New()

    _IPSUseType = EN_AddInUseType.CIPS_ADDIN_MONITOR + EN_AddInUseType.CIPS_ADDIN_CUSTOM_MONITOR
    _IPSIsService = False
    _IPSTitle = "Un-named Add-In Control"
    _IPSDescription = "No Description"
    _IPSMonitorResult = "Result Verbose"
    _GraphProcTime = 0
    _GraphCollection = New Collection
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

Private _IPSUseType As EN_AddInUseType
''' <summary>
''' Return the valid usage types available for this add-in based on
''' EN_AddInUseType values.
''' </summary>
Public ReadOnly Property IPSUseType() As EN_AddInUseType
    Get
        Return _IPSUseType
    End Get
End Property

Private _IPSTitle As String
''' <summary>
''' The title or friendly name of this add-in
''' </summary>
Public ReadOnly Property IPSTitle() As String
    Get
        Return _IPSTitle
    End Get
End Property

Private _IPSDescription As String
''' <summary>
''' The long description of this add-in
''' </summary>
Public ReadOnly Property IPSDescription() As String
    Get
        Return _IPSDescription
    End Get
End Property

Private _IPSIsService As Boolean
''' <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)
        _IPSIsService = value
    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

Private _IPSMonitorResult As String
''' <summary>
''' Provides the caller with verbose description of the monitoring task.
''' </summary>
Public ReadOnly Property IPSMonitorResult() As String
    Get
        Return _IPSMonitorResult
    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

Private _GraphProcTime As Integer
''' <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 _GraphProcTime
    End Get
End Property

Private _GraphResult As Integer
''' <summary>
''' Returns the graph state result (absolute and reverse values of IPSMonitorResult.
''' </summary>
Public ReadOnly Property GraphResult() As Integer
    Get
        Return _GraphResult
    End Get
End Property


''' <summary>
''' Returns the graph value items collections as an XML fragment.
''' This property is not recognized by IPSentry until version 5.60.0
''' Each element contains XML gValue element of the graph enabled value:
''' gValue Name=”” Value=”” Scale=”” Desc=”” State=”” IsGlobal=”0”
''' </summary>
Public ReadOnly Property GraphItemsXML() As String
    Get
        Dim gItems = <GraphValueItems>
                        <gValue Name="importantvalue" Value="42" Scale="21" Desc="some description" State="1" IsGlobal="0"/>
                        <gValue Name="anothergraphvalue" Value="42" Scale="21" Desc="some description" State="1" IsGlobal="0"/>
                    </GraphValueItems>.ToString
        Return gItems
    End Get
End Property

Private _GraphCollection As Microsoft.VisualBasic.Collection
''' <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 Function GraphItems() As Microsoft.VisualBasic.Collection
    'Return a collection of graph items.
    _GraphCollection = New Microsoft.VisualBasic.Collection

    'Add the graph items to the collection
    '(do something here to do this)
    Return _GraphCollection
End Function

''' <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, _
                            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 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)2011 - RGE, Inc.

© 2011 by RGE, Inc.  (All Rights Reserved)
Unauthorized use or reproduction is strictly prohibited
IPSentry® is a registered trademark of RGE, Inc.

https://ipsentry.com
 Support@ipsentry.com