/// <summary>
 /// Delete an exsisting Catalog from the configuration file.
 /// </summary>
 /// <remarks>
 /// The catalog details are deleted from the collection.
 /// The catalog details are also deleted from the configuration file.
 /// </remarks>
 /// <param name="param1">CswCatalog</param>
 /// <param name="param2">the catalog configuration file</param>
 public void deleteCatalogfromConfig(CswCatalog catalog, string filename)
 {
     try {
         this.Remove(catalog.ID);
         updatetoFile(filename);
     }
     catch (Exception ex) {
         throw ex;
     }
 }
 /// <summary>
 /// Add a new Catalog to the collection.
 /// The catalog details are also added to the configuration to the file.
 /// </summary>
 /// <remarks>
 /// The catalog details are added in the collection.
 /// The catalog details are also appended in the configuration file.
 /// </remarks>
 /// <param name="param1">CswCatalog</param>
 /// <param name="param2">the catalog configuration file</param>
 public void AddCatalogtoConfig(CswCatalog catalog, string filename)
 {
     try {
         this.AddCatalog(catalog.ID, catalog);
         updatetoFile(filename);
     }
     catch (Exception e) {
         throw e;
     }
 }
 /// <summary>
 /// Update the name of an exsisting Catalog.
 /// The name is also updated in the configuration file.
 /// </summary>
 /// <remarks>
 /// The catalog name is updated from the collection.
 /// The catalog name is also updated from the configuration file.
 /// </remarks>
 /// <param name="param1">CswCatalog</param>
 /// <param name="param2">The string name</param>
 /// <param name="param2">The string updated url</param>
 ///  <param name="param2">The string name</param>
 /// <param name="param3">the catalog configuration file</param>
 public void updateCatalogNameinConfig(CswCatalog catalog, string displayname, string surl, CswProfile profile, string filename)
 {
     try {
         CswCatalog updatedcatalog = (CswCatalog)this[catalog.ID.ToString()];
         updatedcatalog.Name    = displayname;
         updatedcatalog.URL     = surl;
         updatedcatalog.Profile = profile;
         updatetoFile(filename);
     }
     catch (Exception ex) {
         throw ex;
     }
 }
 /// <summary>
 /// Update the file with the collection details.
 /// The catalog details are also added to the configuration to the file.
 /// </summary>
 /// <remarks>
 /// The catalog details are populated from  the collection.
 /// The catalog details are added to the configuration file.
 /// </remarks>
 /// <param name="param1">the catalog configuration filename</param>
 private void updatetoFile(string filename)
 {
     try
     {
         XmlDocument xmlDoc  = new XmlDocument();
         XmlNode     xmlnode = xmlDoc.CreateNode(XmlNodeType.XmlDeclaration, "", "");
         XmlElement  root    = xmlDoc.CreateElement("CSWCatalogs");
         xmlDoc.AppendChild(root);
         if (this.Count > 0)
         {
             for (int i = 0; i < this.Count; i++)
             {
                 CswCatalog newcatalog      = this[i];
                 XmlElement childNode       = xmlDoc.CreateElement("CSWCatalog");
                 XmlElement urlNode         = xmlDoc.CreateElement("URL");
                 XmlElement nameNode        = xmlDoc.CreateElement("Name");
                 XmlElement profileNode     = xmlDoc.CreateElement("CSWProfile");
                 XmlElement lockNode        = xmlDoc.CreateElement("Lock");
                 XmlElement credentialsNode = xmlDoc.CreateElement("Credentials");
                 XmlElement userNode        = xmlDoc.CreateElement("Username");
                 XmlElement passwdNode      = xmlDoc.CreateElement("Password");
                 XmlNode    rootnode        = xmlDoc.DocumentElement;
                 credentialsNode.AppendChild(userNode);
                 credentialsNode.AppendChild(passwdNode);
                 childNode.AppendChild(urlNode);
                 childNode.AppendChild(nameNode);
                 childNode.AppendChild(profileNode);
                 childNode.AppendChild(lockNode);
                 childNode.AppendChild(credentialsNode);
                 rootnode.AppendChild(childNode);
                 //setting values
                 urlNode.InnerText     = XmlEscape(newcatalog.URL.Trim());
                 nameNode.InnerText    = XmlEscape(newcatalog.Name.Trim());
                 profileNode.InnerText = newcatalog.Profile.ID;
                 lockNode.InnerText    = newcatalog.Locking.ToString();
             }
             xmlDoc.Save(filename);
         }
         else
         {
             System.IO.File.Delete(filename);
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
        /// <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;
            }
        }
예제 #6
0
        /// <summary>
        /// Event handler for configure tab save  button.
        /// </summary>
        /// <param name="sender">The sender object</param>
        /// <param name="e">The event arguments</param>
        private void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                if (newClicked == true)
                {
                    newClicked = false;
                    CswProfile profile = combProfile.SelectedItem as CswProfile;
                    string url = "";
                    url = txtURL.Text.Trim();
                    string name = "";
                    name = txtDisplayName.Text.Trim();
                    if (url.Length == 0)
                    {
                        MessageBox.Show(resourceManager.GetString("urlEmptyError"), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                    else
                    {
                        CswCatalog catalog = new CswCatalog(url, name, profile);
                        _cswManager.addCatalog(catalog);
                        MessageBox.Show(resourceManager.GetString("catalogAdded"), "Success", MessageBoxButtons.OK, MessageBoxIcon.None);
                        cleardata();
                        adddata();
                        catalog.resetConnection();
                        lblCatalogs.Text = resourceManager.GetString("catalogsTxt") + " (" + lstCatalog.Items.Count + ")";
                        _isCatalogListDirty = true;
                    }
                }
                else if (lstCatalog.SelectedItem == null)
                {
                    MessageBox.Show(resourceManager.GetString("resultNotSelected"));
                }
                else
                {
                    CswCatalog catalog = (CswCatalog)lstCatalog.SelectedItem;
                    int index = lstCatalog.SelectedIndex;
                    CswProfile profile = combProfile.SelectedItem as CswProfile;
                    _cswManager.updateCatalog(catalog, txtDisplayName.Text, txtURL.Text, profile);
                    cleardata();
                    adddata();
                    catalog.resetConnection();
                    lstCatalog.SelectedIndex = index;
                    MessageBox.Show(resourceManager.GetString("dataSaved"), "Success", MessageBoxButtons.OK, MessageBoxIcon.None);
                    _isCatalogListDirty = true;
                }

            }
            catch (Exception ex)
            {
                MessageBox.Show(resourceManager.GetString("dataSavedFailed"), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);

            }
        }
        /// <summary>
        /// Save/Update a catalog
        /// </summary>
        /// <param name="sender">event sender</param>
        /// <param name="e">event args</param>
        private void SaveCatalogButton_Click(object sender, EventArgs e)
        {
            try
            {
                if (_newClicked == true)
                {
                    CswProfile profile = catalogProfileComboBox.SelectedItem as CswProfile;

                    string url = "";
                    url = catalogUrlTextBox.Text.Trim();
                    string name = "";
                    name = catalogDisplayNameTextBox.Text.Trim();
                    if (url.Length == 0)
                    {
                        ShowErrorMessageBox(StringResources.UrlIsEmpty);
                    }
                    else
                    {
                        CswCatalog catalog = new CswCatalog(url, name, profile);
                        catalog.resetConnection();
                        _cswManager.addCatalog(catalog);
                        ClearData();
                        AddData();
                        catalogListBox.SelectedIndex = catalogListBox.Items.IndexOf(catalog);
                        _newClicked = false;
                        MessageBox.Show(StringResources.CatalogAddedSuccessfully, StringResources.Success, MessageBoxButtons.OK, MessageBoxIcon.None);
                    }
                }
                else if (catalogListBox.SelectedItem == null)
                {
                    MessageBox.Show(StringResources.SelectAnItemToUpdate);
                }
                else
                {
                    CswCatalog catalog = (CswCatalog)catalogListBox.SelectedItem;
                    int index = catalogListBox.SelectedIndex;
                    CswProfile profile = catalogProfileComboBox.SelectedItem as CswProfile;
                    _cswManager.updateCatalog(catalog, catalogDisplayNameTextBox.Text, catalogUrlTextBox.Text, profile);
                    catalog.resetConnection();
                    ClearData();
                    AddData();
                    catalogListBox.SelectedIndex = index;
                    MessageBox.Show(StringResources.CatalogSavedSuccessfully, StringResources.Success, MessageBoxButtons.OK, MessageBoxIcon.None);
                }
                _isCatalogListDirty = true;

            }
            catch (Exception ex)
            {
                ShowErrorMessageBox(ex.Message);
            }
            finally
            {
                UpdateCatalogListLabel();
            }
        }
예제 #8
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;
           }

       }
