예제 #1
0
        public static bool SendDigitalPage(INotifyObject notifyObject)
        {
            if (notifyObject.NotifierSettings["AttemptCount"].ToInt16() > MAX_ATTEMPTS)
            {
                LogBook.Write("Max attempts (" + MAX_ATTEMPTS.ToString() + ") completed for current page and removing from queue.");
                new NotificationStyle().RecordNotification("Max attempts (" + MAX_ATTEMPTS.ToString() + ") completed for current page and removing from queue.", notifyObject.NotifierSettings["NotificationID"].ToInt(), 0, NotifyStatus.FAIL, NotifyTypes.PAGER);
                return(true);
            }


            /* get end point for voice composer*/
            NotificationEndPointElement element;

            NotificationComposer.NotificationClient _client = NotificationComposer.NotificationClient.GetInstance();
            _client.WhoAmI("Pager", out element);
            NotifyComResponse response = _client.InvokeNotifyEngine(notifyObject, element);

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

                /*Log response content*/
                LogBook.Write(" Pager Response: " + response.ResponseContent.ToStr());
            }

            return(response.IsSucceeded);
        }
        public NotifyComResponse Invoke(INotifyObject notifyObject)
        {
            NotifyComResponse response      = new NotifyComResponse();
            object            obj           = new object();
            INotifyObject     _notifyObject = null;

            try
            {
                {
                    _notifyObject = notifyObject;

                    /* Dialing to a phone number.*/
                    response.TransactionIDReturned = DialNumber(_notifyObject);
                    if (response.TransactionIDReturned > -1)
                    {
                        response.IsError     = false;
                        response.IsSucceeded = true;
                    }
                    else
                    {
                        response.IsError     = true;
                        response.IsSucceeded = false;
                    }
                }
            }
            catch (Exception ex)
            {
                response.ResponseContent = "Error dialing the number, message: " + ex.Message;
                response.IsError         = true;
                response.IsSucceeded     = false;
                LogBook.Write("Error dialing the number, message", ex, "CooperAtkins.NotificationServer.NotifyEngine");
            }
            return(response);
        }
예제 #3
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");
     }
 }
        public NotifyComResponse Invoke(INotifyObject notifyObject)
        {
            NotifyComResponse response;

            POPUP.PopupClient client = new POPUP.PopupClient(notifyObject);

            /*Log
             * Notification data received from Pager notification composer
             * Sending Pager...*/
            LogBook.Write("Notification data received from Popup Notification Composer");
            LogBook.Write("Sending Popup notification to: " + notifyObject.NotifierSettings["RemoteHost"].ToStr());

            try
            {
                /*sending notification.*/
                response = client.Send();

                /*Log : Sending response to Email Notification Composer */
                LogBook.Write("Sending response to Popup Notification Composer");
            }
            catch (Exception ex)
            {
                response             = new NotifyComResponse();
                response.IsSucceeded = true;
                response.IsError     = false;

                /*Debug Object values for reference*/
                LogBook.Debug(response, this);

                /*Write exception log*/
                LogBook.Write(ex, "CooperAtkins.NotificationServer.NotifyEngine.PopupNotifyCom");
            }
            return(response);
        }
        public NotifyComResponse Invoke(INotifyObject notifyObject)
        {
            object            obj      = new object();
            NotifyComResponse response = new NotifyComResponse();

            lock (obj)
            {
                try
                {
                    /*Write Log*/
                    LogBook.Write("Sending SMS to: " + notifyObject.NotifierSettings["ToPhoneNumber"].ToStr());

                    /* call the send method of sms client */
                    // we now set and write success / error messages in the send routine instead of here
                    response = client.Send(notifyObject);
                }
                catch (Exception ex)
                {
                    /*Write exception log*/
                    response.IsError         = true;
                    response.IsSucceeded     = false;
                    response.ResponseContent = "SMS to [" + notifyObject.NotifierSettings["ToName"].ToStr() + "] " + notifyObject.NotifierSettings["ToPhoneNumber"].ToStr() + ", Failed";
                    LogBook.Write(ex, "CooperAtkins.NotificationServer.NotifyEngine.SMSNotifyCom");
                }
            }
            return(response);
        }
예제 #6
0
        public NotifyComResponse Invoke(INotifyObject notifyObject)
        {
            NotifyComResponse response;
            ScriptHelper      client = new ScriptHelper(notifyObject);

            /*Log
             * Notification data received from email notification composer
             * Executing Script...*/
            LogBook.Write("Notification data received from Script Notification Composer");
            LogBook.Write("Executing Script");

            try
            {
                /* sending notification.*/
                response = client.Send();

                /*Log : Sending response to Script Notification Composer */
                LogBook.Write("Sending response to Script Notification Composer");
            }
            catch (Exception ex)
            {
                response             = new NotifyComResponse();
                response.IsSucceeded = false;
                response.IsError     = true;
                //response.ResponseContent = ex.Message + "\n" + ex.StackTrace;

                /*Debug Object values for reference*/
                LogBook.Debug(response, this);

                /*Write exception log*/
                LogBook.Write(ex, "CooperAtkins.NotificationServer.NotifyEngine.ScriptNotifyCom");
            }
            return(response);
        }
