public bool createDbTest(
			string	sDbName,
			DbSystem	dbSystem)
        {
            Db			db = null;
            RCODE	rc;

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

            for (;;)
            {
                rc = RCODE.NE_XFLM_OK;
                try
                {
                    XFLM_CREATE_OPTS	createOpts = new XFLM_CREATE_OPTS();

                    createOpts.uiBlockSize = 8192;
                    createOpts.uiVersionNum = (uint)DBVersions.XFLM_CURRENT_VERSION_NUM;
                    createOpts.uiMinRflFileSize = 2000000;
                    createOpts.uiMaxRflFileSize = 20000000;
                    createOpts.bKeepRflFiles = 1;
                    createOpts.bLogAbortedTransToRfl = 1;
                    createOpts.eDefaultLanguage = Languages.FLM_DE_LANG;
                    db = dbSystem.dbCreate( sDbName, null, null, null, null, createOpts);
                }
                catch (XFlaimException ex)
                {
                    rc = ex.getRCode();

                    if (rc != RCODE.NE_XFLM_FILE_EXISTS)
                    {
                        endTest( false, ex, "creating database");
                        return( false);
                    }
                }
                if (rc == RCODE.NE_XFLM_OK)
                {
                    break;
                }

                // rc better be NE_XFLM_FILE_EXISTS - try to delete the file

                try
                {
                    dbSystem.dbRemove( sDbName, null, null, true);
                }
                catch (XFlaimException ex)
                {
                    endTest( false, ex, "removing database");
                    return( false);
                }
            }
            if (db != null)
            {
                db.close();
                db = null;
            }
            endTest( false, true);
            return( true);
        }
        public bool rebuildDbTest(
			string	sSrcDbName,
			string	sDestDbName,
			DbSystem	dbSystem)
        {
            MyDbRebuildStatus	dbRebuildStatus = null;
            XFLM_CREATE_OPTS	createOpts = null;

            // Try restoring the database

            beginTest( "Rebuild Database Test (" + sSrcDbName + " to " + sDestDbName + ")");

            dbRebuildStatus = new MyDbRebuildStatus();
            createOpts = new XFLM_CREATE_OPTS();

            createOpts.uiBlockSize = 8192;
            createOpts.uiVersionNum = (uint)DBVersions.XFLM_CURRENT_VERSION_NUM;
            createOpts.uiMinRflFileSize = 2000000;
            createOpts.uiMaxRflFileSize = 20000000;
            createOpts.bKeepRflFiles = 1;
            createOpts.bLogAbortedTransToRfl = 1;
            createOpts.eDefaultLanguage = Languages.FLM_DE_LANG;
            try
            {
                dbSystem.dbRebuild( sSrcDbName, null, sDestDbName, null, null,
                    null, null, createOpts, dbRebuildStatus);
            }
            catch (XFlaimException ex)
            {
                endTest( dbRebuildStatus.outputLines(), ex, "rebuilding database");
                return( false);
            }

            endTest( true, true);
            return( true);
        }
        public bool domNodesTest(
            string	sDbName,
            DbSystem	dbSystem)
        {
            bool	bOk = false;
            Db		db = null;
            bool	bStartedTrans = false;
            RCODE	rc;

            // Create the database

            beginTest( "Create database \"" + sDbName + "\"");

            for (;;)
            {
                rc = RCODE.NE_XFLM_OK;
                try
                {
                    XFLM_CREATE_OPTS	createOpts = new XFLM_CREATE_OPTS();

                    createOpts.uiBlockSize = 8192;
                    createOpts.uiVersionNum = (uint)DBVersions.XFLM_CURRENT_VERSION_NUM;
                    createOpts.uiMinRflFileSize = 2000000;
                    createOpts.uiMaxRflFileSize = 20000000;
                    createOpts.bKeepRflFiles = 1;
                    createOpts.bLogAbortedTransToRfl = 1;
                    createOpts.eDefaultLanguage = Languages.FLM_DE_LANG;
                    db = dbSystem.dbCreate( sDbName, null, null, null, null, createOpts);
                }
                catch (XFlaimException ex)
                {
                    rc = ex.getRCode();

                    if (rc != RCODE.NE_XFLM_FILE_EXISTS)
                    {
                        endTest( false, ex, "creating database");
                        return( false);
                    }
                }
                if (rc == RCODE.NE_XFLM_OK)
                {
                    break;
                }

                // rc better be NE_XFLM_FILE_EXISTS - try to delete the file

                try
                {
                    dbSystem.dbRemove( sDbName, null, null, true);
                }
                catch (XFlaimException ex)
                {
                    endTest( false, ex, "removing database");
                    return( false);
                }
            }
            endTest( false, true);

            // Start a transaction

            beginTest( "Start Update Transaction Test");
            try
            {
                db.transBegin( eDbTransType.XFLM_UPDATE_TRANS, 255, 0);
            }
            catch (XFlaimException ex)
            {
                endTest( false, ex, "starting update transaction");
                goto Exit;
            }
            endTest( false, true);
            bStartedTrans = true;

            // Create a document

            if (!createDocumentTest( db))
            {
                goto Exit;
            }

            // Commit the transaction

            beginTest( "Commit Update Transaction Test");
            try
            {
                bStartedTrans = false;
                db.transCommit();
            }
            catch (XFlaimException ex)
            {
                endTest( false, ex, "committing update transaction");
                goto Exit;
            }
            endTest( false, true);

            bOk = true;

            Exit:
            if (bStartedTrans)
            {
                db.transAbort();
            }
            if (db != null)
            {
                db.close();
                db = null;
            }
            return( bOk);
        }
