Change Management

Change Management

Old forum URL: forums.lhotka.net/forums/t/2758.aspx


ksirmons posted on Monday, April 23, 2007

Howdy,

I need to design a ChangeManagement system for a CSLA project we are working on.

The system needs to be able to track the changes of a CSLA Object and persist the "before" data to a changelog table in the database. 

I want to, somehow before the changed object is saved back to the database, create an XML representation of the object's changed properties. 

Example, if I have a simple object Person with 5 properties and I make changes to 3 of the 5 properties, I want to build an XML document with the 3 changed properties "original" data to be stored in the log.

I have thought of somehow keeping a key value list associated with each object and as properties are changed, storing a key(property name) and value(original data) in the list, then passing the list at save to a changelog object.

I have also thought about trying to hook into some event, but I am new to programming and very new to CSLA and still do not fully understand how events work or how to use them in this situation.

I have also wondered if there was some way to use the N-undo feature and compare the "before" in the undo level with the current state about to be saved to generate the changes XML.

 

Thank you for any direction and guidance you can give,

Keith

 

 

Q Johnson replied on Monday, April 23, 2007

Since you are "new to programming,"  I think the best advice you can get to a question like this is to learn about Source Control software.  There is no reason to write an application like this unless you're doing what we used to call in the Air Force "practice bleeding." 

The goals you mention for your app sure make it look like you're just re-inventing the wheel. 

Source control is a pretty big issue, but if you're going to be a programmer, you need to get started.  I'd recommend setting aside a time budget of, say, two hours to explore the various links you find when you Google "source control."  If you have a mentor where you work, ask him/her to show you how they use theirs.  They probably use SourceSafe (comes with Visual Studio), but there are other products out there (notably CVS and SubVersion which you'll see mentioned here from time to time). 

Any of them will let you save the current "version" of any source code file and to run a comparison (called "viewing differences") with another version that you select.  That's what you seem to be describing to me.  Welcome to programming, .NET, CSLA, Source Control,  (and soon, likely, Code Generation). 

Another quick recommendation - check out www.onelittlevictory.com.  It's a very nice resource for folks new to CSLA and will get you grounded quickly.  Chris did a really nice job with it and it's a shame to struggle with any CSLA topic when so much is offered there. 

Good luck.

Michael Hildner replied on Monday, April 23, 2007

I may be reading the OP's post wrong, but I thought he meant tracking the changes of a business object's data properties when the user is running the app, not changes to code files.

If that's the case, one thing that comes to mind to save the inital BO, say right after you fetch from the DB, would be to .Clone the BO. Not sure if that's a good idea though.

There's a few posts in the forum where people are asking how to determine which property has changed - following what people have suggested there might work. Again I don't know because I never tried it, but you could probably do something either with PropertyHasChanged or something in your setter block.

glenntoy replied on Monday, April 23, 2007

Keith,

For me, it sounds like an object level audit trail. Please check the below threads, this might help you:
Object Level Audit Trail
Change Tracking

I hope it will give you an idea on what you want to achieve.

Cheers,
Glenn

ksirmons replied on Tuesday, April 24, 2007

Thank you for the links.  The Object Level Audit is what I am looking for.

Keith

Yang replied on Tuesday, April 24, 2007

Keith,

We are doing data auditing here at my work. One of our requirements was to keep track of all changes whether done on the UI or sometimes some database utility application like TOAD.

We created history tables which is a mirror of the actual tables plus some user and time stamping mechanism  and update type columns so we do not combine historical data with the active data. Since we do not have control over how TOAD or other utilities does the updates, we created insert/update/delete triggers on the tables we want audited and have it insert into the corresponding history table every time a change in the data occurs.

On the business object side, we created readonly business objects for viewing the history.

Hope this helps

Yang

Copyright (c) Marimer LLC