/// <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> /// 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; }
/// <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; } }