Exemplo n.º 1
0
        public void WriteString(string key, string value)
        {
            lock (_staticLock)
            {
                var    configFile = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
                var    settings   = configFile.AppSettings.Settings;
                string fileKey    = GetFileKey(key);
                if (settings[fileKey] == null)
                {
                    settings.Add(fileKey, value);
                }
                else
                {
                    if (settings[fileKey].Value == value)
                    {
                        return;
                    }
                    settings[fileKey].Value = value;
                }

                configFile.Save(ConfigurationSaveMode.Modified);
                ConfigurationManager.RefreshSection(configFile.AppSettings.SectionInformation.Name);

                ServiceSetting setting = ServiceSettings.GetServiceSetting(_loginUser, _serviceID, key, "");
                setting.SettingValue = value;
                setting.Collection.Save();
            }
        }
        public static string GetServiceSetting(RestCommand command, int serviceSettingID)
        {
            ServiceSetting serviceSetting = ServiceSettings.GetServiceSetting(command.LoginUser, serviceSettingID);

            if (serviceSetting.OrganizationID != command.Organization.OrganizationID)
            {
                throw new RestException(HttpStatusCode.Unauthorized);
            }
            return(serviceSetting.GetXml("ServiceSetting", true));
        }
Exemplo n.º 3
0
        public string ReadString(string key, string defaultValue)
        {
            string result = defaultValue;

            lock (_staticLock)
            {
                NameValueCollection settings = ConfigurationManager.AppSettings;
                result = settings[GetFileKey(key)];

                if (string.IsNullOrWhiteSpace(result))
                {
                    // look up in old system settings table, we can take out after all the services have been updated
                    result = ServiceSettings.GetServiceSetting(_loginUser, _serviceID, key, defaultValue).SettingValue;
                    WriteString(key, result);
                }
            }
            return(result);
        }