예제 #9
0
  /// <summary>
  /// Update the name of an exsisting Catalog. 
  /// The name is also updated in the configuration file.
  /// </summary>
  /// <remarks>
  /// The catalog name is updated from the collection.
  /// The catalog name is also updated from the configuration file.
  /// </remarks>
  /// <param name="param1">CswCatalog</param>
  /// <param name="param2">The string name</param>
  /// <param name="param2">The string updated url</param>
  ///  <param name="param2">The string name</param>
  /// <param name="param3">the catalog configuration file</param>
 public void updateCatalogNameinConfig(CswCatalog catalog, string displayname, string surl,CswProfile profile,string filename) {
     try {
         CswCatalog updatedcatalog = (CswCatalog)this[catalog.ID.ToString()];
         updatedcatalog.Name = displayname;
         updatedcatalog.URL =surl;
         updatedcatalog.Profile = profile;
         updatetoFile(filename);
     }
     catch (Exception ex) {
         throw ex;
     }
 }
예제 #10
0
 /// <summary>
 /// Delete an exsisting Catalog from the configuration file. 
 /// </summary>
 /// <remarks>
 /// The catalog details are deleted from the collection.
 /// The catalog details are also deleted from the configuration file.
 /// </remarks>
 /// <param name="param1">CswCatalog</param>
 /// <param name="param2">the catalog configuration file</param>
 public void deleteCatalogfromConfig(CswCatalog catalog,string filename) {
     try {
         this.Remove(catalog.ID);
         updatetoFile(filename);
     }
     catch (Exception ex) {
         throw ex;
     }
 }
