Exemplo n.º 1
0
        private Hashtable loadConfig(string fileName)
        {
            Hashtable ds = new Hashtable();

            try
            {
                XmlTextReader xmlr = new XmlTextReader(fileName);
                while (xmlr.Read())
                {
                    if (xmlr.Name == "add")
                    {
                        string infoKey = xmlr.GetAttribute("key");
                        if (infoKey != null && infoKey.StartsWith("Connection-"))
                        {
                            int           startDSName   = infoKey.IndexOf("-");
                            int           endDSName     = infoKey.IndexOf("-", startDSName + 1);
                            string        dataStoreName = infoKey.Substring(startDSName + 1, endDSName - startDSName - 1);
                            DataStoreInfo s             = (DataStoreInfo)(ds[dataStoreName]);
                            if (s == null)
                            {
                                s = new DataStoreInfo(dataStoreName);
                                ds.Add(dataStoreName, s);
                            }

                            if (infoKey.StartsWith("Connection-" + s.Name.Trim() + "-User"))
                            {
                                s.UserName = xmlr.GetAttribute("value");
                            }
                            if (infoKey.StartsWith("Connection-" + s.Name.Trim() + "-Password"))
                            {
                                s.UserPassword = xmlr.GetAttribute("value");
                            }
                            if (infoKey.StartsWith("Connection-" + s.Name.Trim() + "-DBMS"))
                            {
                                s.DBMS = xmlr.GetAttribute("value");
                            }
                            if (infoKey.StartsWith("Connection-" + s.Name.Trim() + "-Datasource"))
                            {
                                s.Datasource = xmlr.GetAttribute("value");
                            }
                            if (infoKey.StartsWith("Connection-" + s.Name.Trim() + "-DB"))
                            {
                                s.DBName = xmlr.GetAttribute("value");
                            }
                        }
                    }
                }
                xmlr.Close();
            }
            catch (FileNotFoundException)
            {
                MessageBox.Show(fileName + " not found.");
            }
            return(ds);
        }
Exemplo n.º 2
0
 private void saveCurrentDataStoreInfo()
 {
     if (currentlySelected.Length > 0)
     {
         DataStoreInfo dsi = (DataStoreInfo)(dataStores[currentlySelected]);
         if (dsi != null)
         {
             dsi.DBName       = encrypt(tbDB.Text);
             dsi.Datasource   = encrypt(tbDatasource.Text);
             dsi.UserName     = encrypt(tbUserName.Text);
             dsi.UserPassword = encrypt(tbUserPassword.Text);
         }
     }
 }