Esempio n. 1
0
        public List <DatapointEvent> Refresh()
        {
            //this does not need lock, it's internal data structure, and this actually takes time
            bool fullRefresh = XMLAPIClient.FetchData();

            //this should be quick
            lock (RefreshLock)
            {
                BuildPrevDataPointsByISEID();

                if (fullRefresh)
                {
                    BuildDeviceList();
                    BuildRoomList();
                }
                else
                {
                    foreach (var cgi_dev in XMLAPIClient.StateList.Device)
                    {
                        Device d = null;
                        if (DevicesByISEID.TryGetValue(cgi_dev.Ise_id, out d))
                        {
                            d.FillFromStateList(cgi_dev);
                        }
                    }
                }
            }

            PingUnreachableDevices(1);
            return(GetEvents());
        }
Esempio n. 2
0
        public List <DatapointEvent> Refresh()
        {
            if (LegacyXMLAPIClient == null)
            {
                return(NewRefresh());
            }

            //this does not need lock, it's internal data structure, and this actually takes time
            var refreshTask = LegacyXMLAPIClient.FetchData();

            refreshTask.Wait();

            bool fullRefresh = refreshTask.Result;

            //this should be quick
            lock (RefreshLock)
            {
                BuildPrevDataPointsByISEID();

                if (fullRefresh)
                {
                    BuildDeviceList();
                    BuildRoomList();
                }
                else
                {
                    foreach (var cgi_dev in LegacyXMLAPIClient.StateList.Device)
                    {
                        Device d = null;
                        if (DevicesByISEID.TryGetValue(cgi_dev.Ise_id, out d))
                        {
                            d.FillFromStateList(cgi_dev);
                        }
                    }
                }
            }

            return(GetEvents());
        }