예제 #7
0
        public NotifyComResponse Invoke(INotifyObject notifyObject)
        {
            NotifyComResponse response;
            EmailClient       client = new EmailClient(notifyObject);

            /*Log
             * Notification data received from email notification composer
             * Sending Email...*/
            LogBook.Write("Notification data received from Email Notification Composer");
            LogBook.Write("Sending Email notification to: " + notifyObject.NotifierSettings["ToAddress"].ToStr());

            try
            {
                response = client.Send();
                /*Log : Sending response to Email Notification Composer */
                LogBook.Write("Sending response to Email Notification Composer");
            }
            catch (Exception ex)
            {
                response             = new NotifyComResponse();
                response.IsSucceeded = false;
                response.IsError     = true;
                //response.ResponseContent = ex.Message + "\n" + ex.StackTrace;

                /*Debug Object values for reference*/
                LogBook.Debug(response, this);

                /*Write exception log*/
                LogBook.Write(ex, "CooperAtkins.NotificationServer.NotifyEngine.INotifyCom");
            }
            return(response);
        }
        /// <summary>
        /// Send Popup message
        /// </summary>
        /// <returns></returns>
        public NotifyComResponse Send()
        {
            NotifyComResponse notifyComResponse = new NotifyComResponse();

            try
            {
                /*Send Pop up using UDP Client*/
                NetworkClient networkClient = new NetworkClient();
                networkClient.UdpClient(_remoteHost, _remotePort, _alertMessage);

                /*Record notify response*/
                notifyComResponse.IsError         = false;
                notifyComResponse.IsSucceeded     = true;
                notifyComResponse.ResponseContent = "Popup message sent to [" + _addressBookName + "] " + _remoteHost;
            }
            catch (Exception ex)
            {
                /*Log remote port,host*/
                /*Record notify response*/
                notifyComResponse.IsError         = true;
                notifyComResponse.IsSucceeded     = false;
                notifyComResponse.ResponseContent = "Popup message to [" + _addressBookName + "] " + _remoteHost + " Failed.";

                /*Debug Object values for reference*/
                LogBook.Debug(notifyComResponse, this);

                /*Write exception log*/
                LogBook.Write("Error has occurred while sending popup to ." + _remoteHost, ex, "CooperAtkins.NotificationServer.NotifyEngine.POPUP.PopupClient");
            }

            return(notifyComResponse);
        }
예제 #9
0
        public NotifyComResponse Invoke(INotifyObject notifyObject)
        {
            NotifyComResponse response = new NotifyComResponse();
            object            obj      = new object();

            try
            {
                /* lock the current process to stop accessing from new process until the current process completed*/
                // lock (obj)
                {
                    _notifyObject = notifyObject;
                    LogBook.Write("CDyneIvrNotificationCom Invoke() Method.");



                    /* Dialing to a phone number.*/
                    response.TransactionIDReturned = DialNumber();
                }
            }
            catch (Exception ex)
            {
                response.ResponseContent = "Error dialing the number, message: " + ex.Message;
                response.IsError         = true;
                response.IsSucceeded     = false;
                LogBook.Write("Error dialing the number, message", ex, "CooperAtkins.NotificationServer.NotifyEngine");
            }
            return(response);
        }
