コード例 #1
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());
        }
コード例 #2
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);
        }
コード例 #3
0
        /// <summary>
        /// Get E-mail Notification ID
        /// </summary>
        /// <param name="notifyProfileID"></param>
        /// <returns></returns>
        private int GetEmailNotificationID(int notifyProfileID)
        {
            NotificationProfile notificationProfile = null;
            int emailNotificationID = 0;

            try
            {
                /*Create NotificationProfile instance*/
                notificationProfile = new NotificationProfile();
                /*Send criteria notifyProfileID to get the Notification ID*/
                notificationProfile.NotifyProfileID = notifyProfileID;
                /*Execute*/
                notificationProfile = notificationProfile.Execute();
                /*Assign the EmailNotifyID to local variable emailNotificationID*/
                emailNotificationID = notificationProfile.EmailNotifyID;
            }
            catch (Exception ex)
            {
                /*Debug Object values for reference*/
                LogBook.Debug(notificationProfile, this);

                /*Write exception log*/
                LogBook.Write("Error has occurred while fetching EmailNotifyID ", ex, "CooperAtkins.NotificationClient.NotificationComposer.EmailNotificationComposer");
            }
            finally
            {
                /*Dispose the notificationProfile object*/
                notificationProfile.Dispose();
            }
            return(emailNotificationID);
        }
コード例 #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
        /// <summary>
        /// Record notification results in the database
        /// </summary>
        /// <param name="logText"></param>
        /// <param name="notificationID"></param>
        /// <param name="status"></param>
        /// <param name="notificationType"></param>
        public void RecordNotification(string logText, int notificationID, int transactionID, NotifyStatus status, NotifyTypes notificationType)
        {
            RecordNotification recordNotification = null;

            try
            {
                recordNotification = new RecordNotification();
                /*Error or Notification response is recorded*/
                recordNotification.LogText        = logText;
                recordNotification.NotificationID = notificationID;
                recordNotification.TransID        = transactionID;
                recordNotification.Status         = status;
                recordNotification.NotifyType     = notificationType;
                recordNotification.Execute();
            }
            catch (Exception ex)
            {
                /*Debug Object values for reference*/
                LogBook.Debug(recordNotification, this);

                /*Write exception log*/
                LogBook.Write("Error has occurred while inserting record notification parameters into 'ttNotificationLog' table", ex, "CooperAtkins.NotificationClient.NotificationComposer.EmailNotificationComposer");
            }
            finally
            {
                recordNotification.Dispose();
            }
        }
コード例 #6
0
        /// <summary>
        /// Get Pager Notification Address List
        /// </summary>
        /// <param name="alarmObject"></param>
        /// <returns></returns>
        private NotifyPagerAddressList GetPagerAddressList(Interface.Alarm.AlarmObject alarmObject)
        {
            NotifyPagerAddressList notifyPagerAddressList = null;

            try
            {
                /*Fetch Email Address list based on Notification Profile ID*/
                notifyPagerAddressList = new NotifyPagerAddressList();
                Criteria criteria = new Criteria();
                criteria.ID = GetPagerNotificationID(alarmObject.NotifyProfileID);//Replace with
                notifyPagerAddressList.Load(criteria);
            }
            catch (Exception ex)
            {
                /*Debug Object values for reference*/
                LogBook.Debug(notifyPagerAddressList, this);

                /*Write exception log*/
                LogBook.Write(_logContent + " Error has occurred while fetching pager address list from 'GenNotifyPagers' table", ex, "CooperAtkins.NotificationClient.NotificationComposer.PagerNotificationComposer");
            }
            finally
            {
                notifyPagerAddressList.Dispose();
            }
            return(notifyPagerAddressList);
        }
コード例 #7
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());
        }
