Ejemplo n.º 1
0
        /// <summary>
        /// Retrieve all settings from DB
        /// </summary>
        /// <returns>Setting Key/Value</returns>
        public static NameValueCollection GetSettings()
        {
            int environmentId = APConvert.ToInt(ConfigurationManager.AppSettings[GlobalConstants.EnvironmentIDAppSettingName]);

            //Get Environment settings for specific Environment Id
            return(GetSettings(environmentId));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Get settings for Areas using Stored Procedure
        /// </summary>
        /// <param name="environmentId">Identity of Environment</param>
        /// <returns>Environment Setting Information</returns>
        private static EnvironmentSettingInformation GetSettingsForUI(int environmentId)
        {
            EnvironmentSettingInformation   settingInfo = new EnvironmentSettingInformation();
            Collection <ApplicationSetting> settings    = new Collection <ApplicationSetting>();

            //Get SQL Reader for a specific environment
            using (IDataReader reader = GetReadSettingsReader(environmentId))
            {
                while (reader.Read())                  //Read data set of settings information
                {
                    ApplicationSetting setting = new ApplicationSetting();
                    setting.Id    = APConvert.ToInt(reader[DataConstants.SpGetEnvironmentSettingsAppSettingID]);
                    setting.Key   = (APConvert.ToString(reader[DataConstants.SpGetEnvironmentSettingsKey])).Trim();
                    setting.Value = (APConvert.ToString(reader[DataConstants.SpGetEnvironmentSettingsValue])).Trim();
                    setting.Area  = (APConvert.ToString(reader[DataConstants.SpGetEnvironmentSettingsAreaName])).Trim();                    //Area name of the setting
                    setting.IsEnvironmentRelated = APConvert.ToBoolean(reader[DataConstants.SpGetEnvironmentSettingsIsEnvironmentRelated]); //Whether setting is Environment related or not
                    setting.IsReadOnly           = APConvert.ToBoolean(reader[DataConstants.SpGetEnvironmentSettingsIsReadOnly]);           //Whether setting is Read only or editable
                    settings.Add(setting);
                }
                reader.NextResult();
                if (reader.Read())                  //Get the environment name for the environment id from the databse SP
                {
                    settingInfo.EnvironmentName = reader[DataConstants.SpGetEnvironmentSettingsEnvironmentName].ToString();
                }
                else
                {
                    settingInfo.EnvironmentName = string.Empty;
                }
            }
            settingInfo.Settings = settings;
            return(settingInfo);
        }