Example #1
0
        /// <summary> Save the individual user settings </summary>
        public static void Save()
        {
            // If this is the save after first launch, then include the new version number
            if (First_Launch)
            {
                Add_Setting("Settings_Version", "1.1");
            }

            // Clear existing Z39.50 endpints from the dataset
            DataTable z3950_table = dsSettings.Tables["Z3950_Endpoints"];

            z3950_table.Rows.Clear();

            // Get information for encrypting the password
            SecurityInfo securityInfo = new SecurityInfo();
            string       machine_name = (Environment.MachineName + "abcedefgh").Substring(0, 8);
            string       user         = (Environment.UserName.Replace("\\", "").Replace("//", "") + "abcedefgh").Substring(0, 8);

            // Copy each endpoint over into the dataset
            foreach (Z3950_Endpoint thisEndpoint in z3950_endpoints)
            {
                DataRow thisRow = z3950_table.NewRow();
                thisRow["Name"]          = thisEndpoint.Name;
                thisRow["URI"]           = thisEndpoint.URI;
                thisRow["Port"]          = thisEndpoint.Port;
                thisRow["Database_Name"] = thisEndpoint.Database_Name;
                thisRow["UserName"]      = thisEndpoint.Username;
                if ((thisEndpoint.Save_Password_Flag) && (thisEndpoint.Password.Length > 0))
                {
                    string password           = "******" + thisEndpoint.Password + "x";
                    string encrypted_password = securityInfo.EncryptString(password, machine_name, user);
                    thisRow["Password"] = encrypted_password;
                }
                z3950_table.Rows.Add(thisRow);
            }

            // Ask the base class to save the data
            Write_XML_File(SETTINGS_FILENAME);
        }