public IActionResult GetSingleDeviceSetup(int id)
        {
            var deviceSetup = _deviceSetupRepository.GetSingle(id);

            if (deviceSetup == null)
            {
                return(NotFound());
            }

            return(Ok(AutoMapper.Mapper.Map <DeviceSetupDto>(deviceSetup)));
        }
示例#2
0
        public void PollDevice(int deviceId)
        {
            //Execute this in Background, because it will take a while and the core might be blocked
            BackgroundJob.Enqueue(() => ExecutePollAction(deviceId));

            //if polling is not done by the device, to it using this website //todo: check if this is initiated, seems to be improper to be done in this method
            DeviceSetup deviceSetup = _deviceSetupRepository.GetSingle(deviceId);

            if (deviceSetup != null && !deviceSetup.PollingEnabled)
            {
                var minutes = deviceSetup.PostBackIntervalMinutes;
                RecurringJob.AddOrUpdate(_recurringDevicePollingTaskName, () => ExecutePollAction(deviceId),
                                         "*/" + minutes + " * * * *");
            }
        }
示例#3
0
        public IActionResult GetAllWateringAreas(int deviceId)
        {
            DeviceConfiguration device = _deviceSetupRepository.GetSingle(deviceId);

            if (device == null)
            {
                return(NotFound());
            }

            ICollection <WateringArea> wateringAreas = device.WateringAreas;

            if (wateringAreas == null || !wateringAreas.Any())
            {
                return(NotFound());
            }

            var mappedItems = wateringAreas.Select(AutoMapper.Mapper.Map <WateringAreaDto>);

            return(Ok(mappedItems));
        }