private void SendToNotifyEngine(CooperAtkins.Interface.Alarm.AlarmObject alarmObject, INotificationComposer composer, string composeType, NotificationEndPointElement endpoint) { INotifyObject[] notifyObjects = null; if (composer != null) { notifyObjects = composer.Compose(alarmObject); } if (notifyObjects != null) { foreach (INotifyObject notifyObject in notifyObjects) { notifyObject.NotificationType = composeType; Interface.NotifyCom.NotifyComResponse response = null; //Invoke Engine and send //Engine returns NotifyComResponse response = InvokeNotifyEngine(notifyObject, endpoint); composer.Receive(response, notifyObject); } } }
public void Send(CooperAtkins.Interface.Alarm.AlarmObject alarmObject, string[] notificationTypes) { INotificationComposer composer = null; string[] notificationTypes4Ref = notificationTypes; bool ImDone = false; /*Added on 02/28/2011 to update genStore values for every new alarm object.*/ new CooperAtkins.NotificationClient.Generic.DataAccess.GenStoreInfo().UpdateGenStore(); Label4Revisit: if (notificationTypes != null) { foreach (string notifyType in notificationTypes) { /* As we are using same composer for Server Popup and Remote Popup we are using this * flag in composer to differentiate the notification object*/ if (notifyType == SERVERPOPUP) { alarmObject.IsServerPopup = true; } /* if already sent the notification, do not send it again for always invokes */ if (ImDone && notificationTypes4Ref != null) { bool flag = false; foreach (string nextType in notificationTypes4Ref) { if (nextType.ToLower().Trim() == notifyType.ToLower().Trim()) { flag = true; break; } } if (flag) { continue; } } NotificationEndPointElement endpoint; composer = GetComposer(WhoAmI(notifyType, out endpoint)); if (composer != null) { SendToNotifyEngine(alarmObject, composer, notifyType, endpoint); } /*After sending the notify type(Server pop) to Notification Server, * set the flag to false so that we can use remote popup as notification */ if (notifyType == SERVERPOPUP) { alarmObject.IsServerPopup = false; } } } if (!ImDone) { ImDone = true; notificationTypes = _alwaysInvokeComposers; goto Label4Revisit; } }
public void Send(CooperAtkins.Interface.Alarm.AlarmObject alarmObject) { try { /* get type of notifications based on notify profile id */ NotificationEligibility notificationEligibility = new NotificationEligibility(alarmObject.NotifyProfileID, alarmObject.IsDynamicNotificationCleared, alarmObject.IsDynamicNotificationRemoved, alarmObject.IsProcessCompleted, alarmObject.IsResumedNitification); notificationEligibility.NotificationSentCount = alarmObject.NotificationSentCount; string[] notificationTypes = notificationEligibility.GetNotifyTypes(); alarmObject.IVRUserID = notificationEligibility.IVRUserID; string nTypes = string.Empty; // if (notificationTypes != null) // { foreach (string item in notificationTypes) { nTypes += ", " + item; } LogBook.Write(AlarmHelper.BasicAlarmInformation(alarmObject) + ", active notification types:" + nTypes); // } /* if user configured dynamic objects for one escalation and if the user not configured in next escalation then do not update the "HasDynamicTypes", * to clear the previous dynamic notification, "HasDynamicTypes" should not become false. */ #if DEBUG LogBook.Write(String.Format("HasDynamicTypes = {0} HasPreviousMessageBoard = {1} HasPreviousSwitch = {2}", alarmObject.HasDynamicTypes, alarmObject.HasPreviousMessageBoard, alarmObject.HasPreviousSwitch)); LogBook.Write(String.Format("IsDynamicNotificationCleared = {0} IsDynamicNotificationRemoved = {1} AlarmStateExitTime = {2}", alarmObject.IsDynamicNotificationCleared, alarmObject.IsDynamicNotificationRemoved, alarmObject.AlarmStateExitTime)); #endif if (!alarmObject.HasDynamicTypes) { alarmObject.HasDynamicTypes = notificationEligibility.HasDynamicTypes; if (!alarmObject.HasPreviousMessageBoard) { alarmObject.HasPreviousMessageBoard = notificationEligibility.HasPreviousMessageBoard; } if (!alarmObject.HasPreviousSwitch) { alarmObject.HasPreviousSwitch = notificationEligibility.HasPreviousSwitch; } } if ((alarmObject.HasPreviousSwitch || alarmObject.HasPreviousMessageBoard) && alarmObject.IsDynamicNotificationCleared && !alarmObject.IsDynamicNotificationRemoved) { // this is where we would need to add logic // but the settings likely carry through only for the previous notification which in this case was blank. if (!nTypes.ToLower().Contains("switch") && alarmObject.HasPreviousSwitch) { LogBook.Write("Adding switch to list"); nTypes += ", " + "Switch"; string[] tempArray = new string[notificationTypes.Length + 1]; for (int arrIndex = 0; arrIndex < notificationTypes.Length; arrIndex++) { tempArray[arrIndex] = notificationTypes[arrIndex]; } tempArray[notificationTypes.Length] = "Switch"; notificationTypes = tempArray; } if (!nTypes.ToLower().Contains("messageboard") && alarmObject.HasPreviousMessageBoard) { LogBook.Write("Adding messageboard to list"); nTypes += ", " + "MessageBoard"; string[] tempArray = new string[notificationTypes.Length + 1]; for (int arrIndex = 0; arrIndex < notificationTypes.Length; arrIndex++) { tempArray[arrIndex] = notificationTypes[arrIndex]; } tempArray[notificationTypes.Length] = "MessageBoard"; notificationTypes = tempArray; } } // We should only allow specific types to be "sent" if dynamic notifications have not been removed // ONLY SEND IF IT HAS NOT EXITED ALARM STATE OR IF IT NEEDS TO REMOVE DYNAMIC NOTIFICATIONS // correction - if this is an escalation and the option to continue escalation when it returns to normal is selected, it also needs to send the notifications on // the previous change stopped this from happening, also if it is a first alarm that has since returned to normal, we need to send it on. //if ((alarmObject.AlarmStateExitTime == DateTime.MinValue) || // ((alarmObject.HasPreviousSwitch || alarmObject.HasPreviousMessageBoard) && // alarmObject.IsDynamicNotificationCleared && !alarmObject.IsDynamicNotificationRemoved) || // (alarmObject.AlarmStateExitTime != DateTime.MinValue && alarmObject.IsEscalationNotification && alarmObject.StopEscalationOnExitAlarm == false) ) if ((alarmObject.AlarmStateExitTime == DateTime.MinValue) || ((alarmObject.HasPreviousSwitch || alarmObject.HasPreviousMessageBoard) && alarmObject.IsDynamicNotificationCleared && !alarmObject.IsDynamicNotificationRemoved) || (alarmObject.AlarmStateExitTime != DateTime.MinValue && alarmObject.IsEscalationNotification && alarmObject.StopEscalationOnExitAlarm == false) || // next line would address a first time alarm that had already "returned to normal" and would allow it to send. Case in point is when a Wi-Fi transmitter buffers readings, //goes out of range and back in, then re-establishes communication with Wi-Fi and server (alarmObject.AlarmStateExitTime != DateTime.MinValue && alarmObject.IsEscalationNotification == false && alarmObject.IsFailsafeEscalationNotification == false)) { if (alarmObject.IsDynamicNotificationCleared && !alarmObject.IsDynamicNotificationRemoved && alarmObject.AlarmStateExitTime != DateTime.MinValue) //&& (alarmObject.IsEscalationNotification && alarmObject.StopEscalationOnExitAlarm == false)) // We are removing dynamic notifications, so remove all other types and only add the dynamic ones that should be included { string[] tempArray = null; if (alarmObject.HasPreviousSwitch && alarmObject.HasPreviousMessageBoard) { tempArray = new string[2]; tempArray[0] = "MessageBoard"; tempArray[1] = "Switch"; } else if (alarmObject.HasPreviousSwitch) { tempArray = new string[1]; tempArray[0] = "Switch"; } else if (alarmObject.HasPreviousMessageBoard) { tempArray = new string[1]; tempArray[0] = "MessageBoard"; } notificationTypes = tempArray; } Send(alarmObject, notificationTypes); if (notificationTypes != null) { alarmObject.NotificationSentCount++; } } //} } catch (Exception ex) { LogBook.Write("NotificationClient.Send line 263 Exception: " + ex.Message); } }