示例#4
0
        //-----------------------------------------------------------------------------
        // dbRebuild
        //-----------------------------------------------------------------------------
        /// <summary>
        /// Rebuild a database.
        /// </summary>
        /// <param name="sSourceDbPath">
        /// The name of the control file of the database that is to be rebuilt.
        /// </param>
        /// <param name="sSourceDataDir">
        /// The data file directory.  See <see cref="dbCreate"/> for more information.
        /// </param>
        /// <param name="sDestDbPath">
        /// The name of the control file of the destination
        /// database that is to be built from the source database.
        /// </param>
        /// <param name="sDestDataDir">
        /// The destination database's data file directory.  See <see cref="dbCreate"/> for
        /// more information.
        /// </param>
        /// <param name="sDestRflDir">
        /// The destination database's roll-forward log
        /// directory.  See <see cref="dbCreate"/> for more information.
        /// </param>
        /// <param name="sDictPath">
        /// The name of a file containing dictionary definitions that
        /// are to be put into the destination database when it is created.
        /// May be null.
        /// </param>
        /// <param name="sPassword">
        /// Password for opening the source database.  This is only needed
        /// if the database key is currently wrapped in a password instead of the
        /// local NICI storage key.  May be null.
        /// </param>
        /// <param name="createOpts">
        /// A <see cref="XFLM_CREATE_OPTS"/> object that contains several parameters that
        /// are used in the creation of the destination database.
        /// </param>
        /// <param name="rebuildStatus">
        /// If non-null this is an object that implements the <see cref="DbRebuildStatus"/>
        /// interface.  It is a callback object that is used to report rebuild progress.
        /// </param>
        public void dbRebuild(
			string				sSourceDbPath,
			string				sSourceDataDir,
			string				sDestDbPath,
			string				sDestDataDir,
			string				sDestRflDir,
			string				sDictPath,
			string				sPassword,
			XFLM_CREATE_OPTS	createOpts,
			DbRebuildStatus	rebuildStatus)
        {
            RCODE							rc;
            DbRebuildStatusDelegate	dbRebuildStatus = null;
            DbRebuildStatusCallback	fnDbRebuildStatus = null;

            if (rebuildStatus != null)
            {
                dbRebuildStatus = new DbRebuildStatusDelegate( rebuildStatus);
                fnDbRebuildStatus = new DbRebuildStatusCallback( dbRebuildStatus.funcDbRebuildStatus);
            }

            if ((rc = xflaim_DbSystem_dbRebuild( m_pDbSystem, sSourceDbPath, sSourceDataDir, sDestDbPath,
                sDestDataDir, sDestRflDir, sDictPath, sPassword,
                createOpts, fnDbRebuildStatus)) != 0)
            {
                throw new XFlaimException( rc);
            }
        }