예제 #10
0
        public NotifyComResponse Invoke(INotifyObject notifyObject)
        {
            while (!IsProcessCompleted)
            {
                System.Threading.Thread.Sleep(200);
            }
            lock (LockObj)
            {
                IsProcessCompleted = false;

                NotifyComResponse response = null;
                response = new NotifyComResponse();

                try
                {
                    LogBook.Write("Executing Invoke Method for Sensor: " + notifyObject.NotifierSettings["SensorAlarmID"].ToStr());
                    //get the message board instance
                    IMessageBoard messageBoard = GetMessageBoard(notifyObject);
                    //invoke display message method
                    messageBoard.DisplayMessage(notifyObject.NotificationData.ToStr());
                    response.IsSucceeded = true;
                    response.IsError     = false;

                    if (notifyObject.NotifierSettings["ClearMessage"].ToBoolean() || notifyObject.NotifierSettings["IsDynamicNotificationCleared"].ToBoolean())
                    {
                        response.ResponseContent = "Clearing message from message board: [" + notifyObject.NotifierSettings["Name"].ToStr() + "] " + (notifyObject.NotifierSettings["IsNetworkConnected"].ToBoolean() == true ? "IP:" : "COM") + notifyObject.NotifierSettings["IpAddress"].ToStr() + ":" + notifyObject.NotifierSettings["Port"] + ".";
                    }
                    else
                    {
                        response.ResponseContent = "Message to: [" + notifyObject.NotifierSettings["Name"].ToStr() + "] " + (notifyObject.NotifierSettings["IsNetworkConnected"].ToBoolean() == true ? "IP:" : "COM") + notifyObject.NotifierSettings["IpAddress"].ToStr() + ":" + notifyObject.NotifierSettings["Port"] + " sent successfully.";
                    }

                    IsProcessCompleted = true;
                }
                catch (Exception ex)
                {
                    IsProcessCompleted   = true;
                    response.IsSucceeded = false;
                    response.IsError     = true;
                    if (notifyObject.NotifierSettings["ClearMessage"].ToBoolean() || notifyObject.NotifierSettings["IsDynamicNotificationCleared"].ToBoolean())
                    {
                        response.ResponseContent = "Clearing message from message board: [" + notifyObject.NotifierSettings["Name"].ToStr() + "] " + (notifyObject.NotifierSettings["IsNetworkConnected"].ToBoolean() == true ? "IP:" : "COM") + notifyObject.NotifierSettings["IpAddress"].ToStr() + ":" + notifyObject.NotifierSettings["Port"] + " failed.";
                    }
                    else
                    {
                        response.ResponseContent = "Message to: [" + notifyObject.NotifierSettings["Name"].ToStr() + "] " + (notifyObject.NotifierSettings["IsNetworkConnected"].ToBoolean() == true ? "IP:" : "COM") + notifyObject.NotifierSettings["IpAddress"].ToStr() + ":" + notifyObject.NotifierSettings["Port"] + " Failed.";
                    }
                    LogBook.Write(ex, "CooperAtkins.NotificationServer.NotifyEngine.MessageBoardNotifyCom");
                }

                return(response);
            }
        }
        /// <summary>
        /// Send Script for execution
        /// </summary>
        /// <returns></returns>
        public NotifyComResponse Send()
        {
            NotifyComResponse notifyComResponse = new NotifyComResponse();

            try
            {
                /*log that script started*/
                LogBook.Write("Notification Script Started");
                Process process = new Process();
                process.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
                process.StartInfo.Arguments   = _scriptArguments;
                process.StartInfo.FileName    = _scriptName;
                try
                {
                    process.Start();
                    /*Record notify response*/
                    notifyComResponse.IsError         = false;
                    notifyComResponse.IsSucceeded     = true;
                    notifyComResponse.ResponseContent = "Script executed successfully.";
                }
                catch (Exception ex)
                {
                    /*Record notify response*/
                    notifyComResponse.IsError         = true;
                    notifyComResponse.IsSucceeded     = false;
                    notifyComResponse.ResponseContent = "Script execution failed";

                    /*Debug Object values for reference*/
                    LogBook.Debug(notifyComResponse, this);

                    /*Write exception log*/
                    LogBook.Write("Error has occurred while running the script.", ex, "CooperAtkins.NotificationServer.NotifyEngine.ScriptHelper");
                }
            }
            catch (Exception ex)
            {
                /*Record notify response*/
                notifyComResponse.IsError         = true;
                notifyComResponse.IsSucceeded     = false;
                notifyComResponse.ResponseContent = "Script execution failed";

                /*Debug Object values for reference*/
                LogBook.Debug(notifyComResponse, this);

                /*Write exception log*/
                LogBook.Write("Error has occurred while preparing script settings.", ex, "CooperAtkins.NotificationServer.NotifyEngine.Script.ScriptHelper");
            }
            return(notifyComResponse);
        }
예제 #12
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());
            }
        }
        /// <summary>
        /// Invoke notification components
        /// </summary>
        /// <param name="alarmObject"></param>
        /// <returns></returns>
        public NotifyComResponse Run(INotifyObject notifyObject)
        {
            string            comFullName = WhoAmI(notifyObject.NotificationType);
            NotifyComResponse response    = null;

            foreach (INotifyCom nCom in _notifyComs)
            {
                if (nCom.GetType().FullName == comFullName.Trim())
                {
                    response = nCom.Invoke(notifyObject);
                    break;
                }
            }
            return(response);
        }
        public NotifyComResponse Invoke(INotifyObject notifyObject)
        {
            NotifyComResponse notifyComResponse = new NotifyComResponse();

            LogBook.Write("Executing Invoke method");
            RelaySwitch relaySwitch = null;

            try
            {
                //set the configuration, get the relay switch object
                relaySwitch = GetRelaySwitchObject(notifyObject);
                //call the send data method

                notifyComResponse.IsSucceeded = true;

                if (notifyObject.NotifierSettings["IsDynamicNotificationCleared"].ToBoolean())
                {
                    relaySwitch.ClearData(notifyObject.NotifierSettings["SensorAlarmID"].ToStr());
                    notifyComResponse.ResponseContent = "Clearing notification from " + relaySwitch.ResponseContent;
                }
                else
                {
                    relaySwitch.SendData();

                    notifyComResponse.ResponseContent = "Notification to [" + notifyObject.NotifierSettings["Name"].ToStr() + "] " + (notifyObject.NotifierSettings["SwitchInfo"].ToStr().Contains("NET") == true ? "IP:" : " ") + notifyObject.NotifierSettings["SwitchInfo"].ToStr().Replace("NET:", "") + ", Current state " + relaySwitch.CurrentState + ", New State:" + relaySwitch.NewState + ", sent successfully.";
                }
            }
            catch (Exception ex)
            {
                notifyComResponse             = new NotifyComResponse();
                notifyComResponse.IsSucceeded = false;
                notifyComResponse.IsError     = true;
                if (notifyObject.NotifierSettings["IsDynamicNotificationCleared"].ToBoolean())
                {
                    notifyComResponse.ResponseContent = "Clearing notification failed for switch(s), " + relaySwitch.ResponseContent;
                }
                else
                {
                    notifyComResponse.ResponseContent = "Notification to [" + notifyObject.NotifierSettings["Name"].ToStr() + "] " + (notifyObject.NotifierSettings["SwitchInfo"].ToStr().Contains("NET") == true ? "IP:" : "COM") + notifyObject.NotifierSettings["SwitchInfo"].ToStr().Replace("NET:", "") + ", Failed.";
                }

                LogBook.Write(ex, "NotifyEngine-SwicthNotifyCom");
            }
            return(notifyComResponse);
        }
