Esempio n. 1
0
        public void PublishAlarmsEvents(AlarmHelper alarm, PublishingStatus status)
        {
            switch (status)
            {
            case PublishingStatus.INSERT:
            {
                AlarmsEventsEventArgs e = new AlarmsEventsEventArgs()
                {
                    Alarm = alarm
                };

                try
                {
                    AlarmEvent(this, e);
                }
                catch (Exception ex)
                {
                    string message = string.Format("AES does not have any subscribed client for publishing new alarms. {0}", ex.Message);
                    CommonTrace.WriteTrace(CommonTrace.TraceVerbose, message);
                    Console.WriteLine(message);
                }

                break;
            }

            case PublishingStatus.UPDATE:
            {
                alarm.PubStatus = PublishingStatus.UPDATE;
                AlarmUpdateEventArgs e = new AlarmUpdateEventArgs()
                {
                    Alarm = alarm
                };

                try
                {
                    AlarmUpdate(this, e);
                }
                catch (Exception ex)
                {
                    string message = string.Format("AES does not have any subscribed client for publishing alarm status change. {0}", ex.Message);
                    CommonTrace.WriteTrace(CommonTrace.TraceVerbose, message);
                    Console.WriteLine(message);
                }
                break;
            }
            }
        }
Esempio n. 2
0
        public void PublishStateChange(AlarmHelper alarm)
        {
            AlarmUpdateEventArgs e = new AlarmUpdateEventArgs()
            {
                Alarm = alarm
            };

            try
            {
                AlarmUpdate(this, e);
            }
            catch (Exception ex)
            {
                string message = string.Format("AES does not have any subscribed client for publishing alarm status change. {0}", ex.Message);
                CommonTrace.WriteTrace(CommonTrace.TraceVerbose, message);
                Console.WriteLine(message);
            }
        }
Esempio n. 3
0
        public void AlarmsUpdateEventsHandler(object sender, AlarmUpdateEventArgs e)
        {
            List <IAesPubSubCallbackContract> faultetClients = new List <IAesPubSubCallbackContract>(4);

            foreach (IAesPubSubCallbackContract client in clientsToPublish)
            {
                if ((client as ICommunicationObject).State.Equals(CommunicationState.Opened))
                {
                    client.UpdateAlarmsEvents(e.Alarm);
                }
                else
                {
                    faultetClients.Add(client);
                }
            }
            lock (clientsLocker)
            {
                foreach (IAesPubSubCallbackContract client in faultetClients)
                {
                    clientsToPublish.Remove(client);
                }
            }
        }