コード例 #1
0
 public Pomodoro(INotifyObject notifyObject, int startTimeInMinutes)
 {
     _timer.Elapsed     += TimerElapsed;
     _notifyObject       = notifyObject;
     _startTimeInMinutes = startTimeInMinutes;
     Reset();
 }
コード例 #2
0
        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>
        /// 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);
        }
コード例 #4
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);
        }
コード例 #5
0
        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);
        }
コード例 #6
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);
        }
コード例 #7
0
        public EmailClient(INotifyObject notifyObject)
        {
            try
            {
                /*Set Email parameters*/
                _smtpServer       = notifyObject.NotifierSettings["SMTPServer"].ToStr();
                _sendMethod       = notifyObject.NotifierSettings["SMTPSendMethod"].ToInt();
                _fromAddress      = notifyObject.NotifierSettings["FromAddress"].ToStr();
                _toAddress        = notifyObject.NotifierSettings["ToAddress"].ToStr();
                _fromName         = notifyObject.NotifierSettings["FromName"].ToStr();
                _smtpPort         = notifyObject.NotifierSettings["SMTPPort"].ToInt();
                _subject          = notifyObject.NotifierSettings["Subject"].ToStr();
                _smtpAuthUserName = notifyObject.NotifierSettings["SMTPAuthUserName"].ToStr();
                _smtpAuthPassword = notifyObject.NotifierSettings["SMTPAuthPassword"].ToStr();
                _smtpAuthDomain   = notifyObject.NotifierSettings["SMPTAuthDomain"].ToStr();
                _smtpAuthMethod   = notifyObject.NotifierSettings["SMTPAuthMethod"].ToStr();
                _isSSL            = notifyObject.NotifierSettings["IsSSL"].ToBoolean();
                _isTLS            = notifyObject.NotifierSettings["IsTLS"].ToBoolean();
                _emailToName      = notifyObject.NotifierSettings["EmailToName"].ToStr();
                _readTimeOut      = notifyObject.NotifierSettings["ReadTimeOut"].ToInt();
                _isBodyHTML       = notifyObject.NotifierSettings["IsBodyHTML"].ToBoolean();
                _isAlphaPager     = notifyObject.NotifierSettings["IsAlphaPager"].ToBoolean();
                _body             = notifyObject.NotificationData.ToStr();
            }
            catch (Exception ex)
            {
                /*Debug Object values for reference*/
                LogBook.Debug(notifyObject, this);

                /*Write exception log*/
                LogBook.Write("Error has occurred while retrieving values from notification settings", ex, "CooperAtkins.NotificationServer.NotifyEngine.Email.EmailClient");
            }
        }
コード例 #8
0
        public INotifyObject[] Compose(AlarmObject alarmObject)
        {
            List <INotifyObject> notifyList = new List <INotifyObject>();



            /*Write Log:
             * Started Script Notification
             * Reached Script Notification Composer*/

            if (alarmObject.IsMissCommNotification)
            {
                _logContent = "Missed Communication";
            }
            else
            {
                _logContent = "SensorID: " + alarmObject.UTID.ToStr() + " SensorAlarmID: " + alarmObject.SensorAlarmID.ToStr();
            }
            LogBook.Write("*** Started Composing Script Notification for " + _logContent + "***");

            /*Get Notification Object*/
            INotifyObject notifyObject = GetNotifyObject(alarmObject);

            /*Add to Notification List*/
            notifyList.Add(notifyObject);

            if (notifyList.Count > 0)
            {
                /*Write Log
                 * Sending Script notification data to Notification Engine*/
                LogBook.Write(_logContent + " Sending notification data to Script  Notification Engine.");
            }

            return(notifyList.ToArray());
        }
