Example #1
0
        void myExplorer_DeviceAddedEvent(object sender, DeviceChangedEventArgs e)
        {
            if (e.Device.Type == "Msr")
            {
                myMsr = (Msr)myExplorer.CreateInstance(e.Device);

                myMsr.Open();
                myMsr.Claim(1000);
                myMsr.DeviceEnabled    = true;
                myMsr.DataEventEnabled = true;
                myMsr.DecodeData       = true;

                //  Update();
                myMsr.DataEvent += new DataEventHandler(myMsr_DataEvent);
            }
        }
Example #2
0
        /// <summary>
        /// Connect to Msr Device and Get Card Data.
        /// </summary>
        public void Connect()
        {
            myExplorer = new PosExplorer();


            DeviceInfo device = myExplorer.GetDevice("Msr", "MagTekMSR_Encrypted");


            //device= myExplorer.GetDevices()[0];

            /// <summary>
            /// To check if device found or not
            /// </summary>

            if (device != null)
            {
                Disconnect();

                myMsr = (Msr)myExplorer.CreateInstance(device);

                try
                {
                    myMsr.Open();
                    if (myMsr.Claimed == false)
                    {
                        myMsr.Claim(1000);
                    }
                    myMsr.DeviceEnabled = true;
                }
                catch
                {
                }
                myMsr.DataEventEnabled = true;
                myMsr.DecodeData       = true;
                myMsr.DataEvent       += new DataEventHandler(myMsr_DataEvent);
            }
            else
            {
                throw new Exception("pos device not founded");

                //return;
            }
            myExplorer.DeviceAddedEvent   += new DeviceChangedEventHandler(myExplorer_DeviceAddedEvent);
            myExplorer.DeviceRemovedEvent += new DeviceChangedEventHandler(myExplorer_DeviceRemovedEvent);
            //myMsr.DataEvent += new DataEventHandler(myMsr_DataEvent);
        }