Click here to Skip to main content
15,889,651 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I am creating object for each device and then connecting the devices as below.

C#
int iNoOfPunchStation = int.Parse(System.Configuration.ConfigurationSettings.AppSettings["NoOfPunchStation"]);
            for (int i = 0; i < oPunchStation.Length; i++)
            {

                oPunchStation[i] = new zkemkeeper.CZKEMClass();
                bIsConnected = oPunchStation[i].Connect_Net(System.Configuration.ConfigurationSettings.AppSettings["Station" + (i + 1)], Convert.ToInt32("4370"));
                if (bIsConnected == true)
                {
                    if (oPunchStation[i].RegEvent(1, 65535))//Here you can register the realtime events that you want to be triggered(the parameters 65535 means registering all)
                    {

                        oPunchStation[i].OnKeyPress += new zkemkeeper._IZKEMEvents_OnKeyPressEventHandler(axCZKEM1_OnKeyPress);
                        oPunchStation[i].OnHIDNum += new zkemkeeper._IZKEMEvents_OnHIDNumEventHandler(axCZKEM1_OnHIDNum);

                    }
                }
            }


my doubt is. I want to identify the device from which the data coming in event name 'axCZKEM1_OnHIDNum'
that is, which punching device?

the event 'axCZKEM1_OnHIDNum' as below.

C#
private void axCZKEM1_OnHIDNum(int iCardNumber)
       {
          
       }



no idea.. :(

Thanks..
Posted
Updated 30-Oct-14 20:09pm
v3
Comments
BillWoodruff 31-Oct-14 2:40am    
Where is 'axCZKEM1_OnHIDNum' implemented: in the Class definition for 'zkemkeeper.CZKEMClass ?
hasbina 31-Oct-14 2:57am    
zkemkeeper.CZKEMClass class have
[TypeLibType(16)]
[ComVisible(false)]
public delegate void _IZKEMEvents_OnHIDNumEventHandler(int CardNumber);

then I implemented.
viranjapro 3-Mar-23 2:05am    
what is action, we have to do fire on this event OnHIDNum

1 solution

You can pass the event source via closure. First change your event handler signature to this:

C#
private void axCZKEM1_OnHIDNum(zkemkeeper.CZKEMClass oPunchStation, int iCardNumber)


And register the handler like this:

C#
oPunchStation[i].OnHIDNum += x => axCZKEM1_OnHIDNum(oPunchStation[i], x);
 
Share this answer
 
Comments
Tomas Takac 31-Oct-14 7:33am    
I assumed zkemkeeper.CZKEMClass (oPunchStation) represents the device. So where is the device id hidden then?
hasbina 31-Oct-14 7:46am    
Thank you sir. now working . but passing ip address of device instead of object and make a single object.

thank you sir...thanks a lotss..

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900