Quantcast
Channel: ZK Forum - Individual question feed
Viewing all articles
Browse latest Browse all 356

Add RealTime Events in windows service

$
0
0
Hi forum, I have a ZK Fingerprint device. I have developed a windows service to download attendance log from the device to a database. I would like to use realtime events of SDK, like axCZKEM1_OnKeyPress and axCZKEM1_OnAttTransactionEx to write in the lcd of the device error message if the user doesn' click a specific botton (ex. F1 or F2) from the device, but the code written by me doesn' work. I have defined the real time event on Start() event of service:   protected override void OnStart(string[] args) { eventLog1.WriteEntry("servizio gestione presenze avviato"); axCZKEM1 = new zkemkeeper.CZKEMClass(); IsConnected = axCZKEM1.Connect_Net("192.168.1.201", Convert.ToInt32(4370)); if (IsConnected) { iMachineNumber = 1; _clickedKey = 0; //initialize variable that contain the button key clicked //eventi real time if (axCZKEM1.RegEvent(iMachineNumber, 65535)) { * //eventi real time this.axCZKEM1.OnKeyPress += new zkemkeeper._IZKEMEvents_OnKeyPressEventHandler(axCZKEM1_OnKeyPress); this.axCZKEM1.OnAttTransactionEx += new zkemkeeper._IZKEMEvents_OnAttTransactionExEventHandler(axCZKEM1_OnAttTransactionEx); this.axCZKEM1.OnNewUser += new zkemkeeper._IZKEMEvents_OnNewUserEventHandler(axCZKEM1_OnNewUser);* } } } Follow the events: private void axCZKEM1_OnAttTransactionEx(string sEnrollNumber, int iIsInValid, int iAttState, int iVerifyMethod, int iYear, int iMonth, int iDay, int iHour, int iMinute, int iSecond, int iWorkCode) { eventLog1.WriteEntry("OnAttTransactionEx"); if (_clickedKey == 12 || _clickedKey == 13) { if (iWorkCode != 0) { if (axCZKEM1.ClearLCD()) { axCZKEM1.RefreshData(iMachineNumber);//the data in the device should be refreshed int iRow = 1; int iCol = 1; string sText1 = @"Errore"; string sText2 = @"CheckIn\Out"; axCZKEM1.WriteLCD(iRow, iCol, sText1); axCZKEM1.WriteLCD(iRow + 1, iCol, sText2); if (axCZKEM1.WriteLCD(iRow, iCol, sText1) && axCZKEM1.WriteLCD(iRow + 1, iCol, sText2)) { axCZKEM1.RefreshData(iMachineNumber);//the data in the device should be refreshed } } } } else { if (_clickedKey == 11 || _clickedKey == 14) { if (iWorkCode == 0) { if (axCZKEM1.ClearLCD()) { axCZKEM1.RefreshData(iMachineNumber);//the data in the device should be refreshed int iRow = 1; int iCol = 1; string sText1 = @"Errore"; string sText2 = @"Permesso"; axCZKEM1.WriteLCD(iRow, iCol, sText1); axCZKEM1.WriteLCD(iRow + 1, iCol, sText2); if (axCZKEM1.WriteLCD(iRow, iCol, sText1) && axCZKEM1.WriteLCD(iRow + 1, iCol, sText2)) { axCZKEM1.RefreshData(iMachineNumber);//the data in the device should be refreshed } } } } else { if (axCZKEM1.ClearLCD()) { axCZKEM1.RefreshData(iMachineNumber);//the data in the device should be refreshed int iRow = 1; int iCol = 1; string sText1 = @"Errore"; string sText2 = @"CheckIn\Out"; axCZKEM1.WriteLCD(iRow, iCol, sText1); axCZKEM1.WriteLCD(iRow + 1, iCol, sText2); if (axCZKEM1.WriteLCD(iRow, iCol, sText1) && axCZKEM1.WriteLCD(iRow + 1, iCol, sText2)) { axCZKEM1.RefreshData(iMachineNumber);//the data in the device should be refreshed } } } } _clickedKey = 0; } //When you press the keypad,this event will be triggered. private void axCZKEM1_OnKeyPress(int iKey) { eventLog1.WriteEntry("OnKeyPress"); //memorizzo il tasto cliccato this._clickedKey = iKey; } But none of this event works infact none of eventlog is written! Why this happens? The same code in a Windows application works fine, why? Can help me please? Thans a lot in advance!

Viewing all articles
Browse latest Browse all 356

Trending Articles