コード例 #1
0
        public void AddReadLogTest()
        {
            // Add logs out of order.
            Guid l1Id = this.uut.AddLogToDb(log1);
            Guid l3Id = this.uut.AddLogToDb(log3);
            Guid l2Id = this.uut.AddLogToDb(log2);

            Assert.AreEqual(log1, this.uut[l1Id]);
            Assert.AreEqual(log2, this.uut[l2Id]);
            Assert.AreEqual(log3, this.uut[l3Id]);

            this.CheckLogbook();

            this.uut.ClearCache();
            Assert.AreEqual(0, this.uut.Count);
            this.CheckShortcutProperties();

            this.uut.Dispose();

            // Close / reopen.  Everything should still match.
            this.uut = new LogBook(fileName);
            Assert.AreEqual(0, this.uut.Count);
            this.uut.Refresh();

            Assert.AreEqual(log1, this.uut[l1Id]);
            Assert.AreEqual(log2, this.uut[l2Id]);
            Assert.AreEqual(log3, this.uut[l3Id]);

            this.CheckLogbook();

            this.uut.ResetState();
            this.CheckForEmptyProperties();
        }
コード例 #2
0
 public async Task PostAsync([FromBody] LogBook value)
 {
     value.logBookId   = Guid.NewGuid();
     value.logBookDate = DateTime.Now;
     context.logBooks.Add(value);
     await context.SaveChangesAsync();
 }
コード例 #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
        /// <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);
        }
コード例 #5
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);
        }
コード例 #6
0
 public List <LogBook> UpdateLog([FromBody] LogBook log)
 {
     log.UserId = DbContext.Users.Where(p => p.Email == User.Claims.Last().Value).Select(p => p.Id).FirstOrDefault();
     DbContext.pl_logBook.Update(log);
     DbContext.SaveChanges();
     return(GetLogBookList());
 }
コード例 #7
0
        public Guid InsertNewNote(Guid id, string purpose)
        {
            LogBook note = new LogBook
            {
                EntryTime    = DateTime.Now,
                VisitorId    = id,
                VisitPurpose = purpose
            };

            try
            {
                context.LogBooks.Add(note);
                context.SaveChanges();
                Console.WriteLine("\nДанные записаны!");
            }
            catch (Exception exception)
            {
                Console.WriteLine(exception.Message);
            }
            finally
            {
                Console.Write("Нажмите Enter чтобы продолжить...");
                Console.ReadLine();
            }
            return(note.Id);
        }
コード例 #8
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);
        }
コード例 #9
0
        private void ReceiveMessages()
        {
            if (_waitingReceivers > 0 || _disposed)
            {
                return;
            }

            Interlocked.Increment(ref _waitingReceivers);

            lock (_messageReaderLock)
            {
                Interlocked.Decrement(ref _waitingReceivers);

                if (_disposed)
                {
                    return;
                }

                LogBook logBook  = DeserializeLogBook(_memoryMappedFile.Read());
                Int64   readFrom = _lastEntryId;
                _lastEntryId = logBook.LastId;

                foreach (LogEntry entry in logBook.Entries.Where(entry => entry.Id > readFrom && entry.Instance != _instanceId && entry.Message.Length != 0))
                {
                    _receivedMessages.Enqueue(entry);

                    Interlocked.Increment(ref _messagesReceived);
                }
            }
        }
コード例 #10
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);
        }
コード例 #11
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");
        }
コード例 #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
 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);
     }
 }
コード例 #14
0
        public async Task LBRepositoryTest()
        {
            ImportDataTest import = new ImportDataTest();

            import.InitContext();

            try
            {
                _context          = import._context;
                logbookRepository = new LogbookRepository(_context);

                logbookService = new LogbookService(logbookRepository, null, null);
                IEnumerable <FlightRecord> fr = await logbookService.GetRecordByAircrafAsync(12, 8);

                foreach (var f in fr)
                {
                    System.Diagnostics.Debug.WriteLine(f.ToString());
                }

                LogBook logBook = await logbookRepository.GetByIdWithItemsAsync(1);

                LogBook logBook1 = await logbookRepository.GetFlightRecordsByPilotIdAsync(12);

                LogBook a = await logbookService.GetLogbookByPilotAsync(12);
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex.Message);
            }
        }
コード例 #15
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);
        }
コード例 #16
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);
        }
コード例 #17
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());
        }
コード例 #18
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);
        }
コード例 #19
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);
        }
コード例 #20
0
        //CheckIfUserIsAllowedToSeeLogAsync_Should
        public static void GetContextWithUserLogBooksAndUserAndLogBook(string DbName, string userId, string username, int logbookId)
        {
            var options = GetOptions(DbName);

            var context = new AlphaHotelDbContext(options);
            var user    = new User()
            {
                Id       = userId,
                UserName = username,
            };

            var logbook = new LogBook()
            {
                Id = logbookId
            };

            var usersLogbooks = new UsersLogbooks()
            {
                User    = user,
                LogBook = logbook
            };

            context.Users.Add(user);
            context.LogBooks.Add(logbook);
            context.UsersLogbooks.Add(usersLogbooks);
            context.SaveChanges();
        }
コード例 #21
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);
        }
コード例 #22
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);
        }
コード例 #23
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();
            }
        }
コード例 #24
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;
            }
        }
コード例 #25
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);
        }
コード例 #26
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");
     }
 }
コード例 #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
        /// <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);
        }
コード例 #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
        /// <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);
        }