private void LoadClientAlarm() { try { IAlarmClient alarmClient = _alarmClientManager.GetAlarmClient(EnvironmentManager.Instance.MasterSite.ServerId); AlarmLine[] alarms = alarmClient.GetAlarmLines(0, 10, new VideoOS.Platform.Proxy.Alarm.AlarmFilter() { Orders = new OrderBy[] { new OrderBy() { Order = Order.Descending, Target = Target.Timestamp } } }); foreach (AlarmLine line in alarms) { Alarm alarm = alarmClient.Get(line.Id); DataGridViewRow row = new DataGridViewRow(); row.Tag = alarm; string alarmDef = alarm.RuleList != null && alarm.RuleList.Count > 0 ? alarm.RuleList[0].Name : ""; row.CreateCells(dataGridViewAlarm, alarm.EventHeader.Source.Name, alarm.EventHeader.Timestamp.ToLocalTime(), alarm.EventHeader.Message, alarm.EventHeader.Priority, alarm.State, alarmDef); dataGridViewAlarm.Rows.Add(row); } } catch (Exception ex) { EnvironmentManager.Instance.ExceptionDialog("OnLoad", ex); } }
private object ChangedAlarmMessageHandler(VideoOS.Platform.Messaging.Message message, FQID dest, FQID source) { if (_viewMode != ViewMode.Alarm) { return(null); } if (InvokeRequired) { BeginInvoke(new MessageReceiver(ChangedAlarmMessageHandler), message, dest, source); } else { try { ChangedAlarmData changedAlarmData = message.Data as ChangedAlarmData; if (changedAlarmData != null) { switch (changedAlarmData.ChangeHint) { case ChangedAlarmData.ChangeHintSingleAlarm: for (int ix = 0; ix < dataGridViewAlarm.Rows.Count; ix++) { Alarm alarm = dataGridViewAlarm.Rows[ix].Tag as Alarm; if (alarm != null && alarm.EventHeader.ID == changedAlarmData.AlarmId) { IAlarmClient alarmClient = LookupAlarmClient(alarm.EventHeader.Source.FQID); Alarm newAlarm = alarmClient.Get(alarm.EventHeader.ID); dataGridViewAlarm.Rows[ix].Tag = newAlarm; dataGridViewAlarm.Rows[ix].Cells[3].Value = "" + newAlarm.EventHeader.Priority; dataGridViewAlarm.Rows[ix].Cells[4].Value = "" + newAlarm.State; } } break; default: break; } } } catch (Exception ex) { EnvironmentManager.Instance.ExceptionDialog("MessageHandler", ex); } } return(null); }