//When you are enrolling your finger,this event will be triggered.
        void axCZKEM1_OnEnrollFingerEx(string EnrollNumber, int FingerIndex, int ActionResult, int TemplateLength)
        {
            Pergjigje pergjigje = new Pergjigje();

            pergjigje.Komanda = "New_Finger_Skanned";
            string msg;

            if (ActionResult == 0)
            {
                msg = "SUCCESS: Enroll finger succeed. UserID=" + EnrollNumber.ToString() + "...FingerIndex=" + FingerIndex.ToString();
                Logger.WriteLog(msg);
                pergjigje.Sukses = true;
                pergjigje.Mesazh = msg;
                pergjigje.AttId  = int.Parse(EnrollNumber);
            }
            else
            {
                msg = "ERROR: Enroll finger failed. Result=" + ActionResult.ToString();
                Logger.WriteLog(msg);
                pergjigje.Sukses = false;
                pergjigje.Mesazh = msg;
            }
            string URI = ConfReader.Read("api") + ConfReader.Read("middlewareendpoint") + "?access_token=" + AccessToken.Get().id;
            string pergjigjeStringify = JsonConvert.SerializeObject(pergjigje);

            HttpCallApi.Post(URI, pergjigjeStringify);
            //throw new NotImplementedException();
        }
        public int sta_SetUserInfo(string txtUserID, string txtName, string cbPrivilege, string txtPassword)
        {
            Pergjigje pergjigje = new Pergjigje();

            pergjigje.Komanda = "New_Finger_Skanned";
            string msg;

            if (GetConnectState() == false)
            {
                msg = "ERROR: Nuk jeni lidhur me pajisjen";
                Logger.WriteLog(msg);
                pergjigje.Sukses = false;
                pergjigje.Mesazh = msg;
                return(-1024);
            }

            if (txtUserID == "" || cbPrivilege == "")
            {
                msg = "ERROR: Plotesoni te gjitha fushat e kerkuara. userId, cbPrivilege";
                Logger.WriteLog(msg);
                pergjigje.Sukses = false;
                pergjigje.Mesazh = msg;
                return(-1023);
            }
            int iPrivilege = int.Parse(cbPrivilege);

            //bool bFlag = false;
            if (iPrivilege == 5)
            {
                msg = "*User Defined Role is Error! Please Register again!";
                Logger.WriteLog(msg);
                pergjigje.Sukses = false;
                pergjigje.Mesazh = msg;
                return(-1023);
            }

            /*
             * if(iPrivilege == 4)
             * {
             *  axCZKEM1.IsUserDefRoleEnable(iMachineNumber, 4, out bFlag);
             *
             *  if (bFlag == false)
             *  {
             *      Logger.WriteLog("*User Defined Role is unable!");
             *      return -1023;
             *  }
             * }
             */
            //Logger.WriteLog("[func IsUserDefRoleEnable]Temporarily unsupported");

            int    iPIN2Width      = 0;
            int    iIsABCPinEnable = 0;
            int    iT9FunOn        = 0;
            string strTemp         = "";

            axCZKEM1.GetSysOption(GetMachineNumber(), "~PIN2Width", out strTemp);
            iPIN2Width = Convert.ToInt32(strTemp);
            axCZKEM1.GetSysOption(GetMachineNumber(), "~IsABCPinEnable", out strTemp);
            iIsABCPinEnable = Convert.ToInt32(strTemp);
            axCZKEM1.GetSysOption(GetMachineNumber(), "~T9FunOn", out strTemp);
            iT9FunOn = Convert.ToInt32(strTemp);

            /*
             * axCZKEM1.GetDeviceInfo(iMachineNumber, 76, ref iPIN2Width);
             * axCZKEM1.GetDeviceInfo(iMachineNumber, 77, ref iIsABCPinEnable);
             * axCZKEM1.GetDeviceInfo(iMachineNumber, 78, ref iT9FunOn);
             */
            if (txtUserID.Length > iPIN2Width)
            {
                Logger.WriteLog("*User ID error! The max length is " + iPIN2Width.ToString());
                return(-1022);
            }

            if (iIsABCPinEnable == 0 || iT9FunOn == 0)
            {
                if (txtUserID.Substring(0, 1) == "0")
                {
                    msg = "*User ID error! The first letter can not be as 0";
                    Logger.WriteLog(msg);
                    pergjigje.Sukses = false;
                    pergjigje.Mesazh = msg;
                    return(-1022);
                }

                foreach (char tempchar in txtUserID.ToCharArray())
                {
                    if (!(char.IsDigit(tempchar)))
                    {
                        msg = "*User ID error! User ID only support digital";
                        Logger.WriteLog(msg);
                        pergjigje.Sukses = false;
                        pergjigje.Mesazh = msg;
                        return(-1022);
                    }
                }
            }

            int    idwErrorCode    = 0;
            string sdwEnrollNumber = txtUserID;
            string sName           = txtName.Trim();
            string sPassword       = txtPassword;

            bool bEnabled = true;

            /*if (iPrivilege == 4)
             * {
             *  bEnabled = false;
             *  iPrivilege = 0;
             * }
             * else
             * {
             *  bEnabled = true;
             * }*/

            axCZKEM1.EnableDevice(iMachineNumber, false);
            //axCZKEM1.SetStrCardNumber(sCardnumber);//Before you using function SetUserInfo,set the card number to make sure you can upload it to the device
            if (axCZKEM1.SSR_SetUserInfo(iMachineNumber, sdwEnrollNumber, sName, sPassword, iPrivilege, bEnabled))//upload the user's information(card number included)
            {
                msg = "SUCCESS: Perdoruesi u regjistrua me sukses";
                Logger.WriteLog(msg);
                pergjigje.Sukses = true;
                pergjigje.Mesazh = msg;
                pergjigje.AttId  = int.Parse(txtUserID);
            }
            else
            {
                axCZKEM1.GetLastError(ref idwErrorCode);
                msg = "ERROR: *Operation failed,ErrorCode=" + idwErrorCode.ToString();
                Logger.WriteLog(msg);
                pergjigje.Sukses = false;
            }
            axCZKEM1.RefreshData(iMachineNumber);//the data in the device should be refreshed
            axCZKEM1.EnableDevice(iMachineNumber, true);
            string URI = ConfReader.Read("api") + ConfReader.Read("middlewareendpoint") + "?access_token=" + AccessToken.Get().id;
            string pergjigjeStringify = JsonConvert.SerializeObject(pergjigje);

            HttpCallApi.Post(URI, pergjigjeStringify);
            return(1);
        }