Changed how callbacks are done in C#

git-svn-id: https://svn.code.sf.net/p/flaim/code/trunk@856 0109f412-320b-0410-ab79-c3e0c5ffbbe6
This commit is contained in:
dsandersoremutah
2006-09-18 21:19:55 +00:00
parent a9acd3ea7a
commit 427e3734ef
7 changed files with 690 additions and 611 deletions

View File

@@ -789,9 +789,9 @@ endif
xflaim_jni_jar = $(java_output_dir)/xflaimjni.jar
xflaim_jar_manifest = $(java_output_dir)/xflaimjni.mf
xflaim_csharp_assembly = $(csharp_output_dir)/$(lib_prefix)$(project_name)_csharp$(shared_lib_suffix)
xflaim_csharp_assembly_xml = $(csharp_output_dir)/$(lib_prefix)$(project_name)_csharp.xml
cstest_exe = $(cstest_output_dir)/cstest$(exe_suffix)
xflaim_csharp_assembly = $(csharp_output_dir)/xflaim_csharp.dll
xflaim_csharp_assembly_xml = $(csharp_output_dir)/xflaim_csharp.xml
cstest_exe = $(cstest_output_dir)/cstest.exe
util_dir = $(target_path)/util
test_dir = $(target_path)/test
@@ -823,6 +823,12 @@ ccflags =
clrflags =
noclrflags =
cs_flags = /nologo /warn:4 /warnaserror+
ifeq ($(target_build_type),debug)
cs_flags += /debug+ /debug:full /define:FLM_DEBUG
else
cs_flags += /optimized+
endif
ccdefs =
ifeq ($(target_word_size),64)
@@ -855,10 +861,8 @@ ifdef win_target
ccflags += /Ob1 /Od /Wp64
noclrflags += /RTC1
ccdefs += FLM_DEBUG
cs_flags += /debug+ /debug:full /define:FLM_DEBUG
else
ccflags += /O2
cs_flags += /optimized+
endif
# Linker switches
@@ -996,6 +1000,7 @@ ifdef unix_target
endif
ifeq ($(target_os_family),linux)
csharp_compiler := mcs
# Must support 64 bit file sizes - even for 32 bit builds.

View File

