WriteCard

Definition

Usage

Write the information and fingerprint template of a specified user into the MF card. After this function is called, the MF card must be verified by the device.

Parameter

Device number

User ID

Index of fingerprint (0-3)

Fingerprint templates corresponding to fingerprints. TmpData1 cannot be null.

Return Value

Return True if it is successful, or return False.

Related Function

EmptyCard

 

Ejemplo

C#

private static void WriteCard(string sIp = "10.0.0.44", int iPort = 4370, string sdwEnrollNumber = "1")
{
    //Create Standalone SDK class dynamicly.
    zkemkeeper.CZKEMClass axCZKEM1 = new zkemkeeper.CZKEMClass();
    axCZKEM1.Connect_Net(sIp, iPort);
    int iMachineNumber = 1;

    int idwErrorCode = 0;

    string sName = "";
    string sPassword = "";
    int iPrivilege = 0;
    bool bEnabled = false;
    int idwFingerIndex;
    int iTmpLength = 0;

    int iTmpToWrite = 1;//the possible values 1,2,3,4
    int iTmpCount = 0;//the count of the fingerprint templates to be written in
    byte[] byTmpData0 = new byte[700];//9.0 fingerprint arithmetic templates
    byte[] byTmpData1 = new byte[700];
    byte[] byTmpData2 = new byte[700];
    byte[] byTmpData3 = new byte[700];

    axCZKEM1.ReadAllTemplate(iMachineNumber);//it's nesessary to read the templates to the memory
    if (axCZKEM1.SSR_GetUserInfo(iMachineNumber, sdwEnrollNumber, out sName, out sPassword, out iPrivilege, out bEnabled))//modify by Darcy on Nov.23 2009
    {
        //Here we write at most 4 fingerprint templates(the user's first four ones) in the Mifare card.
        //If you want to write other indexs of the templates,you can write your own code to achive.
        for (idwFingerIndex = 0; idwFingerIndex < iTmpToWrite; idwFingerIndex++)
        {
            byte[] byTmpData = new byte[700];
            if (axCZKEM1.SSR_GetUserTmp(iMachineNumber, sdwEnrollNumber, idwFingerIndex, out byTmpData[0], out iTmpLength))//modify by Darcy on Nov.23 2009
            {
                iTmpCount++;
                switch (iTmpCount)
                {
                    case 1:
                        Array.Copy(byTmpData, byTmpData0, iTmpLength);
                        break;
                    case 2:
                        Array.Copy(byTmpData, byTmpData1, iTmpLength);
                        break;
                    case 3:
                        Array.Copy(byTmpData, byTmpData2, iTmpLength);
                        break;
                    case 4:
                        Array.Copy(byTmpData, byTmpData3, iTmpLength);
                        break;
                }
            }
            byTmpData = null;
        }
    }
    int iEnrollNumber = Convert.ToInt32(sdwEnrollNumber); 
    if (axCZKEM1.WriteCard(iMachineNumber, iEnrollNumber, 0, ref byTmpData0[0], 1, ref byTmpData1[0], 2, ref byTmpData2[0], 3, ref byTmpData3[0]))//write templates into card
    {
        MessageBox.Show("WriteCard(Mifare)! ", "Success");
    }
    else
    {
        axCZKEM1.GetLastError(ref idwErrorCode);
        MessageBox.Show("Operation failed,ErrorCode=" + idwErrorCode.ToString(), "Error");
    }
}

VB

Private Shared Sub WriteCard(Optional ByVal sIp As String = "10.0.0.44", Optional ByVal iPort As Integer = 4370, Optional ByVal sdwEnrollNumber As Integer = "1")
    'Create Standalone SDK class dynamicly.
    Dim axCZKEM1 As New zkemkeeper.CZKEM
    axCZKEM1.Connect_Net(sIp, iPort)
    Dim iMachineNumber As Integer
    Dim idwErrorCode As Integer

    Dim sName As String = ""
    Dim sPassword As String = ""
    Dim iPrivilege As Integer
    Dim bEnabled As Boolean = False
    Dim idwFingerIndex As Integer
    Dim iTmpLength As Integer

    Dim iTmpToWrite As Integer = 1 'the possible values 1,2,3,4
    Dim iTmpCount = 0 'the count of the fingerprint templates to be written in
    Dim byTmpData0(700) As Byte '9.0 fingerprint arithmetic templates
    Dim byTmpData1(700) As Byte
    Dim byTmpData2(700) As Byte
    Dim byTmpData3(700) As Byte

    axCZKEM1.ReadAllTemplate(iMachineNumber) 'it's nesessary to read the templates to the memory
    If axCZKEM1.SSR_GetUserInfo(iMachineNumber, sdwEnrollNumber, sName, sPassword, iPrivilege, bEnabled) = True Then
        'Here we write at most 4 fingerprint templates(the user's first four ones) in the Mifare card.
        'If you want to write other indexs of the templates,you can write your own code to achive.
        For idwFingerIndex = 0 To iTmpToWrite - 1
            Dim byTmpData(700) As Byte
            If axCZKEM1.SSR_GetUserTmp(iMachineNumber, sdwEnrollNumber, idwFingerIndex, byTmpData(0), iTmpLength) Then
                iTmpCount += 1
                Select Case iTmpCount
                    Case 1
                        Array.Copy(byTmpData, byTmpData0, iTmpLength)
                        Exit Select
                    Case 2
                        Array.Copy(byTmpData, byTmpData1, iTmpLength)
                        Exit Select
                    Case 3
                        Array.Copy(byTmpData, byTmpData2, iTmpLength)
                        Exit Select
                    Case 4
                        Array.Copy(byTmpData, byTmpData3, iTmpLength)
                        Exit Select
                End Select
            End If
            byTmpData = Nothing
        Next
    End If

    If axCZKEM1.WriteCard(iMachineNumber, sdwEnrollNumber, 0, byTmpData0(0), 1, byTmpData1(0), 2, byTmpData2(0), 3, byTmpData3(0)) = True Then 'write templates into card
        MsgBox("WriteCard(Mifare)!", MsgBoxStyle.Information, "Success")
    Else
        axCZKEM1.GetLastError(idwErrorCode)
        MsgBox("Operation failed,ErrorCode=" & idwErrorCode.ToString(), MsgBoxStyle.Exclamation, "Error")
    End If
End Sub