コード例 #9
0
        public INotifyObject[] Compose(AlarmObject alarmObject)
        {
            NotifyPagerAddressList notifyPagerAddressList = null;
            List <INotifyObject>   notifyObjectList       = null;

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

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

            try
            {
                /*Get Pager Address List*/
                notifyPagerAddressList = GetPagerAddressList(alarmObject);
                LogBook.Debug("NotifyPagerAddressList count: " + notifyPagerAddressList.Count.ToStr());
                /*Get notification List*/
                notifyObjectList = GetNotificationList(notifyPagerAddressList, alarmObject);
                LogBook.Debug("NotifyObjectList count: " + notifyObjectList.Count.ToStr());
            }
            catch (Exception ex)
            {
                /*Write exception log*/
                if (_logContent.Trim() != string.Empty)
                {
                    LogBook.Write(_logContent);
                }
                LogBook.Write(ex, "CooperAtkins.NotificationClient.NotificationComposer.PagerNotificationComposer");
            }

            if (notifyObjectList.Count > 0)
            {
                /*Write Log
                 * Sending Pager notification data to Notification Engine*/
                LogBook.Write(_logContent + " Sending notification data to Pager Notification Engine.");
            }


            for (int index = notifyObjectList.Count - 1; index >= 0; index--)
            {
                INotifyObject notifyObject = notifyObjectList[index];
                /*if the pager type is digital then add it to the queue, removing from the current list (queue will be processed separately)*/
                if (notifyObject.NotifierSettings["DeliveryMethod"].ToInt() != 1)
                {
                    DigitalPagerHelper.DigitalPagerQueue.Add(notifyObject);
                    notifyObjectList.Remove(notifyObject);
                    new NotificationStyle().RecordNotification("Page queued: " + notifyObject.NotifierSettings["ToAddress"].ToStr() + ", Message:" + notifyObject.NotifierSettings["PagerMessage"].ToStr(), notifyObject.NotifierSettings["NotificationID"].ToInt(), 0, NotifyStatus.STATUS, NotifyTypes.PAGER);
                }
            }

            return(notifyObjectList.ToArray());
        }
コード例 #10
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);
        }
コード例 #11
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);
        }
コード例 #12
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);
        }
コード例 #13
0
        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);
        }
コード例 #14
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");
     }
 }
コード例 #15
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);
            }
        }
