コード例 #1
0
        public INotifyObject[] Compose(AlarmObject alarmObject)
        {
            //  LogBook.Write("CDYNEIvrNotificationComposer  Compose() Method");
            List <INotifyObject> notifyList = new List <INotifyObject>();

            _alarmObject = alarmObject;

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

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

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

            /* Inserting the IVR Notification to database tables TTNotifications and TTIVRNotifications.*/
            //if (_alarmObject.AlarmID > 0)
            RecordIVRNotification(_alarmObject);
            return(null);
        }
コード例 #2
0
        private void IvrNotification()
        {
            Thread.Sleep(5000);

            //timerIvrNotification.Stop();
            while (true)
            {
                bool CDYNE_ACCOUNT = GenStoreInfo.GetInstance().CDYNE_ACCOUNT == "" ? false : true;
                target.ProcessIVRNotification();
                //target.DialNumber();
            }
        }
コード例 #3
0
        public string[] GetNotifyTypes()
        {
            List <string> notifyTypes  = new List <string>();
            GenStoreInfo  genStoreInfo = null;

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

            /* 10/22/15 JH
             * below 3 lines of code are junk - this will never return NULL  */
            NotificationProfile notificationProfile = GetActiveNotificationProfile(genStoreInfo.StoreID);


            /*Check for IsAlertEnabled flag.If the flag is not set return null to stop all notifications*/
            if (notificationProfile.IsAlertEnabled)
            {
                return(null);
            }

            /*get all notification type from configuration file.*/
            List <NotificationTypes> notificationTypelist = new NotificationTypes().GetNotificationTypes();

            IVRUserID = notificationProfile.IVR_UserID;

            HasDynamicTypes = false;

            /* Check for the alarm cleared or Check for the sensor comes to the normal range or the notification type is resumed type
             * then load only dynamic notification types */

            if ((_isProcessCompleted && NotificationSentCount > 0) || _isResumedNotification)
            {
                /*Stop notifications for email,popup,script,pager.... and check whether MessageBoard and Relay Switch are active or not */
                foreach (NotificationTypes notificationType in notificationTypelist)
                {
                    if ((notificationProfile.NotifyType & notificationType.Value).ToBoolean() && notificationType.IsDynamicType)
                    {
                        HasDynamicTypes = true;
                        notifyTypes.Add(notificationType.Name);
                        if (notificationType.Name == "MessageBoard")
                        {
                            HasPreviousMessageBoard = true;
                        }
                        if (notificationType.Name == "Switch")
                        {
                            HasPreviousSwitch = true;
                        }
                    }
                }
            }
            else
            {
                /* Otherwise load all configured notification types*/
                foreach (NotificationTypes notificationType in notificationTypelist)
                {
                    if ((notificationProfile.NotifyType & notificationType.Value).ToBoolean())
                    {
                        /*if this is to clear dynamic notification then do not add other types to  the notify types*/
                        if (_isDynamicNotificationCleared == true && _isDynamicNotificationRemoved == false)
                        {
                            if (notificationType.IsDynamicType)
                            {
                                notifyTypes.Add(notificationType.Name);
                                if (notificationType.Name == "MessageBoard")
                                {
                                    HasPreviousMessageBoard = true;
                                }
                                if (notificationType.Name == "Switch")
                                {
                                    HasPreviousSwitch = true;
                                }
                            }
                            continue;
                        }
                        /* checking whether the notification type is dynamic*/
                        if (notificationType.IsDynamicType)
                        {
                            HasDynamicTypes = true;
                            if (notificationType.Name == "MessageBoard")
                            {
                                HasPreviousMessageBoard = true;
                            }
                            if (notificationType.Name == "Switch")
                            {
                                HasPreviousSwitch = true;
                            }
                        }

                        /* don't add dynamic types if the user already cleared dynamic in previous escalation*/
                        if (_isDynamicNotificationRemoved && notificationType.IsDynamicType)
                        {
                            continue;
                        }

                        notifyTypes.Add(notificationType.Name);
                    }
                }
            }

            return(notifyTypes.ToArray());
        }
コード例 #4
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);
        }
コード例 #5
0
        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());
        }
