/// <summary> /// Get Notification E-Mail Object /// </summary> /// <param name="alarmObject"></param> /// <returns></returns> private NotifyPopupAddressList GetNotifyPopupAddressList(Interface.Alarm.AlarmObject alarmObject) { NotifyPopupAddressList notificationPopupAddressList = null; try { /*Fetch Popup Address list based on Notification Profile ID*/ notificationPopupAddressList = new NotifyPopupAddressList(); Criteria criteria = new Criteria(); criteria.ID = GetPopupNotificationID(alarmObject.NotifyProfileID);//Replace with notificationPopupAddressList.Load(criteria); } catch (Exception ex) { /*Debug Object values for reference*/ LogBook.Debug(notificationPopupAddressList, this); /*Write exception log*/ LogBook.Write(_logContent + " Error has occurred while fetching Popup address list from 'GenNotifyEmails' table", ex, "CooperAtkins.NotificationClient.NotificationComposer.EmailNotificationComposer"); } return(notificationPopupAddressList); }
/// <summary> /// Get Popup notification list /// </summary> /// <param name="notifyEmailAddressList"></param> /// <returns></returns> private List <INotifyObject> GetNotificationList(NotifyPopupAddressList notificationPopupAddressList, AlarmObject alarmObject, string popupMessage) { List <INotifyObject> notifyList = new List <INotifyObject>(); NotificationStyle notificationStyle = new NotificationStyle(); foreach (NotifyPopupAddress notifyPopupAddress in notificationPopupAddressList) { /*Check for Notification Popup Address and exit the sending process, if NotificationEmailAddress object is NULL*/ if (notifyPopupAddress != null) { /*Get Notification Object*/ INotifyObject notifyObject = GetNotifyObject(alarmObject, popupMessage, notifyPopupAddress); //Add notification object to array list notifyList.Add(notifyObject); } else { /*Record notification if Popup Address parameters are not supplied properly*/ notificationStyle.RecordNotification("", alarmObject.NotificationID, 0, NotifyStatus.FAIL, NotifyTypes.POPUP); } } return(notifyList); }
public INotifyObject[] Compose(AlarmObject alarmObject) { NotifyPopupAddressList notificationPopupAddressList = null; string popupMessage = ""; /*Notify List*/ List <INotifyObject> notifyList = new List <INotifyObject>(); /*Initialize NotifySettings*/ NotificationStyle notificationStyle = new NotificationStyle(); if (alarmObject.IsMissCommNotification) { _logContent = "Missed Communication"; } else { _logContent = "SensorID: " + alarmObject.UTID.ToStr() + " SensorAlarmID: " + alarmObject.SensorAlarmID.ToStr(); } /*Check whether server popup or remote popup*/ if (alarmObject.IsServerPopup) { /*Write Log: * Started Server popup Notification * Reached Server popup Notification Composer*/ LogBook.Write("*** Started Composing Server popup Notification for " + _logContent + "***"); /*Get custom message for missed communication*/ if (alarmObject.IsMissCommNotification) { popupMessage = "Missed Communication" + " [" + alarmObject.MissedCommSensorCount + "] sensors"; } else { /*Get popup message*/ popupMessage = notificationStyle.GetFormatString(alarmObject, 1, "Popup"); /*Substitute message parameters*/ popupMessage = notificationStyle.SubstituteFormatString(popupMessage, alarmObject); } /*Server popup*/ NotifyPopupAddress notifyPopupAddress = new NotifyPopupAddress(); notifyPopupAddress.NetSendTo = ConfigurationManager.AppSettings.Get("NetSendTo").ToStr(); notifyPopupAddress.Name = ConfigurationManager.AppSettings.Get("NetSendFromName").ToStr(); /*Get Notification Object*/ INotifyObject notifyObject = GetNotifyObject(alarmObject, popupMessage, notifyPopupAddress); if (notifyList.Count > 0) { /*Write Log * Sending Server Popup notification data to Notification Engine*/ LogBook.Write(_logContent + " Sending notification data to Server Popup Notification Engine."); } notifyList.Add(notifyObject); } else { /*Write Log: * Started Server popup Notification * Reached Server popup Notification Composer*/ LogBook.Write("*** Started Composing Remote popup Notification for " + _logContent + "***"); /*Get custom message for missed communication*/ if (alarmObject.IsMissCommNotification) { popupMessage = "Missed Communication" + " [" + alarmObject.MissedCommSensorCount + "] sensors"; } else { /*Get NetSend message*/ popupMessage = notificationStyle.GetFormatString(alarmObject, 1, "NetSend"); /*Notification Tree*/ string notifyTree = notificationStyle.GetFormatString(alarmObject, 1, "NotifyTree"); /*Format Subject*/ string netSendMsg = notificationStyle.SubstituteFormatString(popupMessage, alarmObject); popupMessage = netSendMsg; /*Format Notify Tree*/ string netTreeMsg = notificationStyle.SubstituteFormatString(notifyTree, alarmObject); notifyTree = netTreeMsg; if (notifyTree != string.Empty) { popupMessage = popupMessage + "%%NOTIFYTREE%%" + notifyTree; } } /*Get Notification Popup Address List*/ notificationPopupAddressList = GetNotifyPopupAddressList(alarmObject); if (notificationPopupAddressList.Count != 0) { /*Get Popup Notification list*/ notifyList = GetNotificationList(notificationPopupAddressList, alarmObject, popupMessage); } else { /*Log when we don't have Popup address to notify*/ LogBook.Write(_logContent + " Error: Missing entry in NotifyEmails/Groups"); } if (notifyList.Count > 0) { /*Write Log * Sending Remote Popup notification data to Notification Engine*/ LogBook.Write(_logContent + " Sending notification data to Remote Popup Notification Engine."); } } return(notifyList.ToArray()); }