Beispiel #1
0
        /// <summary>
        /// method to compose notify object to be used in NotifyCom
        /// </summary>
        /// <param name="alarmObject"></param>
        /// <returns></returns>
        public INotifyObject[] Compose(AlarmObject alarmObject)
        {
            List <INotifyObject> notifyObjectList = null;

            try
            {
                //if the dynamic notification is already cleared , no need to send to Notify objects list to notify engine
                if (alarmObject.IsSwitchNotificationClearProcessStarted == true)
                {
                    return(new List <INotifyObject>().ToArray());
                }
                //if IsDynamicNotificationCleared is true we need to set the below flag in order skip notifications
                //received from any escalations while the clear process is going on
                if (alarmObject.IsDynamicNotificationCleared)
                {
                    alarmObject.IsSwitchNotificationClearProcessStarted = true;
                }

                notifyObjectList = new List <INotifyObject>();

                //Get Switch notifyID using NotifyProfileID
                int switchNotifyID = GetSwitchNotifyID(alarmObject.NotifyProfileID, alarmObject.NotificationID);

                //Get relay switch configuration object
                RelaySwitchConfig relaySwitchConfig = GetRelaySwitchConfig(switchNotifyID);

                //Populate the relaySwitch config settings into notification settings, for use in Switch Notify Com
                NotifyObject notifyObject = new NotifyObject();

                //assign the bit mask value set in the escalation profiles and sensor attributes
                notifyObject.NotificationData = alarmObject.SwitchBitmask;

                //set the notification type
                notifyObject.NotificationType = "RELAYSWITCH";

                //assign the switch configurations to notified settings
                Hashtable ht = GetNotificationSettings(relaySwitchConfig);
                ht["IsDynamicNotificationCleared"] = alarmObject.IsDynamicNotificationCleared;
                ht["SensorAlarmID"]  = alarmObject.SensorAlarmID;
                ht["FactoryID"]      = alarmObject.FactoryID;
                ht["NotificationID"] = alarmObject.NotificationID;

                notifyObject.NotifierSettings = ht;

                //add notify object to list
                notifyObjectList.Add(notifyObject);
            }
            catch (Exception ex)
            {
                LogBook.Write(ex, "CooperAtkins.NotificationClient.NotificationComposer.SwitchNotificationComposer");
            }
            //return the notify objects to Notify Com
            return(notifyObjectList.ToArray());
        }
Beispiel #2
0
        /// <summary>
        /// method to get the relay switch configuration
        /// </summary>
        /// <param name="switchNotifyID"></param>
        /// <returns></returns>
        private RelaySwitchConfig GetRelaySwitchConfig(int switchNotifyID)
        {
            RelaySwitchConfig relaySwitchConfig = new RelaySwitchConfig();

            using (RelaySwitchConfigContext context = new RelaySwitchConfigContext())
            {
                relaySwitchConfig = context.GetEntity(new Criteria()
                {
                    ID = switchNotifyID
                });
            }

            return(relaySwitchConfig);
        }
Beispiel #3
0
        /// <summary>
        /// method to set relay switch configuration details to notifications settings hashtable
        /// </summary>
        /// <param name="relaySwitchConfig"></param>
        /// <returns></returns>
        private Hashtable GetNotificationSettings(RelaySwitchConfig relaySwitchConfig)
        {
            Hashtable notificationSettings = new Hashtable();

            try
            {
                notificationSettings.Add("NotifyID", relaySwitchConfig.NotifyID);
                notificationSettings.Add("Name", relaySwitchConfig.Name);
                notificationSettings.Add("SwitchInfo", relaySwitchConfig.SwitchInfo);
                notificationSettings.Add("IsEnabled", relaySwitchConfig.IsEnabled);
            }
            catch (Exception ex)
            {
                LogBook.Write("   *** Error in GetNotificationSettings method:" + ex.Message);
            }
            return(notificationSettings);
        }