Exemplo n.º 1
0
        protected override DbCommand CreateDbCommand()
        {
            QaCommand cmd = new QaCommand();

            cmd.Connection = this;
            return(cmd);
        }
Exemplo n.º 2
0
 protected override DbCommand CreateDbCommand()
 {
     QaCommand cmd = new QaCommand();
     cmd.Connection = this;
     return cmd;
 }
Exemplo n.º 3
0
        internal QaDataReaderRIndex(QaCommand cm, ref QaConnection.Index sysindex, System.Net.Sockets.NetworkStream ns)
            : base()
        {
            cmd             = cm;
            netstm          = ns;
            isClosed        = false;
            eof             = false;
            isRindexEnabled = cm.conn.isRIndexEnabled();

            {
                int columnCount = sysindex.Table.Columns.Length;
                metadata = new MetaData[columnCount];
                ordinals = new Dictionary <string, int>();

                recordsize = 0;
                for (int i = 0; i < columnCount; i++)
                {
                    string cname = sysindex.Table.Columns[i].Name;

                    Type type;
                    {
                        string colType = sysindex.Table.Columns[i].Type;
                        if (colType.StartsWith("char(", StringComparison.OrdinalIgnoreCase))
                        {
                            colType = "char";
                        }
                        switch (colType)
                        {
                        case "long":
                            type = typeof(System.Int64);
                            break;

                        case "int":
                            type = typeof(System.Int32);
                            break;

                        case "double":
                            type = typeof(System.Double);
                            break;

                        case "char":
                            type = typeof(System.String);
                            break;

                        case "DateTime":
                            type = typeof(System.DateTime);
                            break;

                        default:
                            throw new Exception("Type: " + colType + " is invalid.");
                        }
                    }

                    int frontbytes = 1;

                    int csize = sysindex.Table.Columns[i].Bytes - 1;

                    int backbytes = 0;

                    MetaData md = MetaData.Prepare(cname, type, csize, frontbytes, backbytes);
                    metadata[i] = md;

                    recordsize += csize + frontbytes + backbytes;

                    ordinals[cname.ToLower()] = i;
                }

                if (null == cmd.buf ||
                    cmd.buf.Length < recordsize)
                {
                    cmd.buf = new byte[recordsize];
                }

                currow = new object[columnCount];
            }
        }
Exemplo n.º 4
0
        // Note: the below constructor isn't used for rindex.
        public QaDataReader(QaCommand cm, System.Net.Sockets.NetworkStream ns)
        {
            cmd             = cm;
            netstm          = ns;
            isClosed        = false;
            eof             = false;
            isRindexEnabled = cm.conn.isRIndexEnabled();

            //Get metadata
            try
            {
                //column count
                int bc = 0;
                cmd.buf = XContent.ReceiveXBytes(netstm, out bc, cmd.buf);

                if (bc != 4)
                {
                    throw new Exception("Column count expected 4 bytes.");
                }

                int columnCount = Utils.BytesToInt(cmd.buf);
                metadata = new MetaData[columnCount];
                ordinals = new Dictionary <string, int>();

                recordsize = 0;
                for (int i = 0; i < columnCount; i++)
                {
                    string cname = XContent.ReceiveXString(netstm, cmd.buf);
                    string ctype = XContent.ReceiveXString(netstm, cmd.buf);
                    cmd.buf = XContent.ReceiveXBytes(netstm, out bc, cmd.buf);
                    if (bc != 4)
                    {
                        throw new Exception("Front bytes expected 4 bytes.");
                    }
                    int frontbytes = Utils.BytesToInt(cmd.buf);
                    cmd.buf = XContent.ReceiveXBytes(netstm, out bc, cmd.buf);
                    if (bc != 4)
                    {
                        throw new Exception("Size expected 4 bytes.");
                    }
                    int csize = Utils.BytesToInt(cmd.buf);
                    cmd.buf = XContent.ReceiveXBytes(netstm, out bc, cmd.buf);
                    if (bc != 4)
                    {
                        throw new Exception("Back bytes expected 4 bytes.");
                    }
                    int backbytes = Utils.BytesToInt(cmd.buf);

                    MetaData md = MetaData.Prepare(cname, Type.GetType(ctype), csize, frontbytes, backbytes);
                    metadata[i] = md;

                    recordsize += csize + frontbytes + backbytes;

                    ordinals[cname.ToLower()] = i;
                }

                if (null == cmd.buf ||
                    cmd.buf.Length < recordsize)
                {
                    cmd.buf = new byte[recordsize];
                }

                currow = new object[columnCount];
            }
            catch
            {
                cmd.Abort();
                throw;
            }
        }