Hi Vince
Many thanks for your reply and sorry for the delay in replying . All my EO objects have the audit trail code in them . two issues were encountered
1 - if an object is not selected for audit trail from the UI I get an exception when I update I got around it
by making the following mod ( ****** ) to the AuditUpdate method in the base class
Code:
PublicSub AuditUpdate(ByRef validationErrors As ENTValidationErrors, ByVal userAccountId AsInteger)
Using db2 AsNew ENTFrammeworkDataContext(DBHelper.GetConnectionString(DBHelper.SCADADBConnectionKey))
' Check if the object has been selected for auditing
Dim auditObject AsNew ENTAuditObjectEO()
************** If auditObject.Load(db2, Me.[GetType]().Name) *************Then
'
ForEach [property] As ENTProperty In _originalPropertyValues
' Get the value of this property in this instance
Dim value AsObject = Me.GetType.GetProperty([property].Name).GetValue(Me, Nothing)
' compare properties in before and after update and if changed log in audit.
IfNot (value IsNothing) AndNot ([property].Value IsNothing) And _
Convert.ToString(value) <> Convert.ToString([property].Value) Then
Dim audit AsNew ENTAuditEO
audit.ObjectName = Me.GetType.Name
audit.RecordId = ID
audit.PropertyName = [property].Name
audit.OldValue = (If([property].Value IsNothing, Nothing, Convert.ToString([property].Value)))
audit.NewValue = (If(value IsNothing, Nothing, Convert.ToString(value)))
audit.AuditType = ENTAuditEO.AuditTypeEnum.Update
' save to audit object
audit.Save(db2, validationErrors, userAccountId)
EndIf
Next
'
EndIf
'
EndUsing
EndSub
The second issue is, to audit trail the role capabilities/ role user accounts as and when
a role is changed. the issue here is the storePropertyValues method is in the load mehtod. of the EO object not the EOList object so I got arrount it as follows:
Code:
PrivateSub LoadFromList(ByVal roleCapabilities As List(Of ENTRoleCapability))
If roleCapabilities.Count > 0 Then
ForEach roleCapability As ENTRoleCapability In roleCapabilities
Dim newRoleCapabilityEO AsNew ENTRoleCapabilityEO()
*************newRoleCapabilityEO.Load(roleCapability.ENTRoleCapabilityId) ***********
Me.Add(newRoleCapabilityEO)
Next
EndIf
EndSub
I did send you an email a while ago regarding my other issues posted in multuple datacontext thread. I would be grateful if you let me have your opinion.
regards