If you want to perform any action in the process of updating service data storage, it is possible to organize the processing of event data service through a dedicated business server.
So, to organize this processing, you must:
- Describe the class — business server, a successor from
ICSSoft.STORMNET.Business.BusinessServer
. - To describe the method-interceptor view
public DataObject[] OnUpdateXXXXX(XXXXX UpdatedObject)
where XXXXX is the name of the data class whose instances updates service data. To implement this method (to perform the necessary actions when you upgrade).
Specify the business server to the data class
To register a business server needs data class .Net
-attribute BusinessServer
, at the same time indicating the type of event.
The event types are as follows:
DataServiceObjectEvents.OnAllEvents
— all the events of data service;DataServiceObjectEvents.OnAnyEvent
— any events of data service (irrelevant when attributing events that are important when obtaining a business server viaBusinessServerProvider.GetBusinessServer
, you can get a business server, without distinction regarding the types of events on which it was signed);DataServiceObjectEvents.OnDeleteFromStorage
— data object be deleted service data;DataServiceObjectEvents.OnInsertToStorage
— data object will be created in хранилище;DataServiceObjectEvents.OnUpdateInStorage
— data object will be updated in the repository.
Event types can be combined using |
.
The data service will call a method-interceptor just before executing the operation. Parameter the method will come data object, on which the operation is performed. Method can return any additional data objects that will be picked up by the» «service data.
About why you need to return data objects instead of doing individual calls to the data service directly from within an interceptor. The answer is obvious — in order to update attached objects executed in the same transaction](fo_bs-transact.html). Otherwise, a separate call data service — private transaction, respectively, if the code is not running under a transaction server (eg. COM
), there will be a gap.
The programmer can know what business server assigned to the data class via provider business servers, the method BusinessServerProvider.GetBusinessServer
.
An example of a business server and data class with assigned business server
public class DataServiceEventsServer:ICSSoft.STORMNET.Business.BusinessServer
{
public DataObject[] OnUpdateЖурнал(Журнал UpdatedObject)
{
Console.WriteLine("Caught log update {0}." , UpdatedObject.Наименование);
return new DataObject[0];
}
}
[BusinessServer(typeof(DataServiceEventsServer), DataServiceObjectEvents.OnInsertToStorage)]
// *** End programmer edit section *** (Log CustomAttributes)
public class Журнал : Ресурс
{
/*Something*/
}
Other examples
- Check uniqueness of data entered in the business server.
- Example of use business-servers.
- Checking the validity of changes to the data object in business server
- github.com.
Features of functioning
Service data will cause a method interceptor immediately before the operation. Parameter the method will come data object, on which the operation is performed. Method can return any additional data objects that will be picked up by the» «service data.
You need to return data objects instead of doing individual calls to the data service directly from within an interceptor to updates added executed in the same transaction. Otherwise, a separate call data service — private transaction, respectively, if the code is not running under a transaction server (eg. COM
), there will be a gap.