Exemplo n.º 1
0
        public uint GetPosition(PositionBlock positionBlock)
        {
            var dataBuffer = new byte[4];

            this.GetPosition(positionBlock, dataBuffer);
            return(BitConverter.ToUInt32(dataBuffer, 0));
        }
Exemplo n.º 2
0
 public void GetDirect(PositionBlock positionBlock, byte[] dataBuffer, ref ushort dataBufferLength, byte[] keyBuffer, sbyte keyNumber, LockBias lockBias = LockBias.None)
 {
     if (positionBlock == null || dataBuffer == null)
     {
         throw new ArgumentNullException();
     }
     this.Operate(Operation.GetDirect, positionBlock, dataBuffer, ref dataBufferLength, keyBuffer, keyNumber, (ushort)lockBias);
 }
Exemplo n.º 3
0
 public void UpdateChunk(PositionBlock positionBlock, byte[] dataBuffer, ref ushort dataBufferLength, byte[] keyBuffer = null, sbyte keyNumber = -1)
 {
     if (positionBlock == null || dataBuffer == null)
     {
         throw new ArgumentNullException();
     }
     this.Operate(Operation.UpdateChunk, positionBlock, dataBuffer, ref dataBufferLength, keyBuffer, keyNumber);
 }
Exemplo n.º 4
0
 public void GetLessThanOrEqualKey(PositionBlock positionBlock, byte[] keyBuffer, sbyte keyNumber, LockBias lockBias = LockBias.None)
 {
     if (positionBlock == null || keyBuffer == null)
     {
         throw new ArgumentNullException();
     }
     this.Operate(Operation.GetLessThanOrEqualKey, positionBlock, null, keyBuffer, keyNumber, (ushort)lockBias);
 }
Exemplo n.º 5
0
 public void UnlockSingleRecord(PositionBlock positionBlock, sbyte keyNumber)
 {
     if (positionBlock == null)
     {
         throw new ArgumentNullException();
     }
     this.Operate(Operation.Unlock, positionBlock, null, null, keyNumber);
 }
Exemplo n.º 6
0
        public void Insert(PositionBlock positionBlock, byte[] dataBuffer, ushort dataBufferLength, sbyte keyNumber = -1, byte keyLength = 255)
        {
            if (positionBlock == null || dataBuffer == null)
            {
                throw new ArgumentNullException();
            }
            var keyBuffer = keyNumber == -1 ? _zero : new byte[keyLength];

            this.Operate(Operation.Insert, positionBlock, dataBuffer, ref dataBufferLength, keyBuffer, keyNumber);
        }
Exemplo n.º 7
0
        public void Delete(PositionBlock positionBlock)
        {
            if (positionBlock == null)
            {
                throw new ArgumentNullException();
            }
            var keyNumber = (sbyte)0;

            this.Operate(Operation.Delete, positionBlock, null, null, keyNumber);
        }
Exemplo n.º 8
0
        public void GetDirect(PositionBlock positionBlock, byte[] dataBuffer, byte[] keyBuffer, sbyte keyNumber, LockBias lockBias = LockBias.None)
        {
            if (positionBlock == null || dataBuffer == null)
            {
                throw new ArgumentNullException();
            }
            var dataBufferLength = (ushort)dataBuffer.Length;

            this.GetDirect(positionBlock, dataBuffer, ref dataBufferLength, keyBuffer, keyNumber, lockBias);
        }
Exemplo n.º 9
0
        public void StepPreviousExtended(PositionBlock positionBlock, byte[] dataBuffer, ref ushort dataBufferLength, LockBias lockBias = LockBias.None)
        {
            if (positionBlock == null || dataBuffer == null)
            {
                throw new ArgumentNullException();
            }
            var keyNumber = (sbyte)0;

            this.Operate(Operation.StepPreviousExtended, positionBlock, dataBuffer, ref dataBufferLength, null, keyNumber, (ushort)lockBias);
        }
