Newer
Older
IRIS_REFACTOR / irisRefactor / FingerIdentifyTh.cs
using irisDataBase.Model;
using irisHelper;
using irisRefactor.FrmService;
using libzkfpcsharp;
using Newtonsoft.Json.Linq;
using System;
using System.Reflection;
using System.Threading;

namespace irisRefactor.fingerThread
{
    public class FingerIdentifyTh
    {
        private FingerIdentifyTh() { }

        private bool captureWorking = false;

        private static readonly FingerIdentifyTh fingerIdentifyTh = new FingerIdentifyTh();

        public static FingerIdentifyTh GetInstance { get => fingerIdentifyTh; }
        public bool CaptureWorking { get => captureWorking; set => captureWorking = value; }

        public void FingerIdentify()
        {
            LogHelper.WriteDebugLog(MethodBase.GetCurrentMethod().DeclaringType, "FingerIdentifyStarted");
            
            while(true)
            {
                if (CaptureWorking)
                {
                    int retCode = ProMemory.fingerPrintModule.DoCapture();
                    LogHelper.WriteDebugLog(MethodBase.GetCurrentMethod().DeclaringType, "FingerIdentify Result: " + retCode);
                    if (retCode > 0)
                    {
                        JObject personFound = new JObject();
                        ProMemory.fingerPrintModule.FingerPrintZkMgr.UserFingerList.TryGetValue(retCode, out personFound);
                        string personId = personFound.GetValue("personId").ToString();
                        if (ProMemory.formType == "1")
                            Form1.GetInstance().Success(personId, 3);
                        else if (ProMemory.formType == "2")
                            Form2.GetInstance().Success(personId, 3);

                        captureWorking = false;
                    } else if (retCode == zkfperrdef.ZKFP_ERR_VERIFY_FP || retCode == zkfperrdef.ZKFP_ERR_FAIL)
                    {
                        if (ProMemory.formType == "1")
                            Form1.GetInstance().Failure();
                        else if (ProMemory.formType == "2")
                            Form2.GetInstance().Failure();
                    }

                    Thread.Sleep(200);
                }
            }
        }
    }
}