Example #1
0
        public static string ReturnConfigurationSetting(ConfigurationKeys sConfigName)
        {
            // Given a configuration file key, return the value from the App.Config File

             AppSettingsReader appSettings = new AppSettingsReader();
             string configValue = appSettings.GetValue(sConfigName.ToString(), typeof(string)).ToString();

             return configValue;
        }
        /// <summary>
        /// WARNING: Elevated priviledges are required!! (Use within try-catch block)
        /// </summary>
        /// <param name="key">key to be retrieved || Constrained to enum</param>
        /// <param name="newValue"></param>
        public static void UpdateValue(ConfigurationKeys key, string newValue)
        {
            var branch = Registry.LocalMachine.OpenSubKey(REGISTRY_BRANCH, true);

            if (branch == null)
            {
                Registry.LocalMachine.CreateSubKey(REGISTRY_BRANCH);
                branch = Registry.LocalMachine.OpenSubKey(REGISTRY_BRANCH, true);
            }
            branch.SetValue(key.ToString(), newValue);
            branch.Close();
        }
 /// <summary>
 /// Return the selected configuration value
 /// </summary>
 /// <param name="key">key to be retrieved || Constrained to enum</param>
 /// <param name="defaultValue"></param>
 /// <returns>key value or empty string</returns>
 public static string GetValue(ConfigurationKeys key, string defaultValue = DEFAULT_STRING)
 {
     try
     {
         return(Registry.LocalMachine
                .OpenSubKey(REGISTRY_BRANCH, false)
                .GetValue(key.ToString(), defaultValue).ToString());
     }
     catch (Exception)
     {
         return(defaultValue);
     }
 }
Example #4
0
 public SystemConfigurationView GetConfig(int societyId, ConfigurationKeys key, DateTime StartDate,
                                          DateTime?EndDate)
 {
     return(_omnitureContext.SystemConfiguration.Where(t =>
                                                       t.ConfigKey.ToUpper() == key.ToString().ToUpper() &&
                                                       t.StartDate <= StartDate && (t.EndDate >= EndDate || t.EndDate == null)).Select(t => new SystemConfigurationView
     {
         ConfigKey = t.ConfigKey,
         ConfigValue = t.ConfigValue,
         DisplayName = t.DisplayName,
         AdditionalDetails = t.AdditionalDetails
     }).FirstOrDefault());
 }
Example #5
0
 public List <SystemConfigurationView> GetAllConfig(ConfigurationKeys key, DateTime StartDate,
                                                    DateTime?EndDate)
 {
     return(_omnitureContext.SystemConfiguration.Where(t =>
                                                       string.Equals(t.ConfigKey, key.ToString(), StringComparison.CurrentCultureIgnoreCase) &&
                                                       t.StartDate >= StartDate && (t.EndDate <= EndDate || t.EndDate == null)).Select(t => new SystemConfigurationView
     {
         ConfigKey = t.ConfigKey,
         ConfigValue = t.ConfigValue,
         DisplayName = t.DisplayName,
         AdditionalDetails = t.AdditionalDetails,
         StartDate = t.StartDate,
         EndDate = t.EndDate
     }).ToList());
 }
Example #6
0
 public SystemConfigurationView GetConfig(ConfigurationKeys key)
 {
     return(GetConfig(key.ToString()));
 }
Example #7
0
 public string GetConfigValue(ConfigurationKeys key)
 {
     return(GetConfigValue(key.ToString()));
 }