using System; using System.Collections.Generic; using System.Linq; using System.Text; using Newtonsoft.Json; using Project; namespace Project.Web { public partial class MachineBridge { public string GetSettings() { try { return JsonConvert.SerializeObject(Pub.setting); } catch (Exception ex) { return JsonConvert.SerializeObject(new { Error = ex.Message }); } } public string SaveSettings(string jsonSettings) { try { if (string.IsNullOrEmpty(jsonSettings)) { return JsonConvert.SerializeObject(new { Success = false, Message = "Empty settings data" }); } var dict = JsonConvert.DeserializeObject>(jsonSettings); // Update properties using reflection or manual mapping // Since Setting class inherits arUtil.Setting and might have complex types, manual mapping for known properties or generic reflection is better. // For now, let's target 'Theme' specifically as requested, and generic handling for others if possible? // Actually, Pub.setting is an instance. We can try to deserialize INTO it, or update properties. if (dict.ContainsKey("Theme")) { Pub.setting.Theme = dict["Theme"]?.ToString(); } // Add other setting properties here as needed in the future // or implement a generic property updater Pub.setting.Save(); // Save to XML return JsonConvert.SerializeObject(new { Success = true }); } catch (Exception ex) { return JsonConvert.SerializeObject(new { Success = false, Message = ex.Message }); } } } }