コード例 #6
0
        /// <summary>
        /// Create Notification Object
        /// </summary>
        /// <param name="genStoreDAO"></param>
        /// <returns></returns>
        private NotifyObject GetNotifyObject(Interface.Alarm.AlarmObject alarmObject, GenStoreInfo genStoreInfo, NotifyMobiles notifyMobiles)
        {
            string            toPhoneNumber     = string.Empty;
            string            toName            = string.Empty;
            string            message           = string.Empty;
            NotificationStyle notificationStyle = new NotificationStyle();


            //*Initialize NotifyObject*//
            NotifyObject notifyObject = new NotifyObject();

            //*Mobile Number*//
            toPhoneNumber = notifyMobiles.MobileNumber;

            //*Mobile name*//
            toName = notifyMobiles.Name;

            //* Message *//
            message = alarmObject.Value.ToString();

            //if message length is greater than zero, get the format string for the message//
            if (message.Length > 0)
            {
                message = notificationStyle.GetFormatString(alarmObject, 1, "MessageBoard");
            }

            //replace line breaks with spaces
            message = message.Replace("\\n", " ");

            //substitute actual values for the format strings using the alarm object
            message = notificationStyle.SubstituteFormatString(message, alarmObject);

            ///*Assigning values to notification object*/
            notifyObject.NotificationType = "SMS";

            ///*Assign values to Notification settings*/
            Hashtable notificationSettings = new Hashtable();

            notificationSettings.Add("COMPort", genStoreInfo.MobileCOMPort);
            notificationSettings.Add("COMSettings", genStoreInfo.MobileCOMSettings);
            notificationSettings.Add("PIN1", genStoreInfo.PIN1);
            notificationSettings.Add("PIN2", genStoreInfo.PIN2);
            notificationSettings.Add("ServiceCenterNumber", genStoreInfo.SMSProviderServiceCenter);
            notificationSettings.Add("ToPhoneNumber", toPhoneNumber);
            notificationSettings.Add("FrqBand", genStoreInfo.FrequencyBand);
            notificationSettings.Add("ToName", toName);
            notificationSettings.Add("NotificationID", alarmObject.NotificationID);
            notificationSettings.Add("AttemptCount", "0");
            notifyObject.NotifierSettings = notificationSettings;
            ///* Notification Data */
            notifyObject.NotificationData = message;

            return(notifyObject);
        }
コード例 #7
0
        /// <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);
        }
コード例 #8
0
        /// <summary>
        /// Gets all active IVR alarms.
        /// </summary>
        /// <param name="criteria"></param>
        /// <returns></returns>
        protected override IvrAlarmList LoadList(BaseCriteria criteria)
        {
            try
            {
                Criteria listCriteria = (Criteria)criteria;

                //Initialize the CSqlDbCommand for execute the stored procedure
                CSqlDbCommand cmd = new CSqlDbCommand(DBCommands.USP_NS_GET_IVRALARMLIST, System.Data.CommandType.StoredProcedure);
                cmd.AddWithValue("numAttempts", NumAttempts);
                //Execute reader
                CDAO.ExecReader(cmd);

                /*fill the object and add to list.*/
                while (CDAO.DataReader.Read())
                {
                    IvrAlarm alarm = new IvrAlarm();

                    alarm.IVRPhoneNumber  = CDAO.DataReader["PhoneNumber"].ToStr();
                    alarm.AlarmID         = CDAO.DataReader["AlarmID"].ToInt();
                    alarm.IsSuccess       = CDAO.DataReader["isSuccess"].ToBoolean();
                    alarm.NotificationID  = CDAO.DataReader["Notification_RecID"].ToInt();
                    alarm.AttemptCount    = CDAO.DataReader["numAttempts"].ToInt16();
                    alarm.QueueTime       = TypeCommonExtensions.IfNull(CDAO.DataReader["QueueTime"], DateTime.UtcNow).ToDateTime();
                    alarm.LastAttemptTime = TypeCommonExtensions.IfNull(CDAO.DataReader["LastAttemptTime"], DateTime.UtcNow).ToDateTime();
                    alarm.IvrAlarmID      = CDAO.DataReader["RecID"].ToInt();

                    alarm.UTID       = CDAO.DataReader["UTID"].ToStr();
                    alarm.Probe      = CDAO.DataReader["Probe"].ToInt();
                    alarm.SensorType = CDAO.DataReader["SensorType"].ToStr();
                    if (CDAO.DataReader["IVR_SensorName"] != DBNull.Value)
                    {
                        alarm.IVR_SensorName = CDAO.DataReader["IVR_SensorName"].ToStr();
                    }
                    else
                    {
                        alarm.IVR_SensorName = (CDAO.DataReader["PuckName"].ToStr() == string.Empty ? "Sensor" : CDAO.DataReader["PuckName"].ToStr());
                    }

                    alarm.Value = CDAO.DataReader["AlarmData"].ToDecimal();

                    alarm.AlarmMaxValue     = CDAO.DataReader["CondMaxValue"].ToDecimal();
                    alarm.AlarmMinValue     = CDAO.DataReader["CondMinValue"].ToDecimal();
                    alarm.CondThresholdMins = CDAO.DataReader["CondThresholdMins"].ToInt();
                    alarm.AlarmTime         = TypeCommonExtensions.IfNull(CDAO.DataReader["AlarmTime"], DateTime.UtcNow).ToDateTime();

                    alarm.IVRUserID  = CDAO.DataReader["UserID"].ToInt();
                    alarm.PersonName = CDAO.DataReader["FirstName"].ToString() + " " + CDAO.DataReader["LastName"].ToString();

                    alarm.LanguageID     = (CDAO.DataReader["LanguageID"].ToInt() == 0 ? 1 : CDAO.DataReader["LanguageID"].ToInt());
                    alarm.IsCelsius      = CDAO.DataReader["isCelsius"].ToBoolean();
                    alarm.StoreName      = GenStoreInfo.GetInstance().StoreName;
                    alarm.IvrID          = CDAO.DataReader["RecID"].ToInt();
                    alarm.StoreNumber    = GenStoreInfo.GetInstance().StorePhoneNumber.ToString();
                    alarm.AlarmStartTime = TypeCommonExtensions.IfNull(CDAO.DataReader["AlarmStartTime"], DateTime.UtcNow).ToDateTime();

                    //if (alarm.AlarmID > 0)
                    this.Add(alarm);
                }
            }
            catch
            {
                throw;
            }
            finally
            {
                CDAO.CloseDataReader();
                CDAO.Dispose();
            }

            return(this);
        }
