Esempio n. 1
0
        public bool ProcessTableDefinitionData(int tableID, byte[] defintionData)
        {
            _id = tableID;

            _fields  = new List <TableField>();
            _memos   = new List <TableMemo>();
            _indexes = new List <TableIndex>();

            RandomAccess ra = new RandomAccess();

            ra.OpenStream(new System.IO.MemoryStream(defintionData));

            _driverVersion = ra.leShort();
            _recordLength  = ra.leShort();
            _noOfFields    = ra.leShort();
            _noOfMemos     = ra.leShort();
            _noOfIndexes   = ra.leShort();


            try {
                for (int t = 0; t < _noOfFields; t++)
                {
                    _fields.Add(new TableField(ref ra));
                }

                for (int t = 0; t < _noOfMemos; t++)
                {
                    _memos.Add(new TableMemo(ref ra));
                }
                for (int t = 0; t < _noOfIndexes; t++)
                {
                    _indexes.Add(new TableIndex(ref ra));
                }
            } catch (Exception ex) {
                throw new Exception("Bad Table Definition ", ex);
            }

            ra       = null;
            _tableDT = BuildEmptyDataTable();

            return(true);
        }
Esempio n. 2
0
        /// <summary>
        /// Returns all records of the page
        /// <returns></returns>
        public List <TPSRecord> GetRecords()
        {
            List <TPSRecord> records = new List <TPSRecord>();

            byte[] pageData = GetData();
            //go through each record in the page
            RandomAccess ra = new RandomAccess();

            ra.OpenStream(new MemoryStream(pageData));

            records.Clear();
            // Skip pages with non 0x00 flags as they don't seem to contain TpsRecords.
            if (flags == 0x00)
            {
                //data.pushPosition();
                try {
                    TPSRecord prev = null;
                    do
                    {
                        TPSRecord current = null;
                        if (prev == null)
                        {
                            current = new TPSRecord(ref ra);
                        }
                        else
                        {
                            current = new TPSRecord(ref prev, ref ra);
                        }

                        records.Add(current);
                        prev = current;
                    } while (!ra.isAtEnd() && records.Count < recordCount);
                } finally {
                    //data.popPosition();
                }
            }

            return(records);
        }