This discussion has been locked. The information referenced herein may be inaccurate due to age, software updates, or external references.
You can no longer post new replies to this discussion. If you have a similar question you can start a new discussion in this forum.

how to List Resource using C# and orion sdk

I was checking the thread: List Resources By C# Orion SDK?  but when i go to execute the list resource i don't have answer when i go to execute a list resource with the next code:

        public JToken GetInterfaces(ISwisClient swisClient, int nodes)

        {

            try

            {

                int[] arrnode = new int[1];

                arrnode[0] = nodes;

                JToken invokeResult = swisClient.InvokeAsync("Orion.NPM.Interfaces", "DiscoverInterfacesOnNode", arrnode[0]).Result;

                return invokeResult;

            }

            catch (Exception e)

            {

                return 0;

            }

        }

But it never goes over the return sentence, and neither enters the catch sentence.

with the add node, i can have a good experience. But in this moment i can't continue.

robdogaz​ thanks for your help.

Can you please help me?.

  • There are really only three possibilities: the method returns, the method throws an exception, or the method is still running. DiscoverInterfacesOnNode can take a little while for a device with a lot of interfaces. If you run it in the debugger and hit "Break", where is it? Does anything interesting show up in the visual studio debugger output window?

  • Hi tdanner​,

    First of all, thanks for your support. I'll explain what I've done, but first I'll answer your questions:

    1. When I debug and I put the break point does not reach the return invokeResult.

    2. I do not see anything interesting, even in the result, the maximum I got was to the following line: return SwisCallAsync (client => client.PostAsync (string.Format ("Invoke / {0} / {1}", entity , Verb), MakeHttpContent (args))); Which is part of the SwisClient.cs class and up to here don't have to be modified, right?

    I finally decided to embed Powershell inside C # to execute the two actions (Add Node and DiscoveryInterfacesOnNode). But it is not a suitable way. I am analyzing if I can directly enter to create a SOAP service structure like the SWQL has, but I really see a long way there, can you please tell me how to make a decision ?, if you prefer I can move my question in another post?, Because I see that I am diverting a little from this topic, right ?. I am very grateful if you can give me a light with this situation because for me it is very complicated to understand how SWQL works internally, or do you know if there is technical documentation of this development (SWQL)?

  • You may be hitting the deadlock described here: http://blog.stephencleary.com/2012/07/dont-block-on-async-code.html

    The recommended cure is not to use ".Result". Instead, use "await" to get the result of the task.