예제 #1
0
        public Result GetLength(long lobId)
        {
            Result result;

            Monitor.Enter(this);
            try
            {
                object[] lobHeader = this.GetLobHeader(lobId);
                if (lobHeader == null)
                {
                    throw Error.GetError(0xd92);
                }
                long length = (long)lobHeader[1];
                int  num1   = (int)lobHeader[3];
                result = ResultLob.NewLobSetResponse(lobId, length);
            }
            catch (CoreException exception1)
            {
                result = Result.NewErrorResult(exception1);
            }
            finally
            {
                Monitor.Exit(this);
            }
            return(result);
        }
예제 #2
0
 public Result SetChars(long lobId, long offset, char[] chars)
 {
     lock (this)
     {
         if (chars.Length != 0)
         {
             object[] lobHeader = this.GetLobHeader(lobId);
             if (lobHeader == null)
             {
                 return(Result.NewErrorResult(Error.GetError(0xd92)));
             }
             long   num       = Convert.ToInt64(lobHeader[1]);
             byte[] dataBytes = ArrayUtil.CharArrayToBytes(chars);
             Result result2   = this.SetBytesBa(lobId, dataBytes, offset * 2L, chars.Length * 2);
             if (result2.IsError())
             {
                 return(result2);
             }
             if ((offset + chars.Length) > num)
             {
                 result2 = this.SetLength(lobId, offset + chars.Length);
                 if (result2.IsError())
                 {
                     return(result2);
                 }
             }
         }
         return(ResultLob.NewLobSetResponse(lobId, 0L));
     }
 }
예제 #3
0
 public Result SetBytesBa(long lobId, byte[] dataBytes, long offset, int length)
 {
     lock (this)
     {
         int num = (int)(offset / ((long)this._lobBlockSize));
         int destinationIndex = (int)(offset % ((long)this._lobBlockSize));
         int limit            = (int)((offset + length) / ((long)this._lobBlockSize));
         if (((int)((offset + length) % ((long)this._lobBlockSize))) == 0)
         {
             int num1 = this._lobBlockSize;
         }
         else
         {
             limit++;
         }
         int[][] numArray         = this.GetBlockAddresses(lobId, num, limit);
         byte[]  destinationArray = new byte[(limit - num) * this._lobBlockSize];
         if (numArray.Length != 0)
         {
             int blockAddress = numArray[0][0] + (num - numArray[0][2]);
             try
             {
                 Array.Copy(this._lobStore.GetBlockBytes(blockAddress, 1), 0, destinationArray, 0, this._lobBlockSize);
                 if (numArray.Length > 1)
                 {
                     blockAddress = numArray[numArray.Length - 1][0] + ((limit - numArray[numArray.Length - 1][2]) - 1);
                     Array.Copy(this._lobStore.GetBlockBytes(blockAddress, 1), 0, destinationArray, (limit - num) - 1, this._lobBlockSize);
                 }
                 else if ((limit - num) > 1)
                 {
                     blockAddress = numArray[0][0] + ((limit - numArray[0][2]) - 1);
                     Array.Copy(this._lobStore.GetBlockBytes(blockAddress, 1), 0, destinationArray, ((limit - num) - 1) * this._lobBlockSize, this._lobBlockSize);
                 }
             }
             catch (CoreException exception1)
             {
                 return(Result.NewErrorResult(exception1));
             }
             this.DivideBlockAddresses(lobId, num);
             this.DivideBlockAddresses(lobId, limit);
             this.DeleteBlockAddresses(lobId, num, limit);
         }
         this.CreateBlockAddresses(lobId, num, limit - num);
         Array.Copy(dataBytes, 0, destinationArray, destinationIndex, length);
         numArray = this.GetBlockAddresses(lobId, num, limit);
         try
         {
             for (int i = 0; i < numArray.Length; i++)
             {
                 this._lobStore.SetBlockBytes(destinationArray, numArray[i][0], numArray[i][1]);
             }
         }
         catch (CoreException exception2)
         {
             return(Result.NewErrorResult(exception2));
         }
         return(ResultLob.NewLobSetResponse(lobId, 0L));
     }
 }
