private void ActulizarControl(ControlNotification result) { var oldItems = dataAccess.GetList <ControlNotification>(); oldItems.ForEach(s => dataAccess.Delete(s)); dataAccess.Insert(result); }
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); }
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); }
public async void guardarSw(ControlNotification notificacionControl) { ActulizarControl(notificacionControl); if (netService.IsConected()) { await apiService.APICosumePut($"api/ControlNotifications/{notificacionControl.device}", notificacionControl); } }
public NotificationViewModel() { Title = "Ahorro de energia"; notificacion = new Notification(); notificacionControl = new ControlNotification(); ShowLoading(true); CargarNotificacion(); ShowLoading(false); }
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, }); } }
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); }
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); }
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); }
private async void CargarNotificacion() { notificacionControl = await DataStoreNotification.getControlNotification(); notificacion = await DataStoreNotification.getNotification(); }