OpenPetra
Free Administration Software for Non-Profits
Ict.Petra.Shared.TCacheableTablesManager Class Reference
Inheritance diagram for Ict.Petra.Shared.TCacheableTablesManager:
Ict.Common.Remoting.Shared.ICacheableTablesManager

Public Member Functions

 TCacheableTablesManager (TDelegateSendClientTask ADelegateSendClientTask)
 Constructor More...
 
String AddCachedTable (DataTable ACacheableTable)
 Adds the passed in DataTable to the Cache. More...
 
String AddCachedTable (String ACacheableTableName, DataTable ACacheableTable)
 Adds the passed in DataTable to the Cache. More...
 
DataTable GetCachedDataTable (String ACacheableTableName, out System.Type AType)
 Returns a DataTable from the Cache. More...
 
String GetCachedDataTableHash (String ACacheableTableName)
 Returns the Hash Code of a DataTable in the Cache. More...
 
Int32 GetCachedDataTableSize (String ACacheableTableName)
 Returns the TableSize of a DataTable in the Cache. More...
 
System.Type GetCachedDataTableType (String ACacheableTableName)
 Returns the System.Type of a DataTable in the Cache. More...
 
void AddOrRefreshCachedTable (DataTable ACacheableTable, System.Int32 AClientID)
 Adds the passed in DataTable to the Cache. If it is already there, the DataTable in the Cache is replaced with the one that is passed in. More...
 
void AddOrRefreshCachedTable (String ACacheableTableName, DataTable ACacheableTable, System.Int32 AClientID)
 Adds the passed in DataTable to the Cache. If it is already there, the DataTable in the Cache is replaced with the one that is passed in. More...
 
void RefreshCachedTable (DataTable ACacheableTable, System.Int32 AClientID)
 Replaces a DataTable in the Cache with the one that is passed in. More...
 
void RefreshCachedTable (String ACacheableTableName, DataTable ACacheableTable, System.Int32 AClientID)
 Replaces a DataTable in the Cache with the one that is passed in. More...
 
void AddOrMergeCachedTable (DataTable ACacheableTable, System.Int32 AClientID)
 Adds the passed in DataTable to the Cache. If it is already there, a Merge operation is done. More...
 
void AddOrMergeCachedTable (DataTable ACacheableTable, System.Int32 AClientID, object AFilterCriteria)
 Adds the passed in DataTable to the Cache. If it is already there, a Merge operation is done. More...
 
void AddOrMergeCachedTable (String ACacheableTableName, DataTable ACacheableTable, System.Int32 AClientID)
 Adds the passed in DataTable to the Cache. If it is already there, a Merge operation is done. More...
 
void AddOrMergeCachedTable (String ACacheableTableName, DataTable ACacheableTable, System.Int32 AClientID, object AFilterCriteria)
 Adds the passed in DataTable to the Cache. If it is already there, a Merge operation is done. More...
 
Boolean IsTableCached (String ACacheableTableName)
 Returns true if the DataTable with the specified TableName is in the DataCache and does not need refreshing. More...
 
Boolean IsTableCached (String ACacheableTableName, out Boolean AIsUpToDate)
 Returns true if the DataTable with the specified TableName is in the DataCache. If it returns true the AIsUpToDate parameter will indicate if the cached table is up-to-date. This method is required by the client-side manager only. More...
 
void MarkCachedTableNeedsRefreshing (String ACacheableTableName)
 Marks a DataTable in the Cache to be no longer up-to-date (=out of sync with the data that was originally placed in the DataTable). More...
 
void MarkAllCachedTableNeedsRefreshing ()
 Marks all DataTables in the Cache to be no longer up-to-date (=out of sync with the data that was originally placed in the DataTable). More...
 
void MarkChangedCacheTableSaved (String ACacheableTableName)
 Marks a DataTable as being saved to the external source of the data and having no changes to it. More...
 

Static Public Member Functions

static void Init ()
 

Static Public Attributes

static TCacheableTablesManager GCacheableTablesManager
 a static instance for this class More...
 

Properties

Int32 CacheSize [get]
 Current size of the data in the Cache More...
 
Int32 CachedTablesCount [get]
 Number of DataTables in the Cache More...
 
Int32 MaxCacheSize [get, set]
 Maximum size that the Cache shouldn't exceed More...
 
TimeSpan MaxTimeInCache [get, set]
 Maximum time that a DataTable in the Cache should be cached More...
 

Detailed Description

<summary>

Contains methods that allow managing a Cache that can contain arbitrary DataTables (typed and untyped DataTables).

