Exemple #1
0
 /// <summary>
 /// method to handle response received after invoking the Notify object
 /// </summary>
 /// <param name="response"></param>
 /// <param name="notifyObject"></param>
 public void Receive(NotifyComResponse response, INotifyObject notifyObject)
 {
     try
     {
         /*Check the response object*/
         if (response != null)
         {
             NotificationStyle notificationStyle = new NotificationStyle();
             if (response.IsError == false)
             {
                 /*Record notification information.*/
                 notificationStyle.RecordNotification(response.ResponseContent.ToStr(), notifyObject.NotifierSettings["NotificationID"].ToInt(), 0, response.IsSucceeded ? NotifyStatus.PASS : NotifyStatus.FAIL, NotifyTypes.SWITCH);
             }
             else
             {
                 notificationStyle.RecordNotification(response.ResponseContent.ToStr(), notifyObject.NotifierSettings["NotificationID"].ToInt(), 0, NotifyStatus.FAIL, NotifyTypes.SWITCH);
                 //Write Log
                 LogBook.Write(response.ResponseContent.ToString());
             }
         }
     }
     catch (Exception ex)
     {
         LogBook.Write(ex, "CooperAtkins.NotificationClient.NotificationComposer.SwitchNotificationComposer");
     }
 }
Exemple #2
0
        /// <summary>
        /// Get Email notification list
        /// </summary>
        /// <param name="notifyEmailAddressList"></param>
        /// <returns></returns>
        private List <INotifyObject> GetNotificationList(NotifyEmailAddressList notifyEmailAddressList, AlarmObject alarmObject, GenStoreInfo genStoreInfo)
        {
            List <INotifyObject> notifyList        = new List <INotifyObject>();
            NotificationStyle    notificationStyle = new NotificationStyle();

            foreach (NotifyEmailAddress notifyEmailAddress in notifyEmailAddressList)
            {
                /*Check for Notification Email Address and exit the sending process, if NotificationEmailAddress object is NULL*/
                if (notifyEmailAddress != null)
                {
                    /*Get Notification Object*/
                    INotifyObject notifyObject = GetNotifyObject(alarmObject, genStoreInfo, notifyEmailAddress);

                    if (notifyObject.NotifierSettings["FromAddress"].ToStr() == string.Empty || notifyObject.NotifierSettings["ToAddress"].ToStr() == string.Empty)
                    {
                        /*Record notification if Email (To/From) Address parameters are not supplied properly*/
                        notificationStyle.RecordNotification(ErrorMessages.EmailComposer_InvalidEmailAddress, alarmObject.NotificationID, 0, NotifyStatus.FAIL, NotifyTypes.EMAIL);
                    }
                    else
                    {
                        //Add notification object to array list
                        notifyList.Add(notifyObject);
                    }
                }
                else
                {
                    /*Record notification if Email Address parameters are not supplied properly*/
                    notificationStyle.RecordNotification(ErrorMessages.EmailComposer_EmailParamsNotSupplied, alarmObject.NotificationID, 0, NotifyStatus.FAIL, NotifyTypes.EMAIL);
                }
            }
            return(notifyList);
        }
        /// <summary>
        /// Get Sms notification list
        /// </summary>
        /// <param name="notifySmsAddressList"></param>
        /// <returns></returns>
        private List <INotifyObject> GetNotificationList(NotifyMobileList notifyMobileList, AlarmObject alarmObject, GenStoreInfo genStoreInfo)
        {
            List <INotifyObject> notifyList        = new List <INotifyObject>();
            NotificationStyle    notificationStyle = new NotificationStyle();

            foreach (NotifyMobiles notifyMobiles in notifyMobileList)
            {
                /*Check for Notification Sms Address and exit the sending process, if NotificationSmsAddress object is NULL*/
                if (notifyMobiles != null)
                {
                    /*Get Notification Object*/
                    INotifyObject notifyObject = GetNotifyObject(alarmObject, genStoreInfo, notifyMobiles);

                    if (notifyObject.NotifierSettings["ToPhoneNumber"].ToStr() == string.Empty || notifyObject.NotifierSettings["COMSettings"].ToStr() == string.Empty)
                    {
                        LogBook.Write("Missing mobile number or COM Settings");
                        /*Record notification if Sms parameters are not supplied properly*/
                        notificationStyle.RecordNotification(ErrorMessages.SMSComposer_InvalidSettings, notifyObject.NotifierSettings["NotificationID"].ToInt(), 0, NotifyStatus.FAIL, NotifyTypes.SMS);
                    }
                    else
                    {
                        //Add notification object to array list
                        notifyList.Add(notifyObject);
                    }
                }
                else
                {
                    /*Record notification if Sms parameters are not supplied properly*/
                    notificationStyle.RecordNotification(ErrorMessages.SMSComposer_InvalidSettings, alarmObject.NotificationID, 0, NotifyStatus.FAIL, NotifyTypes.SMS);
                }
            }
            return(notifyList);
        }
Exemple #4
0
        /// <summary>
        /// Get notification object
        /// </summary>
        /// <param name="alarmObject"></param>
        /// <returns></returns>
        private NotifyObject GetNotifyObject(AlarmObject alarmObject)
        {
            string       scriptArgs   = GetScriptArguments(alarmObject);
            string       errorMsg     = string.Empty;
            string       scriptName   = ConfigurationManager.AppSettings.Get("ScriptPath").ToStr();
            NotifyObject notifyObject = new NotifyObject();

            NotificationStyle notificationStyle = new NotificationStyle();

            /*Set Notification Type*/
            notifyObject.NotificationType = "Switch";

            /*Notification Data*/
            notifyObject.NotificationData = "";

            Hashtable notificationSettings = new Hashtable();

            /*Script Arguments*/
            notificationSettings.Add("ScriptArgs", scriptArgs);

            /*Script Name*/
            notificationSettings.Add("ScriptName", scriptName);

            /*Notification ID*/
            notificationSettings.Add("NotificationID", alarmObject.NotificationID);

            /*Notification Settings*/
            notifyObject.NotifierSettings = notificationSettings;

            if (scriptName == string.Empty)
            {
                errorMsg = string.Format(ErrorMessages.ScriptComposer_InvalidScriptFileName, scriptName);

                /*If the script file name is empty record notification.*/
                notificationStyle.RecordNotification(errorMsg, alarmObject.NotificationID, 0, NotifyStatus.FAIL, NotifyTypes.SCRIPT);

                /*Log error*/
                LogBook.Write(_logContent + " *** Skipping custom alert script - no script found");
            }
            else if (!File.Exists(scriptName)) /*Check weather the script file exist or not*/
            {
                errorMsg = string.Format(ErrorMessages.ScriptComposer_ScriptFileNotFound, scriptName);

                /*If file doesn't exist in the specified path record notification*/
                notificationStyle.RecordNotification(errorMsg, alarmObject.NotificationID, 0, NotifyStatus.FAIL, NotifyTypes.SCRIPT);

                /*Log if script file not found*/
                LogBook.Write(_logContent + " *** Skipping custom alert script - file not found: ");
            }

            return(notifyObject);
        }
