13 Replies Latest reply on May 8, 2018 7:01 PM by SivaR

    PI AF SDK exception not bubbling up in C#

    SivaR

      Hello All,

       

      I am using the OSIsoft.AF.UI.PropertyPage.EventFrameSearchPage control and programmatically calling the SearchButton.PerformClick() function. When the query is malformed this throws a System.FormatException but I am unable to trap it using try catch block.

      The execution just passes on to the next line of code, any ideas from the PI team how i can catch and rethrow.

       

      Thanks!

      Siva

        • Re: PI AF SDK exception not bubbling up in C#
          Rick Davin

          Hi Sivakumar,

           

          Dialog forms like that are intended to be self-contained and insulated from throwing exceptions back to the containing application.  Typically, one would expect an interactive user to click the "Search" button and see the error message within the dialog, as well as seeing 0 event frames returned.  It appears you are issuing the dialog's SearchButton.PerformClick() programmatically, which makes me wonder are you also entering the search criteria programmatically?  How does a user interact with this dialog within your application?  Can you share you code related to this?  Can you explain what your application or your end user will do after finding event frames?  Will they continue to interact with the dialog, or do you read the EventFrames property and do something else?

            • Re: PI AF SDK exception not bubbling up in C#
              SivaR

              HI @Rick Davin,

              I have two work flows

              1. where the dialog is visible to the user and he does the selections and searches

              2. where i serialize these search settings and save it. Later the user can edit this string and can run it in a headless instance where i call the SearchButton.PerformClick() function

               

              Here is what my code block looks like

              try

              {

                   var efCriteria = new AFEventFrameCriteria(afDataBase)

                                            {

                                                  MaximumQueryCount = iMaxRes,

                                                  SearchType = efSearchType,

                                                  StartTime = startTime,

                                                  EndTime = endTime,

                                                  LastFullSearchString = efQuery

                                             };

                     eventFrameSearchPage.EventFrameCriteria = efCriteria;

                     eventFrameSearchPage.Update();

                     eventFrameSearchPage.SearchButton.PerformClick(); // This line throws the error but the try/catch block doesn't trap it

                      //Parse returned event frames and get the attribute data

                      GetData(eventFrameSearchPage.EventFrames);  

              }

              catch(System.FormatException ef)

              {

              }

              catch(Exception e)

              {

              }

               

              So there is no way to do this?

              Thanks!

            • Re: PI AF SDK exception not bubbling up in C#
              SivaR

              @Mike Zboray, @Rick Davin

              While I have you guys here another question about the various criteria elements (Add Criteria) on the OSIsoft.AF.UI.PropertyPage.EventFrameSearchPage control, I have a database picker control on this dialog and when i switch databases I call

              EventFrameSearchPage.Reset() and EventFrameSearchPage.Update() but some of the criteria do not update unless i close them and re add them. Is there a call i can use thanks!