コード例 #16
0
        /// <summary>
        /// Dials the number.
        /// </summary>
        public long DialNumber(INotifyObject _notifyObject)
        {
            long   QueueID          = -1;
            string sensorInfo       = _notifyObject.NotificationData.ToString();
            string phoneNumber      = _notifyObject.NotifierSettings["PhoneNo"].ToString();
            string storePhoneNumber = _notifyObject.NotifierSettings["StorePhoneNo"].ToString();
            string voiceMode        = _notifyObject.NotifierSettings["CDYNE_VOICEID"].ToString();
            string voiceVolume      = _notifyObject.NotifierSettings["CDYNE_VOLUME"].ToString();
            string voiceLicense     = _notifyObject.NotifierSettings["CDYNE_ID"].ToString();
            string voiceRetries     = _notifyObject.NotifierSettings["CDYNE_RETRIES"].ToString();

            LogBook.Write("PhoneNo.: " + _notifyObject.NotifierSettings["PhoneNumber"] + ", Voice Prompt: " + sensorInfo);



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

            anr.CallerIDName         = "TempTrak";
            anr.CallerIDNumber       = storePhoneNumber; //TT registration #, if blank shows as private
            anr.PhoneNumberToDial    = phoneNumber;
            anr.TextToSay            = /*"~\\ActOnFeature(false)~*/ "~\\SetVar(Attempt|1)~ ~\\ActOnDigitPress(false)~   ~\\Label(Menu)~ ~\\AssignDTMF(*|Ack)~ ~\\ActOnDigitPress(true)~ ~\\Beep()~ ~\\PlaySilence(0.1)~" + sensorInfo + " ~\\WaitForDTMF(1)~" + "Press the star key to acknowledge receipt of this alert.  Press 1 to repeat this message. ~\\PlaySilence(0.1)~   ~\\WaitForDTMF(10)~ ~\\IncreaseVariable(Attempt|1)~ ~\\GotoIf(Attempt|1|Menu)~ ~\\GotoIf(Attempt|2|Menu)~ ~\\GotoIf(Attempt|3|AttemptEnd)~ ~\\Label(AttemptEnd)~ Good Bye ~\\EndCall()~ ~\\Label(Ack)~ ~\\PlaySilence(0.1)~ Thank you for acknowledging receipt of this alert. ~\\PlaySilence(0.1)~ Log into TempTrak to take corrective action and officially clear alert. ~\\PlaySilence(0.1)~ Good Bye. ~\\EndCall()~";
            anr.VoiceID              = voiceMode.ToInt();           //store this in config if customer does not like voice
            anr.UTCScheduledDateTime = DateTime.UtcNow;
            anr.LicenseKey           = voiceLicense;                //"54B1B99F-7E7E-40AC-88EB-A91DBE859B82"; //stored in config file for now
            anr.TryCount             = 0;                           //voiceRetries.ToInt();  //controlled by TT not CDyne
            anr.NextTryInSeconds     = 0;                           //controlled by TT
            anr.TTSvolume            = Convert.ToByte(voiceVolume); //also store this in config


            NotifyReturn nr = pn.NotifyPhoneAdvanced(anr);

            LogBook.Write("Info Passed to Notify Phone Advanced: ");
            LogBook.Write("CallerIDName: " + anr.CallerIDName);
            LogBook.Write("CallerIDNumber: " + anr.CallerIDNumber);
            LogBook.Write("PhoneNumberToDial: " + anr.PhoneNumberToDial);
            LogBook.Write("TextToSay: " + anr.TextToSay);
            LogBook.Write("VoiceID: " + anr.VoiceID);
            LogBook.Write("UTCScheduledDateTime: " + anr.UTCScheduledDateTime);
            LogBook.Write("LicenseKey: " + anr.LicenseKey);
            LogBook.Write("NextTryInSeconds: " + anr.NextTryInSeconds);
            LogBook.Write("TTSVolume: " + anr.TTSvolume);

            LogBook.Write("Dialed: " + phoneNumber + " ......... ");

            //final released version will have script uploaded to CDyne so we can say goodbye if user presses key


            QueueID = nr.QueueID;
            LogBook.Write("QueueID: " + nr.QueueID + " ......... ");
            return(QueueID);
        }
コード例 #17
0
        /// <summary>
        /// Get the message board instance based on the boardtype
        /// </summary>
        /// <param name="boardType"></param>
        /// <returns></returns>
        private IMessageBoard GetMessageBoard(INotifyObject notifyObject)
        {
            IMessageBoard msgBoard  = null;
            int           boardType = notifyObject.NotifierSettings["BoardType"].ToInt();

            switch (((MessageBoardType)boardType).ToStr())
            {
            case "MB_Unknown":
                break;

            case "MB_215C":
                msgBoard           = new MsgBrd215C();
                msgBoard.BoardType = MessageBoardType.MB_215C;
                break;

            case "MB_BetaBrite":
                msgBoard           = new MsgBrdBetaBrite();
                msgBoard.BoardType = MessageBoardType.MB_BetaBrite;
                break;
            }
            msgBoard.COMMSettings      = notifyObject.NotifierSettings["COMSettings"].ToStr().Replace('8', '7');
            msgBoard.Name              = notifyObject.NotifierSettings["Name"].ToStr();
            msgBoard.IPAddress         = notifyObject.NotifierSettings["IpAddress"].ToStr();
            msgBoard.Port              = notifyObject.NotifierSettings["Port"].ToInt();
            msgBoard.IsNetworkAttached = notifyObject.NotifierSettings["IsNetworkConnected"].ToBoolean();
            msgBoard.IsGroup           = notifyObject.NotifierSettings["IsGroup"].ToBoolean();
            msgBoard.IsEnabled         = notifyObject.NotifierSettings["IsEnabled"].ToBoolean();
            msgBoard.SensorAlarmID     = notifyObject.NotifierSettings["SensorAlarmID"].ToStr();
            msgBoard.SensorFactoryID   = (notifyObject.NotifierSettings["SensorFactoryID"] != null) ? notifyObject.NotifierSettings["SensorFactoryID"].ToStr() : "";

            /* added on 02/28/2011 to server time for the first time. */
            if (notifyObject.NotifierSettings.ContainsKey("SetServerTime"))
            {
                msgBoard.SetServerTime = notifyObject.NotifierSettings["SetServerTime"].ToBoolean();
            }

            //add new for multiple message board issue on 02/16/2011
            msgBoard.ID = notifyObject.NotifierSettings["NotifyID"].ToInt();

            if (notifyObject.NotifierSettings["IsDynamicNotificationCleared"] != null)
            {
                msgBoard.IsDynamicNotificationCleared = notifyObject.NotifierSettings["IsDynamicNotificationCleared"].ToBoolean();
            }
            else
            {
                msgBoard.IsDynamicNotificationCleared = null;
            }

            return(msgBoard);
        }