コード例 #8
0
        /// <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
 private void SetRelaySwitchInfo(RelaySwitch relaySwitch)
 {
     try
     {
         this.IoAddress         = relaySwitch.IoAddress;
         this.IsNetworkAttached = relaySwitch.IsNetworkAttached;
         this.IpAddress         = relaySwitch.IpAddress;
         this.IpPort            = relaySwitch.IpPort;
         this.IoAddress         = relaySwitch.IoAddress;
         this.ComPort           = relaySwitch.ComPort;
         if (relaySwitch.ComSettings != null)
         {
             this.ComSettings           = relaySwitch.ComSettings;
             this.ComSettings.BaudRate  = relaySwitch.ComSettings.BaudRate;
             this.ComSettings.DataBits  = relaySwitch.ComSettings.DataBits;
             this.ComSettings.ParityBit = relaySwitch.ComSettings.ParityBit;
             this.ComSettings.StopBit   = relaySwitch.ComSettings.StopBit;
         }
         this.SensorAlarmID = relaySwitch.SensorAlarmID;
         this.IsEnabled     = relaySwitch.IsEnabled;
         this.SwitchName    = relaySwitch.SwitchName;
         this.LastValue     = relaySwitch.LastValue;
         this.SwitchBitMask = relaySwitch.SwitchBitMask;
         this.IsDynamicNotificationCleared = true;
         this.FactoryID = relaySwitch.FactoryID;
     }
     catch (Exception ex)
     {
         LogBook.Write("  *** Error in SetRelaySwitchInfo method : " + ex.Message);
     }
 }
コード例 #10
0
        private void SendToBoard(string messageData)
        {
            LogBook.Write("Enter send to board method");
            //to communicate using TCP/IP
            NetworkClient client = new NetworkClient();
            //to communicate using serial port
            IOPort ioPort = new IOPort();

            if (_isNetworkAttached)
            {
                //send message to message board using TCP/IP
                //client.TcpClient(_ipAddress, _port, messageData);
            }
            else
            {
                string[]           settingsArray = _commSettings.Split(',');
                IOPort.ComSettings commSettings  = new IOPort.ComSettings();
                commSettings.BaudRate  = settingsArray[0].ToInt();
                commSettings.ParityBit = Parity.None;
                commSettings.DataBits  = settingsArray[3].ToInt16();
                commSettings.StopBit   = StopBits.One;

                ioPort.Handshake(_port.ToString(), commSettings, DataRecievedFromCom);
                ioPort.SerialPortOutput(messageData);

                //send message to message board using serial port
                //ioPort.SerialPort(_port.ToString(),commSettings, messageData,null);
            }
            LogBook.Write("Message sent to message board.");
            LogBook.Write("Exit send to board method");
        }
コード例 #11
0
        public INotifyObject[] Compose(AlarmObject alarmObject)
        {
            //  LogBook.Write("CDYNEIvrNotificationComposer  Compose() Method");
            List <INotifyObject> notifyList = new List <INotifyObject>();

            _alarmObject = alarmObject;

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

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

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

            /* Inserting the IVR Notification to database tables TTNotifications and TTIVRNotifications.*/
            //if (_alarmObject.AlarmID > 0)
            RecordIVRNotification(_alarmObject);
            return(null);
        }
コード例 #12
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");
            }
        }
コード例 #13
0
        public void Import()
        {
            try{
                LogBook.Write("NotificationClientEnd - Import Path: " + Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location));
                if (_notificationChannels != null)
                {
                    return;
                }
                //An aggregate catalog that combines multiple catalogs
                var catalog = new AggregateCatalog();
                //Adds all the parts found in all assemblies in current directory
                catalog.Catalogs.Add(
                    new SafeDirectoryCatalog(
                        Path.GetDirectoryName(
                            Assembly.GetExecutingAssembly().Location)));

                //Create the CompositionContainer with the parts in the catalog
                CompositionContainer container = new CompositionContainer(catalog);

                //Fill the imports of this object
                container.ComposeParts(this);

                foreach (INotificationChannelClient channel in _notificationChannels)
                {
                    _notificationChannelsWithName.Add(channel.GetType().FullName, channel);
                }
            }
            catch (Exception Ex)
            {
                LogBook.Write(Ex, "Notification ClientEnd Exception");
            }
        }