예제 #4
0
        private Result SetBytesIs(long lobId, Stream inputStream, long length)
        {
            int count = (int)(length / ((long)this._lobBlockSize));
            int num2  = (int)(length % ((long)this._lobBlockSize));

            if (num2 == 0)
            {
                num2 = this._lobBlockSize;
            }
            else
            {
                count++;
            }
            this.CreateBlockAddresses(lobId, 0, count);
            int[][] numArray = this.GetBlockAddresses(lobId, 0, count);
            byte[]  buffer   = new byte[this._lobBlockSize];
            for (int i = 0; i < numArray.Length; i++)
            {
                for (int j = 0; j < numArray[i][1]; j++)
                {
                    int num5 = this._lobBlockSize;
                    if ((i == (numArray.Length - 1)) && (j == (numArray[i][1] - 1)))
                    {
                        num5 = num2;
                        for (int k = num5; k < this._lobBlockSize; k++)
                        {
                            buffer[k] = 0;
                        }
                    }
                    try
                    {
                        int num8;
                        for (int k = 0; num5 > 0; k += num8)
                        {
                            num8 = inputStream.Read(buffer, k, num5);
                            if (num8 == 0)
                            {
                                return(Result.NewErrorResult(new EndOfStreamException()));
                            }
                            num5 -= num8;
                        }
                    }
                    catch (IOException exception1)
                    {
                        return(Result.NewErrorResult(exception1));
                    }
                    try
                    {
                        this._lobStore.SetBlockBytes(buffer, numArray[i][0] + j, 1);
                    }
                    catch (CoreException exception2)
                    {
                        return(Result.NewErrorResult(exception2));
                    }
                }
            }
            return(ResultLob.NewLobSetResponse(lobId, 0L));
        }
예제 #5
0
        public void Truncate(ISessionInterface session, long len)
        {
            ResultLob r      = ResultLob.NewLobTruncateRequest(this._id, len);
            Result    result = session.Execute(r);

            if (result.IsError())
            {
                throw result.GetException();
            }
        }
예제 #6
0
 public Result SetBytesForNewBlob(long lobId, Stream inputStream, long length)
 {
     lock (this)
     {
         if (length == 0)
         {
             return(ResultLob.NewLobSetResponse(lobId, 0L));
         }
         return(this.SetBytesIs(lobId, inputStream, length));
     }
 }
예제 #7
0
        public long Length(ISessionInterface session)
        {
            ResultLob r      = ResultLob.NewLobGetLengthRequest(this._id);
            Result    result = session.Execute(r);

            if (result.IsError())
            {
                throw result.GetException();
            }
            return(((ResultLob)result).GetBlockLength());
        }
예제 #8
0
        public IClobData GetClob(ISessionInterface session, long position, long length)
        {
            ResultLob r      = ResultLob.NewLobGetRequest(this._id, position, length);
            Result    result = session.Execute(r);

            if (result.IsError())
            {
                throw result.GetException();
            }
            return(new ClobDataId(((ResultLob)result).GetLobId()));
        }
예제 #9
0
        public int SetString(ISessionInterface session, long pos, string str)
        {
            ResultLob r      = ResultLob.NewLobSetCharsRequest(this._id, pos, str.ToCharArray());
            Result    result = session.Execute(r);

            if (result.IsError())
            {
                throw result.GetException();
            }
            return(str.Length);
        }
예제 #10
0
        public byte[] GetBytes(ISessionInterface session, long pos, int length)
        {
            ResultLob r      = ResultLob.NewLobGetBytesRequest(this._id, pos, length);
            Result    result = session.Execute(r);

            if (result.IsError())
            {
                throw Error.GetError(result);
            }
            return(((ResultLob)result).GetByteArray());
        }
예제 #11
0
        public long Position(ISessionInterface session, string searchstr, long start)
        {
            ResultLob r      = ResultLob.NewLobGetCharPatternPositionRequest(this._id, searchstr.ToCharArray(), start);
            Result    result = session.Execute(r);

            if (result.IsError())
            {
                throw result.GetException();
            }
            return(((ResultLob)result).GetOffset());
        }
예제 #12
0
 public Result GetChars(Session session, long lobId, long offset, int length)
 {
     lock (this)
     {
         Result result2 = this.GetBytes(lobId, offset * 2L, length * 2);
         if (result2.IsError())
         {
             return(result2);
         }
         char[] chars = ArrayUtil.ByteArrayToChars(((ResultLob)result2).GetByteArray());
         return(ResultLob.NewLobGetCharsResponse(lobId, offset, chars));
     }
 }
예제 #13
0
        public void AllocateLobForResult(ResultLob result, Stream inputStream)
        {
            long lobId = result.GetLobId();

            switch (result.GetSubType())
            {
            case 7:
            {
                long id;
                long blockLength = result.GetBlockLength();
                if (inputStream == null)
                {
                    id          = lobId;
                    inputStream = result.GetInputStream();
                }
                else
                {
                    id = this._session.CreateBlob(blockLength).GetId();
                    this._resultLobs.Add(lobId, id);
                }
                this._database.lobManager.SetBytesForNewBlob(id, inputStream, result.GetBlockLength());
                break;
            }

            case 8:
            {
                long id;
                long blockLength = result.GetBlockLength();
                if (inputStream == null)
                {
                    id = lobId;
                    if (result.GetReader() != null)
                    {
                        inputStream = new ReaderInputStream(result.GetReader());
                    }
                    else
                    {
                        inputStream = result.GetInputStream();
                    }
                }
                else
                {
                    id = this._session.CreateClob(blockLength).GetId();
                    this._resultLobs.Add(lobId, id);
                }
                this._database.lobManager.SetCharsForNewClob(id, inputStream, result.GetBlockLength());
                break;
            }
            }
        }
