Ejemplo n.º 1
0
        private void OpenDevice(ref PosCommon posCommon, string strDeviceName, string strDeviceLevel)
        {
            if (string.IsNullOrEmpty(strDeviceLevel) || string.IsNullOrEmpty(strDeviceName))
            {
                return;
            }
            DeviceCollection devices = _posExplorer.GetDevices((DeviceCompatibilities)Enum.Parse(typeof(DeviceCompatibilities), strDeviceLevel, false));
            DeviceInfo       drv     = devices.Cast <DeviceInfo>().Where(x => x.ServiceObjectName.Equals(strDeviceName)).FirstOrDefault();

            try
            {
                posCommon = (PosCommon)_posExplorer.CreateInstance(drv);
                posCommon.Open();
                SetDataEventEnabledPosCommon(ref posCommon, true);
                HookUpEvents(posCommon, true);
            }
            catch (Exception ex)
            {
                //sMessengeError = ex.Message;
                throw ex;
            }
        }