Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Auditing
Message
 
To
17/03/2004 19:45:00
General information
Forum:
ASP.NET
Category:
The Mere Mortals .NET Framework
Title:
Miscellaneous
Thread ID:
00887069
Message ID:
00887603
Views:
9
Mine is specific to client needs. App is for maintaining automotive parts in a printed catalogue. So the "PAGE" is of primary concern.

WARNING- SESSION heavy usage ahead. If your Non Session based, this is not for you.

In general I have to compare the ds. I pass it here:

private void UpdateDataSet(DataSet myDataSet)
{
(DataRowState.Modified)) return;
// Create temporary DataSet variable.
DataSet xDataSet;
// GetChanges for modified rows only.
xDataSet = myDataSet.GetChanges();
whatChanged(xDataSet);
// Check the DataSet for errors.
if(xDataSet.HasErrors)
{ //your error handler here }
}

private void whatChanged (DataSet ds)
{
//Set session to 0
Session["Changes"] = 0;
Session["PostChangeYN"] = "Y";
foreach (DataRow r in ds.Tables[0].Rows )
{
switch (r.RowState)
{
case DataRowState.Unchanged :
case DataRowState.Detached :
break;

case DataRowState.Deleted:
//Delete
r.AcceptChanges();
break;
case DataRowState.Modified:
{ // I need to define to user in another form what changed
string lccol ="" , lcDV = "", lcPV = ""; //, lcSess="";
//int ii = 1 , lnSess = 0;
// lnSess is counter for session
// lcSess is string to build
foreach(DataColumn c in ds.Tables[0].Columns)
{
lccol = c.ColumnName;
lcPV = r[c, DataRowVersion.Current].ToString() ; // Present
lcDV = r[c, DataRowVersion.Original].ToString(); // Default
if (!r[c,DataRowVersion.Original].Equals(r[c, DataRowVersion.Current]))

{
postSession(lcPV, lcDV, lccol) ;
//Changed, do some modify.
}
}
r.AcceptChanges();
break;
}
case DataRowState.Added :
//Add
r.AcceptChanges();
break;
}
}
}

private void postSession(string lcPV, string lcDV, string lccol )
{

if ( ! lcPV.Trim().Equals(lcDV.Trim()))
{
// Grab session # and bump by 1
string lcSessNum = Session["Changes"].ToString(), lcSess = "" ;
int lnSessNum = Convert.ToInt32(lcSessNum);
lnSessNum += 1 ;
int l1 = lccol.Length;
string lccolx = lccol.Substring(3,l1-3);

// Put starting and current vals to Session

lcSess = "lcCol"+Convert.ToString(lnSessNum).Trim();
Session[lcSess] = lccolx;
lcSess = "lcPV"+Convert.ToString(lnSessNum).Trim();
Session[lcSess] = lcPV;
lcSess = "lcDV"+Convert.ToString(lnSessNum).Trim();
Session[lcSess] = lcDV;
Session["lcChangeType"] = "Edit";
// Set New # of changes to Session
Session["Changes"] = lnSessNum;
}
}

I then pop a generic page Explain.aspx that reads all the session settings and displays what was, and what is now. It has an edit box to explain WHY your making a change. You then post that data to your change log table.

// called after UpdateDataSet(DataSet myDataSet)
// Get the user to explain what they did
int lnses = Convert.ToInt32(Session["Changes"]);
string lcPostChange = Session["PostChangeYN"].ToString();
Session["Form"]= "SAE"; // This is the page for "where" this change came from.
if (lnses >0 )
{
string sScript = "<script language=javascript>";
sScript += "window.open('Explain.aspx');";
sScript += "</script>";
//Write it into the output stream for immediate execution
Response.Write(sScript);
}

>Stephen,
>
>If you can, please post your code here! I also need auditing fucnction and thinking about doing it with SQL Server triggers, which can be time consuming.
>
>Chen
>
>>I coded this a year ago. If it's now part of the framework, great otherwise I'll post my code for you.
>>
>>__Stephen
>>
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform