using System; using System.Collections.Generic; namespace JiShe.CollectBus.PluginFileWatcher { /// /// 文件监控程序的配置类 /// public class FileMonitorConfig { /// /// 基本配置 /// public GeneralConfig General { get; set; } = new GeneralConfig(); /// /// 文件过滤配置 /// public FileFiltersConfig FileFilters { get; set; } = new FileFiltersConfig(); /// /// 性能相关配置 /// public PerformanceConfig Performance { get; set; } = new PerformanceConfig(); /// /// 健壮性相关配置 /// public RobustnessConfig Robustness { get; set; } = new RobustnessConfig(); /// /// 事件存储和回放配置 /// public EventStorageConfig EventStorage { get; set; } = new EventStorageConfig(); /// /// 文件系统通知过滤器配置 /// public List NotifyFilters { get; set; } = new List(); /// /// 日志配置 /// public LoggingConfig Logging { get; set; } = new LoggingConfig(); } /// /// 常规配置 /// public class GeneralConfig { /// /// 是否启用文件过滤 /// public bool EnableFileFiltering { get; set; } = true; /// /// 内存监控间隔(分钟) /// public int MemoryMonitorIntervalMinutes { get; set; } = 1; /// /// 默认监控路径 /// public string DefaultMonitorPath { get; set; } = string.Empty; } /// /// 文件过滤配置 /// public class FileFiltersConfig { /// /// 允许监控的文件扩展名 /// public string[] AllowedExtensions { get; set; } = new[] { ".dll" }; /// /// 排除的目录 /// public string[] ExcludedDirectories { get; set; } = new[] { "bin", "obj", "node_modules" }; /// /// 是否包含子目录 /// public bool IncludeSubdirectories { get; set; } = true; } /// /// 性能相关配置 /// public class PerformanceConfig { /// /// 内存清理阈值(事件数) /// public int MemoryCleanupThreshold { get; set; } = 5000; /// /// 通道容量 /// public int ChannelCapacity { get; set; } = 1000; /// /// 事件去抖时间(秒) /// public int EventDebounceTimeSeconds { get; set; } = 3; /// /// 最大字典大小 /// public int MaxDictionarySize { get; set; } = 10000; /// /// 清理间隔(秒) /// public int CleanupIntervalSeconds { get; set; } = 5; /// /// 处理延迟(毫秒) /// public int ProcessingDelayMs { get; set; } = 5; } /// /// 健壮性相关配置 /// public class RobustnessConfig { /// /// 是否启用自动恢复机制 /// public bool EnableAutoRecovery { get; set; } = true; /// /// 监控器健康检查间隔(秒) /// public int WatcherHealthCheckIntervalSeconds { get; set; } = 30; /// /// 监控器无响应超时时间(秒) /// public int WatcherTimeoutSeconds { get; set; } = 60; /// /// 监控器重启尝试最大次数 /// public int MaxRestartAttempts { get; set; } = 3; /// /// 重启尝试之间的延迟(秒) /// public int RestartDelaySeconds { get; set; } = 5; /// /// 是否启用文件锁检测 /// public bool EnableFileLockDetection { get; set; } = true; /// /// 对锁定文件的处理策略: Skip(跳过), Retry(重试), Log(仅记录) /// public string LockedFileStrategy { get; set; } = "Retry"; /// /// 文件锁定重试次数 /// public int FileLockRetryCount { get; set; } = 3; /// /// 文件锁定重试间隔(毫秒) /// public int FileLockRetryDelayMs { get; set; } = 500; } /// /// 事件存储和回放配置 /// public class EventStorageConfig { /// /// 是否启用事件存储 /// public bool EnableEventStorage { get; set; } = true; /// /// 存储类型:SQLite 或 File /// public string StorageType { get; set; } = "SQLite"; /// /// 事件存储目录 /// public string StorageDirectory { get; set; } = "D:/EventLogs"; /// /// SQLite数据库文件路径 /// public string DatabasePath { get; set; } = "D:/EventLogs/events.db"; /// /// SQLite连接字符串 /// public string ConnectionString { get; set; } = "Data Source=D:/EventLogs/events.db"; /// /// 数据库命令超时(秒) /// public int CommandTimeout { get; set; } = 30; /// /// 事件日志文件名格式 (使用DateTime.ToString格式) /// public string LogFileNameFormat { get; set; } = "FileEvents_{0:yyyy-MM-dd}.json"; /// /// 存储间隔(秒),多久将缓存的事件写入一次存储 /// public int StorageIntervalSeconds { get; set; } = 60; /// /// 事件批量写入大小,达到此数量时立即写入存储 /// public int BatchSize { get; set; } = 100; /// /// 最大保留事件记录条数 /// public int MaxEventRecords { get; set; } = 100000; /// /// 数据保留天数 /// public int DataRetentionDays { get; set; } = 30; /// /// 最大保留日志文件数 /// public int MaxLogFiles { get; set; } = 30; /// /// 是否压缩存储的事件日志 /// public bool CompressLogFiles { get; set; } = true; /// /// 是否可以回放事件 /// public bool EnableEventReplay { get; set; } = true; /// /// 回放时间间隔(毫秒) /// public int ReplayIntervalMs { get; set; } = 100; /// /// 回放速度倍率,大于1加速,小于1减速 /// public double ReplaySpeedFactor { get; set; } = 1.0; } /// /// 日志相关配置 /// public class LoggingConfig { /// /// 日志级别:Verbose、Debug、Information、Warning、Error、Fatal /// public string LogLevel { get; set; } = "Information"; /// /// 是否记录文件事件处理详情 /// public bool LogFileEventDetails { get; set; } = false; /// /// 日志文件保留天数 /// public int RetainedLogDays { get; set; } = 30; /// /// 日志文件目录 /// public string LogDirectory { get; set; } = "Logs"; } }