-
Re: PI AF SDK exception not bubbling up in C#
Rick DavinMay 4, 2018 8:08 PM (in response to SivaR)
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 May 4, 2018 9:35 PM (in response to Rick Davin)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#
Rick DavinMay 4, 2018 10:01 PM (in response to SivaR)
Hi Sivakumar,
There is a better way to do it but without that particular dialog. Let me emphasize again that the dialog based forms are intended to have user interaction. If you are setting the criteria, pushing the button, then pulling off the event frames, there is absolutely no reason to have an interactive dialog, right? Which means you should also avoid the AFOperations class and its assorted Find methods because it too is intended to be an interactive dialog. If its not interactive with the actual user, it's kind of pointless to use it otherwise.
Instead the more appropriate method would be to use the AFEventFrameSearch method. Here is a blog link on it's use. If you want to aggregate event frames or use a skinny, lightweight search, see this blog series (warning: fairly advanced).
A general introduction to the AFSearch class is at this link. A more recent discussion at PI World may also be found here.
We are more than happy to help you use the right tool for the right job. Keep posting your questions here. AFSearch is our preferred search mechanism, and it offers many advantages. For example, thanks to seamless paging built-in, it is possible to perform searches in a background task, and then once a page is retrieved, send it the event frames to the foreground UI. Overall the app could be more responsive. Or more to your point, you would be able to catch an exception if you were using AFSearch.
-
Re: PI AF SDK exception not bubbling up in C#
SivaR May 4, 2018 11:28 PM (in response to Rick Davin)I will try that.
Thanks!
-
Re: PI AF SDK exception not bubbling up in C#
SivaR May 6, 2018 10:42 PM (in response to Rick Davin)Hi Rick Davin
Is there a way to use EventFrameSearchType criteria with AFEventFrameSearch method, i tried passing it in as the Type parameter but i get an exception (The ParseQuery method returns a valid token for this.)
"The search criteria 'Type:ActiveBetween' is not valid for Event Frame search."
So this method doesn't support the full range of criteria supported in the PI System explorer Event Frames search?
Thanks!
-
Re: PI AF SDK exception not bubbling up in C#
Rick DavinMay 7, 2018 3:44 PM (in response to SivaR)
AFEventFrameSearch supports all criteria and is the recommended search for event frames. What is different is the syntax for the AFSearch classes (including AFEventFrameSearch) is different that the UI control.
You will most likely want to use this constructor overload with the AFSearchMode enumeration set to Overlapped (also known as "Active Between"). If you have troubles with the code, post the code and exception message here.
-
-
-
Re: PI AF SDK exception not bubbling up in C#
Mike ZborayMay 4, 2018 11:04 PM (in response to SivaR)
Are you running with the debugger attached? Is it just a notification that a FormatException was *thrown* inside the method as opposed to one is actually not handled by the method? If you want to know whether the query is valid, try using AFEventFrameSearch.ParseQuery on the query string.
-
Re: PI AF SDK exception not bubbling up in C#
SivaR May 4, 2018 11:18 PM (in response to Mike Zboray)@Mike Zboray
Is this available in SDK version 2.7.5.7166? Doesn't look like it is.
Thanks!
-
Re: PI AF SDK exception not bubbling up in C#
Mike ZborayMay 4, 2018 11:44 PM (in response to SivaR)
-
-
-
-
-
Re: PI AF SDK exception not bubbling up in C#
SivaR May 4, 2018 11:38 PM (in response to 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!
-
Re: PI AF SDK exception not bubbling up in C#
Rick DavinMay 7, 2018 3:47 PM (in response to SivaR)
Seeing how you asked this on May 4 (Star Wars Day), and in light of what we have recommended, let me say: These are not the search methods you are looking for.
-
Re: PI AF SDK exception not bubbling up in C#
SivaR May 8, 2018 3:22 PM (in response to Rick Davin)May the Fourth be with you
Lets assume that I have to use this approach, how can i get the EventFrame Browser to show all the event frames when i click the button on the Event Frame Search Root control? Any tips
Thanks!
-
Re: PI AF SDK exception not bubbling up in C#
SivaR May 8, 2018 7:01 PM (in response to Rick Davin)Looks like I can set the afdb on the AFEventFrameFindCtrl and refresh it.
Is there a way for me to close these programatically?
-
-