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); } }