コード例 #14
0
        public void DisplayMessage(int ID, string msg, int priority = 5)
        {
            string rawMsg = string.Empty;

            LogBook.Write("Enter display message method");

            //if priority is less than 1 and greater than 9 set priority as 5
            if (priority < 1 || priority > 9)
            {
                priority = 5;
            }
            //set raw message
            switch (_brdType)
            {
            default:
                rawMsg = ((char)127).ToString() + "*~ID" + ID + "~PR" + priority + "~CO3" + msg + "~ES" + ((char)3).ToString();
                break;
            }
            _dLastMsg[ID.ToString()]     = msg;
            _dLastMsgRaw[ID.ToString()]  = rawMsg;
            _dLastMsgTime[ID.ToString()] = DateTime.Now;

            SendToBoard(rawMsg);

            if (_dLastMsg.Count == 1)
            {
                //Just added out first alert msg ... clear the time display
                RemoveDateTime();
                //AddBeep();
            }
            LogBook.Write("Exiting method display message");
        }
コード例 #15
0
        public void WriteBytes(byte[] data)
        {
            //create instance for the TCP/IP and Serial port classes
            NetworkClient client  = new NetworkClient(); //for TCP
            IOPort        comPort = new IOPort();        //for COMM port

            //get the comm settings for the connection
            string[]           settingsArray = _commSettings.Split(',');
            IOPort.ComSettings commSettings  = new IOPort.ComSettings();
            commSettings.BaudRate  = settingsArray[0].ToInt();
            commSettings.ParityBit = Parity.Even;
            commSettings.DataBits  = settingsArray[2].ToInt16();
            commSettings.StopBit   = StopBits.One;
            try
            {
                //if the device is attached to network
                if (_isNetworkAttached)
                {
                    //send data using TCP/IP
                    client.TcpClient(_ipAddress, _port, data);
                }
                else
                {
                    //send data using Serial port
                    LogBook.Write(this.SensorFactoryID + " " + this.SensorAlarmID + " " + "Sending data using UDP Port: " + _port.ToString());
                    comPort.Handshake("COM" + _port.ToString(), commSettings, DataRecievedFromCom);
                    comPort.SerialPortOutput(data);
                }
            }
            catch (Exception ex)
            {
                LogBook.Write(ex, this.SensorFactoryID + " " + this.SensorAlarmID + " " + "NotifyEngine-MessageBoard");
                throw ex;
            }
        }
コード例 #16
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);
        }
コード例 #17
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");
     }
 }
コード例 #18
0
        /// <summary>
        /// Get missed communication sensor list
        /// </summary>
        /// <returns></returns>
        private MissedCommunicationList GetMissedCommunicationList()
        {
            MissedCommunicationList missedCommunicationList = null;

            try
            {
                /*Create MissedCommunicationList instance*/
                missedCommunicationList = new MissedCommunicationList();

                /*Create empty Criteria object*/
                Criteria criteria = new Criteria();

                /*Execute to get the missed communication list*/
                missedCommunicationList = missedCommunicationList.Load(criteria);
            }
            catch (Exception ex)
            {
                /*Debug Object values for reference*/
                LogBook.Debug(missedCommunicationList, this);

                /*Write exception log*/
                LogBook.Write("Error has occurred while fetching missed communication data.", ex, "CooperAtkins.NotificationClient.NotificationComposer");
            }
            finally
            {
                missedCommunicationList.Dispose();
            }
            return(missedCommunicationList);
        }