示例#5
0
        //-----------------------------------------------------------------------------
        // dbCreate
        //-----------------------------------------------------------------------------
        /// <summary>
        /// Creates a new XFlaim database.
        /// </summary>
        /// <param name="sDbFileName">
        /// This is the name of the control file for the database.
        /// The control file is the primary database name.  It may include a full
        /// or partial directory name, or no directory name.  If a partial directory
        /// name or is included, it is assumed to be relative to the current working
        /// directory.  If no directory is specified, the file will be created in
        /// the current working directory.
        /// </param>
        /// <param name="sDataDir">
        /// The directory where the database data files are stored.
        /// If null, the data files will be stored in the same directory as the control
        /// file.
        /// </param>
        /// <param name="sRflDir">
        /// The directory where the roll forward log files should be
        /// stored.  If null, this defaults to the same directory where the control file
        /// exists.  Within this directory, XFLAIM expects a subdirectory to exist that
        /// holds the RFL files.  The subdirectory name is derived from the control
        /// file's base name. If the control file's base name has an extension
        /// of ".db", the ".db" is replaced with ".rfl".  If the control file's base
        /// name does not have an extension of ".db", an extension of ".rfl" is simply
        /// appended to the control file's base name.  For example, if the control file's
        /// base name is "MyDatabase.db", the subdirectory will be named "MyDatabase.rfl".
        /// If the control file's base name is "MyDatabase.xyz", the subdirectory will be
        /// named "MyDatabase.xyz.rfl".
        /// </param>
        /// <param name="sDictFileName">
        /// The name of a file which contains dictionary
        /// definition items.  May be null.  Ignored if sDictBuf is non-null.
        /// </param>
        /// <param name="sDictBuf">
        /// Contains dictionary definitions.  If null,
        /// sDictFileName is used.  If both sDictFileName and sDictBuf are null,
        /// the database is created with an empty dictionary.
        /// </param>
        /// <param name="createOpts">
        /// A structure that contains several parameters that affect the creation
        /// of the database.
        /// </param>
        /// <returns>An instance of a <see cref="Db"/> object.</returns>
        public Db dbCreate(
			string 				sDbFileName,
			string 				sDataDir,
			string 				sRflDir,
			string 				sDictFileName,
			string 				sDictBuf,
			XFLM_CREATE_OPTS	createOpts)
        {
            IntPtr	pDb;
            RCODE		rc;

            if ((rc = xflaim_DbSystem_dbCreate( m_pDbSystem, sDbFileName, sDataDir, sRflDir,
                sDictFileName, sDictBuf, createOpts, out pDb)) != 0)
            {
                throw new XFlaimException( rc);
            }
            return( new Db( pDb, this));
        }
示例#6
0
        private static extern RCODE xflaim_DbSystem_dbRebuild(
			IntPtr						pDbSystem,
			[MarshalAs(UnmanagedType.LPStr), In]
			string						pszSourceDbPath,
			[MarshalAs(UnmanagedType.LPStr), In]
			string 						pszSourceDataDir,
			[MarshalAs(UnmanagedType.LPStr), In]
			string 						pszDestDbPath,
			[MarshalAs(UnmanagedType.LPStr), In]
			string 						pszDestDataDir,
			[MarshalAs(UnmanagedType.LPStr), In]
			string 						pszDestRflDir,
			[MarshalAs(UnmanagedType.LPStr), In]
			string 						pszDictPath,
			[MarshalAs(UnmanagedType.LPStr), In]
			string 						pszPassword,
			XFLM_CREATE_OPTS			pCreateOpts,
			DbRebuildStatusCallback	fnDbRebuildStatus);
示例#7
0
        private static extern RCODE xflaim_DbSystem_dbCreate(
			IntPtr				pDbSystem,
			[MarshalAs(UnmanagedType.LPStr), In]
			string				pszDbFileName,
			[MarshalAs(UnmanagedType.LPStr), In]
			string 				pszDataDir,
			[MarshalAs(UnmanagedType.LPStr), In]
			string 				pszRflDir,
			[MarshalAs(UnmanagedType.LPStr), In]
			string 				pszDictFileName,
			[MarshalAs(UnmanagedType.LPStr), In]
			string 				pszDictBuf,
			XFLM_CREATE_OPTS	pCreateOpts,
			out IntPtr			ppDb);