Beispiel #1
0
        public MyStream(BaseStream parent,string fname,string sname,string prefix,string connStr,uint timeout)
        {
            this.parent = parent;
            this.StreamName = fname;
            this.full_name = fname;
            this.short_name = sname;
            this.prefix = prefix;
            this.timeout = timeout;

            CP2TableSet tableset = new CP2TableSetClass();
            tableset.InitFromIni2((this.parent.parent as MainForm).schemeIni, short_name);
            this.TableSet = tableset;
            this.buffer = new DataBuffer(this,this.full_name,connStr + ";Timeout=360;CommandTimeout=360;");

            this.StreamDataInserted+=new IP2DataStreamEvents_StreamDataInsertedEventHandler(this.DI);
            this.StreamDataDeleted+=new IP2DataStreamEvents_StreamDataDeletedEventHandler(this.DD);
            this.StreamDataUpdated+=new IP2DataStreamEvents_StreamDataUpdatedEventHandler(this.DU);
            this.StreamLifeNumChanged += new IP2DataStreamEvents_StreamLifeNumChangedEventHandler(this.lifeNumChanged);
            this.StreamDatumDeleted += new IP2DataStreamEvents_StreamDatumDeletedEventHandler(this.DUD);
        }
Beispiel #2
0
 internal bool WriteStream(BaseStream stream)
 {
     return WriteStream(stream as TextCommandStream);
 }
Beispiel #3
0
 /// <summary>
 /// Seek bzgl. des Streamanfangs
 /// </summary>
 /// <param name="pos"></param>
 /// <param name="where"></param>
 /// <returns></returns>
 public long Seek(long pos, SeekOrigin where = SeekOrigin.Begin)
 {
     return(BaseStream.Seek(pos, where));
 }
 public void Dispose()
 {
     BaseStream.Dispose();
 }
 public void SetBufferSize(int length)
 {
     BaseStream.SetLength(length);
 }
Beispiel #6
0
 /// <summary>
 /// Writes an enumerable of <see cref="Int64"/> values to the underlying stream.
 /// </summary>
 /// <param name="values">The values to write.</param>
 public void WriteInt64s(IEnumerable <Int64> values)
 => BaseStream.Write(values, ByteConverter);
Beispiel #7
0
 /// <summary>
 /// Writes an <see cref="Int64"/> value to the underlying stream.
 /// </summary>
 /// <param name="value">The value to write.</param>
 public void WriteInt64(Int64 value)
 => BaseStream.Write(value, ByteConverter);
Beispiel #8
0
 /// <summary>
 /// Returns an array of <see cref="Int64"/> instances read asynchronously from the underlying stream.
 /// </summary>
 /// <param name="count">The number of values to read.</param>
 /// <param name="cancellationToken">The token to monitor for cancellation requests.</param>
 /// <returns>The array of values read from the current stream.</returns>
 public async Task <Int64[]> ReadInt64sAsync(int count,
                                             CancellationToken cancellationToken = default(CancellationToken))
 => await BaseStream.ReadInt64sAsync(count, ByteConverter, cancellationToken);
 /// <summary>
 /// Sets the position within the current stream.
 /// </summary>
 /// <param name="offset">A byte offset relative to the origin parameter.</param>
 /// <param name="origin">
 /// A value of type System.IO.SeekOrigin indicating the reference point used
 /// to obtain the new position.</param>
 /// <returns>The new position within the current stream.</returns>
 public override long Seek(long offset, SeekOrigin origin)
 {
     return(BaseStream.Seek(offset, origin));
 }
Beispiel #10
0
 public void Seek(long pos, SeekOrigin origin)
 {
     BaseStream.Seek(pos, origin);
 }
        /// <summary>
        /// Clears all output buffers for this stream and causes any buffered data to be written
        /// to the underlying device.
        /// </summary>
        /// <returns>A task that represents the asynchronous flush operation.</returns>
        /// <exception cref="System.ObjectDisposedException">
        /// The stream has been disposed.
        /// </exception>
        /// <exception cref="System.NotSupportedException">
        /// The stream does not support writing.
        /// </exception>
        /// <exception cref="System.IO.IOException">
        /// An I/O error occurred.
        /// </exception>
        public override Task FlushAsync(CancellationToken cancellationToken)
        {
            CheckDisposed();

            return(BaseStream.FlushAsync(cancellationToken));
        }
        /// <summary>
        /// Clears all output buffers for this stream and causes any buffered data to be written
        /// to the underlying device.
        /// </summary>
        /// <exception cref="System.ObjectDisposedException">
        /// The stream has been disposed.
        /// </exception>
        /// <exception cref="System.NotSupportedException">
        /// The stream does not support writing.
        /// </exception>
        /// <exception cref="System.IO.IOException">
        /// An I/O error occurred.
        /// </exception>
        public override void Flush()
        {
            CheckDisposed();

            BaseStream.Flush();
        }
Beispiel #13
0
 public override void set_FileLengthInPhysicalFileDB(FileDB File, Int64 Value)
 {
     BaseStream.Position = 16 + 44 * IndexOfFile[File] + 36;
     BaseStream.WriteInt32(Convert.ToInt32(Value));
 }
