I think one of the place you can look at the ANServiceInformation class, in the OSIsoft.AN.Service namespace part of AN SDK. It provides some static method that can allow you to get the PI Notification services information by providing the information of the PISystem (AF Server) or AFDatabase object
A simple code snippet to get the host of the PI Notifications Service linked to an AF server
using OSIsoft.AF;using OSIsoft.AN.Service;... PISystems _AFSDK = new PISystems(); PISystem _AFServer = _AFSDK["<your AF server name>"]; string Notification_Host = ANServiceInformation.GetHost(_AFServer.ID);
When the Notifications service is stopped, the previous code throws an exception "No PI Notification Service is running".
When the Notifications service is running, the GetHost call succeeds without exception.
So it does the job :)
Using ANServiceInformation.TryGetLocation seems better, as it doesn't throws an exception, just returns a booelan:
PISystems _AFSDK = new PISystems();
PISystem _AFServer = _AFSDK["PIPIAF2010"];
AFDatabase _AFDatabase = null;
_AFDatabase = _AFServer.Databases["Configuration"];
String strMachine = String.Empty;
Boolean bLoc = ANServiceInformation.TryGetLocation(_AFServer.ID, _AFDatabase.ID, out strMachine);
MessageBox.Show("PI Notifications service is running");
MessageBox.Show("PI Notifications service is NOT running");
Thanks for sharing your findings and the code snippet on this =)
Retrieving data ...