Exemplo n.º 1
0
 public NotificationDetails(DatabaseNotification dbNotification)
 {
     NotificationId  = dbNotification.NotificationId;
     AlertId         = dbNotification.AlertId;
     TriggerDateTime = dbNotification.TriggerDateTime;
     Acknowledged    = dbNotification.Acknowledged;
     FailedEmail     = dbNotification.FailedEmail;
 }
Exemplo n.º 2
0
        private void CreateNotificationForTriggeredAlert(DatabaseAlert alert,
                                                         DatabasePerSecondStat earliestStatThatTriggersAlert, bool failedEmail = false)
        {
            DatabaseNotification dbNotification = new DatabaseNotification
            {
                AlertId         = alert.AlertId,
                Acknowledged    = false,
                TriggerDateTime = earliestStatThatTriggersAlert.DateTime,
                FailedEmail     = failedEmail
            };

            _databaseQueryService.PersistNewNotification(dbNotification);
        }
Exemplo n.º 3
0
        public bool DoesNotificationNeedImage(DatabaseAlert dbAlert, DatabaseNotification dbNotification)
        {
            if (DateTime.Now.Subtract(dbNotification.TriggerDateTime).TotalMinutes <= 30)
            {
                //does notification have an image associated with it?
                List <DatabasePerSecondStat> perSecondStatsWithImageForNotification =
                    _databaseQueryService.GetPerSecondStatsWithFrmTriggeringAlert(dbAlert,
                                                                                  dbNotification.TriggerDateTime, dbNotification.TriggerDateTime.AddMinutes(30));
                return(perSecondStatsWithImageForNotification.IsNullOrEmpty());
            }

            return(false);
        }
Exemplo n.º 4
0
        public FrameInformation GetEarliestStatFrameForNotification(int notificationId)
        {
            DatabaseNotification         dbNotification = _dbQueryService.GetNotificationById(notificationId);
            DatabaseAlert                dbAlert        = _dbQueryService.GetAlertById(dbNotification.AlertId);
            List <DatabasePerSecondStat> statsForCamera =
                _dbQueryService.GetPerSecondStatsWithFrmTriggeringAlert(dbAlert, dbNotification.TriggerDateTime, dbNotification.TriggerDateTime.AddMinutes(30));
            var sortedStats = statsForCamera.OrderBy(stat => stat.DateTime);

            foreach (DatabasePerSecondStat stat in sortedStats)
            {
                if (!stat.FrameJpgPath.IsNullOrEmpty())
                {
                    FrameInformation frmInfo = new FrameInformation(stat);
                    if (frmInfo.FrmJpgRelPath.IsNullOrEmpty() == false)
                    {
                        return(frmInfo);
                    }
                }
            }

            return(null);
        }
Exemplo n.º 5
0
        public JpgStatFrameList GetTriggeringStatsFrameList(int notificationId)
        {
            DatabaseNotification         dbNotification = _dbQueryService.GetNotificationById(notificationId);
            DatabaseAlert                dbAlert        = _dbQueryService.GetAlertById(dbNotification.AlertId);
            List <DatabasePerSecondStat> statsForCamera = _dbQueryService.GetPerSecondStatsWithFrmTriggeringAlert(dbAlert, dbNotification.TriggerDateTime, dbNotification.TriggerDateTime.AddMinutes(30));
            JpgStatFrameList             frmList        = new JpgStatFrameList();

            frmList.JpgFramePathList = new List <FrameInformation>();
            foreach (DatabasePerSecondStat stat in statsForCamera)
            {
                if (!stat.FrameJpgPath.IsNullOrEmpty())
                {
                    FrameInformation frmInfo = new FrameInformation(stat);
                    if (frmInfo.FrmJpgRelPath.IsNullOrEmpty() == false)
                    {
                        frmList.JpgFramePathList.Add(frmInfo);
                    }
                }
            }

            return(frmList);
        }
Exemplo n.º 6
0
        public bool IsNotificationAcknowledged(int notificationId)
        {
            DatabaseNotification dbNotification = _databaseQueryService.GetNotificationById(notificationId);

            return(dbNotification.Acknowledged);
        }