New Posts New Posts RSS Feed: BaseEntity - Auditable Entity and Auditing
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

Forum LockedBaseEntity - Auditable Entity and Auditing

 Post Reply Post Reply
Author
HFloyd View Drop Down
Groupie
Groupie


Joined: 27-Jul-2007
Location: United States
Posts: 44
Post Options Post Options   Quote HFloyd Quote  Post ReplyReply Direct Link To This Post Topic: BaseEntity - Auditable Entity and Auditing
    Posted: 13-Mar-2008 at 12:56pm
Hi,

I am making slow progress with my first CAB app. I used the Wizard and then used the "IdeaBlade Object Mapper" to attach to my own database (in which I have both my own business tables as well as several of the "application" tables I copied from the IdeaBlade Tutorial DB).

The questions I have relate to the implementation of Auditing... I didn't see any explanation of Auditing in the PDF doc nor on the website/forums.

So, to the questions:

1. What is the difference between "BaseEntity" and "AuditableEntity"? My guess would be that any BOs I want audited should inherit from "AuditableEntity"?

2. Since I deleted the "Employee" class, I get a build error at this point (AuditableEntity):

    /// <summary>Set the global entity "Audit Columns" for this application.</summary>
    /// <remarks>
    /// Modeled on the columns in the Employee entity.
    /// </remarks>
    private static void SetGlobalAuditColumns() {
      AuditColumnManager.SetGlobalAuditColumns(
        Employee.CrtnUsrIdEntityColumn.ColumnName,
        Employee.CrtnTsEntityColumn.ColumnName,
        Employee.ModUsrIdEntityColumn.ColumnName,
        Employee.ModTsEntityColumn.ColumnName
        );
    }

I assume that this has to do with assigning the "who created or modified this record" data to each row...

Since I kept the Users table, I assumed that I could use that to determine the "who" rather than the Employee, so I changed the code to:

private static void SetGlobalAuditColumns() {
      AuditColumnManager.SetGlobalAuditColumns(
        SecurityUser.CreatedByUserIdEntityColumn.ColumnName,
        SecurityUser.CreatedDateEntityColumn.ColumnName,
        SecurityUser.ModifiedByUserIdEntityColumn.ColumnName,
        SecurityUser.ModifiedDateEntityColumn.ColumnName
        );


I was able to build/run the application, but I just want to be sure I am on the right track here...

Thanks!

Heather


Edited by HFloyd - 13-Mar-2008 at 12:57pm
Back to Top
orcities View Drop Down
Senior Member
Senior Member
Avatar

Joined: 28-Aug-2007
Location: United States
Posts: 454
Post Options Post Options   Quote orcities Quote  Post ReplyReply Direct Link To This Post Posted: 21-Mar-2008 at 12:48pm
You are on the right track. Each time you want to be able to audit a table you need to inherit the AuditableEntity. Will also need to add entries into the metaEntityClass and metaEntityProperty tables to coincide with the table.
Back to Top
HFloyd View Drop Down
Groupie
Groupie


Joined: 27-Jul-2007
Location: United States
Posts: 44
Post Options Post Options   Quote HFloyd Quote  Post ReplyReply Direct Link To This Post Posted: 17-Apr-2008 at 10:05am
Thanks, orcities, for that tip about the metaEntityClass and metaEntityProperty tables - I wouldn't have figured that out.

I had no problem adding all my classes to the metaEntityClass table, but am a bit unsure what I am supposed to put into the metaEntityProperty table.

Am I supposed to put all my class properties into that table? Any tips for doing that in a fast or automated way?

Heather

Back to Top
orcities View Drop Down
Senior Member
Senior Member
Avatar

Joined: 28-Aug-2007
Location: United States
Posts: 454
Post Options Post Options   Quote orcities Quote  Post ReplyReply Direct Link To This Post Posted: 17-Apr-2008 at 10:23am
I haven't done it yet, but I intend to build a module that allows me to set/add info to those tables. This will allow a user to update which fields they want to track. For now I did it by hand.
 
You could also just write a query to add all the properties to the table directly in SQL Server Manager. Then just go through and update the ways to track (i.e. edit, add, delete).
Back to Top
HFloyd View Drop Down
Groupie
Groupie


Joined: 27-Jul-2007
Location: United States
Posts: 44
Post Options Post Options   Quote HFloyd Quote  Post ReplyReply Direct Link To This Post Posted: 17-Apr-2008 at 10:41am
Have a bit of pseudo code for the suggested SQL?

Thanks, Heather
Back to Top
orcities View Drop Down
Senior Member
Senior Member
Avatar

Joined: 28-Aug-2007
Location: United States
Posts: 454
Post Options Post Options   Quote orcities Quote  Post ReplyReply Direct Link To This Post Posted: 17-Apr-2008 at 11:00am

you will need to look up cursors/loops for transact sql as well as the built in functions for getting the tables in the database and the properties in the tables

 
foreach table in database
foreach property in table
     add prop to table
Back to Top
Bill Jensen View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 31-Jul-2007
Location: United States
Posts: 229
Post Options Post Options   Quote Bill Jensen Quote  Post ReplyReply Direct Link To This Post Posted: 18-Apr-2008 at 11:55am
I haven't studied the auditing capabilities in detail yet.  You guys probably know more than I do.
 
Ward created the auditing capability in Cabana primarily as a demonstration.  I'm not sure he envisioned it's being used as a base framework for other applications.
 
I agree with Dan that a Cabana module to manage the EntityClass and EntityProperty model objects is in order--a simple SummaryDetail or SearchSummaryDetail page should do the job.  That would get you the ability to manually add, delete and edit the metadata for audited entities (assuming they inherit from AuditableEntity). 
 
I could also imagine a view that displays a grid of all entities that inherit from AuditableEntity with check boxes to automatically populate the EntityClass objects.  A similar mechanism might be used on each EntityClass object to populate its child EntityProperty objects.
 
I think I'd prefer this approach rather than doing it directly using TSQL in the database.
 
Bill J.
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down