New Posts New Posts RSS Feed: Verifier suggestion?
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

Verifier suggestion?

 Post Reply Post Reply
Author
DenisK View Drop Down
IdeaBlade
IdeaBlade


Joined: 25-Aug-2010
Posts: 715
Post Options Post Options   Quote DenisK Quote  Post ReplyReply Direct Link To This Post Topic: Verifier suggestion?
    Posted: 25-Aug-2011 at 5:29pm
Hi midnit;

Before I answer your questions, I just want to point out our Verifier write up on the DRC (DevForce Resource Center). http://drc.ideablade.com/xwiki/bin/view/Documentation/validate

Now, let me attempt and answer your specific questions, as well as give some suggestions. Please keep in mind that my suggestions might not be the best way for your application but I hope it should get you thinking and started.

I am wanting to a simple way to indicate the entity should undergo the "LockedMonthVerification" check - as in perhaps it either implements an interface or perhaps through your MetadataType attribute?

Once you've read our Verifier write up, you'll notice that to use DevForce Verification, we advice you to do the following steps:

1. Create a class that implements an IVerifierProvider. 
2. Implements the GetVerifiers method that returns IEnumerable<Verifier>.
2. Create your Verifier(s) and add that to a list of Verifiers and return the list.

To indicate whether an entity should undergo a Verifier check, you have to add a trigger to the Verifier. A trigger ultimately consists of an entity type and the entity's property. This is where a Verifier knows when to be invoked. Again, you can read this in more detail in our write up.

I presume the verifier has to query for the locked months for each entity marked as needing that type of verification - assuming they don't have override permission. Can this be done once per call to SaveChangesAsync, or must it be done for every entity?

The query can be done once per call to SaveChangesAsync on the SaveInterceptor.

Since you're doing SL, one suggestion that I have is to override the ValidateSave method on the SaveInterceptor. Inside that method, before you're calling base.ValidateSave, you can query your "locked" months synchronously on the server into the server-side EntityManager. That server-side EntityManager, in turn, can be accessible through the entity you're verifying inside your Verifier and you can retrieve your "locked" months there.

I have attached a code sample/pseudocode here (You can rename it to .cs). Hopefully it can get you started.

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

Joined: 22-Jun-2009
Location: Charlotte
Posts: 112
Post Options Post Options   Quote midnit Quote  Post ReplyReply Direct Link To This Post Posted: 24-Aug-2011 at 12:23pm
Oh, there are also entities that have certain fields (ie. Comment) that can be edited even though the entity is in a locked month. So if anything other than Comment is being edited then it would fail, if just Comment was being edited it would pass.
Back to Top
midnit View Drop Down
Senior Member
Senior Member
Avatar

Joined: 22-Jun-2009
Location: Charlotte
Posts: 112
Post Options Post Options   Quote midnit Quote  Post ReplyReply Direct Link To This Post Posted: 24-Aug-2011 at 11:30am
Could I get a couple suggestions on how (or if) to user your verification in my scenario.
 
In our business we "lock" each month which means certain data cannot be added, edited, or deleted if the data effects a locked month. These entities vary in either having a single date, or a begin and end date. If its a single date you check just the month that dates in, if its a range you verify there are no locked months overlapping or between the dates. Simple enough. We add a little complication that there is an Override security privilege that ignores the date checks.
 
I am wanting to a simple way to indicate the entity should undergo the "LockedMonthVerification" check - as in perhaps it either implements an interface or perhaps through your MetadataType attribute?
 
Being unfamliar with your verification I was worried about where to start with this. We are already handling this on the client and UI but the client can be stale so the server needs to do this so Verifiers seemed the way to head.
 
I presume the verifier has to query for the locked months for each entity marked as needing that type of verification - assuming they don't have override permission. Can this be done once per call to SaveChangesAsync, or must it be done for every entity?
 
I had also considered a SaveInterceptor.
 
Unfortunately we are late in our dev cycle and this need to be implemented as quickly as possible.
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down