Public axCZKEM1,axCZKEM2 As New zkemkeeper.CZKEM
AddHandler axCZKEM1.OnAttTransactionEx, AddressOf Ax_OnAttTransactionEx
AddHandler axCZKEM2.OnAttTransactionEx, AddressOf Ax_OnAttTransactionEx
Private Sub Ax_OnAttTransactionEx(ByVal sEnrollNumber As String, ByVal iIsInValid As Integer, ByVal iAttState As Integer, ByVal iVerifyMethod As Integer, _
ByVal iYear As Integer, ByVal iMonth As Integer, ByVal iDay As Integer)
lbRTShow.Items.Add("RTEvent OnAttTrasactionEx Has been Triggered,Verified OK")
lbRTShow.Items.Add("...UserID:" & sEnrollNumber)
lbRTShow.Items.Add("...isInvalid:" & iIsInValid.ToString())
lbRTShow.Items.Add("...attState:" & iAttState.ToString())
lbRTShow.Items.Add("...VerifyMethod:" & iVerifyMethod.ToString())
End Sub
this code for real-time Triggering fingerprint device'
First question
How will I know which device triggered this event : this device 'axCZKEM1' or 'axCZKEM2'
when I try put 'sender As Object' with parameter give me error :
"does not have signature compatible with delegate"
ADDITIONAL CONCERN
I've researched the internet based from the pointers you gave me.
FIRST: I am already successful with identifying the Sender Device using a Wrapper Class and my code is as shown below:
Imports zkemkeeper
Imports System
Imports System.Collections.Generic
Public Class myzkem
Public Property Name
Private WithEvents CZKEM As zkemkeeper.CZKEM
Public Event AttEventWrapper(SenderName As String, sEnrollNumber As String, iIsInValid As Integer, iAttState As Integer, iVerifyMethod As Integer, iYear As Integer, iMonth As Integer, iDay As Integer, iHour As Integer, iMinute As Integer, iSecond As Integer, iWorkcode As Integer)
Public Shared ListOfDevices As New Dictionary(Of String, zkemkeeper.CZKEM)
Public Sub New(WrapperName As String, CZKEMObject As zkemkeeper.CZKEM)
Me.Name = WrapperName
Me.CZKEM = CZKEMObject
End Sub
Private Sub HandleEvent(ByVal sEnrollNumber As String, ByVal iIsInValid As Integer, ByVal iAttState As Integer, ByVal iVerifyMethod As Integer, ByVal iYear As Integer, ByVal iMonth As Integer, ByVal iDay As Integer, ByVal iHour As Integer, ByVal iMinute As Integer, ByVal iSecond As Integer, ByVal iWorkCode As Integer) Handles CZKEM.OnAttTransactionEx
RaiseEvent AttEventWrapper(Me.Name, sEnrollNumber, iIsInValid, iAttState, iVerifyMethod, iYear, iMonth, iDay, iHour, iMinute, iSecond, iWorkCode)
End Sub
End Class
Note: This is the class where I inserted my shared dictionary [ListOfDevices].
SECOND: I created another class with functions containing my CZKEM Object, add and remove handler codes and connection codes.
Imports zkemkeeper
Public Class ZKEMKEEPERClass
Public CZKEM2 As New zkemkeeper.CZKEM
Public NewKEM As myzkem
Public Function ZKEMAddHandler(iDevice As String, iIP As String, iPort As Integer) As Boolean
If CZKEM2.Connect_Net(iIP, 4370) Then
If CZKEM2.RegEvent(1, 65535) = True Then
NewKEM = New myzkem(iDevice, CZKEM2)
AddHandler NewKEM.AttEventWrapper, AddressOf LoginEvent_1
MsgBox(iDevice)
Return True
Else
Return False
End If
Else
Return False
End If
End Function
Public Function ZKEMRemoveHandler(iDevice As String, CZKEM As zkemkeeper.CZKEM)
NewKEM = New myzkem(iDevice, CZKEM)
RemoveHandler NewKEM.AttEventWrapper, AddressOf LoginEvent_1
MsgBox(iDevice)
End Function
Public Sub LoginEvent_1(ByVal SenderName As String, ByVal sEnrollNumber As String, ByVal iIsInValid As Integer, ByVal iAttState As Integer, ByVal iVerifyMethod As Integer, ByVal iYear As Integer, ByVal iMonth As Integer, ByVal iDay As Integer, ByVal iHour As Integer, ByVal iMinute As Integer, ByVal iSecond As Integer, ByVal iWorkCode As Integer)
MsgBox(SenderName)
End Sub
End Class
THIRD: In my main program, I replicate [ZKEMKEEPERClass] to create multiple objects that are all active at the same time.
Sub CONNECT()
Dim iIP As String
Dim iDevice As String
For x = 1 To 2
Select Case x
Case 1
iIP = "122.3.47.43"
iDevice = "Device 1"
Case 2
iIP = "192.168.10.201"
iDevice = "Device 2"
End Select
Dim NewConnect As New ZKEMKEEPERClass
If NewConnect.ZKEMAddHandler(iDevice, iIP, 4370) Then
MsgBox("success")
Else
MsgBox("failed")
End If
Next
End Sub
MY NEW PROBLEM: I can't remove the handler since I cannot identify it from the replicated classes.
Let me know your ideas.
@AConfusedSimpleton