devicehive-.net /src/Server/DeviceHive.API/Controllers/CronController.cs

Language C# Lines 30
MD5 Hash 94157df84ff3b6cfbc04fda6630e8f8f
Repository https://github.com/oryol/devicehive-.net.git View Raw File
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;
using System.Web.Http.Description;
using DeviceHive.API.Filters;
using DeviceHive.API.Mapping;
using DeviceHive.Data.Model;
using Newtonsoft.Json.Linq;

namespace DeviceHive.API.Controllers
{
    [ApiExplorerSettings(IgnoreApi = true)]
    public class CronController : BaseController
    {
        [HttpGet]
        [HttpNoContentResponse]
        public void RefreshDeviceStatus()
        {
            var devices = DataContext.Device.GetOfflineDevices();
            foreach (var device in devices)
            {
                device.Status = "Offline";
                DataContext.Device.Save(device);
            }
        }
    }
}
Back to Top