This article applies to new audit.

mechanism determining the connection string when the audit

“‘The mechanism works in versions of assemblies after 27.01.2015.”’

The conduct of the audit is important to determine how and what DB will be used to record the audit data. For this you define the connection string name to the audit and the type of data service.

specifying the name of the connection string

Define the name of the connection string occurs according to the following algorithm:

  1. From the settings audit class (AuditClassSetting) does the setting AuditClassConnectionStringName.
public class FirstClass : ICSSoft.STORMNET.DataObject, IDataObjectWithAuditFields
	/// <summary> 
	/// Audit class settings. 
	/// </summary> 
	public class AuditSettings
		/// <summary> 
		/// The name of the connection string to the database where you want to write audit. 
		/// </summary> 
		public static string AuditClassConnectionStringName = "FirstClassConnectionStringName";

If AuditClassConnectionStringName defined in the settings of the audit class and the value is a non-empty sequence of characters, then it is taken as the name of the connection string.

  1. If the previous method the name of the connection string was not specified, the setting IsDatabaseLocal (see also following article).

2.1. If IsDatabaseLocal = false, as the name of the connection string takes the value AuditConnectionStringName.

2.2. If IsDatabaseLocal = true, then the structures AuditDSSetting.

It is believed that if IsDatabaseLocal = true, the audit record will be made in the “current” database by “current” data service (the term “current” conventionally, as a method determine the name of the connection string type “current” data service can get in various ways).

If the “current” data service is incorrect, as the name of the connection string, use the value ConnStringName of the first AuditDSSetting from AuditDSSettings array (connection string name is defined by default as <AppNameForAudit>_<auditconnectionstringname>).

Otherwise, the array is searched AuditDSSettings AuditDSSetting, where ConnString is the connection string “current” data service, and DataServiceType - type of the “current” data service, and the value of the first found ConnStringName is the required name of the connection string for the audit.

Interface implementation IAudit ICSSoft.STORMNET.Business.Audit.Audit processes the received name of the connection string as follows:

Is searching for a connection string by name from the available in the configuration file.

If the connection string was not found, it uses the connection string from DataServiceProvider.DataService.

define the type of data service

Type service data, through which will be recorded in the audit is not determined at the stage of preparing data for recording in the audit. The type determined in the interface implementation IAudit.

Interface implementation IAudit ICSSoft.STORMNET.Business.Audit.Audit determines the type of the service data in the following way (see also following article):

Type of the service data is searched for in the config for the key _DSType.

If there is no such record, the data service specified in the setting “DefaultDSType”.

is used Otherwise the service type data DataServiceProvider.DataService.

Переведено сервисом «Яндекс.Переводчик»