Setting a list of audited fields at design time


Author
Message
Andria Jensen
Andria Jensen
StrataFrame User (382 reputation)StrataFrame User (382 reputation)StrataFrame User (382 reputation)StrataFrame User (382 reputation)StrataFrame User (382 reputation)StrataFrame User (382 reputation)StrataFrame User (382 reputation)StrataFrame User (382 reputation)StrataFrame User (382 reputation)
Group: Forum Members
Posts: 336, Visits: 497
I have created a base business object which all of my BOs will inherit from.  This will handle among other thing, auditing user changes to data.  For each BO, I need to hold a list of AuditedFields so it know which fields it cares about changes on.  I have this working fine by using the same concept as the RequiredFields collection.  However, I would like for all fields to be checked by default instead of unchecked.  I have the following in the constructor of the base business object, which I thought would work:

If Me.AuditUserChanges And Me.AuditedFields.Count = 0 Then
 
For Each field As String In Me.AllFieldsList.ToArray
   
Dim AuditField As New RequiredField()
    AuditField.FieldType =
Me.FieldDbTypes(field)
    AuditField.FieldName = field
    AuditedFields.Add(AuditField)
 
Next
End If

So basically, I'm just saying if i'm auditing and haven't selected any fields to audit, go ahead and default to audit all of them by adding each field from the AllFieldsList to the AuditedFields collection.  The problem is that when I open any of the inherited BOs in the designer I get the following error message:

A class that inherits from MicroFour.StrataFrame.BusinessLayer must implement the AllFieldsList property.

Any idea what is going on here?  Am I just not using the AllFieldsList collection correctly here?  Is there a better way to accomplish what I'm trying to do?

Andria Jensen
Andria Jensen
StrataFrame User (382 reputation)StrataFrame User (382 reputation)StrataFrame User (382 reputation)StrataFrame User (382 reputation)StrataFrame User (382 reputation)StrataFrame User (382 reputation)StrataFrame User (382 reputation)StrataFrame User (382 reputation)StrataFrame User (382 reputation)
Group: Forum Members
Posts: 336, Visits: 497
Just to also note, this approach DOES work in code.  It defaults so that all fields are audited, however I cannot get to the collection in the designer so that I can uncheck the fields which I don't want audited.
Peter Denton
Peter Denton
StrataFrame Novice (97 reputation)StrataFrame Novice (97 reputation)StrataFrame Novice (97 reputation)StrataFrame Novice (97 reputation)StrataFrame Novice (97 reputation)StrataFrame Novice (97 reputation)StrataFrame Novice (97 reputation)StrataFrame Novice (97 reputation)StrataFrame Novice (97 reputation)
Group: Forum Members
Posts: 77, Visits: 787
Andria,

I think I know why this doesn't work in the constructor of your base BO, and that is because in the designer for your end BO will be

Public Overrides ReadOnly Property AllFieldsList() ...

So your end BO will use this property correctly in code, but when the constructor for your base BO runs it will try to use its own AllFieldsList which will not have been instantiated.

I don't have any suggestions to get around the problem, but I hope an understanding of the problem might help you find a solution.

Peter


Andria Jensen
Andria Jensen
StrataFrame User (382 reputation)StrataFrame User (382 reputation)StrataFrame User (382 reputation)StrataFrame User (382 reputation)StrataFrame User (382 reputation)StrataFrame User (382 reputation)StrataFrame User (382 reputation)StrataFrame User (382 reputation)StrataFrame User (382 reputation)
Group: Forum Members
Posts: 336, Visits: 497
Thanks for the clue, but you're right...it doesn't really help me fix it.  w00t

Trent/Ben, can either of you shed some light on the proper way to do what I'm trying to accomplish??  Thanks!

