/// <summary> /// Load the configuration /// </summary> protected void LoadConfiguration() { // --- Check to see if this is in the cache --- string strConfigurationFile = Path.Combine(m_strCacheDir, CONFIGURATION_FILE); XmlDocument oDoc; XmlNodeList oList; double dMaxX, dMaxY, dMinX, dMinY; string strMethod = string.Empty; string strDatum = string.Empty; string strProjection = string.Empty; string strLocalDatum = string.Empty; string strUnits = string.Empty; if (File.Exists(strConfigurationFile)) { oDoc = new XmlDocument(); oDoc.Load(strConfigurationFile); } else { try { oDoc = m_oCommand.GetConfiguration(null); oDoc.Save(strConfigurationFile); } catch (Exception) { // --- this server against a 6.2 server --- try { m_oCommand.ChangeVersion(Geosoft.Dap.Command.Version.GEOSOFT_XML_1_0); oDoc = m_oCommand.GetConfiguration(null); oDoc.Save(strConfigurationFile); } catch (Exception ex) { // --- verify this server is on-line, because if it is then it is an unsupported version --- m_eStatus = ServerStatus.OffLine; GetDapError.Instance.Write("Configure Server, Get Configuration (" + m_strUrl + ") - " + ex.Message); return; } } } oList = oDoc.SelectNodes("/" + Geosoft.Dap.Xml.Common.Constant.Tag.GEO_XML_TAG + "/" + Geosoft.Dap.Xml.Common.Constant.Tag.RESPONSE_TAG + "/" + Geosoft.Dap.Xml.Common.Constant.Tag.CONFIGURATION_TAG + "/" + Geosoft.Dap.Xml.Common.Constant.Tag.META_TAG); if (oList.Count == 0) { m_iMajorVersion = 6; m_iMinorVersion = 1; m_eStatus = ServerStatus.Unsupported; GetDapError.Instance.Write("Configure Server, Default AOI (" + m_strUrl + ")"); return; } m_oServerConfiguration = new Configuration(oList[0]); // --- get the server configuration edition --- m_oServerConfiguration.GetEdition(out m_strCacheVersion); // --- get the default aoi --- if (m_oServerConfiguration.GetDefaultAOI(out dMaxX, out dMaxY, out dMinX, out dMinY, out strProjection, out strDatum, out strMethod, out strUnits, out strLocalDatum)) { m_oServerBoundingBox.MaxX = dMaxX; m_oServerBoundingBox.MaxY = dMaxY; m_oServerBoundingBox.MinX = dMinX; m_oServerBoundingBox.MinY = dMinY; m_oServerBoundingBox.CoordinateSystem.Projection = strProjection; m_oServerBoundingBox.CoordinateSystem.Datum = strDatum; m_oServerBoundingBox.CoordinateSystem.Method = strMethod; m_oServerBoundingBox.CoordinateSystem.LocalDatum = strLocalDatum; m_oServerBoundingBox.CoordinateSystem.Units = strUnits; } m_strName = m_oServerConfiguration.GetServerName(); m_oServerConfiguration.GetVersion(out m_iMajorVersion, out m_iMinorVersion); // --- this is a 6.3 server, get increased configuration parameters --- if (m_iMajorVersion <= 6 && m_iMinorVersion <= 2) { m_oCommand.ChangeVersion(Geosoft.Dap.Command.Version.GEOSOFT_XML_1_0); } else if (m_iMajorVersion > 6 || (m_iMajorVersion == 6 && m_iMinorVersion >= 3)) { // --- Is this server Secure ? --- if (m_oServerConfiguration.bLogin()) { // --- Mark the server secure --- m_bLogin = true; SetServerToken(); } } }
/// <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; } } }