Get alarms - Metasys - LIT-12013522 - Software Application - Basic Services client library for .NET (and COM) - Metasys API - 4.2

Metasys REST Client for .NET and COM Developer Guide

Brand
Metasys
Product name
Basic Services client library for .NET (and COM)
Metasys API
Document type
API Reference Guide
Document number
LIT-12013522
Version
4.2
Revision date
2021-04-07
Language
English

To get all available alarms use the Get method. The library delivers a PagedResult that contains a list of Alarm objects. The Get method accepts the AlarmFilter object to filter the response.

Table 1. Get alarms .NET signature
Library method name Get
Description Get available alarms.
Method signature PagedResult<Alarm> GetAlarms(AlarmFilter alarmFilter);
Method input parameters AlarmFilter: the filter object specifies the criteria to use to filter the target alarms.
Return value A PagedResult of Alarm.
The following .NET C# code is an example of a successful get alarms response:
AlarmFilter alarmFilter = new AlarmFilter
  {
    StartTime = new DateTime(2019, 12, 12),
    EndTime = new DateTime(2020, 1, 12),
    ExcludeAcknowledged = true
  };
PagedResult<Alarm> alarmsPager = client.Alarms.Get(alarmFilter);
// Prints the number of records fetched and paging information
Console.WriteLine("Total:" + alarmsPager.Total);
Console.WriteLine("Current page:" + alarmsPager.CurrentPage);
Console.WriteLine("Page size:" + alarmsPager.PageSize);
Console.WriteLine("Pages:" + alarmsPager.PageCount);
/*                      
  Total:4611
  Current page:1
  Page size:100
  Pages:47
*/
Alarm alarm = alarmsPager.Items.ElementAt(0);
Console.WriteLine(alarm);
/*                       
  {
    "Self": "https://win-21dj9jv9qh6/api/v3/alarms/e03d81f9-69de-48e8-92d7-81167df19f6c",
    "Id": "e03d81f9-69de-48e8-92d7-81167df19f6c",
    "ItemReference": "WIN-21DJ9JV9QH6:EECMI-NCE25-3",
    "Name": "EECMI-NCE25-3",
    "Message": "WIN-21DJ9JV9QH6:EECMI-NCE25-3 is offline",
    "IsAckRequired": true,
    "TypeUrl": null,
    "Type": "alarmValueEnumSet.avOffline",
    "Priority": 106,
    "TriggerValue": 
    {
      "Value": "",
      "UnitsUrl": null,
      "Units": "unitEnumSet.noUnits"
    },
    "CreationTime": "2020-06-17T11:22:30Z",
    "IsAcknowledged": false,
    "IsDiscarded": false,
    "CategoryUrl": null,
    "Category": "objectCategoryEnumSet.systemCategory",
    "ObjectUrl": "https://win-21dj9jv9qh6/api/v3/objects/e03d81f9-69de-48e8-92d7-81167df19f6c",
    "AnnotationsUrl": "https://win-21dj9jv9qh6/api/v3/alarms/e03d81f9-69de-48e8-92d7-81167df19f6c/annotations"
  }
*/