Exemplo n.º 10
0
        public void ClearOwner(PositionBlock positionBlock)
        {
            if (positionBlock == null)
            {
                throw new ArgumentNullException();
            }
            var dataBuffer = _zero;
            var keyBuffer  = _zero;
            var keyNumber  = (sbyte)0;

            this.Operate(Operation.ClearOwner, positionBlock, dataBuffer, keyBuffer, keyNumber);
        }
Exemplo n.º 11
0
        public StatData Stat(PositionBlock positionBlock, byte[] dataBuffer)
        {
            if (positionBlock == null || dataBuffer == null)
            {
                throw new ArgumentNullException();
            }
            var keyBuffer = new byte[64];
            var keyNumber = (sbyte)-1;

            this.Operate(Operation.Stat, positionBlock, dataBuffer, keyBuffer, keyNumber);

            return(new StatData(dataBuffer));
        }
Exemplo n.º 12
0
        public void SetOwner(PositionBlock positionBlock, string ownerName, OwnerNameOption option = OwnerNameOption.NoEncryption)
        {
            if (positionBlock == null || ownerName == null)
            {
                throw new ArgumentNullException();
            }
            ownerName = ownerName == null ? "\0" : ownerName.TrimEnd('\0') + "\0";

            var dataBuffer = (this.OwnerNameEncoding ?? Encoding.Default).GetBytes(ownerName);
            var keyBuffer  = (this.OwnerNameEncoding ?? Encoding.Default).GetBytes(ownerName);
            var keyNumber  = (sbyte)option;

            this.Operate(Operation.SetOwner, positionBlock, dataBuffer, keyBuffer, keyNumber);
        }
Exemplo n.º 13
0
        public void GetPosition(PositionBlock positionBlock, byte[] dataBuffer)
        {
            if (positionBlock == null || dataBuffer == null)
            {
                throw new ArgumentNullException();
            }
            if (dataBuffer.Length < 4)
            {
                throw new ArgumentException();
            }
            var keyNumber = (sbyte)0;

            this.Operate(Operation.GetPosition, positionBlock, dataBuffer, null, keyNumber);
        }
Exemplo n.º 14
0
        public void UnlockMultiRecord(PositionBlock positionBlock, byte[] recordPosition = null, bool isBufferReused = true)
        {
            if (positionBlock == null)
            {
                throw new ArgumentNullException();
            }
            if (recordPosition.Length != 4)
            {
                throw new ArgumentException();
            }
            var dataBuffer = recordPosition;
            var keyNumber  = recordPosition == null ? (sbyte)-2 : (sbyte)-1;

            this.Operate(Operation.Unlock, positionBlock, dataBuffer, null, keyNumber);
        }
Exemplo n.º 15
0
 internal OperationResult(
     Operation operationType,
     PositionBlock positionBlock,
     byte[] dataBuffer,
     int dataBufferLength,
     byte[] keyBuffer,
     sbyte keyNumber,
     ClientId clientId)
 {
     this.OperationType    = operationType;
     this.PositionBlock    = positionBlock;
     this.DataBuffer       = dataBuffer;
     this.DataBufferLength = dataBufferLength;
     this.KeyBuffer        = keyBuffer;
     this.KeyNumber        = keyNumber;
     this.ClientId         = clientId;
 }
Exemplo n.º 16
0
        public PositionBlock Open(string filePath, string ownerName = null, OpenMode openMode = OpenMode.Normal)
        {
            if (filePath == null)
            {
                throw new ArgumentNullException();
            }
            filePath  = filePath.TrimEnd('\0') + "\0";
            ownerName = ownerName == null ? "\0" : ownerName.TrimEnd('\0') + "\0";

            var positionBlock = new PositionBlock();
            var dataBuffer    = (this.OwnerNameEncoding ?? Encoding.Default).GetBytes(ownerName);
            var keyBuffer     = (this.PathEncoding ?? Encoding.Default).GetBytes(filePath);
            var keyNumber     = (sbyte)openMode;

            this.Operate(Operation.Open, positionBlock, dataBuffer, keyBuffer, keyNumber);

            return(positionBlock);
        }