This Class is an implementation of a Cache Manager. It gets used by both PetraServer and PetraClient to manage a Cache of DataTables (that would usually be lookup tables for ComboBoxes, etc.). When it is used by the PetraServer, it is instantiated only once in the main AppDomain of the PetraServer. Each time a Client requests a Cacheable DataTable from the PetraServer, a cross-AppDomain call from the Client's AppDomain to methods of the Object of this Class that is instantiated in the main AppDomain is made. When it is used by the PetraClient, it is instantiated only once by the TDataCache Class in Ict.Petra.Client.App.Core.Cache, which is the only Class that programmers need to use on the Client side.

@comment This class is thread save. It protects two resources, UDataCacheDataSet and UDataCacheContentsDT with the same ReaderWriterLock (not with a Monitor - for performance). The DataTables that are handed out of TCacheableTablesManager are copies of the DataTables in the Cache. This is done to get around multi-threading reading/writing issues that might occur when the caller performs read or write operations on the DataTable - which are out of control of this class.

@comment Several of the Methods are declared as 'virtual'. This is necessary for all Methods that are called cross-AppDomain. Explanation for this: mono can't cope with method calls into different AppDomains if these methods are not marked virtual (see answer of Lluis Sanchez for the filed bug #76752 in mono's bugzilla). Apparently, C# code automatically marks such methods virtual when it is JITted, but Delphi.NET code doesn't do this.

@TODO Test some cache management functions (enabled by setting Properties MaxCacheSize and MaxTimeInCache) - the implementation of adhering to these settings is probably not quite finished yet (due to time constraints).

Constructor & Destructor Documentation

◆ TCacheableTablesManager()

Ict.Petra.Shared.TCacheableTablesManager.TCacheableTablesManager ( TDelegateSendClientTask  ADelegateSendClientTask)
inline

Constructor

Parameters
ADelegateSendClientTaskDelegate that is used for sending a ClientTask to all other Clients to tell them to reload a certain Cacheable DataTable
Returns
void

Member Function Documentation

◆ AddCachedTable() [1/2]

String Ict.Petra.Shared.TCacheableTablesManager.AddCachedTable ( DataTable  ACacheableTable)
inline

Adds the passed in DataTable to the Cache.

Parameters
ACacheableTableDataTable that should be added to the Cache
Returns
HashCode of the DataTable

◆ AddCachedTable() [2/2]

String Ict.Petra.Shared.TCacheableTablesManager.AddCachedTable ( String  ACacheableTableName,
DataTable  ACacheableTable 
)
inline

Adds the passed in DataTable to the Cache.

Parameters
ACacheableTableNameName of the DataTable. This is the name by which the DataTable will be identified in the Cache. Also, the TableName property of the DataTable is set to this
ACacheableTableDataTable that should be added to the Cache
Returns
HashCode of the DataTable

◆ AddOrMergeCachedTable() [1/4]

void Ict.Petra.Shared.TCacheableTablesManager.AddOrMergeCachedTable ( DataTable  ACacheableTable,
System.Int32  AClientID 
)
inline

Adds the passed in DataTable to the Cache. If it is already there, a Merge operation is done.

Parameters
ACacheableTableDataTable that should be added to the Cache/merged with an already existing DataTable in the Cache with the same TableName
AClientIDThe ClientID that should be exempt from getting a ClientTask queued for updating of the Cached DataTable (only if a Merge operation is done). This would be the ClientID of the Client that performed the call to this procedure
Returns
void

◆ AddOrMergeCachedTable() [2/4]

void Ict.Petra.Shared.TCacheableTablesManager.AddOrMergeCachedTable ( DataTable  ACacheableTable,
System.Int32  AClientID,
object  AFilterCriteria 
)
inline

Adds the passed in DataTable to the Cache. If it is already there, a Merge operation is done.

Parameters
ACacheableTableDataTable that should be added to the Cache/merged with an already existing DataTable in the Cache with the same TableName
AClientIDThe ClientID that should be exempt from getting a ClientTask queued for updating of the Cached DataTable (only if a Merge operation is done). This would be the ClientID of the Client that performed the call to this procedure
AFilterCriteriaFilter Criteria (eg. Ledger Number for the Finance Module) that will be needed by the Clients that receive the ClientTask to be able to request the update of the filtered Cached DataTable
Returns
void

◆ AddOrMergeCachedTable() [3/4]

void Ict.Petra.Shared.TCacheableTablesManager.AddOrMergeCachedTable ( String  ACacheableTableName,
DataTable  ACacheableTable,
System.Int32  AClientID 
)
inline

Adds the passed in DataTable to the Cache. If it is already there, a Merge operation is done.

Parameters
ACacheableTableNameName of the DataTable
ACacheableTableDataTable that should be added to the Cache/merged with an already existing DataTable in the Cache with the same TableName
AClientIDThe ClientID that should be exempt from getting a ClientTask queued for updating of the Cached DataTable (only if a Merge operation is done). This would be the ClientID of the Client that performed the call to this procedure
Returns
void

◆ AddOrMergeCachedTable() [4/4]