Exemple #5
0
        /// <summary>
        /// To Record IVRNotification.
        /// </summary>
        private void RecordIVRNotification(AlarmObject _alarmObject)
        {
            NotificationStyle notificationStyle = null;

            try
            {
                notificationStyle = new NotificationStyle();
                TTIvrNotifications tTIVRNotifications = new TTIvrNotifications()
                {
                    Action             = "C",
                    AlarmID            = _alarmObject.AlarmID,
                    LastAttemptTime    = DateTime.UtcNow,
                    Notification_RecID = _alarmObject.NotificationID,
                    TransID            = _alarmObject.TransID,
                    PersonName         = _alarmObject.PersonName,
                    NumAttempts        = 0,
                    PhoneNumber        = _alarmObject.IVRPhoneNumber,
                    UserID             = _alarmObject.IVRUserID,
                    QueueTime          = DateTime.UtcNow,
                    isInProcess        = 1,
                    ThreadID           = _alarmObject.ThreadID
                };

                tTIVRNotifications.Execute();

                _recID = tTIVRNotifications.RecID;



                if (tTIVRNotifications.PhoneNumber.Trim() != string.Empty)
                {
                    //write to TTNotifcationLog table
                    notificationStyle.RecordNotification("Queued for Voice: " + tTIVRNotifications.PersonName + " @ " + tTIVRNotifications.PhoneNumber, _alarmObject.NotificationID, _alarmObject.TransID, NotifyStatus.PASS, NotifyTypes.VOICE);
                    // INotifyObject notifyObject = GetNotifyObject(_alarmObject, _genStore);
                }
                else
                {
                    //write to TTNotifcationLog table
                    notificationStyle.RecordNotification("Phone number does not exists. Queue failed ", _alarmObject.NotificationID, _alarmObject.TransID, NotifyStatus.FAIL, NotifyTypes.VOICE);
                }
                LogBook.Write("IVRNotification has been ADDED for AlarmID[" + tTIVRNotifications.AlarmID + "] To User [+" + tTIVRNotifications.UserID + "] at [" + tTIVRNotifications.PhoneNumber + "]");
            }
            catch (Exception ex)
            {
                //write to TTNotifcationLog table
                notificationStyle.RecordNotification("Queued for Voice: " + _alarmObject.IVRPhoneNumber.ToStr() + " Failed", _alarmObject.NotificationID, _alarmObject.TransID, NotifyStatus.FAIL, NotifyTypes.VOICE);
                LogBook.Write(ex, "CooperAtkins.IVRNotification");
            }
        }
Exemple #6
0
        /// <summary>
        /// Get Email notification list
        /// </summary>
        /// <param name="notifyEmailAddressList"></param>
        /// <returns></returns>
        private List <INotifyObject> GetNotificationList(NotifyPagerAddressList notifyPagerAddressList, AlarmObject alarmObject)
        {
            List <INotifyObject> notifyList        = new List <INotifyObject>();
            NotificationStyle    notificationStyle = new NotificationStyle();

            foreach (NotifyPagerAddress notifyPagerAddress in notifyPagerAddressList)
            {
                /*Check for Notification Pager Address and exit the sending process, if NotificationPagerAddress object is NULL*/
                if (notifyPagerAddress != null)
                {
                    /*Get Notification Object*/
                    //if (notifyPagerAddress.DeliveryMethod == 1) // DeliveryMethod 0 = Modem 1 = SNPP
                    //{
                    /*Get SNPP notify settings*/
                    if (GetNotifySNPPObject(alarmObject, notifyPagerAddress) != null)
                    {
                        notifyList.Add(GetNotifySNPPObject(alarmObject, notifyPagerAddress));
                    }
                    //}
                }
                else
                {
                    /*Record notification if Email Address parameters are not supplied properly*/
                    notificationStyle.RecordNotification(ErrorMessages.PagerComposer_SNPPParmsNotSupplied, alarmObject.NotificationID, 0, NotifyStatus.FAIL, NotifyTypes.PAGER);
                }
            }
            return(notifyList);
        }
Exemple #7
0
 /// <summary>
 /// Method to send the response received from the Invoking the Notification
 /// </summary>
 /// <param name="response"></param>
 /// <param name="notifyObject"></param>
 public void Receive(NotifyComResponse response, INotifyObject notifyObject)
 {
     /*Check the response object*/
     if (response != null && notifyObject.NotifierSettings["NotificationID"].ToInt() != 0)
     {
         NotificationStyle notificationStyle = new NotificationStyle();
         if (response.IsError == false)
         {
             /*Record notification information.*/
             notificationStyle.RecordNotification(response.ResponseContent.ToStr(), notifyObject.NotifierSettings["NotificationID"].ToInt(), 0, response.IsSucceeded ? NotifyStatus.PASS : NotifyStatus.FAIL, NotifyTypes.MSGBOARD);
             LogBook.Write("Notification sent to message board: " + notifyObject.NotifierSettings["IpAddress"]);
         }
         else
         {
             notificationStyle.RecordNotification(response.ResponseContent.ToStr(), notifyObject.NotifierSettings["NotificationID"].ToInt(), 0, NotifyStatus.FAIL, NotifyTypes.MSGBOARD);
             LogBook.Write("     *** Error sending message board notification to" + notifyObject.NotifierSettings["IpAddress"]);
             LogBook.Write("     *** Error :" + response.ResponseContent);
         }
     }
 }
        /// <summary>
        /// To Record IVRNotification.
        /// </summary>
        private void RecordIVRNotification()
        {
            NotificationStyle notificationStyle = null;

            try
            {
                notificationStyle = new NotificationStyle();
                TTIvrNotifications tTIVRNotifications = new TTIvrNotifications()
                {
                    Action             = "C",
                    AlarmID            = _alarmObject.AlarmID,
                    LastAttemptTime    = DateTime.UtcNow,
                    Notification_RecID = _alarmObject.NotificationID,
                    NumAttempts        = 1,
                    PhoneNumber        = _alarmObject.IVRPhoneNumber,
                    TransID            = _alarmObject.TransID,
                    PersonName         = _alarmObject.PersonName,
                    UserID             = _alarmObject.IVRUserID,
                    QueueTime          = DateTime.UtcNow
                };

                tTIVRNotifications.Execute();

                if (tTIVRNotifications.PhoneNumber.Trim() != string.Empty)
                {
                    notificationStyle.RecordNotification("Queued for Voice: " + tTIVRNotifications.PersonName + " @ " + tTIVRNotifications.PhoneNumber, _alarmObject.TransID, _alarmObject.NotificationID, NotifyStatus.PASS, NotifyTypes.VOICE);
                }
                else
                {
                    notificationStyle.RecordNotification("Phone number does not exists. Queue failed ", _alarmObject.TransID, _alarmObject.NotificationID, NotifyStatus.FAIL, NotifyTypes.VOICE);
                }
                LogBook.Write("IVRNotification has been inserted.");
            }
            catch (Exception ex)
            {
                notificationStyle.RecordNotification("Queued for Voice: " + _alarmObject.IVRPhoneNumber.ToStr() + " Failed", _alarmObject.TransID, _alarmObject.NotificationID, NotifyStatus.FAIL, NotifyTypes.VOICE);
                LogBook.Write(ex, "CooperAtkins.IVRNotification");
            }
        }
Exemple #9
0
        /// <summary>
        /// Receive response and record notification
        /// </summary>
        /// <param name="response"></param>
        /// <param name="notifyObject"></param>
        public void Receive(NotifyComResponse response, INotifyObject notifyObject)
        {
            /*Create notification style object*/
            NotificationStyle notificationStyle = new NotificationStyle();

            /*Check the response object*/
            if (response != null)
            {
                /*Record notification information.*/
                notificationStyle.RecordNotification(response.ResponseContent.ToStr().Replace("127.0.0.1", "server"), notifyObject.NotifierSettings["NotificationID"].ToInt(), 0, (response.IsSucceeded ? NotifyStatus.PASS : NotifyStatus.FAIL), NotifyTypes.POPUP);

                /*Log if Popup sent*/
                LogBook.Write(_logContent + " Popup Response: " + response.ResponseContent.ToStr());
            }
        }
