ZKemKeeper:事件未触发

时间:2016-08-12 15:07:51

标签: c#

我正在构建一个C#windows应用程序来获取拇指印象并将其显示在表单上。我成功地将应用程序连接到扫描仪(ZKTeco TX628)。但是,事件不会触发。

这是我的代码: -

    ZKFPEngX fp = new ZKFPEngX();
    zkemkeeper.CZKEMClass axCZKEM1 = new zkemkeeper.CZKEMClass();
    bool bIsConnected = false;

    public Form2()
    {
        InitializeComponent();
    }

    private void button1_Click(object sender, EventArgs e)
    {   
        bIsConnected = axCZKEM1.Connect_Net("192.168.1.201", Convert.ToInt32(4370));

        if (bIsConnected == true)
        {
            if (axCZKEM1.RegEvent(1, 65536))
            {
                this.axCZKEM1.OnFinger += new zkemkeeper._IZKEMEvents_OnFingerEventHandler(axCZKEM1_OnFinger);
                this.axCZKEM1.OnConnected += new _IZKEMEvents_OnConnectedEventHandler(axCZKEM1_OnConnected);
                this.axCZKEM1.OnVerify += new zkemkeeper._IZKEMEvents_OnVerifyEventHandler(axCZKEM1_OnVerify);
            }
        }
        else
        {
            int idwErrorCode=-1;
            this.axCZKEM1.GetLastError(ref idwErrorCode);
            MessageBox.Show("Unable to connect the device,ErrorCode=" + idwErrorCode.ToString(), "Error");
        }
    }

    private void axCZKEM1_OnFinger()
    {
        label1.Text = "OK";
        byte[] TmpData = new byte[700];
        int with = 0;
        int lenth = 0;
        bool fulimage = false;
        string path = "";
        byte a=1;
        axCZKEM1.CaptureImage(fulimage, ref with, ref lenth, ref a, path);
        MessageBox.Show ("RTEvent OnFinger Has been Triggered");
    }

    private void axCZKEM1_OnVerify(int uid)
    {
        label1.Text = "Verified";
    }

    private void axCZKEM1_OnConnected()
    {
        label1.Text = "Connected";
    }

    private void button2_Click(object sender, EventArgs e)
    {
        this.axCZKEM1.EnableDevice(1, true);

        this.axCZKEM1.Disconnect();
        label1.Text = "Disconnected";
    }

1 个答案:

答案 0 :(得分:0)

             bIsConnected = axCZKEM1.Connect_Net("192.168.1.201", Convert.ToInt32(4370));

            if (bIsConnected == true)
            {
                Trace.subWriteInLogFile(string.Concat(DateTime.Now.ToString(formatDateLog), "| " + "Connected"));

                iMachineNumber = 1;//In fact,when you are using the tcp/ip communication,this parameter will be ignored,that is any integer will all right.Here we use 1.
                if (axCZKEM1.RegEvent(iMachineNumber, 65535))//Here you can register the realtime events that you want to be triggered(the parameters 65535 means registering all)
                {
                    this.axCZKEM1.OnFinger += new zkemkeeper._IZKEMEvents_OnFingerEventHandler(axCZKEM1_OnFinger);
                    this.axCZKEM1.OnVerify += new zkemkeeper._IZKEMEvents_OnVerifyEventHandler(axCZKEM1_OnVerify);
                    this.axCZKEM1.OnAttTransactionEx += new zkemkeeper._IZKEMEvents_OnAttTransactionExEventHandler(axCZKEM1_OnAttTransactionEx);
                    this.axCZKEM1.OnFingerFeature += new zkemkeeper._IZKEMEvents_OnFingerFeatureEventHandler(axCZKEM1_OnFingerFeature);
                    this.axCZKEM1.OnEnrollFingerEx += new zkemkeeper._IZKEMEvents_OnEnrollFingerExEventHandler(axCZKEM1_OnEnrollFingerEx);
                    this.axCZKEM1.OnDeleteTemplate += new zkemkeeper._IZKEMEvents_OnDeleteTemplateEventHandler(axCZKEM1_OnDeleteTemplate);
                    this.axCZKEM1.OnNewUser += new zkemkeeper._IZKEMEvents_OnNewUserEventHandler(axCZKEM1_OnNewUser);
                    this.axCZKEM1.OnHIDNum += new zkemkeeper._IZKEMEvents_OnHIDNumEventHandler(axCZKEM1_OnHIDNum);
                    this.axCZKEM1.OnAlarm += new zkemkeeper._IZKEMEvents_OnAlarmEventHandler(axCZKEM1_OnAlarm);
                    this.axCZKEM1.OnDoor += new zkemkeeper._IZKEMEvents_OnDoorEventHandler(axCZKEM1_OnDoor);
                    this.axCZKEM1.OnWriteCard += new zkemkeeper._IZKEMEvents_OnWriteCardEventHandler(axCZKEM1_OnWriteCard);
                    this.axCZKEM1.OnEmptyCard += new zkemkeeper._IZKEMEvents_OnEmptyCardEventHandler(axCZKEM1_OnEmptyCard);
                    Trace.subWriteInLogFile(string.Concat(DateTime.Now.ToString(formatDateLog), "| " + "Events registred"));

                }
            }
            else
            {
                axCZKEM1.GetLastError(ref idwErrorCode);

                Trace.subWriteInLogFile(string.Concat(DateTime.Now.ToString(formatDateLog), "| " + "Unable to connect the device, ErrorCode = " + idwErrorCode.ToString()));

            }