コード例 #18
0
        public INotifyObject PrepareNotifyObject(object data)
        {
            if (data is string || data is XmlReader)
            {
            }
            else
            {
                throw new ArgumentNullException("data parameter must be string or XmlReader type.");
            }

            INotifyObject notifyObject = NotifyObject.Create(data);

            return(notifyObject);
        }
        /// <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);
        }
コード例 #20
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());
            }
        }
コード例 #21
0
        public ScriptHelper(INotifyObject notifyObject)
        {
            try
            {
                /* get settings information.*/
                _scriptName      = notifyObject.NotifierSettings["ScriptName"].ToStr();
                _scriptArguments = notifyObject.NotifierSettings["ScriptArgs"].ToStr();
            }
            catch (Exception ex)
            {
                /*Debug Object values for reference*/
                LogBook.Debug(notifyObject, this);

                /*Write exception log*/
                LogBook.Write("Error has occurred while retrieving values from notification settings", ex, "CooperAtkins.NotificationServer.NotifyEngine.Script.ScriptClient");
            }
        }
コード例 #22
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);
        }
コード例 #23
0
        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);
        }
コード例 #24
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());
            }
        }
コード例 #25
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());
            }
        }
コード例 #26
0
        public PopupClient(INotifyObject notifyObject)
        {
            try
            {
                /* get remote popup settings. */
                _remoteHost      = notifyObject.NotifierSettings["RemoteHost"].ToStr();
                _remotePort      = notifyObject.NotifierSettings["RemotePort"].ToInt();
                _addressBookName = notifyObject.NotifierSettings["Name"].ToStr();
                _alertMessage    = notifyObject.NotificationData.ToStr();
            }
            catch (Exception ex)
            {
                /*Debug Object values for reference*/
                LogBook.Debug(notifyObject, this);

                /*Write exception log*/
                LogBook.Write("Error has occurred while retrieving values from notification settings", ex, "CooperAtkins.NotificationServer.NotifyEngine.POPUP.PopupClient");
            }
        }
コード例 #27
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);
         }
     }
 }
コード例 #28
0
        public PagerHelper(INotifyObject notifyObject)
        {
            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();
            }
            catch (Exception ex)
            {
                /*Debug Object values for reference*/
                LogBook.Debug(notifyObject, this);

                /*Write exception log*/
                LogBook.Write("Error has occurred while retrieving values from notification settings", ex, "CooperAtkins.NotificationServer.NotifyEngine.PagerHelper");
            }
        }
コード例 #29
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);
            });
        }
コード例 #30
0
        /// <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());
                }
            }
        }