예제 #15
0
        public NotifyComResponse Invoke(INotifyObject notifyObject)
        {
            NotifyComResponse response = null;
            PagerHelper       client   = new PagerHelper(notifyObject);

            /*Log
             * Notification data received from Pager notification composer
             * Sending Pager...*/
            LogBook.Write("Notification data received from Pager Notification Composer");
            LogBook.Write("Sending Pager notification to: " + notifyObject.NotifierSettings["ToAddress"].ToStr());

            try
            {
                int waitingSecs = 0;
                response = client.Send(notifyObject);
                while (!client.ProcessCompleted)
                {
                    Thread.Sleep(1 * 1000);
                    waitingSecs++;
                    if (waitingSecs > 120)
                    {
                        client.Message  += "\r\nNo response from last 120 seconds, terminating the process";
                        response.IsError = true;
                        break;
                    }
                }

                if (notifyObject.NotifierSettings["DeliveryMethod"].ToInt() != 1)
                {
                    response.ResponseContent = client.Message;
                }

                /*Log : Sending response to Email Notification Composer */
                LogBook.Write("Sending response to Pager Notification Composer");
            }
            catch (Exception ex)
            {
                /*Debug Object values for reference*/
                LogBook.Debug(response, this);

                /*Write exception log*/
                LogBook.Write(ex, "CooperAtkins.NotificationServer.NotifyEngine.INotifyCom");
            }
            return(response);
        }
예제 #16
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());
            }
        }
예제 #17
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());
            }
        }
        /// <summary>
        /// Dials the number.
        /// </summary>
        public void DialNumber()
        {
            LogBook.Write("Dialing the number");
            InitCall();

            LogBook.Write("InitCall() completed");
            LogBook.Write("PhoneNo. : " + phoneNumber + ", Voice Prompt: " + sensorInfo);

            /* reset previous flags */
            isCallConnected           = false;
            IsDone                    = false;
            stopVoicePrompt           = false;
            digitReceived             = false;
            Action["CallConnected"]   = 0;
            Action["SilenceDetected"] = 0;

            notifyComResponse = new NotifyComResponse();



            CWay2callDriver.Errors xError = (CWay2callDriver.Errors)w2cDrv.Device.Call("w" + phoneNumber, true, true);
            Thread.Sleep(2000);

            /* handling errors  */
            if (xError != CWay2callDriver.Errors.SUCCESS)
            {
                LogBook.Write("Call Error: " + xError.ToString());

                notifyComResponse.ResponseContent += "\r\n Call Error: " + xError.ToString();
                notifyComResponse.IsError          = true;

                w2cDrv.Device.HangUp(false);

                /* update call status as not completed. */
                Action["CallConnected"] = 0;
            }
            else
            {
                /* no errors, dialing the number.*/
                WriteLog("Starting to dial " + phoneNumber);
            }
        }
예제 #19
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);
         }
     }
 }
예제 #20
0
        /// <summary>
        /// Establish communication channel object
        /// </summary>
        public void Open()
        {
            //Import configured end point class
            string[] typeParts = NotifyConfiguration.Instance.Configuration.Type.Split(',');
            Assembly assembly  = Assembly.Load(typeParts[1].Trim());
            // Get the type to use.
            Type protocolWrapper = assembly.GetType(typeParts[0]);

            // Create an instance.
            _server = (INotificationChannelServer)Activator.CreateInstance(protocolWrapper);
            _server.EndPointAddress = NotifyConfiguration.Instance.Configuration.EndpointAddress;

            _server.OnReceive((data, remEndpoint) =>
            {
                if (EnableLog)
                {
                    LogBook.Write("\r\nRemote IP:" + remEndpoint + " Data:" + data);
                }
                string retrunText = string.Empty;
                if (data.StartsWith("command "))
                {
                    retrunText = RunCommand(data);
                }
                else
                {
                    INotifyObject notifyObject = _receiver.PrepareNotifyObject(data);
                    NotifyComResponse response = _receiver.Execute(notifyObject);

                    if (response != null)
                    {
                        retrunText = response.GetXML();
                    }
                    else
                    {
                        retrunText = "[NULL : NotifyComResponse object was not created by target component.]";
                    }
                }
                return(retrunText);
            });
        }