void Ict.Petra.Shared.TCacheableTablesManager.AddOrMergeCachedTable ( String  ACacheableTableName,
DataTable  ACacheableTable,
System.Int32  AClientID,
object  AFilterCriteria 
)
inline

Adds the passed in DataTable to the Cache. If it is already there, a Merge operation is done.

Parameters
ACacheableTableNameName of the DataTable
ACacheableTableDataTable that should be added to the Cache/merged with an already existing DataTable in the Cache with the same TableName
AClientIDThe ClientID that should be exempt from getting a ClientTask queued for updating of the Cached DataTable (only if a Merge operation is done). This would be the ClientID of the Client that performed the call to this procedure
AFilterCriteriaFilter Criteria (eg. Ledger Number for the Finance Module) that will be needed by the Clients that receive the ClientTask to be able to request the update of the filtered Cached DataTable
Returns
void

◆ AddOrRefreshCachedTable() [1/2]

void Ict.Petra.Shared.TCacheableTablesManager.AddOrRefreshCachedTable ( DataTable  ACacheableTable,
System.Int32  AClientID 
)
inline

Adds the passed in DataTable to the Cache. If it is already there, the DataTable in the Cache is replaced with the one that is passed in.

Parameters
ACacheableTableDataTable that should be added to the Cache/merged with an already existing DataTable in the Cache with the same TableName
AClientIDThe ClientID that should be exempt from getting a ClientTask queued for updating of the Cached DataTable (only if a Merge operation is done). This would be the ClientID of the Client that performed the call to this procedure
Returns
void

◆ AddOrRefreshCachedTable() [2/2]

void Ict.Petra.Shared.TCacheableTablesManager.AddOrRefreshCachedTable ( String  ACacheableTableName,
DataTable  ACacheableTable,
System.Int32  AClientID 
)
inline

Adds the passed in DataTable to the Cache. If it is already there, the DataTable in the Cache is replaced with the one that is passed in.

Parameters
ACacheableTableNameDataTable that should be added to the Cache/merged
ACacheableTableDataTable that should be added to the Cache/merged with an already existing DataTable in the Cache with the same TableName
AClientIDThe ClientID that should be exempt from getting a ClientTask queued for updating of the Cached DataTable (only if a Merge operation is done). This would be the ClientID of the Client that performed the call to this procedure
Returns
void

◆ GetCachedDataTable()

DataTable Ict.Petra.Shared.TCacheableTablesManager.GetCachedDataTable ( String  ACacheableTableName,
out System.Type  AType 
)
inline

Returns a DataTable from the Cache.

Parameters
ACacheableTableNameName of the DataTable
AType
Returns
DataTable from the Cache
Exceptions
ECacheableTablesMgrTableNotUpToDateExceptionif the Cacheable DataTable isn't in an up-to-date state. This means it needs to be retrieved anew before it can be used

◆ GetCachedDataTableHash()

String Ict.Petra.Shared.TCacheableTablesManager.GetCachedDataTableHash ( String  ACacheableTableName)
inline

Returns the Hash Code of a DataTable in the Cache.

Parameters
ACacheableTableNameName of the DataTable
Returns
Hash Code of the DataTable in the Cache
Exceptions
ECacheableTablesMgrExceptionIf the DataTable doesn't exist in the Cache (=has no entry in the 'Table of Contents' of the Cache)

◆ GetCachedDataTableSize()

Int32 Ict.Petra.Shared.TCacheableTablesManager.GetCachedDataTableSize ( String  ACacheableTableName)
inline

Returns the TableSize of a DataTable in the Cache.

Parameters
ACacheableTableNameName of the DataTable
Returns
TableSize of the DataTable in the Cache. This size (in bytes) is an approximated size since it isn't possible to get the size in memory of a DataTable object. It is the String Length of all columns' values of all DataRows
Exceptions
ECacheableTablesMgrExceptionif the DataTable doesn't exist in the Cache

◆ GetCachedDataTableType()

System.Type Ict.Petra.Shared.TCacheableTablesManager.GetCachedDataTableType ( String  ACacheableTableName)
inline

Returns the System.Type of a DataTable in the Cache.

Parameters
ACacheableTableNameName of the DataTable
Returns
Type of the DataTable in the Cache. This is only useful for Typed DataTables
Exceptions
ECacheableTablesMgrExceptionif the DataTable doesn't exist in the Cache

◆ Init()

static void Ict.Petra.Shared.TCacheableTablesManager.Init ( )
inlinestatic

◆ IsTableCached() [1/2]

Boolean Ict.Petra.Shared.TCacheableTablesManager.IsTableCached ( String  ACacheableTableName)
inline

Returns true if the DataTable with the specified TableName is in the DataCache and does not need refreshing.

Parameters
ACacheableTableNameName of the DataTable
Returns
true if the DataTable with the specified TableName is in the DataCache and is uptodate, otherwise false