Beispiel #14
0
 //读取文件在索引中的长度信息,所有索引中的长度信息应该在这里更新
 public override Int64 get_FileLengthInPhysicalFileDB(FileDB File)
 {
     BaseStream.Position = 16 + 44 * IndexOfFile[File] + 36;
     return(BaseStream.ReadInt32());
 }
Beispiel #15
0
 public override void Flush()
 {
     BaseStream.Flush();
 }
Beispiel #16
0
        override public String ReadString()
        {
            char[] resultBuffer = null;
            try
            {
                MemoryStream memoryStream = this.BaseStream as MemoryStream;

                int currPos = 0;
                int n       = 0;
                int stringLength;
                int readLength;
                int charsRead = 0;

                // Length of the string in bytes, not chars
                stringLength = Read7BitEncodedInt();
                if (stringLength < 0)
                {
                    throw new IOException();
                }

                if (stringLength == 0)
                {
                    return(String.Empty);
                }

                char[] charBuffer = _buffer.CharBuffer;
                do
                {
                    readLength = ((stringLength - currPos) > MaxCharsBuffer) ? MaxCharsBuffer : (stringLength - currPos);

                    byte[] rawBuffer   = null;
                    int    rawPosition = 0;

                    if (memoryStream != null)
                    {
                        // Optimization: we can avoid reading into a byte buffer
                        // and instead read directly from the memorystream's backing buffer
                        rawBuffer   = memoryStream.GetBuffer();
                        rawPosition = (int)memoryStream.Position;
                        int length = (int)memoryStream.Length;
                        n = (rawPosition + readLength) < length ? readLength : length - rawPosition;

                        // Attempt to track down an intermittent failure -- n should not ever be negative, but
                        // we're occasionally seeing it when we do the decoder.GetChars below -- by providing
                        // a bit more information when we do hit the error, in the place where (by code inspection)
                        // the actual error seems most likely to be occurring.
                        if (n < 0)
                        {
                            ErrorUtilities.ThrowInternalError("From calculating based on the memorystream, about to read n = {0}. length = {1}, rawPosition = {2}, readLength = {3}, stringLength = {4}, currPos = {5}.", n, length, rawPosition, readLength, stringLength, currPos);
                        }

                        memoryStream.Seek(n, SeekOrigin.Current);
                    }

                    if (rawBuffer == null)
                    {
                        rawBuffer   = _buffer.ByteBuffer;
                        rawPosition = 0;
                        n           = BaseStream.Read(rawBuffer, 0, readLength);

                        // See above explanation -- the OutOfRange exception may also be coming from our setting of n here ...
                        if (n < 0)
                        {
                            ErrorUtilities.ThrowInternalError("From getting the length out of BaseStream.Read directly, about to read n = {0}. readLength = {1}, stringLength = {2}, currPos = {3}", n, readLength, stringLength, currPos);
                        }
                    }

                    if (n == 0)
                    {
                        throw new EndOfStreamException();
                    }

                    if (currPos == 0 && n == stringLength)
                    {
                        charsRead = _decoder.GetChars(rawBuffer, rawPosition, n, charBuffer, 0);
                        return(Strings.WeakIntern(charBuffer.AsSpan(0, charsRead)));
                    }
#if !CLR2COMPATIBILITY
                    resultBuffer ??= ArrayPool <char> .Shared.Rent(stringLength); // Actual string length in chars may be smaller.
#else
                    // Since NET35 is only used in rare TaskHost processes, we decided to leave it as-is.
                    resultBuffer ??= new char[stringLength]; // Actual string length in chars may be smaller.
#endif
                    charsRead += _decoder.GetChars(rawBuffer, rawPosition, n, resultBuffer, charsRead);

                    currPos += n;
                }while (currPos < stringLength);

                var retval = Strings.WeakIntern(resultBuffer.AsSpan(0, charsRead));

                return(retval);
            }
            catch (Exception e)
            {
                Debug.Assert(false, e.ToString());
                throw;
            }
#if !CLR2COMPATIBILITY
            finally
            {
                // resultBuffer shall always be either Rented or null
                if (resultBuffer != null)
                {
                    ArrayPool <char> .Shared.Return(resultBuffer);
                }
            }
#endif
        }
Beispiel #17
0
 public override void SetLength(long value)
 {
     BaseStream.SetLength(value);
 }
Beispiel #18
0
 private void MoveTo(uint raw)
 {
     BaseStream.Seek(raw, SeekOrigin.Begin);
 }
Beispiel #19
0
 /// <summary>
 /// Writes an enumerable of <see cref="Int64"/> values to the underlying stream.
 /// </summary>
 /// <param name="values">The values to write.</param>
 /// <param name="cancellationToken">The token to monitor for cancellation requests.</param>
 public async Task WriteAsync(IEnumerable <Int64> values,
                              CancellationToken cancellationToken = default(CancellationToken))
 => await BaseStream.WriteAsync(values, ByteConverter, cancellationToken);