Exemplo n.º 17
0
        public void Operate(
            Operation operation,
            PositionBlock positionBlock,
            byte[] dataBuffer,
            byte[] keyBuffer,
            sbyte keyNumber,
            ushort bias = 0)
        {
            var dataBufferLength = dataBuffer == null ? (ushort)0 : (ushort)dataBuffer.Length;

            this.Operate(
                operation,
                positionBlock,
                dataBuffer,
                ref dataBufferLength,
                keyBuffer,
                keyNumber,
                bias);
        }
Exemplo n.º 18
0
        public void Operate(
            Operation operation,
            PositionBlock positionBlock,
            byte[] dataBuffer,
            ref ushort dataBufferLength,
            byte[] keyBuffer,
            sbyte keyNumber,
            ushort bias = 0)
        {
            if (dataBuffer == null)
            {
                dataBuffer = _zero;
            }
            if (keyBuffer == null)
            {
                keyBuffer = _zero;
            }
            if (keyBuffer.Length > 255)
            {
                throw new ArgumentException();
            }

            byte[] posBlk = positionBlock == null ? _zero : positionBlock.Value;
            short  statusCode;

            if (this.ClientId == null)
            {
                statusCode = _library.BtrCall((ushort)((ushort)operation + bias), posBlk, dataBuffer, ref dataBufferLength, keyBuffer, (ushort)keyBuffer.Length, keyNumber);
            }
            else
            {
                statusCode = _library.BtrCallId((ushort)((ushort)operation + bias), posBlk, dataBuffer, ref dataBufferLength, keyBuffer, (ushort)keyBuffer.Length, keyNumber, this.ClientId.Buffer);
            }
            if (statusCode != 0)
            {
                throw new OperationException(operation, statusCode);
            }
        }
Exemplo n.º 19
0
        public void StepPreviousExtended(PositionBlock positionBlock, byte[] dataBuffer, LockBias lockBias = LockBias.None)
        {
            var dataBufferLength = (ushort)dataBuffer.Length;

            this.StepPreviousExtended(positionBlock, dataBuffer, ref dataBufferLength, lockBias);
        }
Exemplo n.º 20
0
        public void GetPreviousExtended(PositionBlock positionBlock, byte[] dataBuffer, byte[] keyBuffer, sbyte keyNumber, LockBias lockBias = LockBias.None)
        {
            var dataBufferLength = (ushort)dataBuffer.Length;

            this.GetPreviousExtended(positionBlock, dataBuffer, ref dataBufferLength, keyBuffer, keyNumber, lockBias);
        }
Exemplo n.º 21
0
        public void GetLessThanOrEqual(PositionBlock positionBlock, byte[] dataBuffer, byte[] keyBuffer, sbyte keyNumber, LockBias lockBias = LockBias.None)
        {
            var dataBufferLength = (ushort)dataBuffer.Length;

            this.GetLessThanOrEqual(positionBlock, dataBuffer, ref dataBufferLength, keyBuffer, keyNumber, lockBias);
        }
Exemplo n.º 22
0
        public void Update(PositionBlock positionBlock, byte[] dataBuffer, byte[] keyBuffer = null, sbyte keyNumber = -1)
        {
            var dataBufferLength = (ushort)dataBuffer.Length;

            this.Update(positionBlock, dataBuffer, ref dataBufferLength, keyBuffer, keyNumber);
        }
Exemplo n.º 23
0
        public void InsertExtended(PositionBlock positionBlock, byte[] dataBuffer, byte[] keyBuffer = null, sbyte keyNumber = -1)
        {
            var dataBufferLength = (ushort)dataBuffer.Length;

            this.InsertExtended(positionBlock, dataBuffer, dataBufferLength, keyBuffer, keyNumber);
        }
Exemplo n.º 24
0
 public StatData Stat(PositionBlock positionBlock)
 {
     return(this.Stat(positionBlock, new byte[1920]));
 }
Exemplo n.º 25
0
        public void Insert(PositionBlock positionBlock, byte[] dataBuffer, sbyte keyNumber = -1, byte keyLength = 255)
        {
            var dataBufferLength = (ushort)dataBuffer.Length;

            this.Insert(positionBlock, dataBuffer, (ushort)dataBuffer.Length, keyNumber, keyLength);
        }