◆ IsTableCached() [2/2]

Boolean Ict.Petra.Shared.TCacheableTablesManager.IsTableCached ( String  ACacheableTableName,
out Boolean  AIsUpToDate 
)
inline

Returns true if the DataTable with the specified TableName is in the DataCache. If it returns true the AIsUpToDate parameter will indicate if the cached table is up-to-date. This method is required by the client-side manager only.

Parameters
ACacheableTableNameName of the DataTable
AIsUpToDateWill be true if the table is in the cache and up-to-date. False otherwise
Returns
true if the DataTable with the specified TableName is in the DataCache

◆ MarkAllCachedTableNeedsRefreshing()

void Ict.Petra.Shared.TCacheableTablesManager.MarkAllCachedTableNeedsRefreshing ( )
inline

Marks all DataTables in the Cache to be no longer up-to-date (=out of sync with the data that was originally placed in the DataTable).

This will lead to ECacheableTablesMgrTableNotUpToDateException being thrown when GetCachedDataTable is called for this DataTable. This tells the caller of GetCachedDataTable that the DataTable needs to be retrieved anew before it can be used.

Returns
void
Exceptions
ECacheableTablesMgrExceptionif the DataTable doesn't exist in the Cache

◆ MarkCachedTableNeedsRefreshing()

void Ict.Petra.Shared.TCacheableTablesManager.MarkCachedTableNeedsRefreshing ( String  ACacheableTableName)
inline

Marks a DataTable in the Cache to be no longer up-to-date (=out of sync with the data that was originally placed in the DataTable).

This will lead to ECacheableTablesMgrTableNotUpToDateException being thrown when GetCachedDataTable is called for this DataTable. This tells the caller of GetCachedDataTable that the DataTable needs to be retrieved anew before it can be used.

Parameters
ACacheableTableNameName of the DataTable
Returns
void
Exceptions
ECacheableTablesMgrExceptionif the DataTable doesn't exist in the Cache

◆ MarkChangedCacheTableSaved()

void Ict.Petra.Shared.TCacheableTablesManager.MarkChangedCacheTableSaved ( String  ACacheableTableName)
inline

Marks a DataTable as being saved to the external source of the data and having no changes to it.

This will lead to ECacheableTablesMgrTableNotUpToDateException beeing thrown when GetCachedDataTable is called for this DataTable. This tells the caller of GetCachedDataTable that the DataTable needs to be retrieved anew before it can be used.

Parameters
ACacheableTableNameName of the DataTable
Returns
void
Exceptions
ECacheableTablesMgrExceptionif the DataTable doesn't exist in the Cache

◆ RefreshCachedTable() [1/2]

void Ict.Petra.Shared.TCacheableTablesManager.RefreshCachedTable ( DataTable  ACacheableTable,
System.Int32  AClientID 
)
inline

Replaces a DataTable in the Cache with the one that is passed in.

Parameters
ACacheableTableDataTable that should be added to the Cache/merged with an already existing DataTable in the Cache with the same TableName
AClientIDThe ClientID that should be exempt from getting a ClientTask queued for updating of the Cached DataTable (only if a Merge operation is done). This would be the ClientID of the Client that performed the call to this procedure
Returns
void

◆ RefreshCachedTable() [2/2]

void Ict.Petra.Shared.TCacheableTablesManager.RefreshCachedTable ( String  ACacheableTableName,
DataTable  ACacheableTable,
System.Int32  AClientID 
)
inline

Replaces a DataTable in the Cache with the one that is passed in.

Parameters
ACacheableTableNameName of the DataTable
ACacheableTableDataTable that should be added to the Cache/merged with an already existing DataTable in the Cache with the same TableName
AClientIDThe ClientID that should be exempt from getting a ClientTask queued for updating of the Cached DataTable (only if a Merge operation is done). This would be the ClientID of the Client that performed the call to this procedure
Returns
void

Member Data Documentation

◆ GCacheableTablesManager

TCacheableTablesManager Ict.Petra.Shared.TCacheableTablesManager.GCacheableTablesManager
static

a static instance for this class

Property Documentation

◆ CachedTablesCount

Int32 Ict.Petra.Shared.TCacheableTablesManager.CachedTablesCount
get

Number of DataTables in the Cache

◆ CacheSize

Int32 Ict.Petra.Shared.TCacheableTablesManager.CacheSize
get

Current size of the data in the Cache

◆ MaxCacheSize

Int32 Ict.Petra.Shared.TCacheableTablesManager.MaxCacheSize
getset

Maximum size that the Cache shouldn't exceed

◆ MaxTimeInCache

TimeSpan Ict.Petra.Shared.TCacheableTablesManager.MaxTimeInCache
getset

Maximum time that a DataTable in the Cache should be cached


The documentation for this class was generated from the following file: