Learn More

Table of contents

  • Audit API
  • Audit data and criteria
  • Oracle database
  • Attributes

Audit API

To access Auidit settings in code use Xafari.BC.Audit.XafariAuditSettings static class, it exposes the following properties:

TopReturningObjects: specifies the maximum number of records in the database that will be obtained on request (default value is 1000).

UserModifyFieldName: specifies the field name to store the name of user who modified object.

DateModifyFieldName: specifies the field name to store the date of modification of object.

AuditSettingsManager provides manager class to manage Audit data and settings (see AuditSettingsManager Interface). The manager methods are listed below:

  • ApplyAuditSettings(): applies current Audit Settings.
  • DisableAudit(): disables Audit for database.
  • GetAuditDataByObject(IAuditSupport filteringObject): returns Audit data for specified object. If you specify null value, method returns all Audit records.
  • GetAuditDataByObject(DataRow collectionChangedDescription, string collectionName): returns Audit data for modified collection. collectionName parameter specifies the name of the modified collection. collectionChangedDescription parameter is a DataRow that is obtained from all strings GetAuditDataByObject(IAuditSupport  filteringObject).
  • GetAuditDetailDataByObject( XafariAuditedType type, DataRow auditDetailId, out string columns): returns detailed data for the current record from the total transaction log. type parameter specifies the audited type for which the details is requested. auditDetailId is a DataRow that is obtained from all strings GetAuditDataByObject(IAuditSupport  filteringObject). columns specifies the names of the modified columns.
  • GetTablesForType( XafariAuditedType type): returns all the tables that are affected by the specified type.
  • GetColumns( string tableName): returns all available columns of tableName table.
  • AddAuditInfoForObject(IAuditSupport filteringObject, string action [, string notes=null, string currentUserName = null]): add new record about object to Audit protocol. filteringObject specifies the object for recording. action specifies executed Action. notes allows you to specify a note and currentUserName - user name in the record.
  • AddAuditInfo (string action, string notes= null, string currentUserName = null): add new record to Audit log.
  • RemoveAuditData(IAuditSupport dataParameters, PeriodStruct period): clear the Audit protocol for dataParameters type for the specified period. If dataParameters==null, method will comon protocol without type filters.
  • GetChangedObjects(Type objectType, DateTime startDate, DateTime endDate, AuditedActions actions): returns all objectType objects, which was recorded in the Audit protocol for the specified period.

AuditSettingsManagerDbTriggers class inherit from IAuditSettingsManager. It implements Audit based on the triggers. SpecifyAuditDataProvider event allows to set current data provider. It would need to do if the database is different from MS-SQL (Oracle).

Audit data and criteria

XafariTransactionsAudit class allows to successfully use Audit data when constructing criteria. It exposes the following service fields:

Audit_AuditDateTime: date of recording in Audit protocol.

Audit_AuditId: the Id of Audit record.

Audit_TableName: the name of the table on which the record was created.

Audit_AuditTableName: the name of Audit tables, in which  additional Audit data were recorded.

Audit_ActionType: allows you to specify some standard operations that are performed on the object. You can use the following values:

I: create record

U: modify object fields

D: delete object

Action: […]: execute Action

BO: […]: start Business Operation

BO RoledBack: […]: rollback Business Operation

LogIn: […]: user log in

LogOff: […]: user log off

Report: […]: generate report

Audit_SpecifyTransaction: identifier of the transaction in which the changes were made.

Audit_UserName: the name of the user who made the change.

Audit_ObjectId:  Id of the object, which was modified. There are two ways to specify a value: the direct identifier value or a string representation. For example, 'E9B9B41E-2C5D-44C3-A1F3-FE6CEC908993' or '[Guid]' E9B9B41E-2C5D-44C3-A1F3-FE6CEC908993 ''.

Audit_TypeName: the full name of the audited type.

Audit_Notes: note to Audit record.

Examples of criteria:

Sample 1. Get the Audit records for the Xafari.BCDemo.BusinessObjects.DynamicPropertiesDC type for a specific time period:

  • example

[Audit_TypeName] = 'Xafari.BCDemo.BusinessObjects.DynamicPropertiesDC' AND ([Audit_AuditDateTime] > ?) AND ([Audit_AuditDateTime] < ?)

Sample 2. Get the Audit records for the Xafari.BCDemo.BusinessObjects.DynamicPropertiesDC type for a specific time period and which are associated with "Create" operation.

  • example

[Audit_TypeName] = 'Xafari.BCDemo.BusinessObjects.DynamicPropertiesDC' AND ([Audit_AuditDateTime] > ?) AND ([Audit_AuditDateTime] < ?) AND [Audit_ActionType] = 'I'

Such criteria are used by the GetChangedObjects function.

Oracle database

OracleDataProvider class provides Audit work with Oracle database. It implements IDataProvider interface and provides low-level interaction with the database. If the connection string contains XpoProvider = Oracle, then OracleDataProvider will be loaded automatically. It is the default behavior.

If the default behavior is not satisfactory, then there is SpecifyAuditDataProvider event of AuditSettingsManagerDbTriggers class, the event allows you to override the data provider. The developer can specify own provider, which must implement IDataProvider interface.


ReferenceAudit may be applied to the reference property. It specifies that this property must be audited as aggregated (that is, when modifying the object stored in this field, another one record should be made: the record about object-owner modification).  

NotAudited attribute indicates that this field will not be audited and it is not necessary to generate the Setting.