예제 #21
0
        void InitCall()
        {
            LogBook.Write("NotificationDate: " + _notifyObject.NotificationData.ToString());
            LogBook.Write("PhoneNo: " + _notifyObject.NotifierSettings["PhoneNumber"].ToString());
            LogBook.Write("Person: " + _notifyObject.NotifierSettings["PersonName"].ToString());

            /* assign message and phone number from client information. */
            sensorInfo     = _notifyObject.NotificationData.ToString();
            AlarmID        = Convert.ToInt64(_notifyObject.NotifierSettings["AlarmID"].ToString());
            phoneNumber    = _notifyObject.NotifierSettings["PhoneNumber"].ToString();
            personName     = _notifyObject.NotifierSettings["PersonName"].ToString();
            timeOutOfRange = _notifyObject.NotifierSettings["TimeOutOfRange"].ToString();
            value          = _notifyObject.NotifierSettings["Value"].ToString();
            deviceName     = _notifyObject.NotifierSettings["DeviceName"].ToString();
            isMissComm     = _notifyObject.NotifierSettings["isMissComm"].ToString();
            groupName      = _notifyObject.NotifierSettings["GroupName"].ToString();
            alarmTime      = _notifyObject.NotifierSettings["AlarmTime"].ToString();
            probe          = _notifyObject.NotifierSettings["Probe"].ToString();
            fromNumber     = _notifyObject.NotifierSettings["FromNumber"].ToString();

            notifyComResponse = new NotifyComResponse();
        }
        void InitCall()
        {
            /* to hang-up call if the user did not respond.*/
            timerNoConnect          = new System.Timers.Timer();
            timerNoConnect.Elapsed += new System.Timers.ElapsedEventHandler(timerNoConnect_Elapsed);
            timerNoConnect.Interval = WAIT_SECONDS * 1000;

            /* To handle answering machine, answering machine will continue the conversation without any silence.*/
            timerNoSilenceDetected          = new System.Timers.Timer();
            timerNoSilenceDetected.Interval = 1 * 1000;
            timerNoSilenceDetected.Elapsed += new System.Timers.ElapsedEventHandler(timerNoSilenceDetected_Elapsed);



            LogBook.Write("NotificationDate: " + _notifyObject.NotificationData.ToString());
            LogBook.Write("PhoneNo: " + _notifyObject.NotifierSettings["PhoneNo"].ToString());

            /* assign message and phone number from client information. */
            sensorInfo  = _notifyObject.NotificationData.ToString();
            phoneNumber = _notifyObject.NotifierSettings["PhoneNo"].ToString();

            notifyComResponse = new NotifyComResponse();
        }
        /// <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());
                }
            }
        }
        /// <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);
        }
 public void Receive(NotifyComResponse response, INotifyObject notifyObject)
 {
 }
