Example #1
0
 public int CompareTo(object obj)
 {
     if (obj is CswCatalog)
     {
         CswCatalog catalog = (CswCatalog)obj;
         return(this.Name.CompareTo(catalog.Name));
     }
     throw new ArgumentException("object is not a CswCatalog");
 }
Example #2
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);
        }
 /// <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;
            }
        }
Example #8
0
        /// <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();
            }
        }
Example #9
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);

        }
Example #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="catalog">CswCatalog</param>
        public void deleteCatalog(CswCatalog catalog)
        {

            if (!isUserCatalogExists())
            {
                addCatalog(catalog);
                // catalogList.deleteCatalogfromConfig(catalog, DEFAULT_CATALOGFILE);
            }
            // else
            //   {
            catalogList.deleteCatalogfromConfig(catalog, USER_CATALOGFILE);
            //   }                        
        }
Example #11
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;
           }

       }
Example #12
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;
     }
 }
Example #13
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;
     }
 }
Example #14
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;
            }

        }
Example #15
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);
        }
Example #16
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);
        }