Example #1
0
        internal DapServerModelNode GetServer(DapServerUri oUri)
        {
            foreach (DapServerModelNode oServer in UnfilteredChildren)
            {
                if (oServer.Uri.Equals(oUri))
                {
                    return oServer;
                }
            }

            return null;
        }
Example #2
0
 internal DapServerModelNode(DappleModel oModel, DapServerUri oUri, bool blEnabled)
     : base(oModel, blEnabled)
 {
     m_oUri = oUri;
     m_strTitle = m_oUri.ServerTreeDisplayName;
 }
Example #3
0
 internal DapServerModelNode AddServer(DapServerUri oUri, bool blEnabled)
 {
     DapServerModelNode result = new DapServerModelNode(m_oModel, oUri, blEnabled);
     AddChild(result);
     if (blEnabled)
     {
         result.BeginLoad();
     }
     return result;
 }
Example #4
0
        internal ServerModelNode AddDAPServer(DapServerUri oUri, bool blEnabled, bool blUpdateHomeView, bool blSubmitToDappleSearch)
        {
            lock (m_oLock)
            {
                // --- Don't add
                if (oUri.IsForPersonalDAP)
                {
                    return m_oRootNode.PersonalDapServer;
                }

                // --- Don't add the server if it's already in the model ---

                ServerModelNode result = m_oRootNode.DAPServers.GetServer(oUri);
                if (result != null)
                {
                    return result;
                }

                // --- Add the server ---

                result = m_oRootNode.DAPServers.AddServer(oUri, blEnabled);

                // --- Update home view if necessary ---

                if (blUpdateHomeView)
                {
                    result.AddToHomeView();
                }

                // --- Submit to DappleSerach if necessary ---

                if (blSubmitToDappleSearch)
                {
                    SubmitServerToSearchEngine(oUri.ToBaseUri(), ServerModelNode.ServerType.DAP);
                }

                OnServerAdded(EventArgs.Empty);
                return result;
            }
        }
Example #5
0
        private ServerModelNode LoadBuilderEntryType(dappleview.builderentryType entry, Uri favouriteServerUri)
        {
            bool DontUpdateHomeView = false;
            bool DontSubmitToDappleSearch = false;
            ServerModelNode result = null;

            if (entry.Hasbuilderdirectory())
                for (int i = 0; i < entry.builderdirectory.builderentryCount; i++)
                {
                    ServerModelNode newServer = LoadBuilderEntryType(entry.builderdirectory.GetbuilderentryAt(i), favouriteServerUri);
                    if (newServer != null)
                    {
                        result = newServer;
                    }
                }
            else if (entry.Haswmscatalog())
            {
                ServerModelNode newServer = AddWMSServer(new WMSServerUri(entry.wmscatalog.capabilitiesurl.Value), entry.wmscatalog.Hasenabled() ? entry.wmscatalog.enabled.Value : true, DontUpdateHomeView, DontSubmitToDappleSearch);
                if (favouriteServerUri != null && newServer.Uri.ToBaseUri().Equals(favouriteServerUri.ToString()))
                {
                    result = newServer;
                }
            }
            else if (entry.Hasarcimscatalog())
            {
                ServerModelNode newServer = AddArcIMSServer(new ArcIMSServerUri(entry.arcimscatalog.capabilitiesurl.Value), entry.arcimscatalog.Hasenabled() ? entry.arcimscatalog.enabled.Value : true, DontUpdateHomeView, DontSubmitToDappleSearch);
                if (favouriteServerUri != null && newServer.Uri.ToBaseUri().Equals(favouriteServerUri.ToString()))
                {
                    result = newServer;
                }
            }
            else if (entry.Hasdapcatalog())
            {
                DapServerUri oUri = new DapServerUri(entry.dapcatalog.url.Value);
                if (!oUri.IsForPersonalDAP)
                {
                    ServerModelNode newServer = AddDAPServer(oUri, entry.dapcatalog.Hasenabled() ? entry.dapcatalog.enabled.Value : true, DontUpdateHomeView, DontSubmitToDappleSearch);
                    if (favouriteServerUri != null && newServer.Uri.ToBaseUri().Equals(favouriteServerUri.ToString()))
                    {
                        result = newServer;
                    }
                }
            }
            else if (entry.Hastileserverset())
            {
                LoadTileServerSet(entry.tileserverset);
            }

            return result;
        }