コード例 #9
0
        /// <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);
        }
コード例 #10
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());
        }
コード例 #11
0
        /// <summary>
        /// Create Notification Object
        /// </summary>
        /// <param name="genStoreDAO"></param>
        /// <returns></returns>
        private NotifyObject GetNotifyObject(Interface.Alarm.AlarmObject alarmObject, GenStoreInfo genStoreInfo, NotifyEmailAddress notifyEmailAddress)
        {
            bool   isAlphaPager = false, isSSL = false, isTSL = false, isBodyHtml = false;
            int    bodyFormat = Common.FORMAT_TEXT, smtpPort = 0, timeOut = 15000;
            string subject = "", body = "", emailToAddress = "", emailFromAddress = "", name = "", fromName = "TempTrak Monitor";
            string defaultSubject = "", defaultBody = "", defaultPagerSubject = "", defaultPagerBody = "", notifyTree = "";
            Int16  alphaPager = 0;

            /*Initialize NotifyObject*/
            NotifyObject notifyObject = new NotifyObject();
            /*Initialize NotificationStyle*/

            NotificationStyle notificationStyle = new NotificationStyle();

            /*Set SSL and TLS flags*/
            isSSL = (genStoreInfo.SmtpFlags & 1) == 1 ? true : false;
            isTSL = (genStoreInfo.SmtpFlags & 2) == 2 ? true : false;

            /*Set default SMTP Port value*/
            if (genStoreInfo.SmtpPort.ToInt() == 0 || genStoreInfo.SmtpPort.ToInt() < 1 || genStoreInfo.SmtpPort.ToInt() > 32767)
            {
                /*Default SMTP port number*/
                smtpPort = 25;
                /*If SSL is enables set SMTP port to 465*/
                if (isSSL)
                {
                    smtpPort = 465;
                }
            }
            else
            {
                smtpPort = genStoreInfo.SmtpPort.ToInt();
            }

            /*Email Address*/
            emailToAddress = notifyEmailAddress.EmailAddress;

            /*Email notification name*/
            name = notifyEmailAddress.Name;

            /*Alpha Pager*/
            alphaPager = notifyEmailAddress.AlphaPager;

            /*Default Subject*/
            defaultSubject = notificationStyle.GetFormatString(alarmObject, 1, "EmailSubject");

            /*Default Body*/
            defaultBody = notificationStyle.GetFormatString(alarmObject, 1, "EmailBody");

            /*Default Pager Subject*/
            defaultPagerSubject = notificationStyle.GetFormatString(alarmObject, 1, "EmailSubjectPager");

            /*Default Pager Body*/
            defaultPagerBody = notificationStyle.GetFormatString(alarmObject, 1, "EmailBodyPager");

            /*Notification Tree*/
            notifyTree = notificationStyle.GetFormatString(alarmObject, 1, "NotifyTree");

            /*Default Pager Subject*/
            defaultPagerSubject = (defaultPagerSubject == string.Empty) ? defaultSubject : defaultPagerSubject;

            /*Default Pager Subject*/
            defaultPagerBody = (defaultPagerBody == string.Empty) ? defaultBody : defaultPagerBody;

            ///*Set Email Body and Subject format*/
            if (alphaPager == 0)
            {
                isAlphaPager = false;
                subject      = defaultSubject;
                if (body.ToStr() == string.Empty)
                {
                    if (alarmObject.AlarmType != AlarmType.COMMUNICATIONS && alarmObject.AlarmType != AlarmType.RESETCOMMUNICATIONS)
                    {
                        body = notificationStyle.GetEmailBody(alarmObject);
                    }
                    else
                    {
                        if (alarmObject.AlarmType == AlarmType.COMMUNICATIONS)
                        {
                            bodyFormat = Common.FORMAT_HTML;
                            body       = "<html><head><style>TH{font-family: Verdana,Arial;font-weight: bold;font-size: 10pt;background: #333333;color: white;}TD{font-family: Verdana,Arial;font-weight: normal;font-size: 10pt;}</style></head><body style='font-family: Verdana, Arial; font-size: 10pt;'><span style='font-weight: bold; font-size: 14pt; background: black; color: yellow;'>!!! Missed Communication !!!</span><br /><br /><br /><span style='font-weight: bold;'>Sensor Name: %%NAME%%</span><br>FactoryID: %%ID%%<br /><br /><table border='0' cellpadding='1' cellspacing='1'><tr><th align='left'>TYPE:</th><td>%%TYPE%%</td></tr><tr><th align='left'>GROUP:</th><td>%%GROUP%%</td></tr><tr><th align='left'>Time out of range:</th><td>%%TimeOutOfRange%%</td></tr></table></body></html>";
                        }
                        else
                        {
                            bodyFormat = Common.FORMAT_HTML;
                            body       = "<html><head><style>TH{font-family: Verdana,Arial;font-weight: bold;font-size: 10pt;background: #333333;color: white;}TD{font-family: Verdana,Arial;font-weight: normal;font-size: 10pt;}</style></head><body style='font-family: Verdana, Arial; font-size: 10pt;'><span style='font-weight: bold; font-size: 14pt; background: black; color: yellow;'>!!! Back In Sight/Connection Resumed !!!</span><br /><br /><br /><span style='font-weight: bold;'>Sensor Name: %%NAME%%</span><br>FactoryID: %%ID%%<br /><br /><table border='0' cellpadding='1' cellspacing='1'><tr><th align='left'>TYPE:</th><td>%%TYPE%%</td></tr><tr><th align='left'>GROUP:</th><td>%%GROUP%%</td></tr><tr><th align='left'>Time out of range:</th><td>%%TimeOutOfRange%%</td></tr></table></body></html>";
                        }
                    }

                    if (body.ToStr() == string.Empty)
                    {
                        body = defaultBody;
                    }
                    else
                    {
                        bodyFormat = Common.FORMAT_HTML;
                        if (defaultBody.ToStr() != string.Empty)
                        {
                            defaultBody = defaultBody.Replace("\\n", "<br>");
                            body        = body + "<BR></BR>" + defaultBody;
                        }
                    }

                    if (notifyTree.ToStr() != string.Empty)
                    {
                        notifyTree = notifyTree.Replace("\\n", "<br>");
                        body       = body + "<BR><BR><TABLE WIDTH=500 style='padding:5px;'><TR><TD><HR><H4>Alarm Notification Action(s)</H4></TD></TR><TR><TD style='border:1px dotted #000000;background:#99ffff;'>" + notifyTree + "</TD></TR></TABLE>";
                    }
                }
            }
            else /*Alpha pager*/
            {
                isAlphaPager = true;
                subject      = defaultPagerSubject;
                body         = defaultPagerBody.Replace("\\n", Environment.NewLine);
            }
            /*Assign default subject and body values*/
            subject = (subject == string.Empty) ? defaultSubject : subject;
            body    = (body.ToStr() == string.Empty) ? "" : body;


            /*commented on 02/28/2011 to display from email address properly*/
            /*Get a default "From" address*/
            //if (emailToAddress != string.Empty)
            //{
            //    foreach (string item in emailToAddress.ToStr().Split(','))
            //    {
            //        emailFromAddress = item;
            //        break;
            //    }
            //}

            emailFromAddress = genStoreInfo.FromAddress;

            /*Format Subject*/
            subject = notificationStyle.SubstituteFormatString(subject, alarmObject);

            /*Format Body*/
            body = notificationStyle.SubstituteFormatString(body, alarmObject);

            /*Body Format*/
            isBodyHtml = (bodyFormat == Common.FORMAT_HTML) ? true : false;

            /*In case of missed communication set the custom message*/
            if (alarmObject.IsMissCommNotification)
            {
                subject    = "Missed Communication"; //set the appropriate message
                body       = alarmObject.MissedCommSensorInfo;
                isBodyHtml = true;
            }

            /*Set Email From Name*/
            fromName = (genStoreInfo.FromName != string.Empty) ? genStoreInfo.FromName : fromName;

            /*Assigning values to notification object*/
            notifyObject.NotificationType = "EMAIL";

            /*Assign values to Notification settings*/
            Hashtable notificationSettings = new Hashtable();

            notificationSettings.Add("SMTPServer", genStoreInfo.SmtpServer);
            /*0=via SMTPGateway, 1=MX Direct*/
            notificationSettings.Add("SMTPSendMethod", genStoreInfo.SmtpSendMethod);
            notificationSettings.Add("SMTPAuthUserName", genStoreInfo.SmtpAuthUserName);
            notificationSettings.Add("SMTPAuthPassword", genStoreInfo.SmtpAuthPassword);
            notificationSettings.Add("SMPTAuthDomain", genStoreInfo.SmtpAuthDomain);
            notificationSettings.Add("SMTPAuthMethod", genStoreInfo.SMTPAuthMethod);
            notificationSettings.Add("SMTPFlags", genStoreInfo.SmtpFlags);
            /*Bitmask: Bit 1=Use SSL, 2=Use TLS*/
            notificationSettings.Add("IsSSL", isSSL);
            notificationSettings.Add("IsTLS", isTSL);
            notificationSettings.Add("SMTPPort", smtpPort);
            notificationSettings.Add("BodyFormat", bodyFormat);
            notificationSettings.Add("FromAddress", emailFromAddress);
            notificationSettings.Add("ToAddress", emailToAddress);
            notificationSettings.Add("Subject", subject);
            notificationSettings.Add("EmailToName", name);
            notificationSettings.Add("FromName", fromName);
            notificationSettings.Add("IsAlphaPager", isAlphaPager);
            notificationSettings.Add("IsBodyHTML", isBodyHtml);
            //notificationSettings.Add("ReadTimeOut", timeOut); //Default Time out value 15 Sec in old code
            notifyObject.NotifierSettings = notificationSettings;
            /* Notification Data */
            notifyObject.NotificationData = body;
            notifyObject.NotifierSettings.Add("NotificationID", alarmObject.NotificationID);

            return(notifyObject);
        }
