Пример #1
0
        private void btnRead_Click(object sender, EventArgs e)
        {
            _Card = null;
            ClearInput();
            ReadCardResult result = CardReaderManager.GetInstance(UserSetting.Current.WegenType).ReadSection(string.Empty, _CurrentSection, 0, 3, GlobalVariables.ParkingKey, true, true, false);

            if (CardOperationManager.Instance.ShowResultMessage(result.ResultCode))
            {
                this.txtCardID.Text = result.CardID;
                byte[] carddate = result[_CurrentSection];
                _Card = CardDateResolver.Instance.GetCardInfoFromData(result.CardID, carddate);
                List <byte[]> data = new List <byte[]>();
                if (carddate.Length == 16 * 3)
                {
                    for (int i = 0; i < 3; i++)
                    {
                        byte[] bytes = new byte[16];
                        Array.Copy(carddate, i * 16, bytes, 0, 16);
                        data.Add(bytes);
                    }
                    ucSection1.SectionData = data;
                }
            }
            if (_Card != null)
            {
                ShowCard(_Card);
            }
        }
Пример #2
0
        /// <summary>
        /// 读取卡片
        /// </summary>
        /// <param name="cardID">卡号(为空时不检查卡号是否一致)</param>
        /// <returns></returns>
        public CardInfo ReadCardWithMessage(string cardID)
        {
            CardInfo       card   = null;
            ReadCardResult result = CardReaderManager.GetInstance(UserSetting.Current.WegenType).ReadSection(cardID, (int)ICCardSection.Parking, 0, 3, GlobalVariables.ParkingKey, true, true, false);

            if (ShowResultMessage(result.ResultCode))
            {
                card = CardDateResolver.Instance.GetCardInfoFromData(result.CardID, result.ParkingDate);
            }
            return(card);
        }
Пример #3
0
        /// <summary>
        /// 读取卡片
        /// </summary>
        /// <param name="cardID">卡号(为空时不检查卡号是否一致)</param>
        /// <returns></returns>
        public CardInfo ReadCardWithMessage(string cardID)
        {
            CardInfo       card   = null;
            ReadCardResult result = _ReadCard(cardID, true, true);

            if (ShowResultMessage(result.ResultCode))
            {
                card = CardDateResolver.Instance.GetCardInfoFromData(result.CardID, result[GlobalVariables.ParkingSection]);
            }
            return(card);
        }
Пример #4
0
        /// <summary>
        /// 进场
        /// </summary>
        /// <param name="indoor">是否进内车场</param>
        public void Enter(bool indoor)
        {
            ReadCardResult result = _ReadCard(string.Empty, true, true);

            if (result.ResultCode == CardOperationResultCode.Success)
            {
                CardInfo card = CardDateResolver.Instance.GetCardInfoFromData(result.CardID, result.DataList[GlobalVariables.ParkingSection]);
                if (card != null)
                {
                    Enter(card, indoor);
                }
            }
        }
Пример #5
0
        /// <summary>
        /// 进场
        /// </summary>
        /// <param name="indoor">是否进内车场</param>
        public void Enter(bool indoor)
        {
            CardReaderManager manager = CardReaderManager.GetInstance(UserSetting.Current.WegenType);
            ReadCardResult    result  = manager.ReadSection(string.Empty, 2, 0, 3, GlobalVariables.ParkingKey, true, true, false);

            if (result.ResultCode == CardOperationResultCode.Success)
            {
                CardInfo card = CardDateResolver.Instance.GetCardInfoFromData(result.CardID, result.ParkingDate);
                if (card != null)
                {
                    Enter(card, indoor);
                }
            }
        }
Пример #6
0
 private void ChangeKeyTimerHandler(object sender, EventArgs e)
 {
     if (_OldKey != null)
     {
         ReadCardResult result = CardReaderManager.GetInstance(UserSetting.Current.WegenType).ReadSection(null, GlobalVariables.ParkingSection, 0, 3, _OldKey, false, false, false);
         if (!string.IsNullOrEmpty(result.CardID) && _CurrentCardID != result.CardID)
         {
             if (result.ResultCode == CardOperationResultCode.Success)
             {
                 CardOperationResultCode changeResult = CardReaderManager.GetInstance(UserSetting.Current.WegenType).SetSectionKey(result.CardID, GlobalVariables.ParkingSection, _OldKey, GlobalVariables.ParkingKey, true, true);
                 AddCardRow(result.CardID, result[GlobalVariables.ParkingSection], changeResult == CardOperationResultCode.Success ? Color.Green : Color.Red);
             }
             else
             {
                 CardReaderManager.GetInstance(UserSetting.Current.WegenType).FailBuz();
                 AddCardRow(result.CardID, result[GlobalVariables.ParkingSection], Color.Red);
             }
         }
         _CurrentCardID = result.CardID;
     }
 }
