public void PerformScheduleTask(int deviceId, DeviceScheduleTask deviceScheduleTask) { var device = _aquariumDao.GetAquariumDeviceById(deviceId); _deviceClient.Configure(device); _deviceClient.PerformScheduleTask(deviceScheduleTask); }
public void PerformSnapshotTask(DeviceScheduleTask task) { _logger.LogInformation("Taking aquarium snapshot..."); var device = _aquariumAuthService.GetAquarium().Device; var cameraConfiguration = device.CameraConfiguration; var snapshot = TakeSnapshot(); var photo = TakePhoto(cameraConfiguration); SendAquariumSnapshotToHost(snapshot, photo); _logger.LogInformation("Aquarium snapshot sent successfully"); }
/* Tasks */ public void PerformTask(DeviceScheduleTask task) { if (_deviceTaskCallbacks.ContainsKey(task.TaskId)) { _deviceTaskCallbacks[task.TaskId](task); } else { throw new Exception($"Invalid task type id (taskId: {task.Id})"); } }
public IActionResult PerformTask([FromBody] DeviceScheduleTask deviceScheduleTask) { try { _scheduleService.PerformTask(deviceScheduleTask); return(new OkResult()); } catch (Exception ex) { _logger.LogError($"POST /v1/PerformTask endpoint caught exception: { ex.Message } Details: { ex.ToString() }"); return(BadRequest(ex.Message)); } }
public IActionResult PerformScheduleTask(int deviceId, [FromBody] DeviceScheduleTask deviceScheduleTask) { try { _logger.LogInformation($"POST /v1/Device/{deviceId}/Schedule/PerformTask called"); _aquariumService.PerformScheduleTask(deviceId, deviceScheduleTask); return(new OkResult()); } catch (Exception ex) { _logger.LogError($"POST /v1/Device/{deviceId}/Schedule/Status: { ex.Message } Details: { ex.ToString() }"); return(BadRequest(ex.Message)); } }
public void PerformScheduleTask(DeviceScheduleTask deviceScheduleTask) { var path = "/v1/Schedule/PerformTask"; using (var client = GetHttpClient()) { JsonSerializerSettings jss = new JsonSerializerSettings(); jss.ReferenceLoopHandling = ReferenceLoopHandling.Ignore; var config = Device.CameraConfiguration; //config.Device = null; var httpContent = new StringContent(JsonConvert.SerializeObject(deviceScheduleTask, jss), Encoding.UTF8, "application/json"); var result = client.PostAsync(path, httpContent).Result; if (!result.IsSuccessStatusCode) { var error = result.Content.ReadAsStringAsync().Result; throw new Exception(error); } } }