fix alert conditions check

This commit is contained in:
2026-08-28 17:10:13 +03:30
parent b6862aba02
commit 434f1dcba3
2 changed files with 10 additions and 4 deletions

View File

@@ -10,7 +10,7 @@ public sealed class AlertCondition
public Device Device { get; set; } = null!;
/// <summary>
/// نوع اعلان: Call = 0, SMS = 1
/// نوع اعلان: Call = -1, SMS = 0, Relay1..4 = 1..4
/// </summary>
public AlertNotificationType NotificationType { get; set; }
@@ -80,8 +80,12 @@ public sealed class AlertRule
public enum AlertNotificationType
{
Call = 0,
SMS = 1
Call = -1,
SMS = 0,
Relay1 = 1,
Relay2 = 2,
Relay3 = 3,
Relay4 = 4
}
public enum AlertTimeType

View File

@@ -74,7 +74,9 @@ public sealed class AlertService : IAlertService
// 4. Load enabled conditions
var conditions = await _dbContext.AlertConditions
.Include(c => c.Rules)
.Where(c => c.DeviceId == deviceId && c.IsEnabled)
.Where(c => c.DeviceId == deviceId && c.IsEnabled
&& (c.NotificationType == AlertNotificationType.SMS
|| c.NotificationType == AlertNotificationType.Call))
.ToListAsync(cancellationToken);
if (!conditions.Any())