Exemple #10
0
        public void Receive(NotifyComResponse response, INotifyObject notifyObject)
        {
            NotificationStyle notificationStyle = new NotificationStyle();

            /*Write Log
             * Response received from Notification Engine*/
            LogBook.Write(_logContent + " Response received from Script Notification Engine.");

            /*Check the response object*/
            if (response != null)
            {
                /*Record notification indicating that the script executed successfully*/
                notificationStyle.RecordNotification(response.ResponseContent.ToStr(), notifyObject.NotifierSettings["NotificationID"].ToInt(), 0, (response.IsSucceeded ? NotifyStatus.PASS : NotifyStatus.FAIL), NotifyTypes.SCRIPT);

                /*Log response content*/
                LogBook.Write(_logContent + " Script Response: " + response.ResponseContent.ToStr());
            }
        }
Exemple #11
0
        public void Receive(NotifyComResponse response, INotifyObject notifyObject)
        {
            NotificationStyle notificationStyle = new NotificationStyle();

            /*Write Log
             * Response received from Notification Engine*/
            LogBook.Write(_logContent + " Response received from Pager Notification Engine.");

            /*Check the response object*/
            if (response != null)
            {
                /*Record notification information.*/
                notificationStyle.RecordNotification(response.ResponseContent.ToStr(), notifyObject.NotifierSettings["NotificationID"].ToInt(), 0, (response.IsSucceeded ? NotifyStatus.PASS : NotifyStatus.FAIL), NotifyTypes.PAGER);

                /*Log response content*/
                LogBook.Write(_logContent + " Pager Response: " + response.ResponseContent.ToStr());
            }
        }
Exemple #12
0
        private int GetMessageBoardID(int notifyProfileID, int notificationID)
        {
            //get the message board id, to which the message has to be sent
            NotificationProfile notificationProfile = new NotificationProfile();
            NotificationStyle   notificationStyle   = new NotificationStyle();

            try
            {
                notificationProfile.NotifyProfileID = notifyProfileID;
                notificationProfile = notificationProfile.Execute();
                if (notificationProfile.MsgBoardNotifyID == 0)
                {
                    notificationStyle.RecordNotification("Message board not found", notificationID, 0, NotifyStatus.FAIL, NotifyTypes.MSGBOARD);
                }
            }
            catch (Exception ex)
            {
                LogBook.Write("     *** Error in GetMessageBoardID :" + ex.Message);
            }
            return(notificationProfile.MsgBoardNotifyID);
        }
Exemple #13
0
        /// <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);
        }
        /// <summary>
        /// Receive notification response.
        /// </summary>
        /// <param name="response"></param>
        public void Receive(NotifyComResponse response, INotifyObject notifyObject)
        {
            NotificationStyle notificationStyle = new NotificationStyle();

            /*Check the response object*/
            if (response != null)
            {
                /*Record notification information.*/
                notificationStyle.RecordNotification(response.ResponseContent.ToStr(), notifyObject.NotifierSettings["NotificationID"].ToInt(), 0, (response.IsSucceeded ? NotifyStatus.PASS : NotifyStatus.FAIL), NotifyTypes.SMS);

                if (response.IsError == false)
                {
                    /*Log if sms send to particular to address*/
                    LogBook.Write("SMS sent to: " + notifyObject.NotifierSettings["ToPhoneNumber"].ToStr());
                }
                else
                {
                    /*Log when sending sms failed*/
                    LogBook.Write("Error has occurred while sending SMS");
                    /*Log response content*/
                    LogBook.Write(response.ResponseContent.ToStr());
                }
            }
        }
Exemple #15
0
        public INotifyObject[] Compose(AlarmObject alarmObject)
        {
            GenStoreInfo           genStoreInfo           = null;
            NotifyEmailAddressList notifyEmailAddressList = null;
            List <INotifyObject>   notifyList             = new List <INotifyObject>();
            NotificationStyle      notificationStyle      = new NotificationStyle();


            /*Get GenStore Information*/
            genStoreInfo = GenStoreInfo.GetInstance();


            if (alarmObject.IsMissCommNotification)
            {
                _logContent = "Missed Communication";
            }
            else
            {
                _logContent = "SensorID: " + alarmObject.UTID.ToStr() + " SensorAlarmID: " + alarmObject.SensorAlarmID.ToStr();
            }

            /*Write Log:
             * Started Email Notification
             * Reached Email Notification Composer*/
            LogBook.Write("*** Started Composing E-Mail Notification for " + _logContent + "***");

            try
            {
                //If there's no record in the database, Execute method will return null
                if (genStoreInfo != null)
                {
                    /*Record notification if SMTP settings are not supplied properly*/
                    if ((genStoreInfo.SmtpServer.ToStr() == string.Empty && genStoreInfo.SmtpAuthDomain == string.Empty) && genStoreInfo.SmtpSendMethod == 0)
                    {
                        /*SMTP server not defined*/
                        LogBook.Write(_logContent + " Error: No SMTP Server has been defined.");

                        /*Record notification if SMTP parameters are not supplied properly*/
                        notificationStyle.RecordNotification(ErrorMessages.EmailComposer_SMTPParmsNotSupplied, alarmObject.NotificationID, 0, NotifyStatus.FAIL, NotifyTypes.EMAIL);
                    }
                    else
                    {
                        /*Get all the email addresses that are configured for notification*/
                        notifyEmailAddressList = GetNotifyEmailAddressList(alarmObject);

                        if (notifyEmailAddressList.Count != 0)
                        {
                            /*Construct a notification object for each email address and add to the notification list*/
                            notifyList = GetNotificationList(notifyEmailAddressList, alarmObject, genStoreInfo);
                            LogBook.Write("Email Notification count: " + notifyList.Count.ToString());
                        }
                        else
                        {
                            /*Log when we don't have Email address to notify*/
                            LogBook.Write(_logContent + " Error: Missing entry in NotifyEmails/Groups.");
                        }
                    }
                }
                else
                {
                    /*Record notification if genStore parameters are not supplied properly.*/
                    notificationStyle.RecordNotification(ErrorMessages.EmailComposer_GenStoreInvalid, alarmObject.NotificationID, 0, NotifyStatus.FAIL, NotifyTypes.EMAIL);

                    /*Log if genStore information is empty*/
                    LogBook.Write(_logContent + " Error:  Missing GenStores table record.");
                }
            }
            catch (Exception ex)
            {
                /*Write exception log*/
                //LogBook.Write(_logContent + " " + ex);
                LogBook.Write(_logContent + " Error: ", ex, "CooperAtkins.NotificationClient.NotificationComposer.EmailNotificationComposer");
                //, "CooperAtkins.NotificationClient.NotificationComposer.EmailNotificationComposer");
            }

            //if (notifyList.Count > 0)

            /*Write Log
             * Sending Email notification data to Notification Engine*/
            LogBook.Write(_logContent + " Sending notification data to Email  Notification Engine.");

            /*Send notification list to notification engine*/
            return(notifyList.ToArray());
        }
