VERSION 1.0 CLASS
BEGIN
  MultiUse = -1  'True
  Persistable = 0  'NotPersistable
  DataBindingBehavior = 0  'vbNone
  DataSourceBehavior  = 0  'vbNone
  MTSTransactionMode  = 0  'NotAnMTSObject
END
Attribute VB_Name = "EvtRecord"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
Option Explicit

Private m_szRemoteHostIP As String
Private m_dtRecordDateTime As Date
Private m_iRecordIDType As RecordIDType
Private m_szUserID As String
Private m_bIsUserNameSupported As Boolean
Private m_szUserName As String
Private m_bIsXIDSupported As Boolean
Private m_szXID As String
Private m_dtReceiveDateTime As Date

Public Enum RecordIDType
    MifareUID = 1
    DesfireUID = 2
    EM125kUID = 3
    MifareSectorData = 4
    DesfireFileData = 5
    PINCode = 6
    Fingerprint = 7
    UltralightUID = 8
    UnknowUID = 9
    FailureVerification = &HE0
End Enum

Public Sub SetRecord(ByVal szRemoteHostIP As String, ByVal iRecordIDType As RecordIDType, ByVal dtRecordDateTime, ByVal szUserID As String, ByVal bIsUserNameSupported As Boolean, ByVal szUserName As String, ByVal bIsXIDSupported As Boolean, ByVal szXID As String)
    m_szRemoteHostIP = szRemoteHostIP
    m_iRecordIDType = iRecordIDType
    m_dtReceiveDateTime = Now
    m_dtRecordDateTime = dtRecordDateTime
    m_szUserID = szUserID
    m_bIsUserNameSupported = bIsUserNameSupported
    m_szUserName = szUserName
    m_bIsXIDSupported = bIsXIDSupported
    m_szXID = szXID
End Sub

Public Property Get RemoteHostIP() As String
    RemoteHostIP = m_szRemoteHostIP
End Property

Public Property Get IsFailureVerification() As Boolean
    IsFailureVerification = CBool(m_iRecordIDType = FailureVerification)
End Property

Public Property Get RecordDateTime() As Date
    RecordDateTime = m_dtRecordDateTime
End Property

Public Property Get UserID() As String
    UserID = m_szUserID
End Property

Public Property Get IsUserNameSupported() As Boolean
    IsUserNameSupported = m_bIsUserNameSupported
End Property

Public Property Get UserName() As String
    UserName = m_szUserName
End Property

Public Property Get IsXIDSupported() As Boolean
    IsXIDSupported = m_bIsXIDSupported
End Property

Public Property Get XID() As String
    XID = m_szXID
End Property

Public Property Get ReceiveDateTime() As Date
    ReceiveDateTime = m_dtReceiveDateTime
End Property

Public Property Get RecordIDType() As RecordIDType
    RecordIDType = m_iRecordIDType
End Property

Public Property Get RecordIDTypeName() As String
    Dim szResult As String
    Select Case m_iRecordIDType
    Case MifareUID
        szResult = "Mifare UID"
    Case DesfireUID
        szResult = "Desfire UID"
    Case EM125kUID
        szResult = "EM 125k UID"
    Case MifareSectorData
        szResult = "Mifare Sector Data"
    Case DesfireFileData
        szResult = "Desfire File Data"
    Case PINCode
        szResult = "PIN Code"
    Case Fingerprint
        szResult = "Fingerprint"
    Case UltralightUID
        szResult = "Ultralight UID"
    Case UnknowUID
        szResult = "Unknow UID"
    Case FailureVerification
        szResult = "Failure Verification"
    Case Else
        szResult = "Unknown Type"
    End Select
    RecordIDTypeName = szResult
End Property

Public Property Get RecordIDTypeShortName() As String
    Dim szResult As String
    Select Case m_iRecordIDType
    Case MifareUID
        szResult = "MF"  ' "Mifare UID"
    Case DesfireUID
        szResult = "DF"  ' "Desfire UID"
    Case EM125kUID
        szResult = "EM"  ' "EM 125k UID"
    Case MifareSectorData
        szResult = "MSD" ' "Mifare Sector Data"
    Case DesfireFileData
        szResult = "DFD" ' "Desfire File Data"
    Case PINCode
        szResult = "PIN" ' "PIN Code"
    Case Fingerprint
        szResult = "FP"  ' "Fingerprint"
    Case UltralightUID
        szResult = "UL"  ' "Ultralight UID"
    Case UnknowUID
        szResult = "UNU" ' "Unknow UID"
    Case FailureVerification
        szResult = "FV"  ' "Failure Verification"
    Case Else
        szResult = "UNT" ' "Unknown Type"
    End Select
    RecordIDTypeShortName = szResult
End Property

Public Function ToString() As String
    Dim szResult As String
    szResult = m_szRemoteHostIP & vbTab & Format$(m_dtRecordDateTime, "yyyy/mm/dd hh:nn:ss")
    If m_iRecordIDType = FailureVerification Then
        szResult = szResult & vbTab & "<Failure Verification>"
    Else
        szResult = szResult & vbTab & m_szUserID
        If m_bIsUserNameSupported Then
            szResult = szResult & vbTab & m_szUserName
            If m_bIsXIDSupported Then
                szResult = szResult & vbTab & m_szXID
            End If
        End If
    End If
    ToString = szResult
End Function

Public Static Function GetRecordCount(ByRef oEvtRecords() As EvtRecord) As Long
    Dim lCount As Long
    On Error GoTo Err_Proc
    lCount = UBound(oEvtRecords) - LBound(oEvtRecords) + 1
Err_Exit:
    GetRecordCount = lCount
    Exit Function

Err_Proc:
    lCount = 0
    Resume Err_Exit
End Function