예제 #11
0
        /// <summary>
        /// Add a new Catalog to the collection. 
        /// The catalog details are also added to the configuration to the file.
        /// </summary>
        /// <remarks>
        /// The catalog details are added in the collection.
        /// The catalog details are also appended in the configuration file.
        /// </remarks>
        /// <param name="param1">CswCatalog</param>
        /// <param name="param2">the catalog configuration file</param>
        public void AddCatalogtoConfig(CswCatalog catalog,string filename) {
            try {
                this.AddCatalog(catalog.ID, catalog);
                updatetoFile(filename); 
            }
            catch (Exception e) {
                throw e;
            }

        }
예제 #12
0
       /// <summary>
        /// Add a key value pair to catalog collection. 
        /// </summary>
        /// <remarks>
        /// Add to catalog collection.
        /// </remarks>
        /// <param name="param1">The key which is the url hashcode for the catalog</param>
        /// <param name="param2">the catalog object</param>

        public void AddCatalog(object key, CswCatalog catalog) {
            base.Add(key, catalog);
        }
        /// <summary>
        /// Add a key value pair to catalog collection.
        /// </summary>
        /// <remarks>
        /// Add to catalog collection.
        /// </remarks>
        /// <param name="param1">The key which is the url hashcode for the catalog</param>
        /// <param name="param2">the catalog object</param>

        public void AddCatalog(object key, CswCatalog catalog)
        {
            base.Add(key, catalog);
        }
예제 #14
0
        /// <summary>
        /// Add a new Catalog to the configuration file. 
        /// </summary>
        /// <remarks>
        /// The catalog details are added in the collection.
        /// The catalog details are also appended in the configuration file.
        /// </remarks>
        /// <param name="catalog">CswCatalog</param>
        public void addCatalog(CswCatalog catalog)
        {

            if (!isUserCatalogExists())
            {
                createUserCatalogFile();
            }

            catalogList.AddCatalogtoConfig(catalog, USER_CATALOGFILE);
        }
예제 #15
0
        /// <summary>
        /// Update the name of an exsisting Catalog. 
        /// </summary>
        /// <remarks>
        /// The catalog name is updated from the collection.
        /// The catalog name is also updated from the configuration file.
        /// </remarks>
        /// <param name="catalog">CswCatalog</param>
        /// <param name="name">The string display name</param>
        /// <param name="url">The string url</param>
        /// <param name="name">The profile</param>
        public void updateCatalog(CswCatalog catalog, String displayname, String url, CswProfile profile)
        {

            if (!isUserCatalogExists())
            {
                createUserCatalogFile();

            }

            catalogList.updateCatalogNameinConfig(catalog, displayname, url, profile, USER_CATALOGFILE);

        }
예제 #16
0
        /// <summary>
        /// Delete an exsisting Catalog from the configuration file. 
        /// </summary>
        /// <remarks>
        /// The catalog details are deleted from the collection.
        /// The catalog details are also deleted from the configuration file.
        /// </remarks>
        /// <param name="catalog">CswCatalog</param>
        public void deleteCatalog(CswCatalog catalog)
        {

            if (!isUserCatalogExists())
            {
                addCatalog(catalog);
                // catalogList.deleteCatalogfromConfig(catalog, DEFAULT_CATALOGFILE);
            }
            // else
            //   {
            catalogList.deleteCatalogfromConfig(catalog, USER_CATALOGFILE);
            //   }                        
        }