Пример #7
0
        private void btnReadBlock_Click(object sender, EventArgs e)
        {
            string[]    strs     = txtKey.Text.Split(' ');
            List <byte> keybytes = new List <byte>();

            foreach (string str in strs)
            {
                byte b = 0;
                if (byte.TryParse(str, System.Globalization.NumberStyles.HexNumber, null, out b))
                {
                    keybytes.Add(b);
                }
            }

            ReadCardResult result = _MUR200.ReadSection(txtCardID.Text.Trim(), txtSec.IntergerValue, txtBlock.IntergerValue, 1, keybytes.ToArray(), true, false, false);

            byte[] data = result[txtSec.IntergerValue];
            txtCardID.Text   = result.CardID;
            txtReadData.Text = string.Empty;
            if (data != null)
            {
                foreach (byte d in data)
                {
                    txtReadData.Text += d.ToString("X2") + " ";
                }
                MessageBox.Show("读取成功");
            }
            else
            {
                if (result.ResultCode == CardOperationResultCode.CardIDError)
                {
                    MessageBox.Show("读取到的卡号与当前卡号不一致!");
                }
                else
                {
                    MessageBox.Show("读取失败");
                }
            }
        }
Пример #8
0
        /// <summary>
        /// 读卡片信息
        /// </summary>
        /// <param name="cardID">卡号(为空时不检查卡号是否一致)</param>
        /// <param name="successBuz">成功时是否有蜂鸣提示</param>
        /// <param name="failBuz">失败时是否有蜂鸣提示</param>
        /// <param name="init">是否初始化密钥</param>
        /// <returns></returns>
        private ReadCardResult _ReadCard(string cardID, bool successBuz, bool failBuz, bool init)
        {
            ReadCardResult result = null;

            if (GlobalVariables.UseMifareIC)
            {
                result = CardReaderManager.GetInstance(UserSetting.Current.WegenType).ReadSection(cardID, GlobalVariables.ParkingSection, 0, 3, GlobalVariables.ParkingKey, successBuz, failBuz, init);
            }
            else
            {
                result = CardReaderManager.GetInstance(UserSetting.Current.WegenType).CPUReadFile(cardID, GlobalVariables.SamNO, GlobalVariables.ParkingCPUKey, GlobalVariables.ParkingFile, GlobalVariables.AlgorithmType, successBuz, failBuz);
                if (result.ResultCode == CardOperationResultCode.Success &&
                    result[GlobalVariables.ParkingFile] != null &&
                    result[GlobalVariables.ParkingFile].Length > 48)
                {
                    //只取前48字节
                    byte[] data = new byte[48];
                    Array.Copy(result[GlobalVariables.ParkingFile], data, 48);
                    result[GlobalVariables.ParkingFile] = data;
                }
            }

            return(result);
        }
Пример #9
0
        /// <summary>
        /// 检查卡片有效性
        /// </summary>
        /// <param name="cardID">卡号(为空时不检查卡号是否一致)</param>
        /// <returns></returns>
        public CardOperationResultCode CheckCard(string cardID)
        {
            ReadCardResult result = CardReaderManager.GetInstance(UserSetting.Current.WegenType).ReadSection(cardID, (int)ICCardSection.Parking, 0, 3, GlobalVariables.ParkingKey, false, false, false);

            return(result.ResultCode);
        }
Пример #10
0
        /// <summary>
        /// 检查卡片有效性
        /// </summary>
        /// <param name="cardID">卡号(为空时不检查卡号是否一致)</param>
        /// <param name="successBuz">成功时是否有蜂鸣提示</param>
        /// <param name="failBuz">失败时是否有蜂鸣提示</param>
        /// <returns></returns>
        public CardOperationResultCode CheckCard(string cardID, bool successBuz, bool failBuz)
        {
            ReadCardResult result = CardReaderManager.GetInstance(UserSetting.Current.WegenType).ReadSection(cardID, GlobalVariables.ParkingSection, 0, 3, GlobalVariables.ParkingKey, successBuz, failBuz, false);

            return(result.ResultCode);
        }
Пример #11
0
        /// <summary>
        /// 检查卡片有效性
        /// </summary>
        /// <param name="cardID">卡号(为空时不检查卡号是否一致)</param>
        /// <param name="successBuz">成功时是否有蜂鸣提示</param>
        /// <param name="failBuz">失败时是否有蜂鸣提示</param>
        /// <returns></returns>
        public CardOperationResultCode CheckCard(string cardID, bool successBuz, bool failBuz)
        {
            ReadCardResult result = _ReadCard(cardID, successBuz, failBuz);

            return(result.ResultCode);
        }