示例#1
0
        public bool UpdateConfigurationEntry(ConfigurationEntry entry)
        {
            //Create a new configuration entry
            bool updated = false;

            try {
                updated = executeNonQuery(USP_CONFIG_UPDATE, new object[] { entry.Application, entry.UserName, entry.Key, entry.Value, entry.Security });
            }
            catch (Exception ex) { throw new FaultException <ConfigurationFault>(new ConfigurationFault(new ApplicationException("Unexpected error while updating existing configuration entry.", ex))); }
            return(updated);
        }
示例#2
0
        public UserConfiguration GetUserConfiguration(string application, string[] usernames)
        {
            //Get configuration data for the specified application and usernames
            UserConfiguration config = null;

            try {
                //
                config = new UserConfiguration(application);
                AppConfigDS configDS = new AppConfigDS();
                DataSet     ds       = fillDataset(USP_CONFIG_GETLIST, TBL_CONFIGURATION, new object[] { application });
                if (ds != null)
                {
                    configDS.Merge(ds, true, MissingSchemaAction.Ignore);
                    for (int i = 0; i < configDS.ConfigTable.Rows.Count; i++)
                    {
                        ConfigurationEntry entry = new ConfigurationEntry(configDS.ConfigTable[i]);
                        if (!config.ContainsKey(entry.Key))
                        {
                            if (entry.UserName.ToLower() == UserConfiguration.USER_DEFAULT.ToLower())
                            {
                                config.Add(entry.Key, entry.Value);
                            }
                            else
                            {
                                for (int j = 0; j < usernames.Length; j++)
                                {
                                    if (entry.UserName.ToLower() == usernames[j].ToLower())
                                    {
                                        config.Add(entry.Key, entry.Value);
                                    }
                                }
                            }
                        }
                        else
                        {
                            for (int j = 0; j < usernames.Length; j++)
                            {
                                if (entry.UserName.ToLower() == usernames[j].ToLower())
                                {
                                    config[entry.Key] = entry.Value;
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex) { throw new FaultException <ConfigurationFault>(new ConfigurationFault(new ApplicationException("Unexpected error while reading the user configuration.", ex))); }
            return(config);
        }