SelfServicing and log every insert/update/delete

Posts   
 
    
mdissel
User
Posts: 92
Joined: 16-Sep-2003
# Posted on: 17-Jun-2004 14:26:59   

Hello

I wat to use SelfServicing and use some logging feature that will log database calls for important classes.

Is this possible with SelfServicing, without changing every OnSave/OnDelete in the BaseEntities?

Thanks

Marco

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39614
Joined: 17-Aug-2003
# Posted on: 17-Jun-2004 15:32:40   

You have to override the Save and Delete methods in the derived classes for this.

Frans Bouma | Lead developer LLBLGen Pro
mafti
User
Posts: 38
Joined: 27-Oct-2004
# Posted on: 09-Nov-2004 11:31:09   

is this still true?

basically i want to log the session-user and the action he does.

i really don't want to override/write delete() and save() for every entity i have

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39614
Joined: 17-Aug-2003
# Posted on: 09-Nov-2004 14:22:45   

You can override that in 1 include template. Write the routines, place these routines in the file entityAuditingInclude.template in the SharedTemplates\C# folder (or if you're using VB.NET, in the VB.NET folder) and make a copy of the templateset config file you're using (CSharpTemplateSet.config for example)

Open the copy in an editor (it's xml) and change the name tag contents so you'll recognize it in the generator configuration.

Then ADD a new template binding: (Example here is for C#) <templateBinding templateID="Custom_EntityUsingEntityBaseTemplate" templateFilename="......\SharedTemplates\C#\entityAuditingInclude.template" />

save it and re-generate your code using THAT templateset config (the 2nd drop down box in the dialog you get when you press F7)

Now, every derived entity class in the two-class scenario for selfservicing will have your code added to entityAuditingInclude.template. So in entityAuditingInclude.template you implement overrides to InsertEntity(), UpdateEntity() and DeleteEntity(), so you can audit. Be sure to call the base class' version afterwards of course simple_smile

Frans Bouma | Lead developer LLBLGen Pro
mafti
User
Posts: 38
Joined: 27-Oct-2004
# Posted on: 10-Nov-2004 09:17:31   

thanx simple_smile

i'm getting on the way.

it it true when i do a entitycollection.savemulti() my overrides will be called also?

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39614
Joined: 17-Aug-2003
# Posted on: 10-Nov-2004 10:47:37   

mafti wrote:

thanx simple_smile

i'm getting on the way.

it it true when i do a entitycollection.savemulti() my overrides will be called also?

SaveMulti calls Save() on the entities it has to save, and that method will then call the proper InsertEntity or UpdateEntity() so yes, these will be called.

Frans Bouma | Lead developer LLBLGen Pro