using System; /// /// 数据持久化服务接口 /// 负责应用设置、用户数据、系统配置的保存和加载 /// public interface IDataPersistenceService : IService { /// /// 保存系统设置 /// bool SaveSettings(SystemSettings settings); /// /// 加载系统设置 /// SystemSettings LoadSettings(); /// /// 保存用户偏好设置 /// bool SaveUserPreferences(string userId, UserPreferences preferences); /// /// 加载用户偏好设置 /// UserPreferences LoadUserPreferences(string userId); /// /// 保存应用配置 /// bool SaveAppConfig(AppConfig config); /// /// 加载应用配置 /// AppConfig LoadAppConfig(); /// /// 导出数据到指定路径 /// bool ExportData(string filePath, ExportDataType dataType); /// /// 清除所有持久化数据 /// void ClearAllData(); } /// /// 系统设置数据结构 /// [System.Serializable] public class SystemSettings { public float brightness = 50f; public int volume = 50; public int muteDurationMinutes = 3; public DateTime systemTime = DateTime.MinValue; public bool useCustomSystemTime = false; public long customTimeOffsetTicks = 0; public NetworkConfig network = new NetworkConfig { Mode = NetworkMode.Dhcp, IPv4 = "", Mask = "", Gateway = "", Dns1 = "", Dns2 = "" }; public string version = "1.0.0"; public bool autoBackup = true; public int dataRetentionDays = 30; // 串口通信相关设置 public string serialPortName = "COM1"; public int serialBaudRate = 115200; public bool enableSerialCommunication = true; // BFI阈值设置 public float bfiLowThreshold = 30f; // BFI低值阈值,默认30 public float bfiHighThreshold = 70f; // BFI高值阈值,默认70 public int bfiAlarmPriority = 2; // BFI报警优先级,默认高优先级(2) public bool enableBFIAlarm = true; // 是否启用BFI报警,默认启用 } /// /// 用户偏好设置 /// [System.Serializable] public class UserPreferences { public string userId; public string theme = "default"; public bool soundEnabled = true; public float uiScale = 1.0f; public string language = "zh-CN"; public bool autoLogin = false; public DateTime lastLoginTime; } /// /// 应用配置 /// [System.Serializable] public class AppConfig { public string appName = "DCX系统"; public string companyName = "瑞懿为"; public bool debugMode = false; public int maxLogFiles = 10; public bool enableLogging = true; public string logLevel = "Info"; } /// /// 导出数据类型 /// public enum ExportDataType { Settings, UserData, AlarmRecords, PatientInfo, SystemLogs, All }