/// <summary>
 ///		Lanza el evento de lectura de un bloque
 /// </summary>
 private void RaiseEventReadBlock(long row)
 {
     if (NotifyAfter > 0 && row % NotifyAfter == 0)
     {
         ReadBlock?.Invoke(this, new EventArguments.AffectedEvntArgs(row));
     }
 }
Example #2
0
 protected void RegisterReadingMethod(string name, ReadBlock method)
 {
     if (dataReadingTable.ContainsKey(name))
     {
         Debug.LogErrorFormat("reading method name conflict: {0}", name);
         return;
     }
     dataReadingTable.Add(name, method);
 }
Example #3
0
    public override bool OnRow(StaticIDData <TK> data, string key, string value)
    {
        if (!dataReadingTable.ContainsKey(key))
        {
            Debug.LogErrorFormat("reading column not exist: {0}", key);
            return(false);
        }
        ReadBlock rb       = dataReadingTable[key];
        T         specData = data as T;

        return(rb(specData, value));
    }
        private void OnDetected(IFeliCaReader reader)
        {
            Idm.Value    = string.Empty;
            Access.Value = null;
            Logs.Clear();

            var idm = reader.ExecutePolling(0x0003);

            if (idm.Length == 0)
            {
                return;
            }

            var block = new ReadBlock {
                BlockNo = 0
            };

            if (!reader.ExecuteReadWoe(idm, 0x008B, block))
            {
                return;
            }

            var blocks1 = Enumerable.Range(0, 8).Select(x => new ReadBlock {
                BlockNo = (byte)x
            }).ToArray();
            var blocks2 = Enumerable.Range(8, 8).Select(x => new ReadBlock {
                BlockNo = (byte)x
            }).ToArray();
            var blocks3 = Enumerable.Range(16, 4).Select(x => new ReadBlock {
                BlockNo = (byte)x
            }).ToArray();

            if (!reader.ExecuteReadWoe(idm, 0x090F, blocks1) ||
                !reader.ExecuteReadWoe(idm, 0x090F, blocks2) ||
                !reader.ExecuteReadWoe(idm, 0x090F, blocks3))
            {
                return;
            }

            Idm.Value    = HexEncoder.ToHex(idm);
            Access.Value = Suica.ConvertToAccessData(block.BlockData);
            Logs.AddRange(blocks1.Concat(blocks2).Concat(blocks3)
                          .Select(x => Suica.ConvertToLogData(x.BlockData))
                          .Where(x => x != null)
                          .ToArray());
        }
Example #5
0
            public Result <ReadBlock> ReadNext()
            {
                var readBlock = new ReadBlock()
                {
                    ActualReadSize = 0,
                    ReadBlockData  = new byte[_inputBlockSize],
                    BlockIndex     = _currentBlockCount
                };

                try {
                    readBlock.ActualReadSize = _inputStream.Read(readBlock.ReadBlockData, 0, _inputBlockSize);
                    _currentBlockCount++;
                    return(Result.Ok <ReadBlock>(readBlock));
                } catch (Exception ex) {
                    return(Result.Fail <ReadBlock>($"Read original block exception: {ex.Message}"));
                }
            }
Example #6
0
            public Result <ReadBlock> ReadNext()
            {
                var readBlock = new ReadBlock()
                {
                    ActualReadSize = 0,
                    ReadBlockData  = new byte[MaxBlockSize],
                    BlockIndex     = _currentBlockCount
                };

                if (_currentBlockCount >= TotalBlockCount)
                {
                    return(Result.Fail <ReadBlock>($"Extra read block {_currentBlockCount}, but should be no more than {TotalBlockCount}!"));
                }

                var seek = _inputBinaryReader.BaseStream.Seek(_offset, SeekOrigin.Begin);

                if (seek <= 0)
                {
                    return(Result.Ok(readBlock));
                }

                var marker = _inputBinaryReader.ReadInt32();

                if (marker != _marker)
                {
                    return(Result.Fail <ReadBlock>(_nonValidArchiveErrorMessage));
                }
                readBlock.BlockIndex = _inputBinaryReader.ReadInt32();
                if (readBlock.BlockIndex != _currentBlockCount)
                {
                    return(Result.Fail <ReadBlock>(_nonValidArchiveErrorMessage));
                }
                readBlock.ActualReadSize = _inputBinaryReader.ReadInt32();
                readBlock.ReadBlockData  = _inputBinaryReader.ReadBytes(readBlock.ActualReadSize);
                _currentBlockCount++;
                _offset += (blockHeaderSize + readBlock.ActualReadSize);
                return(Result.Ok(readBlock));
            }