예제 #14
0
        public char[] GetChars(ISessionInterface session, long position, int length)
        {
            if (length == 0)
            {
                return(new char[0]);
            }
            Result r       = ResultLob.NewLobGetCharsRequest(this._id, position, length);
            Result result2 = session.Execute(r);

            if (result2.IsError())
            {
                throw result2.GetException();
            }
            return(((ResultLob)result2).GetCharArray());
        }
예제 #15
0
        public int SetString(ISessionInterface session, long pos, string str, int offset, int len)
        {
            if (!IsInLimits((long)str.Length, (long)offset, (long)len))
            {
                throw Error.GetError(0xd49);
            }
            ResultLob r      = ResultLob.NewLobSetCharsRequest(this._id, pos, str.Substring(offset, len).ToCharArray());
            Result    result = session.Execute(r);

            if (result.IsError())
            {
                throw result.GetException();
            }
            return(str.Length);
        }
예제 #16
0
 public Result SetCharsForNewClob(long lobId, Stream inputStream, long length)
 {
     lock (this)
     {
         if (length != 0)
         {
             Result result2 = this.SetBytesIs(lobId, inputStream, length * 2L);
             if (result2.IsError())
             {
                 return(result2);
             }
         }
         return(ResultLob.NewLobSetResponse(lobId, 0L));
     }
 }
예제 #17
0
        public int SetChars(ISessionInterface session, long pos, char[] chars, int offset, int len)
        {
            if (!IsInLimits((long)chars.Length, (long)offset, (long)len))
            {
                throw Error.GetError(0xd49);
            }
            char[] destinationArray = new char[len];
            Array.Copy(chars, offset, destinationArray, 0, len);
            ResultLob r      = ResultLob.NewLobSetCharsRequest(this._id, pos, chars);
            Result    result = session.Execute(r);

            if (result.IsError())
            {
                throw result.GetException();
            }
            return(len);
        }
예제 #18
0
        public int SetBytes(ISessionInterface session, long pos, byte[] bytes, int offset, int len)
        {
            if ((offset != 0) || (len != bytes.Length))
            {
                if (!BinaryData.IsInLimits((long)bytes.Length, (long)offset, (long)len))
                {
                    throw new IndexOutOfRangeException();
                }
                byte[] destinationArray = new byte[len];
                Array.Copy(bytes, offset, destinationArray, 0, len);
                bytes = destinationArray;
            }
            ResultLob r      = ResultLob.NewLobSetBytesRequest(this._id, pos, bytes);
            Result    result = session.Execute(r);

            if (result.IsError())
            {
                throw result.GetException();
            }
            return(bytes.Length);
        }
예제 #19
0
 public Result SetBytes(long lobId, byte[] dataBytes, long offset)
 {
     lock (this)
     {
         if (dataBytes.Length == 0)
         {
             return(ResultLob.NewLobSetResponse(lobId, 0L));
         }
         object[] lobHeader = this.GetLobHeader(lobId);
         if (lobHeader == null)
         {
             return(Result.NewErrorResult(Error.GetError(0xd92)));
         }
         long num = Convert.ToInt64(lobHeader[1]);
         if ((offset + dataBytes.Length) > num)
         {
             this.SetLength(lobId, offset + dataBytes.Length);
         }
         return(this.SetBytesBa(lobId, dataBytes, offset, dataBytes.Length));
     }
 }
