Esempio n. 1
0
        public PartialViewResult GetPluginSettings(long projectId, long pluginId)
        {
            var settings = _apiService
                           .GetPluginSettingsForProject(pluginId, projectId)
                           .Select(_ => _.ToModel())
                           .ToList();

            var model = new PluginSettingsModel
            {
                PluginId  = pluginId,
                ProjectId = projectId,
                Settings  = settings
            };

            return(PartialView(model));
        }
Esempio n. 2
0
        public ActionResult SavePluginSettings(PluginSettingsModel model)
        {
            _apiService.UpdatePluginSettings(
                model.ProjectId,
                model.PluginId,
                new UpdateProjectPluginSettingsDto
            {
                Settings = model.Settings
                           .Select(s => new UpdateProjectPluginSettingDto
                {
                    SettingId = s.SettingId,
                    Value     = s.Value
                })
                           .ToArray()
            });

            return(RedirectToAction("Edit", new { projectId = model.ProjectId }));
        }
Esempio n. 3
0
        public static T Create <T>
            (string pluginId)
            where T : PluginSettingsModel
        {
            PluginSettingsModel rtnModel  = new PluginSettingsModel();
            string pluginDir              = Path.Combine(PluginPathProvider.PluginsRootPath(), pluginId);
            string pluginSettingsFilePath = Path.Combine(pluginDir, SettingsFile);

            if (!File.Exists(pluginSettingsFilePath))
            {
                return(null);
            }
            try
            {
                string settingsStr = File.ReadAllText(pluginSettingsFilePath, Encoding.UTF8);
                rtnModel = System.Text.Json.JsonSerializer.Deserialize <T>(settingsStr);
            }
            catch (Exception ex)
            {
                rtnModel = null;
            }

            return(rtnModel as T);
        }