Exemple #1
0
        /// <summary>
        /// Sends the specified data.
        /// </summary>
        /// <param name="aString">The data.</param>
        /// <param name="raw">whether or not to send raw data</param>
        /// <param name="close">if set to <c>true</c> [close].</param>
        public void Send(String aString, bool raw = false, bool close = false)
        {
            DataFrame dataFrame = DataFrame.CreateInstance();

            dataFrame.Append(aString);
            Context.Handler.Send(dataFrame, Context, raw, close);
        }
        /// <summary>
        /// This method overrides the Execute method from AbstractSqlServerExtensionExecutor.
        /// </summary>
        /// <param name="input">
        /// A C# DataFrame contains the input dataset.
        /// </param>
        /// <param name="sqlParams">
        /// A Dictionary contains the parameters from SQL server with name as the key.
        /// </param>
        /// <returns>
        /// A C# DataFrame contains the output dataset.
        /// </returns>
        public override DataFrame Execute(DataFrame input, Dictionary <string, dynamic> sqlParams)
        {
            // Drop NULL values and sort by id
            //
            input = input.DropNulls().OrderBy("id");

            // Create empty output DataFrame with two columns
            //
            DataFrame output = new DataFrame(new PrimitiveDataFrameColumn <int>("id", 0), new StringDataFrameColumn("text", 0));

            // Filter text containing specific substring using regex expression
            //
            DataFrameColumn texts = input.Columns["text"];

            for (int i = 0; i < texts.Length; ++i)
            {
                if (Regex.IsMatch((string)texts[i], sqlParams["@regexExpr"]))
                {
                    output.Append(input.Rows[i], true);
                }
            }

            // Modify the parameters
            //
            sqlParams["@rowsCount"] = output.Rows.Count;
            sqlParams["@regexExpr"] = "Success!";

            // Return output dataset as a DataFrame
            //
            return(output);
        }
        public void Disconnect()
        {
            _connecting = false;

            if (_client == null)
            {
                return;
            }
            var dataFrame = new DataFrame();

            dataFrame.Append(new byte[0]);

            var bytes = dataFrame.AsFrame()[0].Array;

            ReadyState = ReadyStates.CLOSING;

            bytes[0] = 0x88;
            if (_context != null && _context.UserContext != null)
            {
                _context.UserContext.Send(bytes);
            }

            _client.Close();
            _client    = null;
            ReadyState = ReadyStates.CLOSED;
        }
Exemple #4
0
        /// <summary>
        /// Sends the specified data.
        /// </summary>
        /// <param name="someBytes">The data.</param>
        /// <param name="raw">whether or not to send raw data</param>
        /// <param name="close">if set to <c>true</c> [close].</param>
        public void Send(byte[] someBytes, bool raw = false, bool close = false)
        {
            DataFrame dataFrame = DataFrame.CreateInstance();

            dataFrame.IsByte = true;
            dataFrame.Append(someBytes);
            Context.Handler.Send(dataFrame, Context, raw, close);
        }
        /// <summary>
        /// Sends the specified data buffer.
        /// </summary>
        /// <param name="buffer">The data.</param>
        /// <param name="byteCount">Count of bytes from beginning of buffer. -1 = all bytes.</param>
        /// <param name="raw">if set to <c>true</c> do not add header and do not mask the buffer before sending.</param>
        /// <param name="close">if set to <c>true</c> close the socket after sending.</param>
        public void Send(byte[] buffer, int byteCount = -1, bool raw = false, bool close = false)
        {
            DataFrame dataFrame = DataFrame.CreateInstance();

            dataFrame.IsBinary = true;
            dataFrame.Append(buffer, byteCount);
            Context.Handler.Send(dataFrame, Context, raw, close);
        }