How can I get the list of all protocols in c# and show them in the low code app in dropdown as adhoc-data source?
As in GQI I cannot see any way like engine.GetUserConnection().GetProtocols?
OR
I can see I can get protocols all from Low code app directly, but how can I adjust to bring only names from Query?
Hi Apurva,
It's indeed currently not very straightforward to use the DMS classes in a GQI data source. The trick is to create a class that implements the ICommunication interface. This can be found here.
The 'GqiDmsConnection' class can then be used as follows:
public OnInitOutputArgs OnInit(OnInitInputArgs args)
{
var connection = new GqiDmsConnection(args.DMS);
var dms = DmsFactory.CreateDms(connection);var protocols = dms.GetProtocols();
...return new OnInitOutputArgs();
}
Hi Apurva,
You could leverage the DMS callback that allows you to send any SLNet message (see docs). This callback can be used to retrieve all elements using the 'GetLiteElementInfo' message. These 'LiteElementInfoEvent' responses can then be used to get a list of protocols from them. (This is the way used by our dashboards)
private HashSet<string> GetProtocols()
{
var message = new GetLiteElementInfo()
{
ExcludeSubViews = false,
ViewID = -1,
IncludeHidden = false,
IncludePaused = true,
IncludeStopped = true
};
var elementInfos = _dms.SendMessages(message).OfType<LiteElementInfoEvent>();var protocols = new HashSet<string>();
foreach(var elementInfo in elementInfos)
{
if (protocols.Contains(elementInfo.Protocol)) continue;
protocols.Add(elementInfo.Protocol);
}return protocols;
}
My example only retrieves the protocol names, but you can also get the protocol type, protocol version, ... from these responses.
The retrieved protocols can then be returned as rows by your ad hoc source (see docs).
An other option is to use the same callback with an 'GetInfoMessage' to retrieve all protocols.
Hi Apurva,
Nice to meet you!
This is actually built-in functionality that you can use right away. Simply drag and drop the complete 'Protocols' data onto your Dashboard or Low Code App.
Kind Regards,
Jarno
Hi, thanks
I know this but I want to get in automation script in GQI so wanted to ask how can I use engine.GetUserConnection().Get Protocol things in GQI as dms doesn’t have such thing. I want to use this as adhoc data source