/// <summary>
        /// Loads the catalog details from configuration file.
        /// </summary>
        /// <remarks>
        /// The catalog details are loaded in the collection.
        /// Duplicate or invalid catalog are ignored.
        /// Invalid catalog includes catalogs with profiles information
        /// not present in profiles collection.
        /// </remarks>
        /// <param name="param1">the catalog configuration file</param>
        /// <param name="param2">the profiles collection</param>
        public void loadCatalogfromConfig(string filename, CswProfiles profileList)
        {
            try {
                XmlDocument doc = new XmlDocument();
                doc.Load(filename);
                XmlNodeList xmlnodes = doc.GetElementsByTagName("CSWCatalog");

                foreach (XmlNode xmlnode in xmlnodes)
                {
                    String url       = XmlDatatoString(xmlnode.SelectSingleNode("URL").InnerText);
                    String name      = XmlDatatoString(xmlnode.SelectSingleNode("Name").InnerText);
                    String profileID = xmlnode.SelectSingleNode("CSWProfile").InnerText;
                    if (profileList.ContainsKey(profileID))
                    {
                        CswProfile profile = (CswProfile)profileList[profileID];
                        CswCatalog catalog = new CswCatalog(url, name, profile);
                        this.AddCatalog(catalog.ID, catalog);
                    }
                }
            }
            catch (Exception ex) {
                throw ex;
            }
        }
        /// <summary>
        /// Constructor loads profile and catalogs
        /// </summary>
        private bool LoadCswSearchDialog()
        {
            // load CSW Profiles
            try
            {

                cswProfiles = _cswManager.loadProfile();

                if (cswProfiles == null) { throw new NullReferenceException(resourceManager.GetString("loadProfileFailed")); }

                // populate profiles
                profileList = CswObjectsToArrayList(cswProfiles);
                combProfile.BeginUpdate();
                combProfile.DataSource = profileList;
                combProfile.DisplayMember = "Name";
                combProfile.ValueMember = "ID";
                combProfile.SelectedIndex = -1;
                combProfile.EndUpdate();
            }
            catch (Exception ex)
            {
                MessageBox.Show(resourceManager.GetString("loadProfileFailed"), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return false;
            }

            // load CSW Catalogs
            try
            {
                cswCatalogs = _cswManager.loadCatalog();

                if (cswCatalogs == null) { throw new NullReferenceException("Failed to load catalogs. _cswCatalogs is null."); }

                ArrayList alCatalogs = CswObjectsToArrayList(cswCatalogs);
                cswCatalogCount = alCatalogs.Count;
                alCatalogs.Sort();
                lblCatalogs.Text = resourceManager.GetString("catalogsTxt") + " (" + alCatalogs.Count + ")";
                cmbCswCatalog.DataSource = alCatalogs;
                cmbCswCatalog.DisplayMember = "Name";
                cmbCswCatalog.ValueMember = "URL";
                //populate lst box for configure tab
                lstCatalog.DataSource = alCatalogs;
                lstCatalog.DisplayMember = "Name";
                lstCatalog.ValueMember = "ID";
                lstCatalog.SelectedIndex = cswCatalogs.Count - 1;
            }
            catch (Exception ex)
            {
                MessageBox.Show(resourceManager.GetString("loadCatalogFailed"), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return false;
            }

            return true;
        }
        /// <summary>
        /// Load components for Search Tab
        /// </summary>
        /// <returns>true if successful; false if error occurred. Exception shall be raised if there was any.</returns>
        private bool LoadSearchTab()
        {
            ResetSearchResultsGUI();

            // load CSW Profiles
            try
            {
                _cswProfiles = _cswManager.loadProfile();
                if (_cswProfiles == null) { throw new NullReferenceException(); }
            }
            catch (Exception ex)
            {
                throw new Exception(StringResources.LoadProfilesFailed + "\r\n" + ex.Message, ex);
            }

            // load CSW Catalogs
            try
            {
                _cswCatalogs = _cswManager.loadCatalog();
                if (_cswCatalogs == null) { throw new NullReferenceException(); }

                _catalogList = CswObjectsToArrayList(_cswCatalogs);
                catalogComboBox.BeginUpdate();
                catalogComboBox.DataSource = _catalogList;
                catalogComboBox.DisplayMember = "Name";
                catalogComboBox.ValueMember = "ID";
                catalogComboBox.SelectedIndex = -1;
                catalogComboBox.EndUpdate();
            }
            catch (Exception ex)
            {
                throw new Exception(StringResources.LoadCatalogsFailed + "\r\n" + ex.Message, ex);
            }

            return true;
        }
Example #4
0
       /// <summary>
       /// Loads the catalog details from configuration file. 
       /// </summary>
       /// <remarks>
       /// The catalog details are loaded in the collection.
       /// Duplicate or invalid catalog are ignored.
       /// Invalid catalog includes catalogs with profiles information
       /// not present in profiles collection.
       /// </remarks>
       /// <param name="param1">the catalog configuration file</param>
       /// <param name="param2">the profiles collection</param>
       public void loadCatalogfromConfig(string filename,CswProfiles profileList) {
           try {
               XmlDocument doc = new XmlDocument();
               doc.Load(filename);
               XmlNodeList xmlnodes = doc.GetElementsByTagName("CSWCatalog");

               foreach (XmlNode xmlnode in xmlnodes)
               {
                   String url = XmlDatatoString(xmlnode.SelectSingleNode("URL").InnerText);
                   String name = XmlDatatoString(xmlnode.SelectSingleNode("Name").InnerText);
                   String profileID = xmlnode.SelectSingleNode("CSWProfile").InnerText;
                   if (profileList.ContainsKey(profileID))
                   {
                       CswProfile profile = (CswProfile)profileList[profileID];
                       CswCatalog catalog = new CswCatalog(url, name, profile);
                       this.AddCatalog(catalog.ID, catalog);
                   }
               }
           }
           catch (Exception ex) {
               throw ex;
           }

       }