Hello,
I have a custom alarm table in a low code app (using a table instead of alarm table because I need to use selected rows as a feed for acknowledging alarms). This table is populated from an AdHoc data source currently using the below code to filter by service. I'd like to change this to use a Saved Alarm Filter. I've tried using a GetAlarmFilterMessage (which seems to work in the slnet test app), but this fails in the AdHoc.
Suggestions or a code snippet for retreiving the filter would be greatly appreciated!
_alarms = Task.Factory.StartNew(() =>
{
var item = AlarmFilterItem.Create("service name", "equal to", new string[1] { _service }, null, null);
var filter = new AlarmFilter(item);
var msg = new GetActiveAlarmsMessage() { Filter = filter };
return _dms.SendMessage(msg) as ActiveAlarmsResponseMessage;
});
Hi Jim,
This is probably the snippet you're looking for, note in my case I made the filter configurable in the data source so that you can easily reuse it. The code is also available on GitHub.
_alarms = Task.Factory.StartNew(() =>
{
var filterItem = new AlarmFilterItemFilter(new[] { $"{_filter} (shared filter)" });
var filter = new AlarmFilter(filterItem);
var msg = new GetActiveAlarmsMessage() { Filter = filter };var alarmsResponse = _dms.SendMessage(msg) as ActiveAlarmsResponseMessage;
if (alarmsResponse != null)
{
return alarmsResponse.ActiveAlarms.WhereNotNull().ToList();
}return null;
});
Thanks Sebastiaan, that’s exactly what I needed! And making the filter name a parameter is a great idea, makes it much more user friendly.