コード例 #19
0
        /// <summary>
        /// Get Pager Notification ID
        /// </summary>
        /// <param name="notifyProfileID"></param>
        /// <returns></returns>
        private int GetPagerNotificationID(int notifyProfileID)
        {
            NotificationProfile notificationProfile = null;
            int pagerNotificationID = 0;

            try
            {
                notificationProfile = new NotificationProfile();
                notificationProfile.NotifyProfileID = notifyProfileID;
                notificationProfile = notificationProfile.Execute();
                pagerNotificationID = notificationProfile.PagerNotifyID;
            }
            catch (Exception ex)
            {
                /*Debug Object values for reference*/
                LogBook.Debug(notificationProfile, this);

                /*Write exception log*/
                LogBook.Write(_logContent + " Error has occurred while fetching PagerNotifyID ", ex, "CooperAtkins.NotificationClient.NotificationComposer.PagerNotificationComposer");
            }
            finally
            {
                notificationProfile.Dispose();
            }
            return(pagerNotificationID);
        }
コード例 #20
0
        private void InitProcess()
        {
            LogBook.Write("SqlConnectionString:" + connString);

            _target = new AlarmInitializer();

            LogBook.Write("new AlarmInitializer called");

            try
            {
                /* Added on 02/28/2011 To set server time */
                _target.SetServerTime();
            }
            catch (Exception ex)
            {
                LogBook.Write("Unable to set server time to message boards", ex, "CooperAtkins.NotificationClient.Service.NotificationClientService");
            }

            /* if service restarts, this operation will resumes previously lost notification*/
            _target.ResumeNotificationProcess();

            LogBook.Write("ResumeNotificationProcess Completed");

            /* Stating the process. */
            StartProcess();

            LogBook.Write("StartProcess(); Completed");

            /* listening to external source. */
            UDPListener();
            LogBook.Write("UDPListener(); Completed");
        }
コード例 #21
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);
        }
コード例 #22
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);
        }
コード例 #23
0
        /// <summary>
        /// Get FormatID
        /// </summary>
        /// <param name="alarmObject"></param>
        /// <param name="formatType"></param>
        /// <param name="action"></param>
        /// <returns></returns>
        private int GetFormatID(Interface.Alarm.AlarmObject alarmObject, string formatType, int action)
        {
            int sensorFormatID = 0;
            SensorFormatString sensorFormatString = null;

            try
            {
                sensorFormatString            = new SensorFormatString();
                sensorFormatString.UTID       = alarmObject.UTID;
                sensorFormatString.Probe      = alarmObject.Probe;
                sensorFormatString.FormatType = formatType;
                sensorFormatString.Action     = action;

                sensorFormatString.Execute(sensorFormatString);
                sensorFormatID = sensorFormatString.SensorFormatID;
            }
            catch (Exception ex)
            {
                /*Debug Object values for reference*/
                LogBook.Debug(sensorFormatString, this);

                /*Write exception log*/
                LogBook.Write("Error has occurred while retrieving SensorFormatID", ex, "CooperAtkins.NotificationClient.NotificationComposer.Notification");
            }
            finally
            {
                sensorFormatString.Dispose();
            }
            return(sensorFormatID);
        }
コード例 #24
0
        /// <summary>
        /// Get Notification E-Mail Address list based on Notification Profile ID
        /// </summary>
        /// <param name="alarmObject"></param>
        /// <returns></returns>
        private NotifyMobileList GetNotifyMoibilesList(int notifyProfileID)
        {
            NotifyMobileList notifyMobileList = null;

            try
            {
                LogBook.Write("Fetching Mobile notify ID list");
                /*Create NotifySmsAddressList object*/
                notifyMobileList = new NotifyMobileList();
                /*Create Criteria object*/
                Criteria criteria = new Criteria();
                /*Get the Sms notificationId and assign to criteria.ID*/
                criteria.ID = GetMobileNotificationID(notifyProfileID);
                /*Gets list of notification sms addresses*/
                notifyMobileList.Load(criteria);

                LogBook.Write("Notify Mobile ID list count: " + notifyMobileList.Count);
            }
            catch (Exception ex)
            {
                /*Debug Object values for reference*/
                LogBook.Debug(notifyMobileList, this);

                /*Write exception log*/
                LogBook.Write("Error has occurred while fetching mobile numbers list from 'GenNotifySms' table", ex, "CooperAtkins.NotificationClient.NotificationComposer.SMSNotificationComposer");
            }
            finally
            {
                notifyMobileList.Dispose();
            }
            return(notifyMobileList);
        }
