using System; using System.Collections.Generic; using Haoliang.Models.Common; namespace Haoliang.Models.Models.System { /// /// Rule execution history /// public class RuleExecutionHistory { public int ExecutionId { get; set; } public int RuleId { get; set; } public string RuleName { get; set; } public string InputDataJson { get; set; } public string Result { get; set; } public bool Success { get; set; } public string ErrorMessage { get; set; } public TimeSpan ExecutionTime { get; set; } public DateTime ExecutionTimeUtc { get; set; } public string ExecutedBy { get; set; } public string Context { get; set; } } /// /// Cache statistics /// public class CacheStats { public long TotalItems { get; set; } public long HitCount { get; set; } public long MissCount { get; set; } public double HitRate => HitCount + MissCount > 0 ? (double)HitCount / (HitCount + MissCount) : 0; public long MemoryUsageBytes { get; set; } public DateTime LastCleared { get; set; } public Dictionary ItemsByType { get; set; } public Dictionary EvictionReasons { get; set; } } /// /// WebSocket statistics /// public class WebSocketStats { public DateTime Timestamp { get; set; } public int ConnectedClients { get; set; } public int TotalConnections { get; set; } public int DisconnectedClients { get; set; } public int ActiveStreams { get; set; } public long MessagesSent { get; set; } public long MessagesReceived { get; set; } public long BytesSent { get; set; } public long BytesReceived { get; set; } public Dictionary ClientsByType { get; set; } public Dictionary MessagesByType { get; set; } } /// /// System performance metrics /// public class PerformanceMetrics { public DateTime Timestamp { get; set; } public double CpuUsagePercent { get; set; } public double MemoryUsagePercent { get; set; } public double DiskUsagePercent { get; set; } public double NetworkUsageMbps { get; set; } public int ActiveThreads { get; set; } public int QueueLength { get; set; } public double ResponseTimeMs { get; set; } public double ThroughputPerSecond { get; set; } public Dictionary CustomMetrics { get; set; } } /// /// Device performance metrics /// public class DevicePerformanceMetrics { public int DeviceId { get; set; } public string DeviceName { get; set; } public DateTime Timestamp { get; set; } public double CpuUsagePercent { get; set; } public double MemoryUsagePercent { get; set; } public double TemperatureCelsius { get; set; } public double VibrationLevel { get; set; } public double PowerConsumptionKW { get; set; } public double ToolWearPercent { get; set; } public double SpindleRpm { get; set; } public double FeedRateMmMin { get; set; } public double PositionAccuracyMm { get; set; } public Dictionary CustomMetrics { get; set; } } /// /// Production quality metrics /// public class QualityMetrics { public int DeviceId { get; set; } public string DeviceName { get; set; } public DateTime PeriodStart { get; set; } public DateTime PeriodEnd { get; set; } public int TotalProduced { get; set; } public int TotalGood { get; set; } public int TotalRejected { get; set; } public decimal FirstPassYieldPercent { get; set; } public decimal ReworkRatePercent { get; set; } public decimal ScrapRatePercent { get; set; } public decimal QualityIndex { get; set; } public List Defects { get; set; } public List Inspections { get; set; } } /// /// Defect analysis /// public class DefectAnalysis { public string DefectType { get; set; } public int Count { get; set; } public decimal Percentage { get; set; } public decimal SeverityScore { get; set; } public List OccurrenceTimes { get; set; } public string RootCause { get; set; } public string CorrectiveAction { get; set; } public string Responsibility { get; set; } } /// /// Inspection record /// public class InspectionRecord { public int InspectionId { get; set; } public DateTime InspectionTime { get; set; } public string Inspector { get; set; } public string InspectionType { get; set; } public bool Passed { get; set; } public decimal Score { get; set; } public List FoundDefects { get; set; } public string Notes { get; set; } public string ImageUrl { get; set; } } /// /// Defect detail /// public class Defect { public string DefectType { get; set; } public string Location { get; set; } public decimal Severity { get; set; } public string Description { get; set; } public bool Critical { get; set; } } /// /// System health status /// public class SystemHealthStatus { public DateTime Timestamp { get; set; } public SystemHealth OverallHealth { get; set; } public Dictionary ComponentHealth { get; set; } public List ActiveAlerts { get; set; } public SystemUptime Uptime { get; set; } public Dictionary HealthChecks { get; set; } } /// /// Component health status /// public class ComponentHealth { public string ComponentName { get; set; } public HealthStatus Status { get; set; } public double PerformanceScore { get; set; } public double AvailabilityScore { get; set; } public double QualityScore { get; set; } public DateTime LastCheck { get; set; } public string Message { get; set; } public Dictionary Metrics { get; set; } } /// /// Health alert /// public class HealthAlert { public string AlertId { get; set; } public string Component { get; set; } public AlertSeverity Severity { get; set; } public string Message { get; set; } public DateTime OccurredAt { get; set; } public bool Resolved { get; set; } public DateTime? ResolvedAt { get; set; } public string Resolution { get; set; } } /// /// System uptime information /// public class SystemUptime { public DateTime StartTime { get; set; } public TimeSpan Uptime { get; set; } public int RestartCount { get; set; } public DateTime LastRestart { get; set; } public string LastRestartReason { get; set; } public Dictionary ComponentUptimes { get; set; } } /// /// User preferences /// public class UserPreferences { public string UserId { get; set; } public string Language { get; set; } public string Theme { get; set; } public string TimeZone { get; set; } public bool EmailNotifications { get; set; } public bool SMSNotifications { get; set; } public bool PushNotifications { get; set; } public List DashboardLayout { get; set; } public List FavoriteReports { get; set; } public Dictionary CustomSettings { get; set; } public DateTime LastUpdated { get; set; } } /// /// Audit log entry /// public class AuditLog { public int AuditId { get; set; } public DateTime Timestamp { get; set; } public string UserId { get; set; } public string UserName { get; set; } public string Action { get; set; } public string EntityType { get; set; } public int? EntityId { get; set; } public string Description { get; set; } public string IPAddress { get; set; } public string UserAgent { get; set; } public bool Success { get; set; } public string ErrorMessage { get; set; } public Dictionary OldValues { get; set; } public Dictionary NewValues { get; set; } } /// /// System backup information /// public class BackupInfo { public string BackupId { get; set; } public DateTime BackupTime { get; set; } public string BackupType { get; set; } public long SizeBytes { get; set; } public string Status { get; set; } public string Location { get; set; } public bool IsEncrypted { get; set; } public bool IsCompressed { get; set; } public List IncludedComponents { get; set; } public string VerificationHash { get; set; } public DateTime? NextScheduledBackup { get; set; } } #region Enums public enum SystemHealth { Healthy, Warning, Critical, Unknown } public enum HealthStatus { Healthy, Degraded, Warning, Critical, Unknown } public enum AlertSeverity { Low, Medium, High, Critical } #endregion }