Ejemplo n.º 1
0
        /// <summary>Verify if a system is online or not.</summary>
        /// <param name="elementNumber">The system identifier to query.</param>
        /// <param name="IsOnline">[out] Online status on the train. In case of error, value is forced to false.</param>
        /// <returns>The success of the operation. Possible values are:
        /// <list type="table">
        /// <listheader><term>Error code</term><description>Description</description></listheader>
        /// <item><term>T2GManagerErrorEnum.eSuccess</term><description>Service retrieved successfully and it is available</description></item>
        /// <item><term>T2GManagerErrorEnum.eElementNotFound</term><description>Queried system is unknown.</description></item>
        /// <item><term>T2GManagerErrorEnum.eT2GServerOffline</term><description>T2G services are down.</description></item>
        /// </list>
        /// </returns>
        public T2GManagerErrorEnum IsElementOnline(string elementNumber, out bool isOnline)
        {
            T2GManagerErrorEnum lReturn = T2GManagerErrorEnum.eFailed;

            isOnline = false;

            if (T2GServerConnectionStatus)
            {
                // Get connection status of element first to improve speed when system is online.
                // Then, check if the element exist.
                isOnline = _localDataStorage.IsElementOnline(elementNumber);
                if (isOnline || _localDataStorage.ElementExists(elementNumber))
                {
                    lReturn = T2GManagerErrorEnum.eSuccess;
                }
                else
                {
                    lReturn = T2GManagerErrorEnum.eElementNotFound;
                }
            }
            else
            {
                lReturn = T2GManagerErrorEnum.eT2GServerOffline;
            }

            return(lReturn);
        }