@@ -85,181 +85,182 @@ namespace cstest
//--------------------------------------------------------------------------
// Create database test
//--------------------------------------------------------------------------
static bool createDbTest(
DbSystem dbSystem)
{
Db db = null;
RCODE rc;
beginTest( "Create Database Test (" + CREATE_DB_NAME + ")");
for (;;)
{
rc = RCODE.NE_XFLM_OK;
try
{
CREATE_OPTS createOpts = new 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.uiDefaultLanguage = (uint)Languages.FLM_DE_LANG;
db = dbSystem.dbCreate( CREATE_DB_NAME, null, null, null, null, createOpts);
}
catch (XFlaimException ex)
{
rc = ex.getRCode();
if (rc != RCODE.NE_XFLM_FILE_EXISTS)
{
endTest( 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( CREATE_DB_NAME, null, null, true);
}
catch (XFlaimException ex)
{
endTest( ex, "removing database");
return( false);
}
}
if (db != null)
{
db.close();
db = null;
}
endTest( true);
return( true);
}
static bool createDbTest(
DbSystem dbSystem)
{
Db db = null;
RCODE rc;
beginTest( "Create Database Test (" + CREATE_DB_NAME + ")");
for (;;)
{
rc = RCODE.NE_XFLM_OK;
try
{
CREATE_OPTS createOpts = new 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.uiDefaultLanguage = (uint)Languages.FLM_DE_LANG;
db = dbSystem.dbCreate( CREATE_DB_NAME, null, null, null, null, createOpts);
}
catch (XFlaimException ex)
{
rc = ex.getRCode();
if (rc != RCODE.NE_XFLM_FILE_EXISTS)
{
endTest( 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( CREATE_DB_NAME, null, null, true);
}
catch (XFlaimException ex)
{
endTest( ex, "removing database");
return( false);
}
}
if (db != null)
{
db.close();
db = null;
}
endTest( true);
return( true);
}
//--------------------------------------------------------------------------
// Open database test.
//--------------------------------------------------------------------------
static bool openDbTest(
DbSystem dbSystem)
{
Db db = null;
beginTest( "Open Database Test (" + CREATE_DB_NAME + ")");
try
{
db = dbSystem.dbOpen( CREATE_DB_NAME, null, null, null, false);
}
catch (XFlaimException ex)
{
endTest( ex, "opening database");
return( false);
}
if (db != null)
{
db.close();
db = null;
}
endTest( true);
return( true);
}
static bool openDbTest(
DbSystem dbSystem)
{
Db db = null;
beginTest( "Open Database Test (" + CREATE_DB_NAME + ")");
try
{
db = dbSystem.dbOpen( CREATE_DB_NAME, null, null, null, false);
}
catch (XFlaimException ex)
{
endTest( ex, "opening database");
return( false);
}
if (db != null)
{
db.close();
db = null;
}
endTest( true);
return( true);
}
//--------------------------------------------------------------------------
// Copy database test.
//--------------------------------------------------------------------------
static bool copyDbTest(
DbSystem dbSystem)
{
// Try copying the database
MyDbCopyStatus copyStatus = new MyDbCopyStatus();
beginTest( "Copy Database Test (" + CREATE_DB_NAME + " --> " + COPY_DB_NAME + ")");
try
{
dbSystem.dbCopy( CREATE_DB_NAME, null, null, COPY_DB_NAME, null, null, copyStatus);
}
catch (XFlaimException ex)
{
endTest( ex, "copying database");
return( false);
}
endTest( true);
return( true);
}
static bool copyDbTest(
DbSystem dbSystem)
{
// Try copying the database
MyDbCopyStatus copyStatus = new MyDbCopyStatus();
beginTest( "Copy Database Test (" + CREATE_DB_NAME + " --> " + COPY_DB_NAME + ")");
try
{
dbSystem.dbCopy( CREATE_DB_NAME, null, null, COPY_DB_NAME, null, null, copyStatus);
}
catch (XFlaimException ex)
{
endTest( ex, "copying database");
return( false);
}
endTest( true);
return( true);
}
//--------------------------------------------------------------------------
// Remove database test.
//--------------------------------------------------------------------------
static bool removeDbTest(
DbSystem dbSystem,
string sDbName)
{
beginTest( "Remove Database Test (" + sDbName + ")");
try
{
dbSystem.dbRemove( sDbName, null, null, true);
}
catch (XFlaimException ex)
{
endTest( ex, "removing database");
return( false);
}
endTest( true);
return( true);
}
static bool removeDbTest(
DbSystem dbSystem,
string sDbName)
{
beginTest( "Remove Database Test (" + sDbName + ")");
try
{
dbSystem.dbRemove( sDbName, null, null, true);
}
catch (XFlaimException ex)
{
endTest( ex, "removing database");
return( false);
}
endTest( true);
return( true);
}
//--------------------------------------------------------------------------
// Main for tester program
//--------------------------------------------------------------------------
static void Main()
{
DbSystem dbSystem = new DbSystem();
// Database create test
if (!createDbTest( dbSystem))
{
return;
}
// Database open test
if (!openDbTest( dbSystem))
{
return;
}
// Database copy test
if (!copyDbTest( dbSystem))
{
return;
}
// Database remove test
if (!removeDbTest( dbSystem, CREATE_DB_NAME))
{
return;
}
if (!removeDbTest( dbSystem, COPY_DB_NAME))
{
return;
}
}
static void Main()
{
DbSystem dbSystem = new DbSystem();
// Database create test
if (!createDbTest( dbSystem))
{
return;
}
// Database open test
if (!openDbTest( dbSystem))
{
return;
}
// Database copy test
if (!copyDbTest( dbSystem))
{
return;
}
// Database remove test
if (!removeDbTest( dbSystem, CREATE_DB_NAME))
{
return;
}
if (!removeDbTest( dbSystem, COPY_DB_NAME))
{
return;
}
}
}
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
public class MyDbCopyStatus : DbCopyStatus
{
public RCODE dbCopyStatus(
@@ -277,3 +278,4 @@ namespace cstest
}
}
}

View File

@@ -25,8 +25,6 @@
#include "xflaim.h"
#pragma unmanaged
/****************************************************************************
Desc:
****************************************************************************/

View File

@@ -28,24 +28,24 @@ using System.Runtime.InteropServices;
namespace xflaim
{
/// <remarks>
/// The Db class provides a number of methods that allow C#
/// applications to access an XFLAIM database. A Db object
/// is obtained by calling <see cref="DbSystem.dbCreate"/> or
/// <see cref="DbSystem.dbOpen"/>
/// </remarks>
/// <remarks>
/// The Db class provides a number of methods that allow C#
/// applications to access an XFLAIM database. A Db object
/// is obtained by calling <see cref="DbSystem.dbCreate"/> or
/// <see cref="DbSystem.dbOpen"/>
/// </remarks>
public class Db
{
/// <summary>
/// Db constructor.
/// </summary>
/// <param name="cs_dbRef">
/// Reference to an IF_Db object.
/// </param>
/// <param name="dbSystem">
/// DbSystem object that this Db object is associated with.
/// </param>
/// <summary>
/// Db constructor.
/// </summary>
/// <param name="cs_dbRef">
/// Reference to an IF_Db object.
/// </param>
/// <param name="dbSystem">
/// DbSystem object that this Db object is associated with.
/// </param>
public Db(
ulong cs_dbRef,
DbSystem dbSystem)
@@ -63,18 +63,27 @@ namespace xflaim
}
m_dbSystem = dbSystem;
// Must call something inside of DbSystem. Otherwise, the
// m_dbSystem object gets a compiler warning on linux because
// it is not used anywhere. Other than that, there is really
// no need to make the following call.
if (m_dbSystem.getRef() == 0)
{
throw new XFlaimException( "Invalid DbSystem.getRef()");
}
}
/// <summary>
/// Destructor.
/// </summary>
/// <summary>
/// Destructor.
/// </summary>
~Db()
{
close();
}
/// <summary>
/// Close this database.
/// <summary>
/// Close this database.
/// </summary>
public void close()
{
@@ -93,12 +102,12 @@ namespace xflaim
// PRIVATE METHODS THAT ARE IMPLEMENTED IN C AND C++
[DllImport("xflaim")]
private static extern int xflaim_Db_Release(
ulong ui64This);
/// <summary>
/// Reference to C++ IF_Db object.
[DllImport("xflaim")]
private static extern int xflaim_Db_Release(
ulong ui64This);
/// <summary>
/// Reference to C++ IF_Db object.
/// </summary>
public ulong m_this;
private DbSystem m_dbSystem;

View File

@@ -29,35 +29,35 @@ using System.Runtime.InteropServices;
namespace xflaim
{
/// <summary>
/// <summary>
/// This interface allows XFlaim to periodically pass information back to the
/// client about the status of an ongoing database copy operation. The
/// implementor may do anything it wants with the information, such as write
/// it to a log file or display it on the screen.
/// it to a log file or display it on the screen.
/// </summary>
public interface DbCopyStatus
{
/// <summary>
/// <summary>
/// The <see cref="DbSystem.dbCopy"/> operation calls this method periodically to
/// inform the implementation object about the status of the copy operation.
/// </summary>
/// <param name="ulBytesToCopy">
/// The total number of bytes that the <see cref="DbSystem.dbCopy"/> operation
/// will ultimately copy.
/// </param>
/// <param name="ulBytesCopied">
/// The number of bytes that the <see cref="DbSystem.dbCopy"/> operation has
/// copied so far.
/// </param>
/// <param name="sSrcFileName">
/// The name of the file that is currently being copied. This is only passed
/// when the source file name is changed. Otherwise, it will be null.
/// </param>
/// <param name="sDestFileName">
/// The name of the current destination file. This is only passed when the
/// destination file name is changed. Otherwise, it will be null.
/// </param>
/// inform the implementation object about the status of the copy operation.
/// </summary>
/// <param name="ulBytesToCopy">
/// The total number of bytes that the <see cref="DbSystem.dbCopy"/> operation
/// will ultimately copy.
/// </param>
/// <param name="ulBytesCopied">
/// The number of bytes that the <see cref="DbSystem.dbCopy"/> operation has
/// copied so far.
/// </param>
/// <param name="sSrcFileName">
/// The name of the file that is currently being copied. This is only passed
/// when the source file name is changed. Otherwise, it will be null.
/// </param>
/// <param name="sDestFileName">
/// The name of the current destination file. This is only passed when the
/// destination file name is changed. Otherwise, it will be null.
/// </param>
/// <returns>
/// If the implementation object returns anything but RCODE.NE_XFLM_OK
/// the <see cref="DbSystem.dbCopy"/> operation will abort and throw an

View File

@@ -145,7 +145,6 @@ typedef enum
} eRestoreClientAction;
typedef RCODE (FLMAPI * RESTORE_CLIENT)(
void * pvObj,
eRestoreClientAction eAction,
FLMUINT uiFileNum,
FLMUINT uiBytesRequested,
@@ -160,10 +159,8 @@ class CS_RestoreClient : public IF_RestoreClient
public:
CS_RestoreClient(
void * pvObj,
RESTORE_CLIENT fnRestoreClient)
{
m_pvObj = pvObj;
m_fnRestoreClient = fnRestoreClient;
}
@@ -173,19 +170,19 @@ public:
RCODE FLMAPI openBackupSet( void)
{
return( m_fnRestoreClient( m_pvObj, RESTORE_OPEN_BACKUP_SET, 0, 0, NULL, NULL));
return( m_fnRestoreClient( RESTORE_OPEN_BACKUP_SET, 0, 0, NULL, NULL));
}
RCODE FLMAPI openRflFile(
FLMUINT uiFileNum)
{
return( m_fnRestoreClient( m_pvObj, RESTORE_OPEN_RFL_FILE, uiFileNum, 0, NULL, NULL));
return( m_fnRestoreClient( RESTORE_OPEN_RFL_FILE, uiFileNum, 0, NULL, NULL));
}
RCODE FLMAPI openIncFile(
FLMUINT uiFileNum)
{
return( m_fnRestoreClient( m_pvObj, RESTORE_OPEN_INC_FILE, uiFileNum, 0, NULL, NULL));
return( m_fnRestoreClient( RESTORE_OPEN_INC_FILE, uiFileNum, 0, NULL, NULL));
}
RCODE FLMAPI read(
@@ -193,24 +190,23 @@ public:
void * pvBuffer,
FLMUINT * puiBytesRead)
{
return( m_fnRestoreClient( m_pvObj, RESTORE_READ, 0, uiBytesRequested,
return( m_fnRestoreClient( RESTORE_READ, 0, uiBytesRequested,
pvBuffer, puiBytesRead));
}
RCODE FLMAPI close( void)
{
return( m_fnRestoreClient( m_pvObj, RESTORE_CLOSE, 0, 0, NULL, NULL));
return( m_fnRestoreClient( RESTORE_CLOSE, 0, 0, NULL, NULL));
}
RCODE FLMAPI abortFile( void)
{
return( m_fnRestoreClient( m_pvObj, RESTORE_ABORT_FILE, 0, 0, NULL, NULL));
return( m_fnRestoreClient( RESTORE_ABORT_FILE, 0, 0, NULL, NULL));
}
private:
void * m_pvObj;
RESTORE_CLIENT m_fnRestoreClient;
};
@@ -248,7 +244,6 @@ typedef enum
} eRestoreStatusAction;
typedef RCODE (FLMAPI * RESTORE_STATUS)(
void * pvObj,
eRestoreStatusAction eAction,
eRestoreAction * peRestoreAction,
FLMUINT64 ui64TransId,
@@ -268,10 +263,8 @@ class CS_RestoreStatus : public IF_RestoreStatus
public:
CS_RestoreStatus(
void * pvObj,
RESTORE_STATUS fnRestoreStatus)
{
m_pvObj = pvObj;
m_fnRestoreStatus = fnRestoreStatus;
}
@@ -284,7 +277,7 @@ public:
FLMUINT64 ui64BytesToDo,
FLMUINT64 ui64BytesDone)
{
return( m_fnRestoreStatus( m_pvObj, REPORT_PROGRESS, peAction, 0,
return( m_fnRestoreStatus( REPORT_PROGRESS, peAction, 0,
ui64BytesToDo, ui64BytesDone, 0,
0, 0, 0, 0));
}
@@ -293,7 +286,7 @@ public:
eRestoreAction * peAction,
RCODE rcErr)
{
return( m_fnRestoreStatus( m_pvObj, REPORT_ERROR, peAction, 0,
return( m_fnRestoreStatus( REPORT_ERROR, peAction, 0,
0, 0, 0,
(FLMUINT)rcErr, 0, 0, 0));
}
@@ -302,7 +295,7 @@ public:
eRestoreAction * peAction,
FLMUINT uiFileNum)
{
return( m_fnRestoreStatus( m_pvObj, REPORT_OPEN_RFL_FILE, peAction, 0,
return( m_fnRestoreStatus( REPORT_OPEN_RFL_FILE, peAction, 0,
0, 0, 0,
uiFileNum, 0, 0, 0));
}
@@ -312,7 +305,7 @@ public:
FLMUINT uiFileNum,
FLMUINT uiBytesRead)
{
return( m_fnRestoreStatus( m_pvObj, REPORT_RFL_READ, peAction, 0,
return( m_fnRestoreStatus( REPORT_RFL_READ, peAction, 0,
0, 0, 0,
uiFileNum, uiBytesRead, 0, 0));
}
@@ -321,7 +314,7 @@ public:
eRestoreAction * peAction,
FLMUINT64 ui64TransId)
{
return( m_fnRestoreStatus( m_pvObj, REPORT_BEGIN_TRANS, peAction, ui64TransId,
return( m_fnRestoreStatus( REPORT_BEGIN_TRANS, peAction, ui64TransId,
0, 0, 0,
0, 0, 0, 0));
}
@@ -330,7 +323,7 @@ public:
eRestoreAction * peAction,
FLMUINT64 ui64TransId)
{
return( m_fnRestoreStatus( m_pvObj, REPORT_COMMIT_TRANS, peAction, ui64TransId,
return( m_fnRestoreStatus( REPORT_COMMIT_TRANS, peAction, ui64TransId,
0, 0, 0,
0, 0, 0, 0));
}
@@ -339,7 +332,7 @@ public:
eRestoreAction * peAction,
FLMUINT64 ui64TransId)
{
return( m_fnRestoreStatus( m_pvObj, REPORT_ABORT_TRANS, peAction, ui64TransId,
return( m_fnRestoreStatus( REPORT_ABORT_TRANS, peAction, ui64TransId,
0, 0, 0,
0, 0, 0, 0));
}
@@ -352,7 +345,7 @@ public:
FLMUINT uiEndBlkAddr,
FLMUINT uiCount)
{
return( m_fnRestoreStatus( m_pvObj, REPORT_BLOCK_CHAIN_FREE, peAction, ui64TransId,
return( m_fnRestoreStatus( REPORT_BLOCK_CHAIN_FREE, peAction, ui64TransId,
ui64MaintDocNum, 0, 0,
uiStartBlkAddr, uiEndBlkAddr, uiCount, 0));
}
@@ -362,7 +355,7 @@ public:
FLMUINT64 ui64TransId,
FLMUINT uiIndexNum)
{
return( m_fnRestoreStatus( m_pvObj, REPORT_INDEX_SUSPEND, peAction, ui64TransId,
return( m_fnRestoreStatus( REPORT_INDEX_SUSPEND, peAction, ui64TransId,
0, 0, 0,
uiIndexNum, 0, 0, 0));
}
@@ -372,7 +365,7 @@ public:
FLMUINT64 ui64TransId,
FLMUINT uiIndexNum)
{
return( m_fnRestoreStatus( m_pvObj, REPORT_INDEX_RESUME, peAction, ui64TransId,
return( m_fnRestoreStatus( REPORT_INDEX_RESUME, peAction, ui64TransId,
0, 0, 0,
uiIndexNum, 0, 0, 0));
}
@@ -382,7 +375,7 @@ public:
FLMUINT64 ui64TransId,
FLMUINT uiCount)
{
return( m_fnRestoreStatus( m_pvObj, REPORT_REDUCE, peAction, ui64TransId,
return( m_fnRestoreStatus( REPORT_REDUCE, peAction, ui64TransId,
0, 0, 0,
uiCount, 0, 0, 0));
}
@@ -393,7 +386,7 @@ public:
FLMUINT uiOldDbVersion,
FLMUINT uiNewDbVersion)
{
return( m_fnRestoreStatus( m_pvObj, REPORT_UPGRADE, peAction, ui64TransId,
return( m_fnRestoreStatus( REPORT_UPGRADE, peAction, ui64TransId,
0, 0, 0,
uiOldDbVersion, uiNewDbVersion, 0, 0));
}
@@ -402,7 +395,7 @@ public:
eRestoreAction * peAction,
FLMUINT64 ui64TransId)
{
return( m_fnRestoreStatus( m_pvObj, REPORT_ENABLE_ENCRYPTION, peAction, ui64TransId,
return( m_fnRestoreStatus( REPORT_ENABLE_ENCRYPTION, peAction, ui64TransId,
0, 0, 0,
0, 0, 0, 0));
}
@@ -411,7 +404,7 @@ public:
eRestoreAction * peAction,
FLMUINT64 ui64TransId)
{
return( m_fnRestoreStatus( m_pvObj, REPORT_WRAP_KEY, peAction, ui64TransId,
return( m_fnRestoreStatus( REPORT_WRAP_KEY, peAction, ui64TransId,
0, 0, 0,
0, 0, 0, 0));
}
@@ -420,7 +413,7 @@ public:
eRestoreAction * peAction,
FLMUINT64 ui64TransId)
{
return( m_fnRestoreStatus( m_pvObj, REPORT_ROLL_OVER_DB_KEY, peAction, ui64TransId,
return( m_fnRestoreStatus( REPORT_ROLL_OVER_DB_KEY, peAction, ui64TransId,
0, 0, 0,
0, 0, 0, 0));
}
@@ -431,7 +424,7 @@ public:
FLMUINT uiCollection,
FLMUINT64 ui64DocumentId)
{
return( m_fnRestoreStatus( m_pvObj, REPORT_DOCUMENT_DONE, peAction, ui64TransId,
return( m_fnRestoreStatus( REPORT_DOCUMENT_DONE, peAction, ui64TransId,
ui64DocumentId, 0, 0,
uiCollection, 0, 0, 0));
}
@@ -442,7 +435,7 @@ public:
FLMUINT uiCollection,
FLMUINT64 ui64NodeId)
{
return( m_fnRestoreStatus( m_pvObj, REPORT_NODE_DELETE, peAction, ui64TransId,
return( m_fnRestoreStatus( REPORT_NODE_DELETE, peAction, ui64TransId,
ui64NodeId, 0, 0,
uiCollection, 0, 0, 0));
}
@@ -454,7 +447,7 @@ public:
FLMUINT64 ui64ElementId,
FLMUINT uiAttrNameId)
{
return( m_fnRestoreStatus( m_pvObj, REPORT_ATTRIBUTE_DELETE, peAction, ui64TransId,
return( m_fnRestoreStatus( REPORT_ATTRIBUTE_DELETE, peAction, ui64TransId,
ui64ElementId, 0, 0,
uiCollection, uiAttrNameId, 0, 0));
}
@@ -466,7 +459,7 @@ public:
FLMUINT64 ui64ParentNodeId,
FLMUINT uiNameId)
{
return( m_fnRestoreStatus( m_pvObj, REPORT_NODE_CHILDREN_DELETE, peAction, ui64TransId,
return( m_fnRestoreStatus( REPORT_NODE_CHILDREN_DELETE, peAction, ui64TransId,
ui64ParentNodeId, 0, 0,
uiCollection, uiNameId, 0, 0));
}
@@ -480,7 +473,7 @@ public:
FLMUINT uiNameId,
eNodeInsertLoc eLocation)
{
return( m_fnRestoreStatus( m_pvObj, REPORT_NODE_CREATE, peAction, ui64TransId,
return( m_fnRestoreStatus( REPORT_NODE_CREATE, peAction, ui64TransId,
ui64RefNodeId, 0, 0,
uiCollection, (FLMUINT)eNodeType, uiNameId, (FLMUINT)eLocation));
}
@@ -493,7 +486,7 @@ public:
FLMUINT64 ui64NewChildNodeId,
FLMUINT64 ui64RefChildNodeId)
{
return( m_fnRestoreStatus( m_pvObj, REPORT_INSERT_BEFORE, peAction, ui64TransId,
return( m_fnRestoreStatus( REPORT_INSERT_BEFORE, peAction, ui64TransId,
ui64ParentNodeId, ui64NewChildNodeId, ui64RefChildNodeId,
uiCollection, 0, 0, 0));
}
@@ -504,7 +497,7 @@ public:
FLMUINT uiCollection,
FLMUINT64 ui64NodeId)
{
return( m_fnRestoreStatus( m_pvObj, REPORT_NODE_UPDATE, peAction, ui64TransId,
return( m_fnRestoreStatus( REPORT_NODE_UPDATE, peAction, ui64TransId,
ui64NodeId, 0, 0,
uiCollection, 0, 0, 0));
}
@@ -515,7 +508,7 @@ public:
FLMUINT uiCollection,
FLMUINT64 ui64NodeId)
{
return( m_fnRestoreStatus( m_pvObj, REPORT_NODE_SET_VALUE, peAction, ui64TransId,
return( m_fnRestoreStatus( REPORT_NODE_SET_VALUE, peAction, ui64TransId,
ui64NodeId, 0, 0,
uiCollection, 0, 0, 0));
}
@@ -527,7 +520,7 @@ public:
FLMUINT64 ui64ElementNodeId,
FLMUINT uiAttrNameId)
{
return( m_fnRestoreStatus( m_pvObj, REPORT_ATTRIBUTE_SET_VALUE, peAction, ui64TransId,
return( m_fnRestoreStatus( REPORT_ATTRIBUTE_SET_VALUE, peAction, ui64TransId,
ui64ElementNodeId, 0, 0,
uiCollection, uiAttrNameId, 0, 0));
}
@@ -540,7 +533,7 @@ public:
FLMUINT uiFlags,
FLMBOOL bAdd)
{
return( m_fnRestoreStatus( m_pvObj, REPORT_NODE_FLAGS_UPDATE, peAction, ui64TransId,
return( m_fnRestoreStatus( REPORT_NODE_FLAGS_UPDATE, peAction, ui64TransId,
ui64NodeId, 0, 0,
uiCollection, uiFlags, (FLMUINT)bAdd, 0));
}
@@ -553,7 +546,7 @@ public:
FLMUINT uiAttrNameId,
FLMUINT uiPrefixId)
{
return( m_fnRestoreStatus( m_pvObj, REPORT_NODE_SET_PREFIX_ID, peAction, ui64TransId,
return( m_fnRestoreStatus( REPORT_NODE_SET_PREFIX_ID, peAction, ui64TransId,
ui64NodeId, 0, 0,
uiCollection, uiAttrNameId, uiPrefixId, 0));
}
@@ -565,7 +558,7 @@ public:
FLMUINT64 ui64NodeId,
FLMUINT64 ui64MetaValue)
{
return( m_fnRestoreStatus( m_pvObj, REPORT_NODE_SET_META_VALUE, peAction, ui64TransId,
return( m_fnRestoreStatus( REPORT_NODE_SET_META_VALUE, peAction, ui64TransId,
ui64NodeId, ui64MetaValue, 0,
uiCollection, 0, 0, 0));
}
@@ -576,7 +569,7 @@ public:
FLMUINT uiCollection,
FLMUINT64 ui64NextNodeId)
{
return( m_fnRestoreStatus( m_pvObj, REPORT_SET_NEXT_NODE_ID, peAction, ui64TransId,
return( m_fnRestoreStatus( REPORT_SET_NEXT_NODE_ID, peAction, ui64TransId,
ui64NextNodeId, 0, 0,
uiCollection, 0, 0, 0));
}
@@ -584,7 +577,6 @@ public:
private:
void * m_pvObj;
RESTORE_STATUS m_fnRestoreStatus;
};
@@ -598,9 +590,7 @@ FLMEXTC FLMEXP RCODE FLMAPI xflaim_DbSystem_dbRestore(
const char * pszRflDir,
const char * pszBackupPath,
const char * pszPassword,
void * pvRestoreClientObj,
RESTORE_CLIENT fnRestoreClient,
void * pvRestoreStatusObj,
RESTORE_STATUS fnRestoreStatus)
{
RCODE rc = NE_XFLM_OK;
@@ -608,17 +598,17 @@ FLMEXTC FLMEXP RCODE FLMAPI xflaim_DbSystem_dbRestore(
IF_RestoreClient * pRestoreClient = NULL;
IF_RestoreStatus * pRestoreStatus = NULL;
if (pvRestoreClientObj)
if (fnRestoreClient)
{
if ((pRestoreClient = f_new CS_RestoreClient( pvRestoreClientObj, fnRestoreClient)) == NULL)
if ((pRestoreClient = f_new CS_RestoreClient( fnRestoreClient)) == NULL)
{
rc = RC_SET( NE_XFLM_MEM);
goto Exit;
}
}
if (pvRestoreStatusObj)
if (fnRestoreStatus)
{
if ((pRestoreStatus = f_new CS_RestoreStatus( pvRestoreStatusObj, fnRestoreStatus)) == NULL)
if ((pRestoreStatus = f_new CS_RestoreStatus( fnRestoreStatus)) == NULL)
{
rc = RC_SET( NE_XFLM_MEM);
goto Exit;
@@ -646,7 +636,6 @@ Exit:
}
typedef RCODE (FLMAPI * DB_COPY_STATUS)(
void * pvObj,
FLMUINT64 ui64BytesToCopy,
FLMUINT64 ui64BytesCopied,
FLMBOOL bNewSrcFile,
@@ -661,10 +650,8 @@ class CS_DbCopyStatus : public IF_DbCopyStatus
public:
CS_DbCopyStatus(
void * pvObj,
DB_COPY_STATUS fnCopyStatus)
{
m_pvObj = pvObj;
m_fnCopyStatus = fnCopyStatus;
}
@@ -679,13 +666,12 @@ public:
const char * pszSrcFileName,
const char * pszDestFileName)
{
return( m_fnCopyStatus( m_pvObj, ui64BytesToCopy, ui64BytesCopied,
bNewSrcFile, pszSrcFileName, pszDestFileName));
return( m_fnCopyStatus( ui64BytesToCopy, ui64BytesCopied, bNewSrcFile,
pszSrcFileName, pszDestFileName));
}
private:
void * m_pvObj;
DB_COPY_STATUS m_fnCopyStatus;
};
@@ -701,16 +687,15 @@ FLMEXTC FLMEXP RCODE FLMAPI xflaim_DbSystem_dbCopy(
const char * pszDestDbName,
const char * pszDestDataDir,
const char * pszDestRflDir,
void * pvObj,
DB_COPY_STATUS fnCopyStatus)
{
RCODE rc = NE_XFLM_OK;
IF_DbSystem * pDbSystem = ((IF_DbSystem *)(FLMUINT)ui64This);
IF_DbCopyStatus * pDbCopyStatus = NULL;
if (pvObj)
if (fnCopyStatus)
{
if ((pDbCopyStatus = f_new CS_DbCopyStatus( pvObj, fnCopyStatus)) == NULL)
if ((pDbCopyStatus = f_new CS_DbCopyStatus( fnCopyStatus)) == NULL)
{
rc = RC_SET( NE_XFLM_MEM);
goto Exit;

View File

@@ -29,100 +29,100 @@ using System.Runtime.InteropServices;
namespace xflaim
{
/// <summary>
/// Valid database versions
/// <summary>
/// Valid database versions
/// </summary>
public enum DBVersions
{
/// <summary>Version 5.12</summary>
/// <summary>Version 5.12</summary>
XFLM_VER_5_12 = 512,
/// <summary>Current database version number</summary>
/// <summary>Current database version number</summary>
XFLM_CURRENT_VERSION_NUM = XFLM_VER_5_12
}
/// <summary>
/// Valid languages
/// <summary>
/// Valid languages
/// </summary>
public enum Languages
{
/// <summary>English, United States</summary>
FLM_US_LANG = 0,
/// <summary>Afrikaans</summary>
FLM_AF_LANG = 1,
/// <summary>Arabic</summary>
FLM_AR_LANG = 2,
/// <summary>Catalan</summary>
FLM_CA_LANG = 3,
/// <summary>Croatian</summary>
FLM_HR_LANG = 4,
/// <summary>Czech</summary>
FLM_CZ_LANG = 5,
/// <summary>Danish</summary>
FLM_DK_LANG = 6,
/// <summary>Dutch</summary>
FLM_NL_LANG = 7,
/// <summary>English, Australia</summary>
FLM_OZ_LANG = 8,
/// <summary>English, Canada</summary>
FLM_CE_LANG = 9,
/// <summary>English, United Kingdom</summary>
FLM_UK_LANG = 10,
/// <summary>Farsi</summary>
FLM_FA_LANG = 11,
/// <summary>Finnish</summary>
FLM_SU_LANG = 12,
/// <summary>French, Canada</summary>
FLM_CF_LANG = 13,
/// <summary>French, France</summary>
FLM_FR_LANG = 14,
/// <summary>Galician</summary>
FLM_GA_LANG = 15,
/// <summary>German, Germany</summary>
FLM_DE_LANG = 16,
/// <summary>German, Switzerland</summary>
FLM_SD_LANG = 17,
/// <summary>Greek</summary>
FLM_GR_LANG = 18,
/// <summary>Hebrew</summary>
FLM_HE_LANG = 19,
/// <summary>Hungarian</summary>
FLM_HU_LANG = 20,
/// <summary>Icelandic</summary>
FLM_IS_LANG = 21,
/// <summary>Italian</summary>
FLM_IT_LANG = 22,
/// <summary>Norwegian</summary>
FLM_NO_LANG = 23,
/// <summary>Polish</summary>
FLM_PL_LANG = 24,
/// <summary>Portuguese, Brazil</summary>
FLM_BR_LANG = 25,
/// <summary>Portuguese, Portugal</summary>
FLM_PO_LANG = 26,
/// <summary>Russian</summary>
FLM_RU_LANG = 27,
/// <summary>Slovak</summary>
FLM_SL_LANG = 28,
/// <summary>Spanish</summary>
FLM_ES_LANG = 29,
/// <summary>Swedish</summary>
FLM_SV_LANG = 30,
/// <summary>Ukrainian</summary>
FLM_YK_LANG = 31,
/// <summary>Urdu</summary>
FLM_UR_LANG = 32,
/// <summary>Turkey</summary>
FLM_TK_LANG = 33,
/// <summary>Japanese</summary>
FLM_JP_LANG = 34,
/// <summary>Korean</summary>
FLM_KO_LANG = 35,
/// <summary>Chinese-Traditional</summary>
FLM_CT_LANG = 36,
/// <summary>Chinese-Simplified</summary>
FLM_CS_LANG = 37,
/// <summary>another Asian language</summary>
FLM_LA_LANG = 38
/// <summary>English, United States</summary>
FLM_US_LANG = 0,
/// <summary>Afrikaans</summary>
FLM_AF_LANG = 1,
/// <summary>Arabic</summary>
FLM_AR_LANG = 2,
/// <summary>Catalan</summary>
FLM_CA_LANG = 3,
/// <summary>Croatian</summary>
FLM_HR_LANG = 4,
/// <summary>Czech</summary>
FLM_CZ_LANG = 5,
/// <summary>Danish</summary>
FLM_DK_LANG = 6,
/// <summary>Dutch</summary>
FLM_NL_LANG = 7,
/// <summary>English, Australia</summary>
FLM_OZ_LANG = 8,
/// <summary>English, Canada</summary>
FLM_CE_LANG = 9,
/// <summary>English, United Kingdom</summary>
FLM_UK_LANG = 10,
/// <summary>Farsi</summary>
FLM_FA_LANG = 11,
/// <summary>Finnish</summary>
FLM_SU_LANG = 12,
/// <summary>French, Canada</summary>
FLM_CF_LANG = 13,
/// <summary>French, France</summary>
FLM_FR_LANG = 14,
/// <summary>Galician</summary>
FLM_GA_LANG = 15,
/// <summary>German, Germany</summary>
FLM_DE_LANG = 16,
/// <summary>German, Switzerland</summary>
FLM_SD_LANG = 17,
/// <summary>Greek</summary>
FLM_GR_LANG = 18,
/// <summary>Hebrew</summary>
FLM_HE_LANG = 19,
/// <summary>Hungarian</summary>
FLM_HU_LANG = 20,
/// <summary>Icelandic</summary>
FLM_IS_LANG = 21,
/// <summary>Italian</summary>
FLM_IT_LANG = 22,
/// <summary>Norwegian</summary>
FLM_NO_LANG = 23,
/// <summary>Polish</summary>
FLM_PL_LANG = 24,
/// <summary>Portuguese, Brazil</summary>
FLM_BR_LANG = 25,
/// <summary>Portuguese, Portugal</summary>
FLM_PO_LANG = 26,
/// <summary>Russian</summary>
FLM_RU_LANG = 27,
/// <summary>Slovak</summary>
FLM_SL_LANG = 28,
/// <summary>Spanish</summary>
FLM_ES_LANG = 29,
/// <summary>Swedish</summary>
FLM_SV_LANG = 30,
/// <summary>Ukrainian</summary>
FLM_YK_LANG = 31,
/// <summary>Urdu</summary>
FLM_UR_LANG = 32,
/// <summary>Turkey</summary>
FLM_TK_LANG = 33,
/// <summary>Japanese</summary>
FLM_JP_LANG = 34,
/// <summary>Korean</summary>
FLM_KO_LANG = 35,
/// <summary>Chinese-Traditional</summary>
FLM_CT_LANG = 36,
/// <summary>Chinese-Simplified</summary>
FLM_CS_LANG = 37,
/// <summary>another Asian language</summary>
FLM_LA_LANG = 38
}
/// <summary>
@@ -132,52 +132,52 @@ namespace xflaim
public class CREATE_OPTS
{
/// <summary>
/// Block size, may be 4096 or 8192.
/// <summary>
/// Block size, may be 4096 or 8192.
/// </summary>
public uint uiBlockSize;
/// <summary>
/// Database version number. Should be one of <see cref="DBVersions"/>.
/// <summary>
/// Database version number. Should be one of <see cref="DBVersions"/>.
/// </summary>
public uint uiVersionNum;
/// <summary>
/// Minimum Roll-forward log file size.
/// <summary>
/// Minimum Roll-forward log file size.
/// </summary>
public uint uiMinRflFileSize;
/// <summary>
/// Maximum Roll-forward log file size.
/// <summary>
/// Maximum Roll-forward log file size.
/// </summary>
public uint uiMaxRflFileSize;
/// <summary>
/// Flag indicating whether roll-forward log files should
/// be kept or reused.
/// <summary>
/// Flag indicating whether roll-forward log files should
/// be kept or reused.
/// </summary>
public int bKeepRflFiles;
/// <summary>
/// Flag indicating whether aborted transactions should be
/// logged to the roll-forward log.
/// <summary>
/// Flag indicating whether aborted transactions should be
/// logged to the roll-forward log.
/// </summary>
public int bLogAbortedTransToRfl;
/// <summary>
/// Default language for the database. Should be one of <see cref="Languages"/>
/// <summary>
/// Default language for the database. Should be one of <see cref="Languages"/>
/// </summary>
public uint uiDefaultLanguage;
}
/// <remarks>
/// XFLAIM Exception class.
/// </remarks>
/// <remarks>
/// XFLAIM Exception class.
/// </remarks>
public class XFlaimException : Exception
{
/// <summary>
/// XFLAIM Exception that returns an RCODE.
/// </summary>
/// <summary>
/// XFLAIM Exception that returns an RCODE.
/// </summary>
/// <param name="iRcode">The error code that occurred.</param>
public XFlaimException(
int iRcode)
@@ -186,9 +186,9 @@ namespace xflaim
m_message = null;
}
/// <summary>
/// XFLAIM Exception that returns a message.
/// </summary>
/// <summary>
/// XFLAIM Exception that returns a message.
/// </summary>
/// <param name="message">Message explaining cause of exception.</param>
public XFlaimException(
string message)
@@ -198,23 +198,23 @@ namespace xflaim
}
/// <summary>
/// Returns the error code that caused the exception to be thrown.
/// </summary>
/// <returns>
/// The error code that caused the exception. If zero is returned
/// there is no message associated with this exception. Instead,
/// the application should call <see cref="getString"/> to get
/// the message that explains the cause of the exception.
/// </returns>
/// <summary>
/// Returns the error code that caused the exception to be thrown.
/// </summary>
/// <returns>
/// The error code that caused the exception. If zero is returned
/// there is no message associated with this exception. Instead,
/// the application should call <see cref="getString"/> to get
/// the message that explains the cause of the exception.
/// </returns>
public RCODE getRCode()
{
return m_rc;
}
/// <summary>
/// Returns the string that explains the cause of the exception.
/// </summary>
/// <summary>
/// Returns the string that explains the cause of the exception.
/// </summary>
/// <returns>
/// The string that explains the cause of the exception. If null
/// is returned, there is no message associated with this exception.
@@ -230,16 +230,16 @@ namespace xflaim
private RCODE m_rc;
}
/// <remarks>
/// The DbSystem class provides a number of methods that allow C#
/// applications to access the XFlaim development environment.
/// </remarks>
/// <remarks>
/// The DbSystem class provides a number of methods that allow C#
/// applications to access the XFlaim development environment.
/// </remarks>
public class DbSystem
{
/// <summary>
/// DbSystem constructor.
/// </summary>
/// <summary>
/// DbSystem constructor.
/// </summary>
public DbSystem()
{
int rc = 0;
@@ -250,18 +250,27 @@ namespace xflaim
}
}
/// <summary>
/// DbSystem destructor.
/// </summary>
/// <summary>
/// DbSystem destructor.
/// </summary>
~DbSystem()
{
xflaim_DbSystem_Release( m_this);
m_this = 0;
}
}
/// <summary>
/// Called by <see cref="Db"/> class to silence compiler warning.
/// Has no other important use!
/// </summary>
public ulong getRef()
{
return m_this;
}
/// <summary>
/// Creates a new XFlaim database.
/// </summary>
/// <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
@@ -327,9 +336,9 @@ namespace xflaim
return( db);
}
/// <summary>
/// Creates a new XFlaim database.
/// </summary>
/// <summary>
/// Creates a new XFlaim database.
/// </summary>
/// <param name="sDbFileName">
/// See documentation on <see cref="dbCreate"/>.
/// </param>
@@ -373,19 +382,19 @@ namespace xflaim
return( db);
}
/// <summary>
/// Removes (deletes) an XFlaim database.
/// </summary>
/// <summary>
/// Removes (deletes) an XFlaim database.
/// </summary>
/// <param name="sDbFileName">
/// The name of the control file of the database to delete.
/// For more information see <see cref="dbCreate"/>
/// </param>
/// <param name="sDataDir">
/// The data file directory. For more information see <see cref="dbCreate"/>.
/// </param>
/// <param name="sRflDir">
/// For more information see <see cref="dbCreate"/>
/// </param>
/// <param name="sDataDir">
/// The data file directory. For more information see <see cref="dbCreate"/>.
/// </param>
/// <param name="sRflDir">
/// The roll-forward log file directory. For more information see <see cref="dbCreate"/>.
/// </param>
/// </param>
/// <param name="bRemoveRflFiles">
/// If true, the roll forward log files will be deleted.
/// </param>
@@ -404,39 +413,39 @@ namespace xflaim
}
}
/// <summary>
/// <summary>
/// Restores a previously backed up database. The <paramref name="sBackupPath"/> parameter
/// and the <paramref name="restoreClient"/> parameter are mutually exclusive. If the
/// <paramref name="restoreClient"/> parameter is null, then the backup data will be read from
/// <paramref name="sBackupPath"/>. If <paramref name="restoreClient"/> is non-null,
/// <paramref name="sBackupPath"/> is ignored.
/// </summary>
/// <param name="sDbPath">
/// The name of the control file of the database to restore.
/// </param>
/// <param name="sDataDir">
/// The data file directory. For more information see <see cref="dbCreate"/>.
/// </param>
/// <param name="sRflDir">
/// The roll-forward log file directory. For more information see <see cref="dbCreate"/>.
/// </param>
/// <param name="sBackupPath">
/// <paramref name="sBackupPath"/>. If <paramref name="restoreClient"/> is non-null,
/// <paramref name="sBackupPath"/> is ignored.
/// </summary>
/// <param name="sDbPath">
/// The name of the control file of the database to restore.
/// </param>
/// <param name="sDataDir">
/// The data file directory. For more information see <see cref="dbCreate"/>.
/// </param>
/// <param name="sRflDir">
/// The roll-forward log file directory. For more information see <see cref="dbCreate"/>.
/// </param>
/// <param name="sBackupPath">
/// The path to the backup files. This may be null. If
/// non-null, it specifies the directory where the backup files which are
/// to be restored are found. If null, the <paramref name="restoreClient"/> parameter must be
/// non-null.
/// </param>
/// <param name="sPassword">
/// non-null.
/// </param>
/// <param name="sPassword">
/// Password for the backup. If non-null, the database key in
/// the backup was wrapped in a password instead of the local NICI storage
/// key. This allows the database to be restored to a different machine if
/// desired. If null, the database can only be restored to the same machine
/// where it originally existed.
/// </param>
/// <param name="restoreClient">
/// where it originally existed.
/// </param>
/// <param name="restoreClient">
/// An object implementing the <see cref="RestoreClient"/> interface. This may be null. If
/// non-null, it is an object that knows how to get the backup data.
/// </param>
/// non-null, it is an object that knows how to get the backup data.
/// </param>
/// <param name="restoreStatus">
/// An object implementing <see cref="RestoreStatus"/> interface. This may be null. If
/// non-null, it is a callback object whose methods will be called to report
@@ -452,18 +461,24 @@ namespace xflaim
RestoreStatus restoreStatus)
{
int rc;
RestoreStatusCallback fnRestoreStatus;
RestoreClientCallback fnRestoreClient;
fnRestoreClient = (restoreClient != null)
? new RestoreClientCallback( funcRestoreClient)
: null;
fnRestoreStatus = (restoreStatus != null)
? new RestoreStatusCallback( funcRestoreStatus)
: null;
RestoreClientDelegate restoreClientDelegate = null;
RestoreClientCallback fnRestoreClient = null;
RestoreStatusDelegate restoreStatusDelegate = null;
RestoreStatusCallback fnRestoreStatus = null;
if (restoreClient != null)
{
restoreClientDelegate = new RestoreClientDelegate( restoreClient);
fnRestoreClient = new RestoreClientCallback( restoreClientDelegate.funcRestoreClient);
}
if (restoreStatus != null)
{
restoreStatusDelegate = new RestoreStatusDelegate( restoreStatus);
fnRestoreStatus = new RestoreStatusCallback( restoreStatusDelegate.funcRestoreStatus);
}
if ((rc = xflaim_DbSystem_dbRestore( m_this, sDbPath, sDataDir, sRflDir, sBackupPath,
sPassword, restoreClient, fnRestoreClient, restoreStatus, fnRestoreStatus)) != 0)
sPassword, fnRestoreClient, fnRestoreStatus)) != 0)
{
throw new XFlaimException( rc);
}
@@ -481,37 +496,50 @@ namespace xflaim
}
private delegate RCODE RestoreClientCallback(
RestoreClient restoreClient,
RestoreClientAction eAction,
uint uiFileNum,
uint uiBytesRequested,
IntPtr pvBuffer,
ref uint puiBytesRead);
private RCODE funcRestoreClient(
RestoreClient restoreClient,
RestoreClientAction eAction,
uint uiFileNum,
uint uiBytesRequested,
IntPtr pvBuffer,
ref uint uiBytesRead)
private class RestoreClientDelegate
{
switch (eAction)
public RestoreClientDelegate(
RestoreClient restoreClient)
{
case RestoreClientAction.RESTORE_OPEN_BACKUP_SET:
return( restoreClient.openBackupSet());
case RestoreClientAction.RESTORE_OPEN_RFL_FILE:
return( restoreClient.openRflFile( uiFileNum));
case RestoreClientAction.RESTORE_OPEN_INC_FILE:
return( restoreClient.openIncFile( uiFileNum));
case RestoreClientAction.RESTORE_READ:
return( restoreClient.read( uiBytesRequested, pvBuffer, ref uiBytesRead));
case RestoreClientAction.RESTORE_CLOSE:
return( restoreClient.close());
case RestoreClientAction.RESTORE_ABORT_FILE:
return( restoreClient.abortFile());
m_restoreClient = restoreClient;
}
return( RCODE.NE_XFLM_INVALID_PARM);
~RestoreClientDelegate()
{
}
public RCODE funcRestoreClient(
RestoreClientAction eAction,
uint uiFileNum,
uint uiBytesRequested,
IntPtr pvBuffer,
ref uint uiBytesRead)
{
switch (eAction)
{
case RestoreClientAction.RESTORE_OPEN_BACKUP_SET:
return( m_restoreClient.openBackupSet());
case RestoreClientAction.RESTORE_OPEN_RFL_FILE:
return( m_restoreClient.openRflFile( uiFileNum));
case RestoreClientAction.RESTORE_OPEN_INC_FILE:
return( m_restoreClient.openIncFile( uiFileNum));
case RestoreClientAction.RESTORE_READ:
return( m_restoreClient.read( uiBytesRequested, pvBuffer, ref uiBytesRead));
case RestoreClientAction.RESTORE_CLOSE:
return( m_restoreClient.close());
case RestoreClientAction.RESTORE_ABORT_FILE:
return( m_restoreClient.abortFile());
}
return( RCODE.NE_XFLM_INVALID_PARM);
}
private RestoreClient m_restoreClient;
}
// WARNING NOTE: Any changes to this enum should also be reflected in DbSystem.cpp
@@ -546,9 +574,8 @@ namespace xflaim
REPORT_DOCUMENT_DONE = 27,
REPORT_ROLL_OVER_DB_KEY = 28
}
private delegate RCODE RestoreStatusCallback(
RestoreStatus restoreStatus,
RestoreStatusAction eAction,
ref RestoreAction eRestoreAction,
ulong ulTransId,
@@ -560,115 +587,150 @@ namespace xflaim
uint uiShortNum3,
uint uiShortNum4);
private RCODE funcRestoreStatus(
RestoreStatus restoreStatus,
RestoreStatusAction eAction,
ref RestoreAction eRestoreAction,
ulong ulTransId,
ulong ulLongNum1,
ulong ulLongNum2,
ulong ulLongNum3,
uint uiShortNum1,
uint uiShortNum2,
uint uiShortNum3,
uint uiShortNum4)
private class RestoreStatusDelegate
{
switch (eAction)
public RestoreStatusDelegate(
RestoreStatus restoreStatus)
{
case RestoreStatusAction.REPORT_PROGRESS:
return( restoreStatus.reportProgress( ref eRestoreAction, ulLongNum1, ulLongNum2));
case RestoreStatusAction.REPORT_ERROR:
return( restoreStatus.reportError( ref eRestoreAction, (RCODE)uiShortNum1));
case RestoreStatusAction.REPORT_BEGIN_TRANS:
return( restoreStatus.reportBeginTrans( ref eRestoreAction, ulTransId));
case RestoreStatusAction.REPORT_COMMIT_TRANS:
return( restoreStatus.reportCommitTrans( ref eRestoreAction, ulTransId));
case RestoreStatusAction.REPORT_ABORT_TRANS:
return( restoreStatus.reportAbortTrans( ref eRestoreAction, ulTransId));
case RestoreStatusAction.REPORT_BLOCK_CHAIN_FREE:
return( restoreStatus.reportBlockChainFree( ref eRestoreAction, ulTransId, ulLongNum1,
uiShortNum1, uiShortNum2, uiShortNum3));
case RestoreStatusAction.REPORT_INDEX_SUSPEND:
return( restoreStatus.reportIndexSuspend( ref eRestoreAction, ulTransId, uiShortNum1));
case RestoreStatusAction.REPORT_INDEX_RESUME:
return( restoreStatus.reportIndexResume( ref eRestoreAction, ulTransId, uiShortNum1));
case RestoreStatusAction.REPORT_REDUCE:
return( restoreStatus.reportReduce( ref eRestoreAction, ulTransId, uiShortNum1));
case RestoreStatusAction.REPORT_UPGRADE:
return( restoreStatus.reportUpgrade( ref eRestoreAction, ulTransId, uiShortNum1, uiShortNum2));
case RestoreStatusAction.REPORT_OPEN_RFL_FILE:
return( restoreStatus.reportOpenRflFile( ref eRestoreAction, uiShortNum1));
case RestoreStatusAction.REPORT_RFL_READ:
return( restoreStatus.reportRflRead( ref eRestoreAction, uiShortNum1, uiShortNum2));
case RestoreStatusAction.REPORT_ENABLE_ENCRYPTION:
return( restoreStatus.reportEnableEncryption( ref eRestoreAction, ulTransId));
case RestoreStatusAction.REPORT_WRAP_KEY:
return( restoreStatus.reportWrapKey( ref eRestoreAction, ulTransId));
case RestoreStatusAction.REPORT_SET_NEXT_NODE_ID:
return( restoreStatus.reportSetNextNodeId( ref eRestoreAction, ulTransId, uiShortNum1, ulLongNum1));
case RestoreStatusAction.REPORT_NODE_SET_META_VALUE:
return( restoreStatus.reportNodeSetMetaValue( ref eRestoreAction, ulTransId, uiShortNum1,
ulLongNum1, ulLongNum2));
case RestoreStatusAction.REPORT_NODE_SET_PREFIX_ID:
return( restoreStatus.reportNodeSetPrefixId( ref eRestoreAction, ulTransId, uiShortNum1,
ulLongNum1, uiShortNum2, uiShortNum3));
case RestoreStatusAction.REPORT_NODE_FLAGS_UPDATE:
return( restoreStatus.reportNodeFlagsUpdate( ref eRestoreAction, ulTransId, uiShortNum1,
ulLongNum1, uiShortNum2, (bool)(uiShortNum3 != 0 ? true : false)));
case RestoreStatusAction.REPORT_ATTRIBUTE_SET_VALUE:
return( restoreStatus.reportAttributeSetValue( ref eRestoreAction, ulTransId, uiShortNum1,
ulLongNum1, uiShortNum2));
case RestoreStatusAction.REPORT_NODE_SET_VALUE:
return( restoreStatus.reportNodeSetValue( ref eRestoreAction, ulTransId, uiShortNum1, ulLongNum1));
case RestoreStatusAction.REPORT_NODE_UPDATE:
return( restoreStatus.reportNodeUpdate( ref eRestoreAction, ulTransId, uiShortNum1, ulLongNum1));
case RestoreStatusAction.REPORT_INSERT_BEFORE:
return( restoreStatus.reportInsertBefore( ref eRestoreAction, ulTransId, uiShortNum1, ulLongNum1,
ulLongNum2, ulLongNum3));
case RestoreStatusAction.REPORT_NODE_CREATE:
return( restoreStatus.reportNodeCreate( ref eRestoreAction, ulTransId, uiShortNum1, ulLongNum1,
(eDomNodeType)uiShortNum2, uiShortNum3, (eNodeInsertLoc)uiShortNum4));
case RestoreStatusAction.REPORT_NODE_CHILDREN_DELETE:
return( restoreStatus.reportNodeChildrenDelete( ref eRestoreAction, ulTransId, uiShortNum1,
ulLongNum1, uiShortNum2));
case RestoreStatusAction.REPORT_ATTRIBUTE_DELETE:
return( restoreStatus.reportAttributeDelete( ref eRestoreAction, ulTransId, uiShortNum1, ulLongNum1,
uiShortNum2));
case RestoreStatusAction.REPORT_NODE_DELETE:
return( restoreStatus.reportNodeDelete( ref eRestoreAction, ulTransId, uiShortNum1, ulLongNum1));
case RestoreStatusAction.REPORT_DOCUMENT_DONE:
return( restoreStatus.reportDocumentDone( ref eRestoreAction, ulTransId, uiShortNum1, ulLongNum1));
case RestoreStatusAction.REPORT_ROLL_OVER_DB_KEY:
return( restoreStatus.reportRollOverDbKey( ref eRestoreAction, ulTransId));
m_restoreStatus = restoreStatus;
}
return( RCODE.NE_XFLM_INVALID_PARM);
~RestoreStatusDelegate()
{
}
public RCODE funcRestoreStatus(
RestoreStatusAction eAction,
ref RestoreAction eRestoreAction,
ulong ulTransId,
ulong ulLongNum1,
ulong ulLongNum2,
ulong ulLongNum3,
uint uiShortNum1,
uint uiShortNum2,
uint uiShortNum3,
uint uiShortNum4)
{
switch (eAction)
{
case RestoreStatusAction.REPORT_PROGRESS:
return( m_restoreStatus.reportProgress( ref eRestoreAction,
ulLongNum1, ulLongNum2));
case RestoreStatusAction.REPORT_ERROR:
return( m_restoreStatus.reportError( ref eRestoreAction,
(RCODE)uiShortNum1));
case RestoreStatusAction.REPORT_BEGIN_TRANS:
return( m_restoreStatus.reportBeginTrans( ref eRestoreAction,
ulTransId));
case RestoreStatusAction.REPORT_COMMIT_TRANS:
return( m_restoreStatus.reportCommitTrans( ref eRestoreAction,
ulTransId));
case RestoreStatusAction.REPORT_ABORT_TRANS:
return( m_restoreStatus.reportAbortTrans( ref eRestoreAction,
ulTransId));
case RestoreStatusAction.REPORT_BLOCK_CHAIN_FREE:
return( m_restoreStatus.reportBlockChainFree( ref eRestoreAction,
ulTransId, ulLongNum1, uiShortNum1, uiShortNum2, uiShortNum3));
case RestoreStatusAction.REPORT_INDEX_SUSPEND:
return( m_restoreStatus.reportIndexSuspend( ref eRestoreAction,
ulTransId, uiShortNum1));
case RestoreStatusAction.REPORT_INDEX_RESUME:
return( m_restoreStatus.reportIndexResume( ref eRestoreAction,
ulTransId, uiShortNum1));
case RestoreStatusAction.REPORT_REDUCE:
return( m_restoreStatus.reportReduce( ref eRestoreAction,
ulTransId, uiShortNum1));
case RestoreStatusAction.REPORT_UPGRADE:
return( m_restoreStatus.reportUpgrade( ref eRestoreAction,
ulTransId, uiShortNum1, uiShortNum2));
case RestoreStatusAction.REPORT_OPEN_RFL_FILE:
return( m_restoreStatus.reportOpenRflFile( ref eRestoreAction,
uiShortNum1));
case RestoreStatusAction.REPORT_RFL_READ:
return( m_restoreStatus.reportRflRead( ref eRestoreAction,
uiShortNum1, uiShortNum2));
case RestoreStatusAction.REPORT_ENABLE_ENCRYPTION:
return( m_restoreStatus.reportEnableEncryption( ref eRestoreAction,
ulTransId));
case RestoreStatusAction.REPORT_WRAP_KEY:
return( m_restoreStatus.reportWrapKey( ref eRestoreAction,
ulTransId));
case RestoreStatusAction.REPORT_SET_NEXT_NODE_ID:
return( m_restoreStatus.reportSetNextNodeId( ref eRestoreAction,
ulTransId, uiShortNum1, ulLongNum1));
case RestoreStatusAction.REPORT_NODE_SET_META_VALUE:
return( m_restoreStatus.reportNodeSetMetaValue( ref eRestoreAction,
ulTransId, uiShortNum1, ulLongNum1, ulLongNum2));
case RestoreStatusAction.REPORT_NODE_SET_PREFIX_ID:
return( m_restoreStatus.reportNodeSetPrefixId( ref eRestoreAction,
ulTransId, uiShortNum1, ulLongNum1, uiShortNum2, uiShortNum3));
case RestoreStatusAction.REPORT_NODE_FLAGS_UPDATE:
return( m_restoreStatus.reportNodeFlagsUpdate( ref eRestoreAction,
ulTransId, uiShortNum1, ulLongNum1, uiShortNum2,
(bool)(uiShortNum3 != 0 ? true : false)));
case RestoreStatusAction.REPORT_ATTRIBUTE_SET_VALUE:
return( m_restoreStatus.reportAttributeSetValue( ref eRestoreAction,
ulTransId, uiShortNum1, ulLongNum1, uiShortNum2));
case RestoreStatusAction.REPORT_NODE_SET_VALUE:
return( m_restoreStatus.reportNodeSetValue( ref eRestoreAction,
ulTransId, uiShortNum1, ulLongNum1));
case RestoreStatusAction.REPORT_NODE_UPDATE:
return( m_restoreStatus.reportNodeUpdate( ref eRestoreAction,
ulTransId, uiShortNum1, ulLongNum1));
case RestoreStatusAction.REPORT_INSERT_BEFORE:
return( m_restoreStatus.reportInsertBefore( ref eRestoreAction,
ulTransId, uiShortNum1, ulLongNum1, ulLongNum2, ulLongNum3));
case RestoreStatusAction.REPORT_NODE_CREATE:
return( m_restoreStatus.reportNodeCreate( ref eRestoreAction,
ulTransId, uiShortNum1, ulLongNum1,
(eDomNodeType)uiShortNum2, uiShortNum3, (eNodeInsertLoc)uiShortNum4));
case RestoreStatusAction.REPORT_NODE_CHILDREN_DELETE:
return( m_restoreStatus.reportNodeChildrenDelete( ref eRestoreAction,
ulTransId, uiShortNum1, ulLongNum1, uiShortNum2));
case RestoreStatusAction.REPORT_ATTRIBUTE_DELETE:
return( m_restoreStatus.reportAttributeDelete( ref eRestoreAction,
ulTransId, uiShortNum1, ulLongNum1, uiShortNum2));
case RestoreStatusAction.REPORT_NODE_DELETE:
return( m_restoreStatus.reportNodeDelete( ref eRestoreAction,
ulTransId, uiShortNum1, ulLongNum1));
case RestoreStatusAction.REPORT_DOCUMENT_DONE:
return( m_restoreStatus.reportDocumentDone( ref eRestoreAction,
ulTransId, uiShortNum1, ulLongNum1));
case RestoreStatusAction.REPORT_ROLL_OVER_DB_KEY:
return( m_restoreStatus.reportRollOverDbKey( ref eRestoreAction,
ulTransId));
}
return( RCODE.NE_XFLM_INVALID_PARM);
}
private RestoreStatus m_restoreStatus;
}
/// <summary>
/// Makes a copy of an existing database.
/// </summary>
/// <param name="sSrcDbName">
/// <summary>
/// Makes a copy of an existing database.
/// </summary>
/// <param name="sSrcDbName">
/// The name of the control file of the database to be copied.
/// </param>
/// <param name="sSrcDataDir">
/// The directory where the data files for the source
/// database are stored. See <see cref="dbCreate"/> for more information.
/// </param>
/// <param name="sSrcRflDir">
/// </param>
/// <param name="sSrcDataDir">
/// The directory where the data files for the source
/// database are stored. See <see cref="dbCreate"/> for more information.
/// </param>
/// <param name="sSrcRflDir">
/// The directory where the RFL files for the source
/// database are stored. See <see cref="dbCreate"/> for more information.
/// </param>
/// <param name="sDestDbName">
/// The name of the control file that is to be created for the destination database.
/// </param>
/// <param name="sDestDataDir">
/// The directory where the data files for the destination database will be stored.
/// See <see cref="dbCreate"/> for more information.
/// </param>
/// <param name="sDestRflDir">
/// The directory where the RFL files for the destination database will be stored.
/// See <see cref="dbCreate"/> for more information.
/// </param>
/// database are stored. See <see cref="dbCreate"/> for more information.
/// </param>
/// <param name="sDestDbName">
/// The name of the control file that is to be created for the destination database.
/// </param>
/// <param name="sDestDataDir">
/// The directory where the data files for the destination database will be stored.
/// See <see cref="dbCreate"/> for more information.
/// </param>
/// <param name="sDestRflDir">
/// The directory where the RFL files for the destination database will be stored.
/// See <see cref="dbCreate"/> for more information.
/// </param>
/// <param name="copyStatus">
/// If non-null this is an object that implements the <see cref="DbCopyStatus"/>
/// interface. It is a callback object that is used to report copy progress.
@@ -683,54 +745,75 @@ namespace xflaim
DbCopyStatus copyStatus)
{
int rc;
DbCopyStatusCallback fnDbCopyStatus = new DbCopyStatusCallback( funcDbCopyStatus);
DbCopyStatusDelegate dbCopyStatus = null;
DbCopyStatusCallback fnDbCopyStatus = null;
if (copyStatus != null)
{
dbCopyStatus = new DbCopyStatusDelegate( copyStatus);
fnDbCopyStatus = new DbCopyStatusCallback( dbCopyStatus.funcDbCopyStatus);
}
if ((rc = xflaim_DbSystem_dbCopy( m_this, sSrcDbName, sSrcDataDir, sSrcRflDir,
sDestDbName, sDestDataDir, sDestRflDir, copyStatus, fnDbCopyStatus)) != 0)
sDestDbName, sDestDataDir, sDestRflDir, fnDbCopyStatus)) != 0)
{
throw new XFlaimException( rc);
}
}
private delegate RCODE DbCopyStatusCallback(
DbCopyStatus copyStatus,
ulong ulBytesToCopy,
ulong ulBytesCopied,
int bNewSrcFile,
IntPtr pszSrcFileName,
IntPtr pszDestFileName);
private static RCODE funcDbCopyStatus(
DbCopyStatus copyStatus,
ulong ulBytesToCopy,
ulong ulBytesCopied,
int bNewSrcFile,
IntPtr pszSrcFileName,
IntPtr pszDestFileName)
private class DbCopyStatusDelegate
{
string sSrcFileName = null;
string sDestFileName = null;
if (bNewSrcFile != 0)
public DbCopyStatusDelegate(
DbCopyStatus dbCopyStatus)
{
sSrcFileName = Marshal.PtrToStringAnsi( pszSrcFileName);
sDestFileName = Marshal.PtrToStringAnsi( pszDestFileName);
m_dbCopyStatus = dbCopyStatus;
}
return( copyStatus.dbCopyStatus( ulBytesToCopy, ulBytesCopied,
sSrcFileName, sDestFileName));
~DbCopyStatusDelegate()
{
}
public RCODE funcDbCopyStatus(
ulong ulBytesToCopy,
ulong ulBytesCopied,
int bNewSrcFile,
IntPtr pszSrcFileName,
IntPtr pszDestFileName)
{
RCODE rc = RCODE.NE_XFLM_OK;
string sSrcFileName = null;
string sDestFileName = null;
if (bNewSrcFile != 0)
{
sSrcFileName = Marshal.PtrToStringAnsi( pszSrcFileName);
sDestFileName = Marshal.PtrToStringAnsi( pszDestFileName);
}
rc = m_dbCopyStatus.dbCopyStatus( ulBytesToCopy, ulBytesCopied,
sSrcFileName, sDestFileName);
return( rc);
}
private DbCopyStatus m_dbCopyStatus;
}
// PRIVATE METHODS THAT ARE IMPLEMENTED IN C AND C++
[DllImport("xflaim")]
private static extern int xflaim_DbSystem_createDbSystem(
out ulong pulDbSystemRef);
[DllImport("xflaim")]
private static extern int xflaim_DbSystem_createDbSystem(
out ulong pulDbSystemRef);
[DllImport("xflaim")]
private static extern int xflaim_DbSystem_Release(
ulong ulThis);
[DllImport("xflaim")]
private static extern int xflaim_DbSystem_Release(
ulong ulThis);
[DllImport("xflaim",CharSet=CharSet.Ansi)]
[DllImport("xflaim",CharSet=CharSet.Ansi)]
private static extern int xflaim_DbSystem_dbCreate(
ulong ulThis,
[MarshalAs(UnmanagedType.LPStr)] string pszDbFileName,
@@ -741,7 +824,7 @@ namespace xflaim
CREATE_OPTS pCreateOpts,
out ulong pulDbRef);
[DllImport("xflaim",CharSet=CharSet.Ansi)]
[DllImport("xflaim",CharSet=CharSet.Ansi)]
private static extern int xflaim_DbSystem_dbOpen(
ulong ulThis,
[MarshalAs(UnmanagedType.LPStr)] string pszDbFileName,
@@ -751,7 +834,7 @@ namespace xflaim
int bAllowLimited,
out ulong pulDbRef);
[DllImport("xflaim",CharSet=CharSet.Ansi)]
[DllImport("xflaim",CharSet=CharSet.Ansi)]
private static extern int xflaim_DbSystem_dbRemove(
ulong ulThis,
[MarshalAs(UnmanagedType.LPStr)] string pszDbFileName,
@@ -759,7 +842,7 @@ namespace xflaim
[MarshalAs(UnmanagedType.LPStr)] string pszRflDir,
int bRemoveRflFiles);
[DllImport("xflaim",CharSet=CharSet.Ansi)]
[DllImport("xflaim",CharSet=CharSet.Ansi)]
private static extern int xflaim_DbSystem_dbRestore(
ulong ulThis,
[MarshalAs(UnmanagedType.LPStr)] string pszDbFileName,
@@ -767,12 +850,10 @@ namespace xflaim
[MarshalAs(UnmanagedType.LPStr)] string pszRflDir,
[MarshalAs(UnmanagedType.LPStr)] string pszBackupPath,
[MarshalAs(UnmanagedType.LPStr)] string pszPassword,
RestoreClient restoreClient,
RestoreClientCallback fnRestoreClient,
RestoreStatus restoreStatus,
RestoreStatusCallback fnRestoreStatus);
[DllImport("xflaim",CharSet=CharSet.Ansi)]
[DllImport("xflaim",CharSet=CharSet.Ansi)]
private static extern int xflaim_DbSystem_dbCopy(
ulong ulThis,
[MarshalAs(UnmanagedType.LPStr)] string pszSrcDbName,
@@ -781,7 +862,6 @@ namespace xflaim
[MarshalAs(UnmanagedType.LPStr)] string pszDestDbName,
[MarshalAs(UnmanagedType.LPStr)] string pszDestDataDir,
[MarshalAs(UnmanagedType.LPStr)] string pszDestRflDir,
DbCopyStatus copyStatus,
DbCopyStatusCallback fnDbCopyStatus);
private ulong m_this;