For my access control plugin: how do I create an error message so that it appears in the top section of the UI? See screenshot - error messages are on the top, each with a red “X” on the right side to close the message.
-Lou
For my access control plugin: how do I create an error message so that it appears in the top section of the UI? See screenshot - error messages are on the top, each with a red “X” on the right side to close the message.
-Lou
In the DemoAccessControlPlugin in DemoClient you find:
public void UnlockDoor(string doorId, string username, string password, string vmsUsername)
{
var success = TryCall(client => client.UnlockDoor(username, password, vmsUsername, Guid.Parse(doorId)));
if (!success)
{
throw new DemoApplicationClientException("Failed to unlock the door.");
}
}
I hope it fits..
Thanks for the suggestion Bo.
Unfortunately this won’t work in my case. I need the error message to be shown in the smart client when the user tries to clear an alarm in the Xprotect Client and the corresponding alarm cannot be cleared in the access control system.
The code that handles clearing of an alarm in the MIP plugin is as follows (taken from the demo access control plugin):
private async void \_alarmRepository\_AlarmChanged(object sender, AlarmChangedEventArgs e)
{
// Only handle closed alarms
if (e.Alarm.StateId != BuiltInAlarmStates.Closed)
{
return;
}
// If all alarms for this source and event type are closed in VMS, close corresponding alarm in the Demo Access Control system
var doorId = e.Alarm.ExternalSourceId;
var eventTypeId = e.Alarm.ExternalEventTypeId;
var alarms = \_alarmRepository.GetAlarmsForSource(doorId, eventTypeId, false);
if (!alarms.Any())
{
try
{
await \_client.CloseAlarmAsync(doorId, eventTypeId);
}
catch (DemoApplicationClientException ex)
{
// A retry mechanism would probably be in order...
ACUtil.Log(true, "DemoACPlugin.AlarmManager", "Error closing alarm in Demo Access Control system: " + ex.Message);
}
}
}
In the example above, failure to close the alarm in the access control system logs an error message. As a test, I tried throwing a new exception from the catch() block after the ACUtil.Log() statement. This did not result in an error message being shown in the smart client. The exception seemed to just vanish (no action taken by the smart client).
Do you have any other suggestions for what to do to get the error message to show up in the smart client?
Thanks for your help.
-Lou
Problem here is that the client only knows about clearing the alarm. Seen from the client everything is good when alarm is cleared = no error.
Clearing corresponding alarm on acs is handled in eventserver through the plugin - only place to send the error is to the logfile.
The only way around this at this point - as I see it - is to define an event that is triggered by the failing clearing on acs. Then this event can be seen in the client, it will not show up as an error in the top, and it will be visible in all clients (not just where alarm is cleared).
/Anders
Anders, thanks for the information.
-Lou