Application Service


Plugins can access application-level functions through _host.Application


Method

Description

GetAppPath()

Gets the project folder path


GetCurrentStreamUser()        

Gets the current logged-in Stream user


FlushHistorical(jobName)        

Flushes historical data for a job


AcknowledgeAllAlarms()        

Acknowledges all active alarms



C# Example:        


// Check if Application service is available

if (_host?.Application != null)

{

    // Get project folder path

    string appPath = _host.Application.GetAppPath();

    // Example: "C:\Projects\MyScadaProject"


    // Get current Stream user

    string user = _host.Application.GetCurrentStreamUser();

    // Example: "Admin" or "Guest"


    // Get all tag group names

    List<string> groups = _host.Application.GetGroups();

    // Example: ["Tanks", "Pumps", "Valves"]

    foreach (var group in groups)

    {

        Debug.WriteLine($"Group: {group}");

    }


    // Flush historical data for a specific job

    string result = _host.Application.FlushHistorical("HistoricalJob1");

    // Returns: "OK" or error message


    // Acknowledge all active alarms

    string ackResult = _host.Application.AcknowledgeAllAlarms();

    // Returns: "OK" or error message

}


VB.NET Example:


' Check if Application service is available

If _host?.Application IsNot Nothing Then


    ' Get project folder path

    Dim appPath As String = _host.Application.GetAppPath()

    ' Example: "C:\Projects\MyScadaProject"


    ' Get current Stream user

    Dim user As String = _host.Application.GetCurrentStreamUser()

    ' Example: "Admin" or "Guest"


    ' Get all tag group names

    Dim groups As List(Of String) = _host.Application.GetGroups()

    ' Example: ["Tanks", "Pumps", "Valves"]

    For Each group In groups

        Debug.WriteLine($"Group: {group}")

    Next


    ' Flush historical data for a specific job

    Dim result As String = _host.Application.FlushHistorical("HistoricalJob1")

    ' Returns: "OK" or error message


    ' Acknowledge all active alarms

    Dim ackResult As String = _host.Application.AcknowledgeAllAlarms()

    ' Returns: "OK" or error message


End If