3 Replies Latest reply on Apr 10, 2009 6:17 AM by mhalhead

    Validate user inputs

    mhalhead

      I've written a very quick notifications delivery channel; it works like a charm and took less than a day to write (the plant is quite impressed). However, the one issue this DC has is that the user inputs in the configuration editor are not validated. This isn't a major issue at the moment as only a small number of people have access rights. The question I have is what is the best manner in which to validate configuration inputs? In a similar light what is the best method of handling exceptions with the program execution?

       

      On a related topic what does the IsConfigured property do? When is it called, by whom?

       

      I've placed this post in the AF SDK channel because I don't think that it is Notifications specific.

        • Re: Validate user inputs

          Michael Halhead

          what does the IsConfigured property do?

           

          The IsConfigured property is a virtual member and as such, it would normally be overriden by whom implements a custom delivery channel (i.e. derives from the AFDeliveryChannel class). The default implementation of this property always return true, so it essentially provides a means for you to implement some "validation routine" in your DC.

           

          Michael Halhead

          When is it called, by whom?

           

          **EDIT** The IsConfigured property is retrieved by PI Notifications when a Notification is being triggered. While the Notifications gets triggered no matter what (and hence shows up in the Notifications History), the Send() method does not get called if IsConfigured returned false. As you probably figured if you DC works, the Send() method is where you implement the core logic of what your DC does (i.e. how it 'delivers' notifications).

           

          Hope this helps!

          • Re: Validate user inputs

            Michael Halhead

            what is the best manner in which to validate configuration inputs?

             

            If you want to do "on the fly" validation, then you can simply think of that configuration area (the class you derived from OSIsoft.AN.UI.PlugInEditor) as a standard Windows Forms. It most likely has fields such as text boxes, lists, etc.  and you could use the traditional "1) validate when losing focus   2)message box if faulty   3) set focus back on faulty field"  technique. You should also consider making use of the IsConfigured property to let PI Notifications know if the DC is configured properly and whether it is "safe" to send it.

             

            Hope this helps!

              • Re: Validate user inputs
                mhalhead

                Thanks Steve,

                 

                Both post were helpful. I have implement the IsConfigured Property and I've seen that it prevents a user from adding an incorrectly configured DC to a notification. I glad that notifications will not call Send() if the isconfigured is false.