Exemple #16
0
        /// <summary>
        /// Get Notification settings for SNPP
        /// </summary>
        /// <param name="alarmObject"></param>
        /// <param name="notifyPagerAddress"></param>
        /// <returns></returns>
        private NotifyObject GetNotifySNPPObject(Interface.Alarm.AlarmObject alarmObject, NotifyPagerAddress notifyPagerAddress)
        {
            string snppServer = "", defaultPagerSubject = "", defaultPagerBody = "", defaultSubject = "", defaultBody = "";
            string subject = "", body = "", toAddress = "";
            int    snppPort     = 0;
            int    pagerDelay   = 0;
            string pagerMessage = string.Empty;

            /*Create Notification Style object*/
            NotificationStyle notificationStyle = new NotificationStyle();

            /*Create notification object */
            NotifyObject notifyObject = new NotifyObject();

            /*Set Notification Type*/
            notifyObject.NotificationType = "Pager";

            /*Create hashtable for notification settings*/
            Hashtable notificationSettings = new Hashtable();

            /*Set Default pager subject*/
            defaultPagerSubject = notificationStyle.GetFormatString(alarmObject, 1, "EmailSubjectPager");

            /*Set default pager body*/
            defaultPagerBody = notificationStyle.GetFormatString(alarmObject, 1, "EmailBodyPager");

            /*Set default subject*/
            defaultSubject = notificationStyle.GetFormatString(alarmObject, 1, "EmailSubject");

            /*Set default body*/
            defaultBody = notificationStyle.GetFormatString(alarmObject, 1, "EmailBody");

            /*If default pager subject is empty set default subject as default pager subject*/
            defaultPagerSubject = (defaultPagerSubject == string.Empty) ? defaultSubject : defaultPagerSubject;

            /*If default pager body is empty set default body as default pager body*/
            defaultPagerBody = (defaultPagerBody == string.Empty) ? defaultBody : defaultPagerBody;

            /*Set Email Body and Subject format*/
            subject = defaultPagerSubject;
            body    = defaultPagerBody;

            subject = notificationStyle.SubstituteFormatString(subject, alarmObject);
            body    = notificationStyle.SubstituteFormatString(body, alarmObject);

            /*Pager Body as notification data*/
            /*If pager body is empty assign the default pager body from alarm object*/

            /*Check this logic in old application*/
            /*In case of missed communication assign the custom body and subject*/
            if (alarmObject.IsMissCommNotification || body == string.Empty)
            {
                body = alarmObject.PagerMessage;
            }



            notificationSettings.Add("DeliveryMethod", notifyPagerAddress.DeliveryMethod);


            /*Get SNPP settings from GenStores*/
            GenStoreInfo genStoreInfo = null;

            /*Get GenStore Information*/
            genStoreInfo = GenStoreInfo.GetInstance();

            snppServer = genStoreInfo.SNPPServer;
            snppPort   = genStoreInfo.SNPPPort;

            /*Set PhoneNumber to Pager destination field*/
            toAddress = notifyPagerAddress.PhoneNumber;



            /*Pager Subject*/
            notificationSettings.Add("PagerSubject", subject);


            notificationSettings.Add("Name", notifyPagerAddress.PagerName);


            /*Pager Destination Address*/
            notificationSettings.Add("ToAddress", toAddress);

            /* if the delivery type is modem*/
            if (notifyPagerAddress.DeliveryMethod != 1)
            {
                pagerDelay = notifyPagerAddress.PagerDelay;

                if (alarmObject.PagerMessage.Trim() != string.Empty)
                {
                    pagerMessage = alarmObject.PagerMessage;
                }
                else
                {
                    pagerMessage = notifyPagerAddress.PagerMessage;
                }

                pagerMessage = notificationStyle.SubstituteFormatString(pagerMessage, alarmObject);

                notificationSettings.Add("PagerDelay", pagerDelay);
                notificationSettings.Add("PagerMessage", pagerMessage);

                notificationSettings.Add("AttemptCount", "0");
                notificationSettings.Add("LastSentTime", DateTime.Now);
            }


            notificationSettings.Add("PagerComPort", genStoreInfo.PagerComPort);
            notificationSettings.Add("COMportInitString", genStoreInfo.ComPortInitStr);



            LogBook.Debug("SNPP Server: " + snppServer);
            LogBook.Debug("SNPP Port: " + snppPort);

            notificationSettings.Add("NotificationID", alarmObject.NotificationID);

            if (notifyPagerAddress.DeliveryMethod == 1)
            {
                if (snppServer != string.Empty)
                {
                    /*Set Default SNPP port if not assigned*/
                    snppPort = (snppPort < 1 || snppPort > 32767) ? 444 : snppPort;


                    /*If pager destination address is empty record notification as fail*/
                    if (toAddress != string.Empty)
                    {
                        /*SNPP Server or Host*/
                        notificationSettings.Add("SNPPServer", genStoreInfo.SNPPServer);

                        /*SNPP Port Number*/
                        notificationSettings.Add("SNPPPort", snppPort);
                    }
                    else
                    {
                        notificationStyle.RecordNotification(ErrorMessages.PagerComposer_SNPPToAddressNotSupplied, alarmObject.NotificationID, 0, NotifyStatus.FAIL, NotifyTypes.PAGER);

                        /*Exit and return empty notification object*/
                        return(null);
                    }
                }
                else
                {
                    /*Record notification if SNPP settings are not supplied properly*/
                    notificationStyle.RecordNotification(ErrorMessages.PagerComposer_SNPPParmsNotSupplied, alarmObject.NotificationID, 0, NotifyStatus.FAIL, NotifyTypes.PAGER);

                    /*Exit and return empty notification object*/
                    return(null);
                }
            }

            /*Set notification setting to notification object*/
            notifyObject.NotifierSettings = notificationSettings;

            /*Pager body*/
            notifyObject.NotificationData = body;

            return(notifyObject);
        }
        internal NotifyComResponse InvokeNotifyEngine(INotifyObject notifyObject, NotificationEndPointElement endpoint)
        {
            //Implement client INotifyReceiver for client and notification server communication.
            int    notifyClienttimeOutValue = 0;
            string senderType = "", endpointAddress;

            if (endpoint != null && !string.IsNullOrEmpty(endpoint.WType) && !string.IsNullOrEmpty(endpoint.EndpointAddress))
            {
                senderType               = endpoint.WType;
                endpointAddress          = endpoint.EndpointAddress;
                notifyClienttimeOutValue = endpoint.Timeout;
                LogBook.Write(notifyObject.NotificationType + " end point type is " + endpointAddress);
            }
            else
            {
                senderType               = Interface.Alarm.AlarmModuleConfiguration.Instance.Configuration.EndPoint.WType;
                endpointAddress          = Interface.Alarm.AlarmModuleConfiguration.Instance.Configuration.EndPoint.EndpointAddress;
                notifyClienttimeOutValue = Interface.Alarm.AlarmModuleConfiguration.Instance.Configuration.EndPoint.Timeout;
                LogBook.Write(notifyObject.NotificationType + " end point type is {embed}");
            }

            NotifyComResponse response = null;

            if (senderType == "{embed}")
            {
                _notifyReceiver = CommunicationAdapter.GetInstance();
                response        = _notifyReceiver.Execute(notifyObject);
            }
            else
            {
                //Invoke remote object
                INotificationChannelClient client = _notifyClientEnd.GetClient(senderType, endpointAddress);
                //client.EndPointAddress = endpoint.EndpointAddress;
                client.OnReceive((data, remEndpoint) =>
                {
                    try
                    {
                        response = NotifyComResponse.Create(data);
                    }
                    catch (Exception ex)
                    {
                        response                 = new NotifyComResponse();
                        response.IsSucceeded     = true;
                        response.IsError         = true;
                        response.ResponseContent = "Notification Failed, while receiving data from notification engine.";
                        LogBook.Write("Error has occurred while receiving data from notification engine (Exception Message:" + ex.Message + ") \n Received Data: " + data);
                    }
                });

                bool timeout   = false;
                long startTick = DateTime.Now.Ticks;
Label4Retry:

                try
                {
                    client.Send(notifyObject.GetXML());
                }
                catch (Exception ex)
                {
                    if (notifyClienttimeOutValue == 0 || notifyClienttimeOutValue >= ((DateTime.Now.Ticks - startTick) / TimeSpan.TicksPerMillisecond))
                    {
                        timeout = true;
                    }

                    if (!timeout)
                    {
                        goto Label4Retry;
                    }
                    else
                    {
                        StringBuilder sb = new StringBuilder();
                        sb.AppendLine("Notification Service - Error has occurred while connecting to the remote notification engine.");
                        sb.AppendLine("Remote endpoint:" + endpointAddress);
                        sb.AppendLine("NotificationType:" + notifyObject.NotificationType);
                        sb.AppendLine("Data:" + notifyObject.NotificationData);
                        sb.AppendLine("Technical Information:" + ex.Message + ". " + ex.StackTrace);
                        LogBook.Write(sb.ToString(), "Notification Client", ErrorSeverity.Critical);

                        response                 = new NotifyComResponse();
                        response.IsSucceeded     = false;
                        response.IsError         = true;
                        response.ResponseContent = "Failed, while connecting to notification engine.";
                        LogBook.Write("Error has occurred while connecting to the remote notification engine (Exception Message:" + ex.Message + ")");


                        //record notification

                        NotifyTypes notifyType;
                        Enum.TryParse <NotifyTypes>(notifyObject.NotificationType.Trim(), true, out notifyType);

                        NotificationStyle notificationStyle = new NotificationStyle();
                        notificationStyle.RecordNotification(sb.ToString(), 0, 0, response.IsSucceeded ? NotifyStatus.PASS : NotifyStatus.FAIL, notifyType);
                    }
                }
            }
            return(response);
        }
        public INotifyObject[] Compose(AlarmObject alarmObject)
        {
            GenStoreInfo         genStoreInfo      = null;
            NotifyMobileList     notifyMobileList  = null;
            List <INotifyObject> notifyList        = new List <INotifyObject>();
            NotificationStyle    notificationStyle = new NotificationStyle();

            LogBook.Write("Executing Compose method");


            /*Get GenStore Information*/
            genStoreInfo = GenStoreInfo.GetInstance();

            try
            {
                //If there's no record in the database, Execute method will return null
                if (genStoreInfo != null)
                {
                    /*Record notification if SMTP settings are not supplied properly*/
                    //if (genStoreInfo.SmtpServer.ToStr() != string.Empty && genStoreInfo.SmtpSendMethod != 0)
                    //if ((genStoreInfo.ToPhoneNumber == string.Empty && genStoreInfo.SmtpAuthDomain == string.Empty) && genStoreInfo.SmtpSendMethod == 0)
                    //{
                    //    /*SMTP server not defined*/
                    //    LogBook.Write("Error: No SMTP Server has been defined");

                    //    /*Record notification if SMTP parameters are not supplied properly*/
                    //    notificationStyle.RecordNotification(ErrorMessages.SmsComposer_SMTPParmsNotSupplied, _alarmObject.NotificationID, NotifyStatus.FAIL, NotifyTypes.SMS);

                    //}
                    //else
                    //{
                    LogBook.Write("Fetching notify Mobiles List");
                    /*Get all the sms addresses that are configured for notification*/
                    notifyMobileList = GetNotifyMoibilesList(alarmObject.NotifyProfileID);
                    LogBook.Write("Notify Mobile List Count: " + notifyMobileList.Count.ToString());
                    if (notifyMobileList.Count != 0)
                    {
                        LogBook.Write("Constructing notify list objects");
                        /*Construct a notification object for each sms number and add to the notification list*/
                        notifyList = GetNotificationList(notifyMobileList, alarmObject, genStoreInfo);


                        for (int index = notifyList.Count - 1; index >= 0; index--)
                        {
                            INotifyObject notifyObject = notifyList[index];
                            SmsHelper.SmsQueue.Add(notifyObject);
                            notifyList.Remove(notifyObject);
                            new NotificationStyle().RecordNotification("Sms queued: " + notifyObject.NotifierSettings["ToPhoneNumber"].ToStr(), notifyObject.NotifierSettings["NotificationID"].ToInt(), 0, NotifyStatus.STATUS, NotifyTypes.SMS);
                        }


                        LogBook.Write("Notify list objects count: " + notifyList.Count);
                    }
                    else
                    {
                        /*Log when we don't have sms address to notify*/
                        LogBook.Write("Error: Missing entry in NotifySms/Groups");
                    }
                    //}
                }
                else
                {
                    /*Record notification if genStore parameters are not supplied properly.*/
                    notificationStyle.RecordNotification(ErrorMessages.SMSComposer_InvalidSettings, alarmObject.NotificationID, 0, NotifyStatus.FAIL, NotifyTypes.SMS);

                    /*Log if genStore information is empty*/
                    LogBook.Write("Error:  Missing GenStores table record");
                }
            }
            catch (Exception ex)
            {
                /*Write exception log*/
                LogBook.Write(ex, "CooperAtkins.NotificationClient.NotificationComposer.SmsNotificationComposer");
            }

            /*Send notification list to notification engine*/
            return(notifyList.ToArray());
        }
        /// <summary>
        /// Returns true if the current operation succeeded.
        /// </summary>
        /// <param name="data"></param>
        /// <param name="settings"></param>
        /// <param name="notificationID"></param>
        /// <returns></returns>
        ///



        public static bool Send(string data, Hashtable settings, int notificationID, int ivrID, int alarmID, AlarmObject alarmObject)
        {
            bool   retValue      = false;
            bool   callConnected = false;
            string response      = string.Empty;
            string succeeded     = string.Empty;
            string error         = string.Empty;
            Int16  dailAttempts  = 1;
            string DigitsPressed = string.Empty;

            long QueueID = -1;

            int    TryCount                 = -1;
            bool   CallAnswered             = false;
            bool   Answered                 = false;
            bool   CallComplete             = false;
            string MachineDetection         = string.Empty;
            int    Duration                 = -1;
            string IVRServiceResponseText   = string.Empty;
            int    TTIVRNotifications_RecID = -1;


            NotifyObject      notifyObject      = new NotifyObject();
            NotifyComResponse notifyResponse    = new NotifyComResponse();
            NotifyComResponse notifyComResponse = new NotifyComResponse();

            notifyObject.NotificationType = "Voice";
            notifyObject.NotificationData = data;     //voice message to be played
            notifyObject.NotifierSettings = settings; //hash table of keys and values


            NotificationEndPointElement element;
            string vcElement1;
            string vcElement2;
            string vcElement3;
            string vcElement4;

            /* get end point for voice composer*/


            string method = NotificationClient.GetInstance().WhoAmI("Voice", out element);

            string arguments = null;

            LogBook.Write("Sending voice alert....");
            switch (method.ToLower())
            {
            case "cooperatkins.notificationclient.notifyengine.ivrnotificationcom":


                System.Diagnostics.Process process = new System.Diagnostics.Process();
                if (element == null)
                {
                    arguments = @"-m ""<notification ack='true'><notificationData><![CDATA[" + data + @"]]></notificationData><notificationType><![CDATA[Voice]]></notificationType><notificationSettings><PhoneNo><![CDATA[" + settings["PhoneNo"].ToStr() + @"]]></PhoneNo></notificationSettings></notification>"" ";
                }
                else
                {
                    arguments = @"-c " + element.EndpointAddress + @" -m ""<notification ack='true'><notificationData><![CDATA[" + data + @"]]></notificationData><notificationType><![CDATA[Voice]]></notificationType><notificationSettings><PhoneNo><![CDATA[" + settings["PhoneNo"].ToStr() + @"]]></PhoneNo></notificationSettings></notification>"" ";
                }

                while (!callConnected)
                {
                    IvrAlarmStatus ivrAlarmStatus = new IvrAlarmStatus();
                    try
                    {
                        LogBook.Write("Checking whether alarm is cleared or not");
                        ivrAlarmStatus.AlarmID        = alarmID;
                        ivrAlarmStatus.NotificationID = notificationID;
                        ivrAlarmStatus.StoreID        = GenStoreInfo.GetInstance().StoreID;
                        ivrAlarmStatus.Execute();
                    }
                    catch (Exception ex)
                    {
                        LogBook.Write(ex, "CooperAtkins.NotificationClient.NotificationComposer.IvrClientHelper", ErrorSeverity.High);
                    }
                    finally
                    {
                        ivrAlarmStatus.Dispose();
                    }

                    if (ivrAlarmStatus.IsAlarmClearedOrBackInRange)
                    {
                        break;
                    }

                    /*       analog modem use  */

                    process.StartInfo.UseShellExecute        = false;
                    process.StartInfo.RedirectStandardOutput = true;
                    //process.StartInfo.RedirectStandardError = true;
                    process.StartInfo.CreateNoWindow = true;
                    process.StartInfo.FileName       = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) + @"\Utility.exe";
                    //process.StartInfo.FileName = @"F:\DEV\CooperAtkins\CooperAtkins.NotificationEngine.Utility\bin\Debug\Utility.exe";
                    process.StartInfo.Arguments = arguments;
                    // process.StartInfo.WorkingDirectory = ;
                    process.Start();

                    process.WaitForExit();


                    response = process.StandardOutput.ReadToEnd();

                    callConnected = true;
                    if (response.ToLower().Contains("device initialization failed") || response.ToLower().Contains("invalid_device_id") || response.ToLower().Contains("dll_not_found") || response.ToLower().Contains("exception from hresult"))
                    {
                        callConnected = false;
                    }
                    /*     end  analog modem use  */
                }
                break;


            case "cooperatkins.notificationclient.notificationcomposer.cdyneivrnotificationcomposer":
                long     TransactionID = -1;
                DateTime StartTime;
                DateTime EndTime;
                long     AlarmID = -1;


                string CDYNE_ID      = GenStoreInfo.GetInstance().CDYNE_ACCOUNT;//NotificationClient.GetInstance().GetCustomVoiceSettings("CDyneID", out vcElement1);
                string CDYNE_RETRIES = NotificationClient.GetInstance().GetCustomVoiceSettings("CDyneRetries", out vcElement2);
                string CDYNE_VOICEID = NotificationClient.GetInstance().GetCustomVoiceSettings("CDyneVoiceID", out vcElement3);
                string CDYNE_VOLUME  = NotificationClient.GetInstance().GetCustomVoiceSettings("CDyneVolume", out vcElement4);

                notifyObject.NotifierSettings["CDYNE_ID"]      = CDYNE_ID;
                notifyObject.NotifierSettings["CDYNE_RETRIES"] = CDYNE_RETRIES;
                notifyObject.NotifierSettings["CDYNE_VOICEID"] = CDYNE_VOICEID;
                notifyObject.NotifierSettings["CDYNE_VOLUME"]  = CDYNE_VOLUME;
                NotificationStyle  notificationStyle        = new NotificationStyle();
                TTIvrNotifications tTIvrNotificationsObject = new TTIvrNotifications();
                callConnected = false;

                while (!callConnected)
                {
                    notifyComResponse.IsInProcess = true;
                    int QueryCall = 0;
                    int UnivError = 0;

                    //if (!alarmObject.IsFailsafeEscalationNotification)
                    //{
                    //IvrAlarmStatus ivrAlarmStatus = new IvrAlarmStatus();
                    //try
                    //{
                    //    LogBook.Write("Checking whether alarm is cleared or not");
                    //    ivrAlarmStatus.AlarmID = alarmID;
                    //    ivrAlarmStatus.NotificationID = notificationID;
                    //    ivrAlarmStatus.StoreID = GenStoreInfo.GetInstance().StoreID;
                    //    ivrAlarmStatus.Execute();
                    //}
                    //catch (Exception ex)
                    //{
                    //    LogBook.Write(ex, "CooperAtkins.NotificationClient.NotificationComposer.CDYNEIvrClientHelper", ErrorSeverity.High);
                    //}
                    //finally
                    //{
                    //    ivrAlarmStatus.Dispose();
                    //}

                    //12/9/15 comment start
                    //AlarmStatus alarmStatus = new AlarmStatus();
                    //try
                    //{
                    //    LogBook.Write("IVR Checking whether alarm [" + alarmObject.NotificationID + "] is cleared or not");
                    //    alarmStatus.NotificationID = alarmObject.NotificationID;
                    //    alarmStatus.StoreID = GenStoreInfo.GetInstance().StoreID;
                    //    alarmStatus.Execute();
                    //}
                    //catch (Exception ex)
                    //{
                    //    LogBook.Write(ex, "CooperAtkins.NotificationClient.Alarm.AlarmInitializer", ErrorSeverity.High);
                    //}
                    //finally
                    //{
                    //    alarmStatus.Dispose();
                    //12/9/15 comment end }

                    int threadID = notifyObject.NotifierSettings["ThreadID"].ToInt();

                    //12/9/15 comment start
                    //if (alarmStatus.IsAlarmClearedOrBackInRange)
                    //{
                    //    Answered = false;
                    //    callConnected = false;
                    //    notifyComResponse.IsSucceeded = false;
                    //    notifyComResponse.ResponseContent += "\r\n\r\n\r\n\r\n < Phone Call To " + notifyObject.NotifierSettings["PhoneNo"] + "[" + notifyObject.NotifierSettings["CallerName"] + "]" + " SUSPENDED (Attempt # " + dailAttempts + " of " + (CDYNE_RETRIES.ToInt() + 1) + ")";
                    //    notifyComResponse.ResponseContent += "\r\n\r\n\r\n\r\nALARM WAS CLEARED OR BACK IN RANGE";

                    //    LogBook.Write("CALL SUSPENDED To " + notifyObject.NotifierSettings["PhoneNo"] + IVRServiceResponseText + " for NotificationID: " + notificationID + " [CDyneTransID: " + TransactionID + "] ALARM WAS CLEARED OR SENSOR IS BACK IN RANGE");

                    //    notificationStyle.RecordNotification(notifyComResponse.ResponseContent.ToString(), notificationID, TransactionID.ToInt(), NotifyStatus.FAIL, NotifyTypes.VOICE);
                    //    UpdateIVRNotification(ivrID, false, false, dailAttempts, TransactionID, threadID);

                    //    break;

                    //12/9/15 comment end }


                    int totalCallAttempts = notifyObject.NotifierSettings["Attempts"].ToInt();

                    if ((totalCallAttempts + dailAttempts) > (CDYNE_RETRIES.ToInt() + 1))
                    //also if a notficicationId is in an alert progress state from another thread,
                    //fall into this code to break out OR if cleared or inprogress check to be sure
                    //we made contatc through our maximum attempts value
                    {
                        notifyComResponse.IsInProcess = false;
                        UpdateIVRNotification(ivrID, false, notifyComResponse.IsInProcess, dailAttempts, TransactionID, threadID);
                        break;
                    }
                    //}


                    UpdateIVRNotification(ivrID, false, true, (totalCallAttempts + dailAttempts), TransactionID, threadID);

                    try{
                        IVRProcessor maketheIVRCall = new IVRProcessor();
                        notifyResponse = maketheIVRCall.Invoke(notifyObject);
                        //  notifyComResponse = new NotifyComResponse();
                        TransactionID = notifyResponse.TransactionIDReturned;
                        //query for call result

                        Answered = false;
                        PhoneNotify pn2 = new PhoneNotify();
                        while (!Answered)
                        {
                            if (QueryCall == 0)        //on first call, wait 1 minute for call to complete before getting call results
                            {
                                System.Threading.Thread.Sleep(1 * 60 * 1000);
                            }
                            else
                            {
                                System.Threading.Thread.Sleep(5 * 1000);
                            }
                            NotifyReturn nr2 = pn2.GetQueueIDStatus(TransactionID);
                            MachineDetection       = nr2.MachineDetection;
                            DigitsPressed          = nr2.DigitsPressed;
                            CallAnswered           = nr2.CallAnswered;
                            CallComplete           = nr2.CallComplete;
                            IVRServiceResponseText = nr2.ResponseText;
                            Duration  = nr2.Duration;
                            StartTime = nr2.StartTime;
                            EndTime   = nr2.EndTime;
                            if (CallAnswered == true && DigitsPressed.Contains("*"))
                            {
                                Answered      = true;
                                callConnected = true;
                                notifyComResponse.IsSucceeded = true;
                                //notifyComResponse.ResponseContent += "\r\n\r\n\r\n\r\n < Phone Call To " + notifyObject.NotifierSettings["PhoneNo"] + "[" + notifyObject.NotifierSettings["CallerName"] + "]" + " Connected (Attempt # " + dailAttempts + " of " + (CDYNE_RETRIES.ToInt() + 1) + ")";
                                notifyComResponse.ResponseContent += "\r\n\r\n\r\n\r\n < Phone Call To " + notifyObject.NotifierSettings["PhoneNo"] + "[" + notifyObject.NotifierSettings["CallerName"] + "]" + " Connected.  ";
                                notifyComResponse.ResponseContent += "\r\n\r\n\r\n\r\nAcknowledgement received, " + "'" + DigitsPressed + "' pressed.";
                                notifyComResponse.ResponseContent += "\r\n\r\n\r\n\r\nCall Complete >";

                                LogBook.Write("Query Call State Try: " + (QueryCall + 1) + ": Phone Call " + (totalCallAttempts + dailAttempts) + " of " + (CDYNE_RETRIES.ToInt() + 1) + " To " + notifyObject.NotifierSettings["PhoneNo"] + " Answered and Digits: " + DigitsPressed + " were pressed: " + IVRServiceResponseText + " for NotificationID: " + notificationID + " [CDyneTransID: " + TransactionID + "]");
                                break;
                            }
                            else if (CallAnswered == true && !DigitsPressed.Contains("*") && MachineDetection == "HUMAN" && CallComplete)
                            {
                                Answered = true;
                                notifyComResponse.IsSucceeded = false;
                                //notifyComResponse.ResponseContent += "\r\n\r\n\r\n\r\n < Phone Call To " + notifyObject.NotifierSettings["PhoneNo"] + "[" + notifyObject.NotifierSettings["CallerName"] + "]" + " Connected (Attempt # " + dailAttempts + " of " + (CDYNE_RETRIES.ToInt() + 1) + ")";
                                notifyComResponse.ResponseContent += "\r\n\r\n\r\n\r\n < Phone Call To " + notifyObject.NotifierSettings["PhoneNo"] + "[" + notifyObject.NotifierSettings["CallerName"] + "]" + " Connected.  ";
                                notifyComResponse.ResponseContent += "\r\n\r\n\r\n\r\nNo Acknowledgement received, Digits Pressed: " + DigitsPressed + ">";
                                LogBook.Write("Query Call State Try: " + (QueryCall + 1) + ": Phone Call " + (totalCallAttempts + dailAttempts) + " of " + (CDYNE_RETRIES.ToInt() + 1) + " To " + notifyObject.NotifierSettings["PhoneNo"] + " Answered but no digits were pressed: " + IVRServiceResponseText + " for NotificationID: " + notificationID + " [CDyneTransID: " + TransactionID + "]");
                                break;
                            }
                            else if (CallAnswered == true && DigitsPressed == "" && MachineDetection == "HUMAN" && !CallComplete)
                            {
                                notifyComResponse.IsSucceeded = false;
                                //notifyComResponse.ResponseContent += "\r\n\r\n\r\n\r\n < Phone Call To " + notifyObject.NotifierSettings["PhoneNo"] + "[" + notifyObject.NotifierSettings["CallerName"] + "]" + " Connected (Attempt # " + dailAttempts + " of " + (CDYNE_RETRIES.ToInt() + 1) + ")";
                                notifyComResponse.ResponseContent += "\r\n\r\n\r\n\r\n < Phone Call To " + notifyObject.NotifierSettings["PhoneNo"] + "[" + notifyObject.NotifierSettings["CallerName"] + "]" + " Connected.  ";
                                notifyComResponse.ResponseContent += "\r\n\r\n\r\n\r\nNo Acknowledgement received >";
                                LogBook.Write("Query Call State Try: " + (QueryCall + 1) + ": Phone Call " + (totalCallAttempts + dailAttempts) + " of " + (CDYNE_RETRIES.ToInt() + 1) + " To " + notifyObject.NotifierSettings["PhoneNo"] + " Answered but no digits were pressed: " + IVRServiceResponseText + " for NotificationID: " + notificationID + " [CDyneTransID: " + TransactionID + "]");
                                QueryCall += 1;
                            }
                            else if (CallAnswered == true && DigitsPressed == "" && MachineDetection == "MACHINE")
                            {
                                Answered = false;
                                notifyComResponse.IsSucceeded = false;
                                //notifyComResponse.ResponseContent += "\r\n\r\n\r\n\r\n < Phone Call To " + notifyObject.NotifierSettings["PhoneNo"] +"["+ notifyObject.NotifierSettings["CallerName"]+"]"+ " Connected (Attempt # " + dailAttempts + " of " + (CDYNE_RETRIES.ToInt() + 1) + ")";
                                notifyComResponse.ResponseContent += "\r\n\r\n\r\n\r\n < Phone Call To " + notifyObject.NotifierSettings["PhoneNo"] + "[" + notifyObject.NotifierSettings["CallerName"] + "]" + " Connected.  ";
                                notifyComResponse.ResponseContent += "\r\n\r\n\r\n\r\nAnswering Machine Detected >";
                                LogBook.Write("Query Call State Try: " + (QueryCall + 1) + ": Phone Call " + (totalCallAttempts + dailAttempts) + " of " + (CDYNE_RETRIES.ToInt() + 1) + " To " + notifyObject.NotifierSettings["PhoneNo"] + " Answered by MACHINE: " + IVRServiceResponseText + " for NotificationID: " + notificationID + " [CDyneTransID: " + TransactionID + "]");
                                break;
                            }
                            else if (IVRServiceResponseText == "In Call/Ringing" || IVRServiceResponseText == "Queued" || IVRServiceResponseText == "Universal Error")
                            {
                                notifyComResponse.IsSucceeded = false;
                                notifyComResponse.IsError     = true;
                                //if (notifyComResponse.ResponseContent != null)
                                //{
                                //    if ((!notifyComResponse.ResponseContent.ToString().Contains("Call/Ringing (Attempt # " + dailAttempts)) &&
                                //        (!notifyComResponse.ResponseContent.ToString().Contains("Queued (Attempt # " + dailAttempts)) &&
                                //        (!notifyComResponse.ResponseContent.ToString().Contains("Universal Error  (Attempt # " + dailAttempts)))  //only add line if it has not already been logged for this dial attempt
                                //    {
                                //        notifyComResponse.ResponseContent += "\r\n\r\n\r\n\r\n < Phone Call To " + notifyObject.NotifierSettings["PhoneNo"] + "[" + notifyObject.NotifierSettings["CallerName"] + "] " + IVRServiceResponseText + " (Attempt # " + dailAttempts + " of " + (CDYNE_RETRIES.ToInt() + 1) + ") >";
                                //    }
                                //}
                                //else
                                //{
                                //    notifyComResponse.ResponseContent += "\r\n\r\n\r\n\r\n < Phone Call To " + notifyObject.NotifierSettings["PhoneNo"] + "[" + notifyObject.NotifierSettings["CallerName"] + "] " + IVRServiceResponseText + " (Attempt # " + dailAttempts + " of " + (CDYNE_RETRIES.ToInt() + 1) + ") >";
                                //}
                                //    notifyComResponse.ResponseContent = "";
                                LogBook.Write("Query Call State Try: " + (QueryCall + 1) + ": Phone Call " + (totalCallAttempts + dailAttempts) + " of " + (CDYNE_RETRIES.ToInt() + 1) + " To " + notifyObject.NotifierSettings["PhoneNo"] + " Current Status: " + IVRServiceResponseText + " for NotificationID: " + notificationID + " [CDyneTransID: " + TransactionID + "]");
                                if (IVRServiceResponseText == "Universal Error")
                                {
                                    UnivError += 1;        //if it continues to return Universl Error allow a way to get out
                                }
                                QueryCall += 1;
                            }
                            else
                            {
                                notifyComResponse.IsSucceeded = false;
                                if (notifyComResponse.ResponseContent != null)
                                {
                                    if (!notifyComResponse.ResponseContent.ToString().Contains("ERROR"))         //only add line if it has not already been logged
                                    {
                                        //notifyComResponse.ResponseContent += "\r\n\r\n\r\n\r\n < Phone Call To " + notifyObject.NotifierSettings["PhoneNo"] + "[" + notifyObject.NotifierSettings["CallerName"] + "]" + " ERROR: " + IVRServiceResponseText + " (Attempt # " + dailAttempts + " of " + (CDYNE_RETRIES.ToInt() + 1) + ") >";
                                        notifyComResponse.ResponseContent += "\r\n\r\n\r\n\r\n < Phone Call To " + notifyObject.NotifierSettings["PhoneNo"] + "[" + notifyObject.NotifierSettings["CallerName"] + "]" + " ERROR: " + IVRServiceResponseText + " >";
                                    }
                                }
                                else
                                {
                                    //notifyComResponse.ResponseContent += "\r\n\r\n\r\n\r\n < Phone Call To " + notifyObject.NotifierSettings["PhoneNo"] + "[" + notifyObject.NotifierSettings["CallerName"] + "]" + " ERROR: " + IVRServiceResponseText + " (Attempt # " + dailAttempts + " of " + (CDYNE_RETRIES.ToInt() + 1) + ") >";
                                    notifyComResponse.ResponseContent += "\r\n\r\n\r\n\r\n < Phone Call To " + notifyObject.NotifierSettings["PhoneNo"] + "[" + notifyObject.NotifierSettings["CallerName"] + "]" + " ERROR: " + IVRServiceResponseText + " >";
                                }
                                LogBook.Write("Query Call State Try: " + (QueryCall + 1) + ": Phone Call " + (totalCallAttempts + dailAttempts) + " of " + (CDYNE_RETRIES.ToInt() + 1) + " To " + notifyObject.NotifierSettings["PhoneNo"] + " Current Status: " + IVRServiceResponseText + " for NotificationID: " + notificationID + " [CDyneTransID: " + TransactionID + "]");
                                QueryCall += 1;
                            }
                            if (QueryCall > 2 || Answered || (UnivError > 10))
                            {
                                break;
                            }
                        }
                    }catch (Exception ex)
                    {
                        LogBook.Write(ex, "CooperAtkins.NotificationClient.NotificationComposer.CDYNEIvrClientHelper MAkeTheCall", ErrorSeverity.High);
                    }


                    if (!callConnected || !Answered)
                    {
                        //write to TTNotificationLog

                        if (notifyComResponse.ResponseContent != null)
                        {
                            if (notifyComResponse.ResponseContent.ToString() != "")
                            {
                                notificationStyle.RecordNotification(notifyComResponse.ResponseContent.ToString(), notificationID, TransactionID.ToInt(), NotifyStatus.FAIL, NotifyTypes.VOICE);
                            }
                        }
                        notifyComResponse.ResponseContent = "";

                        //write to TTIVRNotifications
                        UpdateIVRNotification(ivrID, notifyComResponse.IsSucceeded, notifyComResponse.IsInProcess, (totalCallAttempts + dailAttempts), TransactionID, threadID);
                        // System.Threading.Thread.Sleep(30 * 1000); //wait and try that number 1 more time before trying next person
                        dailAttempts += 1;
                        retValue      = false;
                        if (((totalCallAttempts + dailAttempts.ToInt())) > CDYNE_RETRIES.ToInt16() + 1)
                        {        //try each person X times from config
                            LogBook.Write("Exhausted  " + (CDYNE_RETRIES.ToInt()) + " Re-Try Attempts To: " + notifyObject.NotifierSettings["PhoneNo"] + " for NotificationID: " + notificationID + " [CDyneTransID: " + TransactionID + "]");
                            notifyComResponse.IsInProcess = false;

                            if (UnivError >= 10)         //reset call counter, so it will re-attempt to call person has CDyne never truly made a call
                            {                            //4th param in below function
                                UpdateIVRNotification(ivrID, notifyComResponse.IsSucceeded, notifyComResponse.IsInProcess, 0, TransactionID, threadID);
                            }
                            else
                            {
                                UpdateIVRNotification(ivrID, notifyComResponse.IsSucceeded, notifyComResponse.IsInProcess, (totalCallAttempts + dailAttempts), TransactionID, threadID);
                            }
                            retValue = false;
                            alarmObject.IVRSuccess = false;
                            break;
                        }
                        else
                        {
                            LogBook.Write("Trying Retry Call Attempt " + (totalCallAttempts + dailAttempts) + " of " + (CDYNE_RETRIES.ToInt() + 1) + " Attempts To: " + notifyObject.NotifierSettings["PhoneNo"] + " for NotificationID: " + notificationID);
                        }
                    }
                    else
                    {
                        LogBook.Write("Call Complete.  Alert Success during call " + (totalCallAttempts + dailAttempts) + " of " + (CDYNE_RETRIES.ToInt() + 1) + " attempts To: " + notifyObject.NotifierSettings["PhoneNo"] + " for NotificationID: " + notificationID + " [CDyneTransID: " + TransactionID + "]");
                        notifyComResponse.IsInProcess = false;
                        notificationStyle.RecordNotification(notifyComResponse.ResponseContent.ToString(), notificationID, TransactionID.ToInt(), NotifyStatus.PASS, NotifyTypes.VOICE);
                        notifyComResponse.ResponseContent = "";
                        UpdateIVRNotification(ivrID, notifyComResponse.IsSucceeded, notifyComResponse.IsInProcess, (totalCallAttempts + dailAttempts), TransactionID, threadID);
                        retValue = true;
                        alarmObject.IVRSuccess = true;
                    }
                }
                break;         //end call attempts

            default:
                break;
            }

            if (method.ToLower() == "cooperatkins.notificationserver.notifyengine.ivrnotificationcom")
            {
                NotificationStyle notificationStyle = new NotificationStyle();

                foreach (string responseLine in response.Split(new string[] { "\n" }, StringSplitOptions.None))
                {
                    if (responseLine.ToLower().Contains("succeeded"))
                    {
                        succeeded = responseLine.ToLower().Replace("succeeded :", string.Empty);
                    }
                    else if (responseLine.ToLower().Contains("error"))
                    {
                        error = responseLine.ToLower().Replace("error :", string.Empty);
                    }
                }


                LogBook.Write("ResponseContent:" + response + ", IsSucceeded:" + succeeded + ", IsError:" + error);


                /* record the notification information to the database. */
                if (succeeded == "no")
                {
                    notificationStyle.RecordNotification(response.Remove(0, 60).Replace("\n", "\r\n"), notificationID, 0, NotifyStatus.FAIL, NotifyTypes.VOICE);
                }
                else
                {
                    notificationStyle.RecordNotification(response.Remove(0, 60).Replace("\n", "\r\n"), notificationID, 0, NotifyStatus.PASS, NotifyTypes.VOICE);
                }


                retValue = succeeded == "yes";
            }

            return(retValue);
        }