Example #1
0
        public override bool analyzeCardId(IFelica f)
        {
            byte[] data = f.ReadWithoutEncryption(0x110b, 0);
            if (data == null)
            {
                return false;
            }

            mAccountId = binString(data, 2, 8);

            return true;
        }
Example #2
0
        public override bool analyzeCardId(IFelica f)
        {
            byte[] data = f.ReadWithoutEncryption(0x110b, 0);
            if (data == null)
            {
                return(false);
            }

            mAccountId = binString(data, 2, 8);

            return(true);
        }
Example #3
0
        /// <summary>
        /// カード ID 取得
        /// </summary>
        /// <param name="f"></param>
        /// <returns></returns>
        public virtual bool analyzeCardId(IFelica f)
        {
            // デフォルトでは、IDm を用いる。
            byte[] data = f.IDm();
            if (data == null)
            {
                return(false);
            }

            mAccountId = binString(data, 0, 8);

            return(true);
        }
Example #4
0
        protected int mSystemCode; // システムコード

        #endregion Fields

        #region Methods

        /// <summary>
        /// カード ID 取得
        /// </summary>
        /// <param name="f"></param>
        /// <returns></returns>
        public virtual bool analyzeCardId(IFelica f)
        {
            // デフォルトでは、IDm を用いる。
            byte[] data = f.IDm();
            if (data == null)
            {
                return false;
            }

            mAccountId = binString(data, 0, 8);

            return true;
        }
Example #5
0
        public override bool analyzeCardId(IFelica f)
        {
            byte[] data  = f.ReadWithoutEncryption(0x67cf, 0);
            byte[] data2 = f.ReadWithoutEncryption(0x67cf, 1);
            if (data == null || data2 == null)
            {
                return(false);
            }

            mAccountId = binString(data, 12, 4) + binString(data2, 0, 4);

            return(true);
        }
Example #6
0
        /// <summary>
        /// カード読み込み
        /// Note: 本来はこのメソッドは private で良いが、UnitTest 用に public にしてある。
        /// </summary>
        /// <param name="f"></param>
        /// <returns></returns>
        public TransactionList ReadTransactions(IFelica f)
        {
            TransactionList transactions = new TransactionList();

            f.Polling(mSystemCode);

            if (!analyzeCardId(f))
            {
                throw new Exception(Properties.Resources.CantReadCardNo);
            }

            for (int i = 0; i < mMaxTransactions; i++)
            {
                byte[] data  = new byte[16 * mBlocksPerTransaction];
                byte[] block = null;

                for (int j = 0; j < mBlocksPerTransaction; j++)
                {
                    block = f.ReadWithoutEncryption(mServiceCode, i * mBlocksPerTransaction + j);
                    if (block == null)
                    {
                        break;
                    }

                    block.CopyTo(data, j * 16);
                }
                if (block == null)
                {
                    break;
                }

                Transaction t = new Transaction();

                // データが全0かどうかチェック
                int x = 0;
                foreach (int xx in data)
                {
                    x |= xx;
                }
                if (x == 0)
                {
                    // データが全0なら無視(空エントリ)
                    t.Invalidate();
                }

                // トランザクション解析
                else if (!analyzeTransaction(t, data))
                {
                    t.Invalidate();
                }
                transactions.Add(t);
            }

            if (mNeedReverse)
            {
                transactions.Reverse();
            }
            if (mNeedCalcValue)
            {
                CalcValueFromBalance(transactions);
            }
            PostProcess(transactions);

            return(transactions);
        }
Example #7
0
        /// <summary>
        /// カード読み込み
        /// Note: 本来はこのメソッドは private で良いが、UnitTest 用に public にしてある。
        /// </summary>
        /// <param name="f"></param>
        /// <returns></returns>
        public TransactionList ReadTransactions(IFelica f)
        {
            TransactionList transactions = new TransactionList();

            f.Polling(mSystemCode);

            if (!analyzeCardId(f)) {
                throw new Exception(Properties.Resources.CantReadCardNo);
            }

            for (int i = 0; i < mMaxTransactions; i++)
            {
                byte[] data = new byte[16 * mBlocksPerTransaction];
                byte[] block = null;

                for (int j = 0; j < mBlocksPerTransaction; j++)
                {
                    block = f.ReadWithoutEncryption(mServiceCode, i * mBlocksPerTransaction + j);
                    if (block == null)
                    {
                        break;
                    }

                    block.CopyTo(data, j * 16);
                }
                if (block == null)
                {
                    break;
                }

                Transaction t = new Transaction();

                // データが全0かどうかチェック
                int x = 0;
                foreach (int xx in data)
                {
                    x |= xx;
                }
                if (x == 0)
                {
                    // データが全0なら無視(空エントリ)
                    t.Invalidate();
                }

                // トランザクション解析
                else if (!analyzeTransaction(t, data))
                {
                    t.Invalidate();
                }
                transactions.Add(t);
            }

            if (mNeedReverse)
            {
                transactions.Reverse();
            }
            if (mNeedCalcValue)
            {
                CalcValueFromBalance(transactions);
            }
            PostProcess(transactions);

            return transactions;
        }