Exemplo n.º 1
0
        public bool checkDbTest(
            string sDbName,
            DbSystem dbSystem)
        {
            MyDbCheckStatus dbCheckStatus = null;
            DbInfo          dbInfo        = null;
            XFLM_DB_HDR     dbHdr         = new XFLM_DB_HDR();

            // Try restoring the database

            beginTest("Check Database Test (" + sDbName + ")");

            dbCheckStatus = new MyDbCheckStatus();
            try
            {
                dbInfo = dbSystem.dbCheck(sDbName, null, null, null,
                                          DbCheckFlags.XFLM_ONLINE | DbCheckFlags.XFLM_DO_LOGICAL_CHECK,
                                          dbCheckStatus);
            }
            catch (XFlaimException ex)
            {
                endTest(dbCheckStatus.outputLines(), ex, "checking database");
                return(false);
            }

            dbInfo.getDbHdr(dbHdr);
            System.Console.Write("\n");
            System.Console.WriteLine("Signature............. {0}", dbHdr.szSignature);
            System.Console.WriteLine("Database Version...... {0}", dbHdr.ui32DbVersion);
            System.Console.WriteLine("Block Size............ {0}", dbHdr.ui16BlockSize);

            if (dbHdr.szSignature != "FLAIMDB")
            {
                endTest(true, false);
                System.Console.WriteLine("Invalid signature in database header");
                return(false);
            }
            if (dbHdr.ui16BlockSize != 8192 && dbHdr.ui16BlockSize != 4096)
            {
                endTest(true, false);
                System.Console.WriteLine("Invalid block size in database header");
                return(false);
            }
            if ((DBVersions)dbHdr.ui32DbVersion != DBVersions.XFLM_CURRENT_VERSION_NUM)
            {
                endTest(true, false);
                System.Console.WriteLine("Invalid version in database header");
                return(false);
            }
            endTest(true, true);
            return(true);
        }