예제 #20
0
 public Result GetBytes(long lobId, long offset, int length)
 {
     lock (this)
     {
         byte[] blockBytes;
         int    num         = (int)(offset / ((long)this._lobBlockSize));
         int    sourceIndex = (int)(offset % ((long)this._lobBlockSize));
         int    limit       = (int)((offset + length) / ((long)this._lobBlockSize));
         if (((int)((offset + length) % ((long)this._lobBlockSize))) == 0)
         {
             int num1 = this._lobBlockSize;
         }
         else
         {
             limit++;
         }
         int     destinationIndex = 0;
         byte[]  destinationArray = new byte[length];
         int[][] numArray         = this.GetBlockAddresses(lobId, num, limit);
         if (numArray.Length == 0)
         {
             return(Result.NewErrorResult(Error.GetError(0xd92)));
         }
         int index      = 0;
         int blockCount = (numArray[index][1] + numArray[index][2]) - num;
         if ((numArray[index][1] + numArray[index][2]) > limit)
         {
             blockCount -= (numArray[index][1] + numArray[index][2]) - limit;
         }
         try
         {
             blockBytes = this._lobStore.GetBlockBytes(numArray[index][0] + num, blockCount);
         }
         catch (CoreException exception1)
         {
             return(Result.NewErrorResult(exception1));
         }
         int num7 = (this._lobBlockSize * blockCount) - sourceIndex;
         if (num7 > length)
         {
             num7 = length;
         }
         Array.Copy(blockBytes, sourceIndex, destinationArray, destinationIndex, num7);
         destinationIndex += num7;
         index++;
         while ((index < numArray.Length) && (destinationIndex < length))
         {
             blockCount = numArray[index][1];
             if ((numArray[index][1] + numArray[index][2]) > limit)
             {
                 blockCount -= (numArray[index][1] + numArray[index][2]) - limit;
             }
             try
             {
                 blockBytes = this._lobStore.GetBlockBytes(numArray[index][0], blockCount);
             }
             catch (CoreException exception2)
             {
                 return(Result.NewErrorResult(exception2));
             }
             num7 = this._lobBlockSize * blockCount;
             if (num7 > (length - destinationIndex))
             {
                 num7 = length - destinationIndex;
             }
             Array.Copy(blockBytes, 0, destinationArray, destinationIndex, num7);
             destinationIndex += num7;
             index++;
         }
         return(ResultLob.NewLobGetBytesResponse(lobId, offset, destinationArray));
     }
 }
예제 #21
0
        private void PerformPreExecute()
        {
            for (int i = 0; i < this._parameterValues.Length; i++)
            {
                Stream     stream;
                ClobDataId id2;
                TextReader reader;
                object     obj2 = this._parameterValues[i];
                if (obj2 == null)
                {
                    continue;
                }
                ISessionInterface sessionProxy = this._command.Connection.InnerConnection.SessionProxy;
                if (this._parameterTypes[i].TypeCode != 30)
                {
                    goto Label_010B;
                }
                byte[] buffer = obj2 as byte[];
                if (buffer == null)
                {
                    goto Label_00B1;
                }
                long       length = buffer.Length;
                BlobDataId id     = sessionProxy.CreateBlob(length);
                long       lobId  = id.GetId();
                using (MemoryStream stream2 = new MemoryStream(buffer))
                {
                    ResultLob lob = ResultLob.NewLobCreateBlobRequest(sessionProxy.GetId(), lobId, stream2, length);
                    sessionProxy.AllocateResultLob(lob, null);
                    this._resultOut.AddLobResult(lob);
                }
Label_00A2:
                this._parameterValues[i] = id;
                continue;
Label_00B1:
                stream = obj2 as Stream;
                if (stream != null)
                {
                    long      num4 = this._streamLengths[i];
                    long      num5 = sessionProxy.CreateBlob(num4).GetId();
                    ResultLob lob2 = ResultLob.NewLobCreateBlobRequest(sessionProxy.GetId(), num5, stream, num4);
                    sessionProxy.AllocateResultLob(lob2, null);
                    this._resultOut.AddLobResult(lob2);
                    goto Label_00A2;
                }
                throw new InvalidCastException();
Label_010B:
                if (this._parameterTypes[i].TypeCode != 40)
                {
                    continue;
                }
                string s = obj2 as string;
                if (s == null)
                {
                    char[] chArray = obj2 as char[];
                    if (chArray != null)
                    {
                        s = new string(chArray);
                    }
                }
                if (s == null)
                {
                    goto Label_01AD;
                }
                long num6 = s.Length;
                using (TextReader reader2 = new StringReader(s))
                {
                    id2 = sessionProxy.CreateClob(num6);
                    long      num7 = id2.GetId();
                    ResultLob lob3 = ResultLob.NewLobCreateClobRequest(sessionProxy.GetId(), num7, reader2, num6);
                    sessionProxy.AllocateResultLob(lob3, null);
                    this._resultOut.AddLobResult(lob3);
                }
Label_01A1:
                this._parameterValues[i] = id2;
                continue;
Label_01AD:
                reader = obj2 as TextReader;
                if (reader == null)
                {
                    throw new InvalidCastException();
                }
                long      num8   = this._streamLengths[i];
                long      num9   = sessionProxy.CreateClob(num8).GetId();
                ResultLob result = ResultLob.NewLobCreateClobRequest(sessionProxy.GetId(), num9, reader, num8);
                sessionProxy.AllocateResultLob(result, null);
                this._resultOut.AddLobResult(result);
                goto Label_01A1;
            }
        }
예제 #22
0
        public long Position(ISessionInterface session, byte[] pattern, long start)
        {
            ResultLob r = ResultLob.NewLobGetBytePatternPositionRequest(this._id, pattern, start);

            return(((ResultLob)session.Execute(r)).GetOffset());
        }