Exemplo n.º 1
0
        public NotificationDetails GetNotificationDetailsById(int notificationId)
        {
            NotificationDetails notification = new NotificationDetails(_databaseQueryService.GetNotificationById(notificationId));

            notification.Alert                 = new AlertDetails(_databaseQueryService.GetAlertById(notification.AlertId));
            notification.Alert.Camera          = new CameraDetails(_databaseQueryService.GetCameraById(notification.Alert.CameraId));
            notification.Alert.Camera.Location = new LocationDetails(_databaseQueryService.GetLocationById(notification.Alert.Camera.LocationId));
            return(notification);
        }
Exemplo n.º 2
0
        public GraphStatistics GetSharedRoomStatisticsForPastPeriod(List <int> cameraIds, PastPeriod pastPeriod, DateTime?startDate = null, DateTime?endDate = null)
        {
            GraphStatistics graphStatistics = new GraphStatistics();

            if (startDate != null && endDate != null)
            {
                graphStatistics.StartDate = startDate;
                graphStatistics.EndDate   = endDate;
            }

            List <List <DatabasePerSecondStat> > perSecondStatsForEachCamera = new List <List <DatabasePerSecondStat> >();

            foreach (var cameraId in cameraIds)
            {
                perSecondStatsForEachCamera.Add(GetDatabasePerSecondStatsForPastPeriod(cameraId, pastPeriod, startDate, endDate));
            }

            foreach (var perSecondStats in perSecondStatsForEachCamera)
            {
                AddDelimiterStatsForPastPeriod(perSecondStats, pastPeriod, startDate, endDate);
                AddDummyStatsForDeadPeriods(perSecondStats);
            }

            List <string[]> perSecondStatsFormattedStrings = new List <string[]>();

            string[] titleString = new string[perSecondStatsForEachCamera.Count + 1];
            titleString[0] = "DateTime";
            for (int i = 0; i < cameraIds.Count; i++)
            {
                int            cameraId = cameraIds.ElementAt(i);
                DatabaseCamera camera   = _databaseQueryService.GetCameraById(cameraId);
                titleString[i + 1] = $"People Detected for {camera.CameraName}";
            }
            perSecondStatsFormattedStrings.Add(titleString);

            for (int i = 1; i <= perSecondStatsForEachCamera.Count; i++)
            {
                List <DatabasePerSecondStat> perSecondStats = perSecondStatsForEachCamera.ElementAt(i - 1);
                foreach (DatabasePerSecondStat perSecondStat in perSecondStats)
                {
                    string[] row = new string[perSecondStatsForEachCamera.Count + 1];
                    row[0] = perSecondStat.DateTime.ToString("o");
                    row[i] = perSecondStat.NumDetectedObjects.ToString();
                    perSecondStatsFormattedStrings.Add(row);
                }
            }

            graphStatistics.Stats          = perSecondStatsFormattedStrings.ToArray();
            graphStatistics.SelectedPeriod = pastPeriod;
            return(graphStatistics);
        }
Exemplo n.º 3
0
        private AlertTriggeredEmailInformation GetAlertTriggeredInformation(DatabaseAlert alert,
                                                                            DatabasePerSecondStat earliestStatThatTriggersAlert, DatabaseUser user)
        {
            DatabaseCamera camera = _databaseQueryService.GetCameraById(alert.CameraId);
            AlertTriggeredEmailInformation alertEmailInformation = new AlertTriggeredEmailInformation
            {
                CameraName    = camera.CameraName,
                AlertName     = alert.AlertName,
                DateTriggered = earliestStatThatTriggersAlert.DateTime
            };

            alertEmailInformation.Name = GetUserName(user);

            if (camera.LocationId != null)
            {
                alertEmailInformation.LocationName = _databaseQueryService.GetLocationById(camera.LocationId.Value).LocationName;
            }

            return(alertEmailInformation);
        }
Exemplo n.º 4
0
        public CameraInformation getCameraInformationById(int cameraId)
        {
            DatabaseCamera camera = _dbQueryService.GetCameraById(cameraId);

            return(new CameraInformation(camera));
        }