示例#1
0
        /// <summary>
        /// Checks if the cached config information is stale, and updates if it is.
        /// </summary>
        internal void UpdateConfigurationIfNecessary()
        {
            String strConfigEdition, strEdition;

            try
            {
                m_oCommand.GetCatalogEdition(out strConfigEdition, out strEdition);
            }
            catch (System.Net.WebException ex)
            {
                // --- Failed to get the configuration ---
                Status = ServerStatus.OffLine;
                GetDapError.Instance.Write("UpdateConfigurationIfNecessary, Get Catalog Edition (" + m_strUrl + ") - " + ex.Message);
                return;
            }
            catch (DapException ex)
            {
                // --- Failed to get the configuration ---
                Status = ServerStatus.OffLine;
                GetDapError.Instance.Write("UpdateConfigurationIfNecessary, Get Catalog Edition (" + m_strUrl + ") - " + ex.Message);
                return;
            }

            if (m_strCacheVersion != strConfigEdition)
            {
                UpdateConfiguration();
            }
        }
示例#2
0
        internal Server(string strDnsAddress, string strCacheDir, string strSecureToken, bool blEnabled)
#endif
        {
            m_blEnabled = blEnabled;
            string strEdition, strConfigEdition;

            m_strSecureToken = strSecureToken;

            // --- create the connection to the server ---

#if !DAPPLE
            m_oCommand = new Geosoft.Dap.Command(strDnsAddress, true, Geosoft.Dap.Command.Version.GEOSOFT_XML_1_1);

            m_strCacheRoot = string.Empty;
            GXNet.CSYS.IGetDirectory(GXNet.Constant.SYS_DIR_USER, ref m_strCacheRoot);
#else
            m_oCommand     = new Geosoft.Dap.Command(strDnsAddress, false, Geosoft.Dap.Command.Version.GEOSOFT_XML_1_1, WorldWind.Net.WebDownload.DownloadTimeout);
            m_strCacheRoot = strCacheDir;
#endif

            m_strUrl = strDnsAddress;

#if !DAPPLE
            // --- ensure this server is trusted ---

            GXNet.CDAP.SetAuthorization(m_strUrl, Geosoft.GXNet.Constant.GUI_AUTH_TRUST);
#endif
            try
            {
                m_oCatalogs = new CatalogCollection(this);

                if (m_blEnabled)
                {
                    ConfigureServer();

                    // --- If the edition change we need to reload the configuration ---
                    m_oCommand.GetCatalogEdition(out strConfigEdition, out strEdition);
                    if (m_strCacheVersion != strConfigEdition)
                    {
                        UpdateConfiguration();
                    }
                }
            }
            catch
            {
                // we want to support showing servers as offline in the tree (otherwise we may loose them with offline mode)
                m_eStatus = ServerStatus.OffLine;
            }
        }
示例#3
0
        /// <summary>
        ///     <para>Initializes an instance of the <see cref="Server"/> class.</para>
        /// </summary>
        /// <param name="oServerNode">
        /// </param>
        /// <exception cref="ArgumentNullException">
        ///     <para>The argument <paramref name="oServerNode"/> is <langword name="null"/>.</para>
        /// </exception>
        /// <exception cref="ArgumentOutOfRangeException">
        ///     <para>The argument <paramref name="oServerNode"/> is out of range.</para>
        /// </exception>
        internal Server(XmlNode oServerNode, string strSecureToken)
        {
            string  strEdition, strConfigEdition;
            XmlNode oAttr;

            m_strSecureToken = strSecureToken;

            m_strCacheRoot = string.Empty;
            GXNet.CSYS.IGetDirectory(GXNet.Constant.SYS_DIR_USER, ref m_strCacheRoot);

            if (oServerNode == null)
            {
                throw new ArgumentNullException("oServerNode");
            }
            if (oServerNode.Name != Constant.Xml.Tag.Server)
            {
                throw new ArgumentOutOfRangeException("oServerNode");
            }

            oAttr = oServerNode.Attributes.GetNamedItem(Constant.Xml.Attr.Name);
            if (oAttr == null)
            {
                throw new ApplicationException("Missing name attribute in server node");
            }
            m_strName = oAttr.Value;

            oAttr = oServerNode.Attributes.GetNamedItem(Constant.Xml.Attr.Url);
            if (oAttr == null)
            {
                throw new ApplicationException("Missing url attribute in server node");
            }
            m_strUrl = oAttr.Value;

            oAttr = oServerNode.Attributes.GetNamedItem(Constant.Xml.Attr.Status);
            if (oAttr == null)
            {
                throw new ApplicationException("Missing status attribute in server node");
            }
            m_eStatus = ParseStatus(oAttr.Value);

            oAttr = oServerNode.Attributes.GetNamedItem(Constant.Xml.Attr.Major_Version);
            if (oAttr == null)
            {
                throw new ApplicationException("Missing major version attribute in server node");
            }
            m_iMajorVersion = Int32.Parse(oAttr.Value);

            oAttr = oServerNode.Attributes.GetNamedItem(Constant.Xml.Attr.Minor_Version);
            if (oAttr == null)
            {
                throw new ApplicationException("Missing minor version attribute in server node");
            }
            m_iMinorVersion = Int32.Parse(oAttr.Value);

            oAttr = oServerNode.Attributes.GetNamedItem(Constant.Xml.Attr.CacheVersion);
            if (oAttr == null)
            {
                throw new ApplicationException("Missing cache version attribute in server node");
            }
            m_strCacheVersion = oAttr.Value;

            if (m_eStatus != ServerStatus.Disabled)
            {
                m_oCommand = new Geosoft.Dap.Command(m_strUrl, true, Geosoft.Dap.Command.Version.GEOSOFT_XML_1_1);

                // --- this is a 6.2 server, get decreased configuration parameters ---

                if (m_iMajorVersion < 6 || (m_iMajorVersion == 6 && m_iMinorVersion < 3))
                {
                    m_oCommand.ChangeVersion(Command.Version.GEOSOFT_XML_1_0);
                }

                // --- ensure this server is trusted ---

                GXNet.CDAP.SetAuthorization(m_strUrl, Geosoft.GXNet.Constant.GUI_AUTH_TRUST);

                try
                {
                    m_oCatalogs = new CatalogCollection(this);

                    ConfigureServer();

                    // --- If the edition change we need to reload the configuration ---
                    m_oCommand.GetCatalogEdition(out strConfigEdition, out strEdition);
                    if (m_strCacheVersion != strConfigEdition)
                    {
                        UpdateConfiguration();
                    }
                }
                catch
                {
                    // we want to support showing servers as offline in the tree (otherwise we may loose them with offline mode)
                    m_eStatus = ServerStatus.OffLine;
                }
            }
        }