0
Interop.zkemkeeperライブラリを使用して、指紋デバイスからリアルタイムイベントを使用して出席者をフェッチするWindowsサービスを作成しました。サービスではマシンは正常に接続されていますが、サービスがOnAttTransactionExリアルタイムイベントに応答していないということは、OnAttTransactionExイベントを使用してマシンの出席への正常な接続がフェッチされないことを意味します。私は何が問題なのか分からない。ここで ZKemKeeperライブラリのリアルタイムイベントハンドラが応答しない
は、Windowsサービスのためのコードです:using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Linq;
using System.ServiceProcess;
using System.Text;
using System.Timers;
using System.IO;
using zkemkeeper;
using System.Threading;
using System.Windows.Forms;
namespace WindowsService1
{
public partial class Service1 : ServiceBase
{
// private System.Timers.Timer timer1 = null;
string filePath = @"E:\file1.txt";
bool connSatus = false;
CZKEMClass axCZKEM1;
public Service1()
{
InitializeComponent();
}
protected override void OnStart(string[] args)
{
/* timer1 = new Timer();
this.timer1.Interval = 10000;
this.timer1.Elapsed += new System.Timers.ElapsedEventHandler(this.timer1_Tick);
timer1.Enabled = true;
*/
axCZKEM1 = new zkemkeeper.CZKEMClass();
Thread createComAndMessagePumpThread = new Thread(() =>
{
connSatus = axCZKEM1.Connect_Net("192.169.9.34", 4370);
using (StreamWriter writer = new StreamWriter(filePath, true))
{
writer.WriteLine("Machine is connected on" + "Date :" + DateTime.Now.ToString() + "status" + connSatus);
writer.WriteLine(Environment.NewLine + "-----------------------------------------------------------------------------" + Environment.NewLine);
}
if (connSatus == true)
{
this.axCZKEM1.OnAttTransactionEx -= new zkemkeeper._IZKEMEvents_OnAttTransactionExEventHandler(axCZKEM1_OnAttTransactionEx);
if (axCZKEM1.RegEvent(1, 65535))//Here you can register the realtime events that you want to be triggered(the parameters 65535 means registering all)
{
this.axCZKEM1.OnAttTransactionEx += new zkemkeeper._IZKEMEvents_OnAttTransactionExEventHandler(axCZKEM1_OnAttTransactionEx);
using (StreamWriter writer = new StreamWriter(filePath, true))
{
writer.WriteLine("finger print Event is registered... ");
writer.WriteLine(Environment.NewLine + "-----------------------------------------------------------------------------" + Environment.NewLine);
}
}
}
Application.Run();
});
createComAndMessagePumpThread.SetApartmentState(ApartmentState.STA);
createComAndMessagePumpThread.Start();
}
public 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)
{
// if (OnAttTransactionEx != null) OnAttTransactionEx(sEnrollNumber, iIsInValid, iAttState, iVerifyMethod, iYear, iMonth, iDay, iHour, iMinute, iSecond, iWorkCode, axCZKEM1.MachineNumber, Tag);
using (StreamWriter writer = new StreamWriter(filePath, true))
{
writer.WriteLine(" OnAttTrasactionEx Has been Triggered,Verified OK on" + "Date :" + "Enrollnumber" + sEnrollNumber + DateTime.Now.ToString());
writer.WriteLine(Environment.NewLine + "-----------------------------------------------------------------------------" + Environment.NewLine);
}
}
protected override void OnStop()
{
// timer1.Enabled = false;
this.axCZKEM1.OnAttTransactionEx -= new zkemkeeper._IZKEMEvents_OnAttTransactionExEventHandler(axCZKEM1_OnAttTransactionEx);
axCZKEM1.Disconnect();
}
private void timer1_Tick(object sender, EventArgs e)
{
using (StreamWriter writer = new StreamWriter(filePath, true))
{
writer.WriteLine("Message is running on" + "Date :" + DateTime.Now.ToString());
writer.WriteLine(Environment.NewLine + "-----------------------------------------------------------------------------" + Environment.NewLine);
}
}
}
}
axCZKEM1 =新しいzkemkeeper.CZKEMClass();このコードはstaスレッドの内側になければなりません –