Beispiel #20
0
 private void Advance(int bytes)
 {
     BaseStream.Seek(bytes, SeekOrigin.Current);
 }
Beispiel #21
0
 /// <summary>
 /// Writes an <see cref="Int64"/> value to the underlying stream.
 /// </summary>
 /// <param name="value">The value to write.</param>
 /// <param name="cancellationToken">The token to monitor for cancellation requests.</param>
 public async Task WriteInt64Async(Int64 value, CancellationToken cancellationToken = default(CancellationToken))
 => await BaseStream.WriteAsync(value, ByteConverter, cancellationToken);
Beispiel #22
0
 public void Close()
 {
     BaseStream.Close();
 }
Beispiel #23
0
 public void Deactivate()
 {
     BaseStream.Flush();
     IsActive = false;
 }
Beispiel #24
0
 void MoveTo(uint pointer)
 {
     BaseStream.Seek(pointer, SeekOrigin.Begin);
 }
Beispiel #25
0
 public void ReadBytes(int address, byte[] buffer, int offset, int length)
 {
     BaseStream.Position = address;
     BaseStream.Read(buffer, offset, length);
 }
Beispiel #26
0
 void MoveToRVA(Section section, RVA rva)
 {
     BaseStream.Seek(section.PointerToRawData + rva - section.VirtualAddress, SeekOrigin.Begin);
 }
Beispiel #27
0
 /// <summary>
 /// kopiert die restlichen Bytes des Streams
 /// </summary>
 /// <param name="stream"></param>
 public void CopyTo(Stream stream)
 {
     BaseStream.Seek(0, SeekOrigin.Begin);
     BaseStream.CopyTo(stream);
 }
Beispiel #28
0
        // ---- METHODS (PUBLIC) ---------------------------------------------------------------------------------------

        // ---- Read ----

        /// <summary>
        /// Returns an <see cref="Int64"/> instance read from the underlying stream.
        /// </summary>
        /// <returns>The value read from the current stream.</returns>
        public Int64 ReadInt64()
        => BaseStream.ReadInt64(ByteConverter);
Beispiel #29
0
 public void Flush()
 {
     BaseStream.Flush();
 }
Beispiel #30
0
 /// <summary>
 /// Returns an <see cref="Int64"/> instance read asynchronously from the underlying stream.
 /// </summary>
 /// <param name="cancellationToken">The token to monitor for cancellation requests.</param>
 /// <returns>The value read from the current stream.</returns>
 public async Task <Int64> ReadInt64Async(CancellationToken cancellationToken = default(CancellationToken))
 => await BaseStream.ReadInt64Async(ByteConverter, cancellationToken);
        private object xQueueNotifyLock = new object(); // обьект для блокировки очереди поступивших сигналов

        #endregion Fields

        #region Constructors

        public OrdersThread(BaseStream bs,string host,uint port,string pass,string pgConStr,string shemeIni)
        {
            this.bs = bs;
            this.parent = bs.parent;
            this.m_Host = host;
            this.m_Port = port;
            this.m_Pass = pass;
            m_msgFactory = new CP2BLMessageFactory();
            m_msgFactory.Init(shemeIni,"");

            pgConNotify = new NpgsqlConnection(pgConStr);
            pgConSelect = new NpgsqlConnection(pgConStr);
            pgConUpdate = new NpgsqlConnection(pgConStr);

            this.queueMsg = new OrderedDictionary();
            this.queueNotify = new Hashtable();
            this.queueMsgHist = new OrderedDictionary();

            pgConNotify.Notification += new NotificationEventHandler(conNotify);
            pgConNotify.StateChange += new System.Data.StateChangeEventHandler(this.conStateChanged);

            this.mFutOrders = new Orders.futOrders(this);
            this.mFutChangeClientMoney = new Orders.changeClientMoney(this);
            this.mOptOrders = new Orders.optOrders(this);
            this.mOptChangeExp = new Orders.optChangeExpiration(this);
        }
Beispiel #32
0
 /// <summary>
 /// Returns an array of <see cref="Int64"/> instances read from the underlying stream.
 /// </summary>
 /// <param name="count">The number of values to read.</param>
 /// <returns>The array of values read from the current stream.</returns>
 public Int64[] ReadInt64s(int count)
 => BaseStream.ReadInt64s(count, ByteConverter);
Beispiel #33
0
        private void MainForm_Shown(object sender, EventArgs e)
        {
            m_BasePing = new BasePing(this, this.connStr);
            m_BaseStream = new BaseStream(this);
            mLog = new Log(this, this.pPath);
            if (this.fullDump == 1)
                this.fullDumpCheck.Checked = true;

            if (this.autoStartStopConfig == 1)
                this.autoStopStartMenu.Checked = true;
        }
Beispiel #34
0
        /// <summary>
        ///     When overridden in a derived class, sets the length of the current stream.
        /// </summary>
        /// <param name='value'>
        ///     The desired length of the current stream in bytes.
        /// </param>
        public override void SetLength(long value)
        {
            InternalFlushBuffer(true);

            BaseStream.SetLength(value);
        }