Beispiel #1
0
        // -------------------------------------------------------------------------------
        // LoadZoneTime
        // Returns the number of seconds this zone has been online
        // Usually only used for the main zone
        // -------------------------------------------------------------------------------
        public double LoadZoneTime(string zoneName)
        {
            TableNetworkZones row = FindWithQuery <TableNetworkZones>("SELECT * FROM " + nameof(TableNetworkZones) + " WHERE zone=?", zoneName);

            if (row != null)
            {
                return((DateTime.UtcNow - DateTime.Parse(row.online)).TotalSeconds);
            }

            return(Mathf.Infinity);
        }
Beispiel #2
0
        // -------------------------------------------------------------------------------
        // CheckZoneTimeout
        // -------------------------------------------------------------------------------
        public bool CheckZoneTimeout(string zoneName, float timeoutInterval)
        {
            TableNetworkZones row = FindWithQuery <TableNetworkZones>("SELECT * FROM " + nameof(TableNetworkZones) + " WHERE zone=?", zoneName);

            if (row != null)
            {
                double timePassed = (DateTime.UtcNow - row.online).TotalSeconds;

                // -- enough time passed = shutdown
                if (timePassed > timeoutInterval)
                {
                    return(true);
                }

                // -- if we reach this = do not shutdown
                return(false);
            }

            // -- in any other case = shutdown
            return(true);
        }