Book a Demo

Author Topic: Add-in model search with C#  (Read 4110 times)

mvngomes

  • EA Novice
  • *
  • Posts: 12
  • Karma: +0/-0
    • View Profile
Add-in model search with C#
« on: November 08, 2011, 04:28:54 am »
Hello,

I've been trying to use the add-in searches without much success. I've already looked into all of the topics about this in the forum but couldn't exactly find the answer I'm looking for...

First of all, how should the signature for my search method look like? I got EA to call my method correctly, but the model search window does not display any results. I have tried these two:

Code: [Select]
public void testSearch(Repository repository, string searchText, string XMLResults)
Code: [Select]
public string testSearch(Repository repository, string searchText, string XMLResults)
Where on the second one I return XMLResults.

My sample XML result looks like this:

<ReportViewData>
<Fields>
<Field name="Object"/>
</Fields>
<Rows>
<Row>
<Field name="Object" value="Testability"/>
</Row>
</Rows>
</ReportViewData>


Any ideas on what I am doing wrong or missing? Any help would be very appreciated!

Aaron B

  • EA Administrator
  • EA User
  • *****
  • Posts: 941
  • Karma: +18/-0
    • View Profile
Re: Add-in model search with C#
« Reply #1 on: November 08, 2011, 05:13:03 pm »
Try:

 public object testSearch(EA.Repository Repository, String SearchText, out String XMLResults)

Assign your xml results to the XMLResults string.

I can't recall how the return value for this event is handled.  Maybe try either passing the xml results in the return value as well, or maybe just return a true/false boolean value and see what happens.  If you're still stuck, send an email to support and we can look into it.

mvngomes

  • EA Novice
  • *
  • Posts: 12
  • Karma: +0/-0
    • View Profile
Re: Add-in model search with C#
« Reply #2 on: November 09, 2011, 12:04:47 am »
Thank  you very much! I got it to work, with the method you suggested and just return "true" at the end. I guess it doesn't really matter what that value is since it is not read anywhere. The only thing that really has to be done is assigning the results to XMLResults.

Once again, thank you for the help!

One last question: is there any way of letting my method know what are the current results of a search? That is, if I wanted to run a search but only over results already obtained... The only solution I see is saving my XMLResults string in the add-in, but that would mean it would only work if the previous searches have been my custom one, and that I would have to parse the XML every time... am I missing something?

Aaron B

  • EA Administrator
  • EA User
  • *****
  • Posts: 941
  • Karma: +18/-0
    • View Profile
Re: Add-in model search with C#
« Reply #3 on: November 09, 2011, 09:13:56 am »
I don't think there is any way to get the current model search window results returned to the add-in.

If you want to apply a further filter the current search results in EA, try using the Filter Bar.  See the "Toggle Filter Bar" button in the Model Search window toolbar.