Beispiel #1
0
        private void ActulizarControl(ControlNotification result)
        {
            var oldItems = dataAccess.GetList <ControlNotification>();

            oldItems.ForEach(s => dataAccess.Delete(s));
            dataAccess.Insert(result);
        }
Beispiel #2
0
        public void HandleIncominEvent_ControlStreamingResumed_ShouldNotDispatchEvent()
        {
            // Arrange.
            _pushEnabled = null;

            var occupancyNoti = new OccupancyNotification
            {
                Channel = "control_pri",
                Metrics = new OccupancyMetricsData {
                    Publishers = 0
                },
                Type = NotificationType.OCCUPANCY
            };

            var notification = new ControlNotification
            {
                Channel     = "control_pri",
                ControlType = ControlType.STREAMING_RESUMED,
                Type        = NotificationType.CONTROL
            };

            // Act.
            _notificationManagerKeeper.HandleIncomingEvent(occupancyNoti);
            _notificationManagerKeeper.HandleIncomingEvent(notification);

            // Assert.
            Assert.IsFalse(_pushEnabled.Value);
        }
Beispiel #3
0
        public void HandleIncominEvent_ControlStreamingResumed_ShouldNotDispatchEvent()
        {
            // Arrange.
            _event = null;

            var occupancyNoti = new OccupancyNotification
            {
                Channel = "control_pri",
                Metrics = new OccupancyMetricsData {
                    Publishers = 0
                },
                Type = NotificationType.OCCUPANCY
            };

            var notification = new ControlNotification
            {
                Channel     = "control_pri",
                ControlType = ControlType.STREAMING_RESUMED,
                Type        = NotificationType.CONTROL
            };

            // Act & Assert.
            _notificationManagerKeeper.HandleIncomingEvent(occupancyNoti);
            Assert.AreEqual(SSEClientActions.SUBSYSTEM_DOWN, _event.Action);

            _event = null;
            _notificationManagerKeeper.HandleIncomingEvent(notification);
            Assert.IsNull(_event);
        }
Beispiel #4
0
 public async void guardarSw(ControlNotification notificacionControl)
 {
     ActulizarControl(notificacionControl);
     if (netService.IsConected())
     {
         await apiService.APICosumePut($"api/ControlNotifications/{notificacionControl.device}", notificacionControl);
     }
 }
Beispiel #5
0
 public NotificationViewModel()
 {
     Title               = "Ahorro de energia";
     notificacion        = new Notification();
     notificacionControl = new ControlNotification();
     ShowLoading(true);
     CargarNotificacion();
     ShowLoading(false);
 }
Beispiel #6
0
        public async Task <ControlNotification> getControlNotification()
        {
            var controlN = dataAccess.GetList <ControlNotification>();

            if (controlN.Count > 0)
            {
                return(await Task.FromResult(controlN[0]));
            }
            else
            {
                if (netService.IsConected())
                {
                    Response r = new Response();
                    r = await apiService.APICosumeGetiD <ControlNotification>("api/ControlNotifications/" + GetId());

                    if (r.IsSucces)
                    {
                        if (r.Result == null)
                        {
                            var model = new ControlNotification
                            {
                                activo         = false,
                                device         = GetId(),
                                intervaloHoras = 3,
                            };
                            ActulizarControl(model);
                            await apiService.APICosumePost("api/ControlNotifications", model);

                            return(model);
                        }
                        else
                        {
                            ActulizarControl((ControlNotification)r.Result);
                            return((ControlNotification)r.Result);
                        }
                    }
                    else
                    {
                        var model = new ControlNotification
                        {
                            activo         = false,
                            device         = GetId(),
                            intervaloHoras = 3,
                        };
                        await apiService.APICosumePost("api/ControlNotifications", model);

                        return(model);
                    }
                }
                return(new ControlNotification
                {
                    activo = false,
                    device = GetId(),
                    intervaloHoras = 3,
                });
            }
        }
Beispiel #7
0
        public void HandleIncominEvent_ControlStreamingDisabled_ShouldDispatchEvent()
        {
            // Arrange.
            _event = null;

            var notification = new ControlNotification
            {
                Channel     = "control_pri",
                ControlType = ControlType.STREAMING_DISABLED,
                Type        = NotificationType.CONTROL
            };

            // Act.
            _notificationManagerKeeper.HandleIncomingEvent(notification);

            // Assert.
            Assert.IsNotNull(_event);
        }
Beispiel #8
0
        public void HandleIncominEvent_ControlStreamingResumed_ShouldDispatchEvent()
        {
            // Arrange.
            _pushEnabled = null;

            var notification = new ControlNotification
            {
                Channel     = "control_pri",
                ControlType = ControlType.STREAMING_RESUMED,
                Type        = NotificationType.CONTROL
            };

            // Act.
            _notificationManagerKeeper.HandleIncomingEvent(notification);

            // Assert.
            Assert.IsTrue(_pushEnabled.Value);
        }
Beispiel #9
0
        public void HandleIncominEvent_ControlStreamingResumed_ShouldDispatchEvent()
        {
            // Arrange.
            _event = null;

            var notification = new ControlNotification
            {
                Channel     = "control_pri",
                ControlType = ControlType.STREAMING_RESUMED,
                Type        = NotificationType.CONTROL
            };

            // Act.
            _notificationManagerKeeper.HandleIncomingEvent(notification);

            // Assert.
            Assert.AreEqual(SSEClientActions.SUBSYSTEM_READY, _event.Action);
        }
Beispiel #10
0
        private async void CargarNotificacion()
        {
            notificacionControl = await DataStoreNotification.getControlNotification();

            notificacion = await DataStoreNotification.getNotification();
        }