コード例 #12
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);
        }
コード例 #13
0
        /// <summary>
        /// Create Notification Object
        /// </summary>
        /// <param name="genStoreDAO"></param>
        /// <returns></returns>
        private NotifyObject GetNotifyObject(Interface.Alarm.AlarmObject alarmObject, GenStoreInfo genStoreInfo)
        {
            string PhoneNumber = string.Empty;
            string Name        = string.Empty;
            string CallerID    = string.Empty;

            NotificationStyle notificationStyle = new NotificationStyle();


            //*Initialize NotifyObject*//
            NotifyObject notifyObject = new NotifyObject();


            PhoneNumber = alarmObject.IVRPhoneNumber;
            Name        = alarmObject.PersonName;
            CallerID    = genStoreInfo.ToPhoneNumber;



            ///*Assigning values to notification object*/
            notifyObject.NotificationType = "Voice";

            ///*Assign values to Notification settings*/
            Hashtable notificationSettings = new Hashtable();

            notificationSettings.Add("PhoneNumber", PhoneNumber);

            notificationSettings.Add("PersonName", Name);
            notificationSettings.Add("NotificationID", alarmObject.NotificationID);
            notificationSettings.Add("TransactionID", alarmObject.TransID);
            notificationSettings.Add("TimeOutOfRange", alarmObject.TimeOutOfRange);
            notificationSettings.Add("Value", alarmObject.Value);
            notificationSettings.Add("DeviceName", alarmObject.ProbeName);
            notificationSettings.Add("isMissComm", alarmObject.IsMissCommNotification);
            notificationSettings.Add("GroupName", alarmObject.GroupName);
            notificationSettings.Add("AlarmTime", alarmObject.AlarmTime);
            notificationSettings.Add("Probe", alarmObject.Probe);
            notificationSettings.Add("FromNumber", CallerID);
            notificationSettings.Add("AlarmID", alarmObject.AlarmID);


            notifyObject.NotifierSettings = notificationSettings;


            return(notifyObject);
        }