예제 #26
0
        /// <summary>
        /// Dials the number.
        /// </summary>
        public long DialNumber()
        {
            LogBook.Write("Dialing the number");
            InitCall();

            LogBook.Write("InitCall() completed");
            LogBook.Write("PhoneNo. : " + phoneNumber + ", Voice Prompt: " + sensorInfo);

            /* reset previous flags */
            isCallConnected           = false;
            IsDone                    = false;
            stopVoicePrompt           = false;
            digitReceived             = false;
            Action["CallConnected"]   = 0;
            Action["SilenceDetected"] = 0;

            notifyComResponse = new NotifyComResponse();



            LogBook.Write("Starting to dial " + phoneNumber);

            PhoneNotify notify = new PhoneNotify();



            AdvancedNotifyRequest anr = new AdvancedNotifyRequest();
            PhoneNotify           pn  = new PhoneNotify();

            anr.CallerIDName      = "TempTrak";
            anr.CallerIDNumber    = fromNumber;              //TT registration #
            anr.PhoneNumberToDial = phoneNumber;
            //  anr.TextToSay = "This is an important message from your "+_alarmObject.StoreName TempTrak Monitoring System, to alert,,"+personName+",,at <say-as type=\"number:digits\">"+phoneNumber+"</say-as>"+",,that device name,"+deviceName+",probe number,"+probe+", is in violation,,, measuring a value of "+value+" for an elapsed time of "+timeOutOfRange+",,,Press any key to acknowlege this call,, Thank You,,,";
            //  string promptMessage = @"This is the " + alarmObject.StoreName + " Temp Track voice notification system, , , , There is an alarm with "
            //   + alarmObject.IVR_SensorName + ", , Last Reading was " + SensorValueToTTS(alarmObject.UTID, alarmObject.Probe, alarmObject.SensorType, (decimal)alarmObject.Value, alarmObject.IsCelsius)
            //   + ", , , , press any key to acknowledge. ";
            anr.TextToSay = "This is the Temp Track voice notification system, , , , There is an alarm with "
                            + deviceName + ", , Last Reading was " + value + ", , , , press any key to acknowledge. ";
            anr.VoiceID = 6;
            anr.UTCScheduledDateTime = DateTime.UtcNow;
            anr.LicenseKey           = "54B1B99F-7E7E-40AC-88EB-A91DBE859B82";       //stored in config file for now
            anr.TryCount             = 5;
            anr.NextTryInSeconds     = 30;
            anr.TTSvolume            = 5;

            NotifyReturn nr = pn.NotifyPhoneAdvanced(anr);

            //store TransactionID into table where
            QueueID = -1;
            QueueID = nr.QueueID;



            Thread.Sleep(30000);
            //now query the webservice and update records
            MachineDetection       = nr.MachineDetection;
            DigitsPressed          = nr.DigitsPressed;
            CallAnswered           = nr.CallAnswered;
            CallComplete           = nr.CallComplete;
            IVRServiceResponseText = nr.ResponseText;
            Duration  = nr.Duration;
            StartTime = nr.StartTime;
            EndTime   = nr.EndTime;

            if (DigitsPressed.Length > 0)
            {
                notifyComResponse.IsSucceeded      = true;
                notifyComResponse.IsError          = false;
                notifyComResponse.ResponseContent += "\r\n Acknowledgement received, " + DigitsPressed + " pressed.";
                notifyComResponse.IsSucceeded      = true;
                LogBook.Write("Digit Received");
                LogBook.Write("\t" + "Digit: " + DigitsPressed);
            }
            else
            {
                notifyComResponse.IsSucceeded = false;
                notifyComResponse.IsError     = true;
                if (MachineDetection == "MACHINE")
                {
                    notifyComResponse.ResponseContent += "\r\n Answering Machine Detected";
                }
                else if (CallAnswered == false)
                {
                    notifyComResponse.ResponseContent += "\r\n No Answer";
                }
                else if ((CallAnswered == true) && (DigitsPressed.Length == 0))
                {
                    notifyComResponse.ResponseContent += "\r\n Call Answerd, No Digits Pressed";
                }
            }

            return(QueueID);
        }
        public NotifyComResponse Invoke(INotifyObject notifyObject)
        {
            NotifyComResponse response = new NotifyComResponse();
            object            obj      = new object();

            try
            {
                /* lock the current process to stop accessing from new process until the current process completed*/
                lock (obj)
                {
                    /* initialize the way2call device. */
                    if (!InitComponent())
                    {
                        response.IsError         = true;
                        response.IsSucceeded     = false;
                        response.ResponseContent = "Device Initialization failed";
                        return(response);
                    }

                    _notifyObject = notifyObject;
                    LogBook.Write("IvrNotificationCom Invoke() Method.");

                    Thread.Sleep(5000);

                    /* Dialing to a phone number.*/
                    DialNumber();

                    int waitSecs = 0;

                    /*Wait and Check till process completed*/
                    while (true)
                    {
                        System.Windows.Forms.Application.DoEvents();
                        waitSecs++;

                        Thread.Sleep(100);

                        /*if call completed then come out of current process.*/
                        if (IsDone)
                        {
                            response = GetComResponse();
                            break;
                        }
                        /* wait for 1.5 minutes, still if there is no response then disconnect the call.*/
                        else if (waitSecs >= 900)
                        {
                            Hangup();
                            response.IsError         = true;
                            response.IsSucceeded     = false;
                            response.ResponseContent = "No response from the modem, forcefully hanged up.";

                            LogBook.Write("No response from the modem, forcefully hanging up.");
                        }

                        /*if there is no ResponseContent then update it.*/
                        if (response.ResponseContent == null)
                        {
                            response.ResponseContent = "No response.";
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                response.ResponseContent = "Error dialing the number, message: " + ex.Message;
                response.IsError         = true;
                response.IsSucceeded     = false;
                LogBook.Write("Error dialing the number, message", ex, "CooperAtkins.NotificationServer.NotifyEngine");
            }
            return(response);
        }
        /// <summary>
        /// Send Mail
        /// </summary>
        /// <returns></returns>
        public NotifyComResponse Send(INotifyObject notifyObject)
        {
            notifyComResponse = new NotifyComResponse();
            try
            {
                _snppServer     = notifyObject.NotifierSettings["SNPPServer"].ToStr();
                _snppPort       = notifyObject.NotifierSettings["SNPPPort"].ToInt();
                _pagerSubject   = notifyObject.NotifierSettings["PagerSubject"].ToStr();
                _pagerToAddress = notifyObject.NotifierSettings["ToAddress"].ToStr();
                _name           = notifyObject.NotifierSettings["Name"].ToStr();
                _pagerBody      = notifyObject.NotificationData.ToStr();



                /*Send notification to Pager using SNPP Server*/
                try
                {
                    if (notifyObject.NotifierSettings["DeliveryMethod"].ToInt() != 1)
                    {
                        string phone        = notifyObject.NotifierSettings["ToAddress"].ToStr();
                        int    pagerDelay   = notifyObject.NotifierSettings["PagerDelay"].ToInt();
                        string pagerMessage = notifyObject.NotifierSettings["PagerMessage"].ToStr();
                        string comPortId    = notifyObject.NotifierSettings["PagerComPort"].ToStr();

                        Int16 attemptCount = notifyObject.NotifierSettings["AttemptCount"].ToInt16();
                        attemptCount++;
                        notifyObject.NotifierSettings["AttemptCount"] = attemptCount;
                        notifyObject.NotifierSettings["LastSentTime"] = DateTime.Now;

                        Message = " Attempt: " + attemptCount.ToString();

                        sendPageTime = DateTime.Now;

                        /*
                         * "2400,n,8,1"
                         * 1st baud rate
                         * 2nd parity
                         * 3rd data bits
                         * 4th stop bit*/


                        IOPort.ComSettings comSettings = new IOPort.ComSettings();
                        comSettings.BaudRate  = 2400;
                        comSettings.ParityBit = System.IO.Ports.Parity.Even;
                        comSettings.DataBits  = 8;
                        comSettings.StopBit   = System.IO.Ports.StopBits.One;



                        int n = 0;
                        //COMcmds[n++] = "1~+~.1";
                        //COMcmds[n++] = ".3~+~.1";
                        //COMcmds[n++] = ".3~+~.1";

                        //COMcmds[n++] = ".5~ATH~3";          // Hang-up if connected
                        COMcmds[n++] = ".5~ATH~3";          // Hang-up if connected
                        COMcmds[n++] = ".5~ATZ~3";          // Reset modem
                        COMcmds[n++] = ".5~ATL0M0~3";       // Disable modem speaker / sounds
                        COMcmds[n++] = ".5~ATE0~3";         //Turn off echoing

                        if (notifyObject.NotifierSettings["COMportInitString"].ToStr().Length > 0)
                        {
                            COMcmds[n++] = ".5~" + notifyObject.NotifierSettings["COMportInitString"].ToStr() + "~1";
                        }

                        //If Len(InitString) Then COMcmds[n] = ".5~" & InitString & "~1";
                        COMcmds[n++] = ".5~ATDT" + phone + new System.Text.StringBuilder().Append(',', pagerDelay).ToString() + pagerMessage + "~40";
                        //COMcmds[n++] = "0~+~.1";
                        //COMcmds[n++] = ".3~+~.1";
                        //COMcmds[n++] = ".3~+~.1";
                        COMcmds[n++] = ".5~ATH~3";
                        nCOMcmds     = n;

                        comPort = new IOPort();//for COMM port


                        //ping the com port
                        comPort.Handshake("COM" + comPortId, comSettings, DataRecieveFromCom);


                        SendCommand();
                    }
                    else
                    {
                        //snnpObj = new KTGUtil.SNPP();
                        using (SNPPWrapper snppObj = new SNPPWrapper())
                        {
                            /*SNPP Host*/
                            snppObj.Host = _snppServer;

                            /*SNPP Port Number*/
                            snppObj.Port = _snppPort;

                            /*Subject*/
                            snppObj.Subject = _pagerSubject;

                            /*Body*/
                            snppObj.Body = _pagerBody;

                            /*Pager To Address*/
                            snppObj.SendTo = _pagerToAddress;

                            /*Send information to pager*/
                            int res = snppObj.Send();
                            ProcessCompleted = true;



                            if (res == 0)
                            {
                                /*Record notify response*/
                                notifyComResponse.IsError         = false;
                                notifyComResponse.IsSucceeded     = true;
                                notifyComResponse.ResponseContent = "Page to [" + _name + "] " + _pagerToAddress + ", sent successfully.";
                            }
                            else
                            {
                                notifyComResponse.IsError         = true;
                                notifyComResponse.IsSucceeded     = false;
                                notifyComResponse.ResponseContent = "Page to [" + _name + "] " + _pagerToAddress + ", Error:." + snppObj.LastErrorText;
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    /*Record notify response*/
                    notifyComResponse.IsError         = true;
                    notifyComResponse.IsSucceeded     = false;
                    notifyComResponse.ResponseContent = "Page to [" + _name + "] " + _pagerToAddress + ", Failed.";
                    Message         += "Page to [" + _name + "] " + _pagerToAddress + ", Failed (" + ex.Message + ").";
                    ProcessCompleted = true;
                    /*Debug Object values for reference*/
                    LogBook.Debug(notifyComResponse, this);

                    /*Write exception log*/
                    LogBook.Write("Error has occurred while sending pager to ." + _pagerToAddress, ex, "CooperAtkins.NotificationServer.NotifyEngine.PagerHelper");
                }
            }
            catch (Exception ex)
            {
                /*Record notify response*/
                notifyComResponse.IsError         = true;
                notifyComResponse.IsSucceeded     = true;
                notifyComResponse.ResponseContent = "Page to [" + _name + "] " + _pagerToAddress + ", Failed.";
                Message         += "Page to [" + _name + "] " + _pagerToAddress + ", Failed (" + ex.Message + ").";
                ProcessCompleted = true;
                /*Debug Object values for reference*/
                LogBook.Debug(notifyComResponse, this);

                /*Write exception log*/
                LogBook.Write("Error has occurred while preparing SNPP setting.", ex, "CooperAtkins.NotificationServer.NotifyEngine.PagerHelper");
            }
            return(notifyComResponse);
        }
        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);
        }
예제 #30
0
        /// <summary>
        /// Send Mail
        /// </summary>
        /// <returns></returns>
        public NotifyComResponse Send()
        {
            NotifyComResponse notifyComResponse = new NotifyComResponse();

            try
            {
                try
                {
                    MailAddress ma = new MailAddress(_fromAddress);
                }
                catch (FormatException ex)
                {
                    // invalid from mail address, set it to [email protected]
                    LogBook.Write("The format for the from email address (" + _fromAddress + ") is incorrect. [email protected] will be used instead.");
                    _fromAddress = "*****@*****.**";
                }

                SmtpClient ss = new SmtpClient(_smtpServer, _smtpPort);


                MailMessage mm = new MailMessage(_fromAddress, _toAddress, _subject, _body);

                CDO.Message message = new CDO.Message();
                /*Create Mail Message Object*/
                MailMessage mailObj = new MailMessage();
                /*Email from address*/
                mailObj.From = new MailAddress(_fromAddress, _fromName);
                /*Email to address*/
                mailObj.To.Add(new MailAddress(_toAddress));
                /*Email subject*/
                mailObj.Subject = _subject;
                /*Email Body Encoding*/
                mailObj.BodyEncoding = Encoding.Default;
                /*Email Body*/
                mailObj.Body = _body;
                /*Body format (HTML/Text)*/
                mailObj.IsBodyHtml = _isBodyHTML;

                /*Via SMTP Gateway (i.e. your local Exchange Server)-> SmtpSendMethod = 0*/
                /*Via Direct Domain SMTP Connection w/DNS MX Lookup-> SmtpSendMethod = 1*/
                /*When SmtpSendMethod = 1 we are sending via local host instead of using SMTP settings*/
                SmtpClient smtpClientObj = null;
                if (_sendMethod == 1)
                {
                    //Send message
                    string domain = mailObj.To[0].Address.Substring(mailObj.To[0].Address.IndexOf('@') + 1);
                    //To Do :need to check for MX record existence before you send. Left intentionally for you.
                    string mxRecord = SendSMTP.DnsLookUp.GetMXRecords(domain)[0];
                    smtpClientObj = new SmtpClient(mxRecord);
                }
                else
                {
                    if (_isTLS == true && _isSSL == false)
                    {
                        ss.EnableSsl             = true;
                        ss.Timeout               = 20000;
                        ss.DeliveryMethod        = SmtpDeliveryMethod.Network;
                        ss.UseDefaultCredentials = false;
                        ss.Credentials           = new NetworkCredential(_smtpAuthUserName, _smtpAuthPassword);

                        mm.BodyEncoding = UTF8Encoding.UTF8;
                        mm.DeliveryNotificationOptions = DeliveryNotificationOptions.OnFailure;
                        mm.IsBodyHtml = _isBodyHTML;
                    }
                    else
                    {
                        CDO.IConfiguration configuration = message.Configuration;
                        ADODB.Fields       fields        = configuration.Fields;


                        ADODB.Field field = fields["http://schemas.microsoft.com/cdo/configuration/smtpserver"];
                        field.Value = _smtpServer;

                        field       = fields["http://schemas.microsoft.com/cdo/configuration/smtpserverport"];
                        field.Value = _smtpPort;

                        field       = fields["http://schemas.microsoft.com/cdo/configuration/sendusing"];
                        field.Value = CDO.CdoSendUsing.cdoSendUsingPort;

                        field = fields["http://schemas.microsoft.com/cdo/configuration/smtpauthenticate"];

                        if (_smtpAuthMethod == "" || _smtpAuthMethod.ToUpper() == "NONE")
                        {
                            field.Value = CDO.CdoProtocolsAuthentication.cdoAnonymous;
                        }
                        else if (_smtpAuthMethod.ToUpper() == "NTLM")
                        {
                            field.Value = CDO.CdoProtocolsAuthentication.cdoNTLM;
                        }
                        else
                        {
                            field.Value = CDO.CdoProtocolsAuthentication.cdoBasic;
                        }

                        field       = fields["http://schemas.microsoft.com/cdo/configuration/sendusername"];
                        field.Value = _smtpAuthUserName;

                        field       = fields["http://schemas.microsoft.com/cdo/configuration/sendpassword"];
                        field.Value = _smtpAuthPassword;

                        field       = fields["http://schemas.microsoft.com/cdo/configuration/smtpusessl"];
                        field.Value = _isSSL;

                        field       = fields["http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout"];
                        field.Value = 10;

                        fields.Update();

                        message.From    = @"""" + _fromName + @""" <" + _fromAddress + ">";;
                        message.To      = _toAddress;
                        message.Subject = _subject;
                        if (_isBodyHTML)
                        {
                            message.HTMLBody = _body;
                        }
                        else
                        {
                            message.TextBody = _body;
                        }
                    }
                }

                try
                {
                    if (_sendMethod == 1)
                    {
                        smtpClientObj.Send(mailObj);
                    }
                    else
                    {
                        /*Send Mail*/
                        if (_isTLS == true && _isSSL == false)
                        {
                            ss.Send(mm);
                        }
                        else
                        {
                            message.Send();
                        }
                    }

                    /*Record notify response*/
                    notifyComResponse.IsError         = false;
                    notifyComResponse.IsSucceeded     = true;
                    notifyComResponse.ResponseContent = "Email sent to: " + "[" + _emailToName + "]" + _toAddress + ((_isAlphaPager) ? " (ALPHA PAGER) " : "");
                }
                catch (Exception ex)
                {
                    /*Record notify response*/
                    notifyComResponse.IsError         = true;
                    notifyComResponse.IsSucceeded     = false;
                    notifyComResponse.ResponseContent = "Email to: " + "[" + _emailToName + "]" + _toAddress + ((_isAlphaPager) ? " (ALPHA PAGER) " : "") + " Failed " + ex.Message;

                    /*Debug Object values for reference*/
                    LogBook.Debug(notifyComResponse, this);

                    /*Write exception log*/
                    LogBook.Write("Error has occurred while sending email to ." + _emailToName, ex, "CooperAtkins.NotificationServer.NotifyEngine.Email.EmailClient");
                }
                finally
                {
                    // Added on 2/19/2012
                    // Srinivas Rao Eranti
                    // Added try catch to release the message object
                    try
                    {
                        Marshal.FinalReleaseComObject(message);
                        // GC.SuppressFinalize(message);
                    }
                    catch
                    {
                    }
                }
            }
            catch (Exception ex)
            {
                /*Record notify response*/
                notifyComResponse.IsError         = true;
                notifyComResponse.IsSucceeded     = false;
                notifyComResponse.ResponseContent = "Email to: " + "[" + _emailToName + "]" + _toAddress + ((_isAlphaPager) ? "(ALPHA PAGER)" : "") + " Failed " + ex.Message;


                /*Debug Object values for reference*/
                LogBook.Debug(notifyComResponse, this);

                /*Write exception log*/
                LogBook.Write("Error has occurred while preparing SMTP setting.", ex, "CooperAtkins.NotificationServer.NotifyEngine.Email.EmailClient");
            }
            return(notifyComResponse);
        }