コード例 #25
0
        /// <summary>
        /// Get Current minutes in alarm based on alarm exit time
        /// </summary>
        /// <param name="alarmObject"></param>
        private int GetCurrentMinInAlarm(AlarmObject alarmObject)
        {
            int      currentMinInAlarm = 0;
            DateTime exitTime          = DateTime.MinValue;

            try
            {
                if (alarmObject.AlarmStateExitTime < alarmObject.AlarmStartTime)
                {
                    exitTime = DateTime.UtcNow;
                }
                //Get the date difference
                TimeSpan diffTime;
                diffTime          = alarmObject.AlarmStartTime - exitTime;
                currentMinInAlarm = diffTime.Minutes + (60 * diffTime.Hours) + ((diffTime.Days * 24) * 60);
                //LogBook.Write("Minutes to for missed comm: " + diffTime.Minutes + (60 * diffTime.Hours));
                //currentMinInAlarm = diffTime.TotalMinutes.ToInt(); //ASSUMES NO OVERFLOW
            }
            catch (Exception ex)
            {
                //Write Log
                LogBook.Write("Error occurred while getting current alarm minutes", ex, "CooperAtkins.NotificationClient.NotificationComposer.NotificationStyle");
            }
            return(currentMinInAlarm);
        }
コード例 #26
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);
        }
コード例 #27
0
        /// <summary>
        /// Get active notification profile ids
        /// </summary>
        /// <returns></returns>
        private NotificationProfile GetActiveNotificationProfile(int storeID)
        {
            NotificationProfile notificationProfile = null;

            try
            {
                notificationProfile = new NotificationProfile();
                notificationProfile.NotifyProfileID = _notifyProfileID;
                notificationProfile.StoreID         = storeID;
                notificationProfile = notificationProfile.Execute();
            }
            catch (Exception ex)
            {
                /*Debug Object values for reference*/
                LogBook.Debug(notificationProfile, this);

                /*Write exception log*/
                LogBook.Write("Error has occurred while fetching notification profile Ids ", ex, "CooperAtkins.NotificationClient.NotificationComposer.NotificationEligibility");
            }
            finally
            {
                notificationProfile.Dispose();
            }

            return(notificationProfile);
        }
コード例 #28
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);
        }
コード例 #29
0
        /// <summary>
        /// Get Notification E-Mail Address list based on Notification Profile ID
        /// </summary>
        /// <param name="alarmObject"></param>
        /// <returns></returns>
        private NotifyEmailAddressList GetNotifyEmailAddressList(int notifyProfileID)
        {
            NotifyEmailAddressList notifyEmailAddressList = null;

            try
            {
                /*Create NotifyEmailAddressList object*/
                notifyEmailAddressList = new NotifyEmailAddressList();
                /*Create Criteria object*/
                Criteria criteria = new Criteria();
                /*Get the Email notificationId and assign to criteria.ID*/
                criteria.ID = GetEmailNotificationID(notifyProfileID);
                /*Gets list of notification email addresses*/
                notifyEmailAddressList.Load(criteria);
            }
            catch (Exception ex)
            {
                /*Debug Object values for reference*/
                LogBook.Debug(notifyEmailAddressList, this);

                /*Write exception log*/
                LogBook.Write("Error has occurred while fetching email address list from 'GenNotifyEmails' table", ex, "CooperAtkins.NotificationClient.NotificationComposer.EmailNotificationComposer");
            }
            finally
            {
                notifyEmailAddressList.Dispose();
            }
            return(notifyEmailAddressList);
        }
コード例 #30
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);
        }