Trent Taylor
Trent Taylor
StrataFrame Developer (8.5K reputation)StrataFrame Developer (8.5K reputation)StrataFrame Developer (8.5K reputation)StrataFrame Developer (8.5K reputation)StrataFrame Developer (8.5K reputation)StrataFrame Developer (8.5K reputation)StrataFrame Developer (8.5K reputation)StrataFrame Developer (8.5K reputation)StrataFrame Developer (8.5K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 6.9K
We have actually gone down a completely different route, and what you are trying to write is something that will be within the framework within the next several updates.  The problem is adding too much logic on the BO side versus the DAL or SQL side.

But in regards to your problem, this sounds like an issue within inheritance and maybe where you are placing your logic.  The AllFieldsList gets created in the partial class through the BO Mapper.  So that is where that error is coming from.  Past that I guess I don't know if there is anything else you were wanting to know or if I missed something.  Let me know.

Peter Denton
Peter Denton
StrataFrame Novice (97 reputation)StrataFrame Novice (97 reputation)StrataFrame Novice (97 reputation)StrataFrame Novice (97 reputation)StrataFrame Novice (97 reputation)StrataFrame Novice (97 reputation)StrataFrame Novice (97 reputation)StrataFrame Novice (97 reputation)StrataFrame Novice (97 reputation)
Group: Forum Members
Posts: 77, Visits: 787
G'day

I have a further thought, that may provide what you want. If you were to cearte another constructor in your base class something like

Public Sub New (ByVal FieldList() As String)
MyBase.New() ' to call the Strataframe constructor
If Me.AuditUserChanges And Me.AuditedFields.Count = 0 Then
 
For Each field As String In FieldList
   
Dim AuditField As New RequiredField()
    AuditField.FieldType =
Me.FieldDbTypes(field)
    AuditField.FieldName = field
    AuditedFields.Add(AuditField)
 
Next
End If
End Sub

Then in your end class your constructor(s) would look something like

Public Sub New (...)
MyBase.New(Me.AllFieldsList.ToArray) ' calling the base constructor
...

Hope this is more helpful

Peter

Paul Chase
Paul Chase
Advanced StrataFrame User (510 reputation)Advanced StrataFrame User (510 reputation)Advanced StrataFrame User (510 reputation)Advanced StrataFrame User (510 reputation)Advanced StrataFrame User (510 reputation)Advanced StrataFrame User (510 reputation)Advanced StrataFrame User (510 reputation)Advanced StrataFrame User (510 reputation)Advanced StrataFrame User (510 reputation)
Group: Forum Members
Posts: 414, Visits: 2.8K
I just noticed this post and I am getting the same error, I may have had it for awhile as I haven't been in the design surface of a BO in quite some time.

I have a Base BO which inherits from Business layer

Then a Inherited BO this inherits from Base BO

All business object then inherit from Inherited Bo

Paul Chase
Paul Chase
Advanced StrataFrame User (510 reputation)Advanced StrataFrame User (510 reputation)Advanced StrataFrame User (510 reputation)Advanced StrataFrame User (510 reputation)Advanced StrataFrame User (510 reputation)Advanced StrataFrame User (510 reputation)Advanced StrataFrame User (510 reputation)Advanced StrataFrame User (510 reputation)Advanced StrataFrame User (510 reputation)
Group: Forum Members
Posts: 414, Visits: 2.8K
I found my problem. I had some code in the init component that checked the all field list
Trent Taylor
Trent Taylor
StrataFrame Developer (8.5K reputation)StrataFrame Developer (8.5K reputation)StrataFrame Developer (8.5K reputation)StrataFrame Developer (8.5K reputation)StrataFrame Developer (8.5K reputation)StrataFrame Developer (8.5K reputation)StrataFrame Developer (8.5K reputation)StrataFrame Developer (8.5K reputation)StrataFrame Developer (8.5K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 6.9K
I don't know what your base BO looks like, but you will need to have at least this:

Imports System.Runtime.Serialization

Public Class MyBaseBO
    Inherits MicroFour.StrataFrame.Business.BusinessLayer

#Region " Constructors "

    <System.Diagnostics.DebuggerNonUserCodeAttribute()> _
    Public Sub New()
        MyBase.New()
    End Sub

    <System.Diagnostics.DebuggerNonUserCodeAttribute()> _
    Public Sub New(ByVal Container As System.ComponentModel.IContainer)
        MyBase.New()

        '-- Add self to the specified container
        Container.Add(Me)
    End Sub

    Protected Sub New(ByVal info As SerializationInfo, ByVal context As StreamingContext)
        MyBase.New(info, context)
    End Sub

#End Region

End Class

Double check your base BO to make sure that you have at least the constructors and are not calling anything that could cause a problem as design-time, and that you do not have a partial class with other properties, for example, that are getting in the way.  If you were to create this class above, and then inherit from it, you will not get the error you are describing.  I am not sure exactly how you are producing the error, but it will be along these lines.

Trent Taylor
Trent Taylor
StrataFrame Developer (8.5K reputation)StrataFrame Developer (8.5K reputation)StrataFrame Developer (8.5K reputation)StrataFrame Developer (8.5K reputation)StrataFrame Developer (8.5K reputation)StrataFrame Developer (8.5K reputation)StrataFrame Developer (8.5K reputation)StrataFrame Developer (8.5K reputation)StrataFrame Developer (8.5K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 6.9K
I was posting the same time as you....yeah, that would make sense.  Glad you found it Smile
GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search