Exemplo n.º 1
0
 public virtual List <SettingDefinitionOutput> GetAllSettingDefinitionsForApplication()
 {
     return(_settingDefinitionManager.GetAllSettingDefinitions()
            .Where(x => x.Scopes.HasFlag(SettingScopes.Application))
            .Select(Convert)
            .ToList());
 }
Exemplo n.º 2
0
        private async Task <AbpUserSettingConfigDto> GetUserSettingConfig()
        {
            var config = new AbpUserSettingConfigDto
            {
                Values = new Dictionary <string, string>()
            };

            var settingDefinitions = _settingDefinitionManager
                                     .GetAllSettingDefinitions();

            using (var scope = _iocResolver.CreateScope())
            {
                foreach (var settingDefinition in settingDefinitions)
                {
                    if (!await settingDefinition.ClientVisibilityProvider.CheckVisible(scope))
                    {
                        continue;
                    }

                    var settingValue = await _settingManager.GetSettingValueAsync(settingDefinition.Name);

                    config.Values.Add(settingDefinition.Name, settingValue);
                }
            }

            return(config);
        }
Exemplo n.º 3
0
        public async Task <string> GetScriptAsync()
        {
            var script = new StringBuilder();

            script.AppendLine("(function(){");
            script.AppendLine("    CodeZero.setting = CodeZero.setting || {};");
            script.AppendLine("    CodeZero.setting.values = {");

            var settingDefinitions = _settingDefinitionManager
                                     .GetAllSettingDefinitions();

            var added = 0;

            using (var scope = _iocResolver.CreateScope())
            {
                foreach (var settingDefinition in settingDefinitions)
                {
                    if (!await settingDefinition.ClientVisibilityProvider.CheckVisible(scope))
                    {
                        continue;
                    }

                    if (added > 0)
                    {
                        script.AppendLine(",");
                    }
                    else
                    {
                        script.AppendLine();
                    }

                    var settingValue = await _settingManager.GetSettingValueAsync(settingDefinition.Name);

                    script.Append("        '" +
                                  settingDefinition.Name.Replace("'", @"\'") + "': " +
                                  (settingValue == null ? "null" : "'" + HttpEncode.JavaScriptStringEncode(settingValue) + "'"));

                    ++added;
                }
            }

            script.AppendLine();
            script.AppendLine("    };");

            script.AppendLine();
            script.Append("})();");

            return(script.ToString());
        }
        public async Task <SettingsOutput> GetSettingsOptions()
        {
            var settings     = _definitionManager.GetAllSettingDefinitions().Where(a => a.Scopes != SettingScopes.User);
            var settingsList = new List <SettingInputDto>();
            var output       = new SettingsOutput();

            foreach (var settingDefinition in settings)
            {
                var value = await _settingManager.GetSettingValueAsync(settingDefinition.Name);

                var setting = new SettingInputDto()
                {
                    Key                                               = settingDefinition.Name,
                    DisplayName                                       = settingDefinition.DisplayName != null?settingDefinition.DisplayName.Localize(_localizationContext) : settingDefinition.Name,
                                                         Value        = value,
                                                         DefaultValue = settingDefinition.DefaultValue,
                                                         Description  = settingDefinition.Description != null?settingDefinition.Description.Localize(_localizationContext) : "",
                                                                            SettingScopes = settingDefinition.Scopes
                };
                settingsList.Add(setting);
            }
            output.Settings = settingsList;
            return(output);
        }
Exemplo n.º 5
0
        public async Task <string> GetScriptAsync()
        {
            var script = new StringBuilder();

            script.AppendLine("(function(){");
            script.AppendLine("    abp.setting = abp.setting || {};");
            script.AppendLine("    abp.setting.values = {");

            var settingDefinitions = _settingDefinitionManager
                                     .GetAllSettingDefinitions()
                                     .Where(sd => sd.IsVisibleToClients);

            var added = 0;

            foreach (var settingDefinition in settingDefinitions)
            {
                if (added > 0)
                {
                    script.AppendLine(",");
                }
                else
                {
                    script.AppendLine();
                }

                var settingValue = await _settingManager.GetSettingValueAsync(settingDefinition.Name);

                script.Append("        '" +
                              settingDefinition.Name.Replace("'", @"\'") + "': " +
                              (settingValue == null ? "null" : "'" + settingValue.Replace(@"\", @"\\").Replace("'", @"\'") + "'"));

                ++added;
            }

            script.AppendLine();
            script.AppendLine("    };");

            script.AppendLine();
            script.Append("})();");

            return(script.ToString());
        }
Exemplo n.º 6
0
        private async Task <UserSettingConfigDto> GetUserSettingConfig()
        {
            var config = new UserSettingConfigDto
            {
                Values = new Dictionary <string, string>()
            };

            var settingDefinitions = _settingDefinitionManager
                                     .GetAllSettingDefinitions()
                                     .Where(sd => sd.IsVisibleToClients);

            foreach (var settingDefinition in settingDefinitions)
            {
                var settingValue = await _settingManager.GetSettingValueAsync(settingDefinition.Name);

                config.Values.Add(settingDefinition.Name, settingValue);
            }

            return(config);
        }
Exemplo n.º 7
0
        public string GetScript()
        {
            var script = new StringBuilder();

            script.AppendLine("(function(){");

            script.AppendLine("    abp.setting.values = {");

            var settingDefinitions = _settingDefinitionManager
                                     .GetAllSettingDefinitions()
                                     .Where(sd => sd.IsVisibleToClients);

            var added = 0;

            foreach (var settingDefinition in settingDefinitions)
            {
                if (added > 0)
                {
                    script.AppendLine(",");
                }
                else
                {
                    script.AppendLine();
                }

                script.Append("        '" + settingDefinition.Name.Replace("'", @"\'") + "': '" + _settingManager.GetSettingValue(settingDefinition.Name).Replace("'", @"\'") + "'");

                ++added;
            }

            script.AppendLine();
            script.AppendLine("    };");

            script.AppendLine();
            script.Append("})();");

            return(script.ToString());
        }