Esempio n. 1
0
        public void WriteCard(CardTrackMode mode, string readData)
        {
            if (readData == null)
            {
                throw new DeviceException(this.DeviceId, "-7", "参数data值非法");
            }

            int returnCode = 0;
            //BP 盒转口控制
            char bpControlFlag = 'A';

            nCommPort = BpController.CommPortToInt(this.PortName, out bpControlFlag);
            BpController.ChangeTo(nCommPort, bpControlFlag, nBaudRate);
            byte[] writeData = new byte[255];
            byte[] tmpBuf    = System.Text.Encoding.Default.GetBytes(readData);
            Array.Clear(writeData, 0, writeData.Length);
            Array.Copy(tmpBuf, writeData, tmpBuf.Length);
            try
            {
                returnCode = CardReaderDllWrapper.WriteCard(nCommPort, writeData, (int)mode);
            }
            catch (Exception e)
            {
                throw new DeviceException(this.DeviceId, "-9999", e.Message.ToString());
            }
            if (returnCode >= 1)
            {
                throw new DeviceException(this.DeviceId, "-9999", "009");
            }
            else
            {
                switch (returnCode)
                {
                case -11:
                    throw new DeviceException(this.DeviceId, returnCode.ToString(), "打开端口失败");

                case -1:
                    throw new DeviceException(this.DeviceId, "-99", "操作超时");

                case -2:
                    throw new DeviceException(this.DeviceId, returnCode.ToString(), "操作失败");

                case -7:
                    throw new DeviceException(this.DeviceId, returnCode.ToString(), "参数mode值非法");

                default:
                    throw new DeviceException(this.DeviceId, returnCode.ToString(), "失败");
                }
            }
        }
Esempio n. 2
0
        public string ReadCard(CardTrackMode mode)
        {
            int returnCode = 0;
            //BP 盒转口控制
            char bpControlFlag = 'A';

            nCommPort = BpController.CommPortToInt(this.PortName, out bpControlFlag);
            BpController.ChangeTo(nCommPort, bpControlFlag, nBaudRate);
            byte[] readData = new byte[255];
            Array.Clear(readData, 0, readData.Length);
            try
            {
                returnCode = CardReaderDllWrapper.ReadCard(nCommPort, readData, (int)mode);
            }
            catch (Exception e)
            {
                throw new DeviceException(this.DeviceId, "-9999", e.Message.ToString());
            }
            if (returnCode >= 1)
            {
                return(System.Text.Encoding.Default.GetString(readData));
            }
            else
            {
                switch (returnCode)
                {
                case -11:
                    throw new DeviceException(this.DeviceId, returnCode.ToString(), "打开端口失败");

                case -1:
                    throw new DeviceException(this.DeviceId, "-99", "操作超时");

                case -2:
                    throw new DeviceException(this.DeviceId, returnCode.ToString(), "操作失败");

                case -7:
                    throw new DeviceException(this.DeviceId, returnCode.ToString(), "参数mode值非法");

                default:
                    throw new DeviceException(this.DeviceId, returnCode.ToString(), "失败");
                }
            }
        }
Esempio n. 3
0
 public string ReadCard(CardTrackMode mode)
 {
     return("");
 }
Esempio n. 4
0
 public void WriteCard(CardTrackMode mode, string data)
 {
 }
Esempio n. 5
0
 public string WaitReadCard(CardTrackMode mode)
 {
     throw new DeviceException(this.DeviceId, "-1", "设备没有一直等待刷卡功能");
 }