Example #6
0
 private static void AddDAPServer(XmlDocument doc, DapServerUri uri)
 {
     XmlElement oDAPRoot = doc.SelectSingleNode("/dappleview/servers/builderentry/builderdirectory[@specialcontainer=\"DAPServers\"]") as XmlElement;
     XmlElement oBuilderEntry = doc.CreateElement("builderentry");
     oDAPRoot.AppendChild(oBuilderEntry);
     XmlElement oDapCatalog = doc.CreateElement("dapcatalog");
     oDapCatalog.SetAttribute("url", uri.ToString());
     oDapCatalog.SetAttribute("enabled", "true");
     oBuilderEntry.AppendChild(oDapCatalog);
 }
Example #7
0
 private static void SetDAPServerEnabled(XmlDocument doc, DapServerUri uri, bool blValue)
 {
     foreach (XmlElement oDapCatalog in doc.SelectNodes("/dappleview/servers/builderentry/builderdirectory/builderentry/dapcatalog"))
     {
         if (new DapServerUri(oDapCatalog.GetAttribute("url")).ToString().Equals(uri.ToString()))
         {
             oDapCatalog.SetAttribute("enabled", blValue.ToString());
         }
     }
 }
Example #8
0
 private static void RemoveDAPServer(XmlDocument doc, DapServerUri uri)
 {
     foreach (XmlElement oDapCatalog in doc.SelectNodes("/dappleview/servers/builderentry/builderdirectory/builderentry/dapcatalog"))
     {
         if (new DapServerUri(oDapCatalog.GetAttribute("url")).ToString().Equals(uri.ToString()))
         {
             oDapCatalog.ParentNode.ParentNode.RemoveChild(oDapCatalog.ParentNode);
         }
     }
 }
Example #9
0
        private static bool ContainsDAPServer(XmlDocument doc, DapServerUri uri)
        {
            foreach (XmlAttribute oAttr in doc.SelectNodes("//dapcatalog/@url"))
            {
                if (new DapServerUri(oAttr.Value).ToString().Equals(uri.ToString()))
                {
                    return true;
                }
            }

            return false;
        }
Example #10
0
        private void butOK_Click(object sender, EventArgs e)
        {
            Uri oServerUrl = null;
            while (txtDapURL.Text.EndsWith("&")) txtDapURL.Text = txtDapURL.Text.Substring(0, txtDapURL.Text.Length - 1);

            if (txtDapURL.Text.Equals(DEFAULT_TEXT, StringComparison.InvariantCultureIgnoreCase))
            {
                Program.ShowMessageBox(
                    "Please enter a valid URL.",
                    "Add DAP Server",
                    MessageBoxButtons.OK,
                    MessageBoxDefaultButton.Button1,
                    MessageBoxIcon.Error);
                DialogResult = DialogResult.None;
                return;
            }
            if (!(Uri.TryCreate(txtDapURL.Text, UriKind.Absolute, out oServerUrl) || Uri.TryCreate("http://" + txtDapURL.Text, UriKind.Absolute, out oServerUrl)))
            {
                Program.ShowMessageBox(
                    "Please enter a valid URL.",
                    "Add DAP Server",
                    MessageBoxButtons.OK,
                    MessageBoxDefaultButton.Button1,
                    MessageBoxIcon.Error);
                DialogResult = DialogResult.None;
                return;
            }

            if (!oServerUrl.Scheme.Equals("http"))
            {
                Program.ShowMessageBox(
                    "Only web urls are permitted (must start with \"http://\")",
                    "Add DAP Server",
                    MessageBoxButtons.OK,
                    MessageBoxDefaultButton.Button1,
                    MessageBoxIcon.Error);
                DialogResult = DialogResult.None;
                return;
            }

            DapServerUri oUri = new DapServerUri(oServerUrl.ToString());
            if (oUri.IsForPersonalDAP)
            {
                Program.ShowMessageBox(
                    "Cannot add Desktop Cataloger to DAP server tree." + Environment.NewLine + "If \"My Data\" is not visible in the server tree, ensure that Desktop Cataloger is running, then restart Dapple.",
                    "Add DAP Server",
                    MessageBoxButtons.OK,
                    MessageBoxDefaultButton.Button1,
                    MessageBoxIcon.Error);
                DialogResult = DialogResult.None;
                return;
            }

            txtDapURL.Text = oServerUrl.ToString();
        }