using Domain = GreenHome.Domain; namespace GreenHome.Application; // DTOs public sealed class DeviceDto { public int Id { get; set; } public string DeviceName { get; set; } = string.Empty; public int UserId { get; set; } public string UserName { get; set; } = string.Empty; public string UserFamily { get; set; } = string.Empty; public string UserMobile { get; set; } = string.Empty; public string Location { get; set; } = string.Empty; public string NeshanLocation { get; set; } = string.Empty; } public sealed class TelemetryDto { public int Id { get; set; } public int DeviceId { get; set; } public string DeviceName { get; set; } public DateTime TimestampUtc { get; set; } public decimal TemperatureC { get; set; } public decimal HumidityPercent { get; set; } public decimal SoilPercent { get; set; } public int GasPPM { get; set; } public decimal Lux { get; set; } public int PersianYear { get; set; } public int PersianMonth { get; set; } public string PersianDate { get; set; } = string.Empty; public DateTime ServerTimestampUtc { get; set; } } public sealed class TelemetryFilter { public int? DeviceId { get; set; } public DateTime? StartDateUtc { get; set; } public DateTime? EndDateUtc { get; set; } public int Page { get; set; } = 1; public int PageSize { get; set; } = 20; } public sealed class PagedResult { public required IReadOnlyList Items { get; init; } public required int TotalCount { get; init; } public required int Page { get; init; } public required int PageSize { get; init; } } public sealed class TelemetryMinMax { public decimal MinTemperatureC { get; set; } public decimal MaxTemperatureC { get; set; } public decimal MinHumidityPercent { get; set; } public decimal MaxHumidityPercent { get; set; } public decimal MinSoilPercent { get; set; } public decimal MaxSoilPercent { get; set; } public int MinGasPPM { get; set; } public int MaxGasPPM { get; set; } public decimal MinLux { get; set; } public decimal MaxLux { get; set; } } public sealed class DayCount { public string PersianDate { get; set; } = string.Empty; public int Count { get; set; } } public sealed class SendCodeRequest { public required string Mobile { get; set; } } public sealed class SendCodeResponse { public bool Success { get; set; } public string? Message { get; set; } public int ResendAfterSeconds { get; set; } = 120; } public sealed class VerifyCodeRequest { public required string Mobile { get; set; } public required string Code { get; set; } } public sealed class VerifyCodeResponse { public bool Success { get; set; } public string? Message { get; set; } public string? Token { get; set; } public UserDto? User { get; set; } } public sealed class UserDto { public int Id { get; set; } public string Mobile { get; set; } = string.Empty; public string Name { get; set; } = string.Empty; public string Family { get; set; } = string.Empty; public Domain.UserRole Role { get; set; } } public sealed class DeviceFilter { public int? UserId { get; set; } public string? Search { get; set; } // جستجو در نام دستگاه، نام صاحب، نام خانوادگی صاحب، Location public int Page { get; set; } = 1; public int PageSize { get; set; } = 10; } public sealed class DeviceSettingsDto { public int Id { get; set; } public int DeviceId { get; set; } public string DeviceName { get; set; } = string.Empty; public string Province { get; set; } = string.Empty; public string City { get; set; } = string.Empty; public decimal? Latitude { get; set; } public decimal? Longitude { get; set; } public string ProductType { get; set; } = string.Empty; public int MinimumSmsIntervalMinutes { get; set; } = 15; public int MinimumCallIntervalMinutes { get; set; } = 60; public decimal? AreaSquareMeters { get; set; } public int UploadIntervalMin { get; set; } = 5; public string DevicePhoneNumber { get; set; } = string.Empty; public Domain.SimCardType? SimCardType { get; set; } public string? TokenCode { get; set; } public string? VerificationCode { get; set; } public DateTime? TokenExpiresAt { get; set; } public DateTime CreatedAt { get; set; } public DateTime UpdatedAt { get; set; } } public sealed class AlertConditionDto { public int Id { get; set; } public int DeviceId { get; set; } public string DeviceName { get; set; } = string.Empty; public Domain.AlertNotificationType NotificationType { get; set; } public Domain.AlertTimeType TimeType { get; set; } public int CallCooldownMinutes { get; set; } = 60; public int SmsCooldownMinutes { get; set; } = 15; public bool IsEnabled { get; set; } = true; public DateTime CreatedAt { get; set; } public DateTime UpdatedAt { get; set; } public List Rules { get; set; } = new(); } public sealed class AlertRuleDto { public int Id { get; set; } public int AlertConditionId { get; set; } public Domain.SensorType SensorType { get; set; } public Domain.ComparisonType ComparisonType { get; set; } public decimal Value1 { get; set; } public decimal? Value2 { get; set; } public int Order { get; set; } } public sealed class CreateAlertConditionRequest { public required int DeviceId { get; set; } public required Domain.AlertNotificationType NotificationType { get; set; } public required Domain.AlertTimeType TimeType { get; set; } public int CallCooldownMinutes { get; set; } = 60; public int SmsCooldownMinutes { get; set; } = 15; public bool IsEnabled { get; set; } = true; public required List Rules { get; set; } } public sealed class CreateAlertRuleRequest { public required Domain.SensorType SensorType { get; set; } public required Domain.ComparisonType ComparisonType { get; set; } public required decimal Value1 { get; set; } public decimal? Value2 { get; set; } public int Order { get; set; } } public sealed class UpdateAlertConditionRequest { public required int Id { get; set; } public required Domain.AlertNotificationType NotificationType { get; set; } public required Domain.AlertTimeType TimeType { get; set; } public int CallCooldownMinutes { get; set; } = 60; public int SmsCooldownMinutes { get; set; } = 15; public bool IsEnabled { get; set; } = true; public required List Rules { get; set; } } public sealed class DailyReportRequest { public required int DeviceId { get; set; } public required string PersianDate { get; set; } // yyyy/MM/dd } public sealed class DailyReportResponse { public int Id { get; set; } public int DeviceId { get; set; } public string DeviceName { get; set; } = string.Empty; public string PersianDate { get; set; } = string.Empty; public string Analysis { get; set; } = string.Empty; public int RecordCount { get; set; } public int SampledRecordCount { get; set; } public int TotalTokens { get; set; } public DateTime CreatedAt { get; set; } public bool FromCache { get; set; } } public sealed class WeeklyAnalysisRequest { public required int DeviceId { get; set; } public required string StartDate { get; set; } // yyyy/MM/dd public required string EndDate { get; set; } // yyyy/MM/dd } public sealed class MonthlyAnalysisRequest { public required int DeviceId { get; set; } public required int Year { get; set; } public required int Month { get; set; } } public sealed class AlertLogDto { public int Id { get; set; } public int DeviceId { get; set; } public string DeviceName { get; set; } = string.Empty; public int UserId { get; set; } public string UserName { get; set; } = string.Empty; public string UserMobile { get; set; } = string.Empty; public int? AlertConditionId { get; set; } public Domain.AlertType AlertType { get; set; } public Domain.AlertNotificationType NotificationType { get; set; } public string Message { get; set; } = string.Empty; public Domain.AlertStatus Status { get; set; } public string? ErrorMessage { get; set; } public string PhoneNumber { get; set; } = string.Empty; public DateTime SentAt { get; set; } public long ProcessingTimeMs { get; set; } } public sealed class AlertLogFilter { public int? DeviceId { get; set; } public int? UserId { get; set; } public Domain.AlertType? AlertType { get; set; } public Domain.AlertStatus? Status { get; set; } public DateTime? StartDate { get; set; } public DateTime? EndDate { get; set; } public int Page { get; set; } = 1; public int PageSize { get; set; } = 20; } public sealed class UserDailyReportDto { public int Id { get; set; } public int DeviceId { get; set; } public string DeviceName { get; set; } = string.Empty; public int UserId { get; set; } public string UserName { get; set; } = string.Empty; public string UserFamily { get; set; } = string.Empty; public string PersianDate { get; set; } = string.Empty; public string Title { get; set; } = string.Empty; public string Observations { get; set; } = string.Empty; public string Operations { get; set; } = string.Empty; public string? Notes { get; set; } public List Images { get; set; } = new(); public DateTime CreatedAt { get; set; } public DateTime UpdatedAt { get; set; } } public sealed class ReportImageDto { public int Id { get; set; } public string FileName { get; set; } = string.Empty; public string FilePath { get; set; } = string.Empty; public string ContentType { get; set; } = string.Empty; public long FileSize { get; set; } public string? Description { get; set; } public DateTime UploadedAt { get; set; } } public sealed class CreateUserDailyReportRequest { public required int DeviceId { get; set; } public required int UserId { get; set; } public required string PersianDate { get; set; } public required string Title { get; set; } public required string Observations { get; set; } public required string Operations { get; set; } public string? Notes { get; set; } } public sealed class UpdateUserDailyReportRequest { public required int Id { get; set; } public required string Title { get; set; } public required string Observations { get; set; } public required string Operations { get; set; } public string? Notes { get; set; } } public sealed class UserDailyReportFilter { public int? DeviceId { get; set; } public int? UserId { get; set; } public string? PersianDate { get; set; } public int? Year { get; set; } public int? Month { get; set; } public int Page { get; set; } = 1; public int PageSize { get; set; } = 20; } // DTOs برای مدیریت توکن دستگاه /// /// درخواست دریافت فاصله زمانی آپلود /// public sealed class GetUploadIntervalRequest { public int? DeviceId { get; set; } public string? DevicePhoneNumber { get; set; } } /// /// پاسخ دریافت فاصله زمانی آپلود /// public sealed class GetUploadIntervalResponse { public bool Success { get; set; } public string? Message { get; set; } public int? UploadIntervalMin { get; set; } } /// /// درخواست دریافت توکن دستگاه /// public sealed class RequestDeviceTokenRequest { public required string DevicePhoneNumber { get; set; } } /// /// پاسخ دریافت توکن دستگاه /// public sealed class RequestDeviceTokenResponse { public bool Success { get; set; } public string? Message { get; set; } public string? TokenCode { get; set; } } /// /// درخواست تایید توکن دستگاه /// public sealed class VerifyDeviceTokenRequest { public required string DevicePhoneNumber { get; set; } public required string VerificationCode { get; set; } } /// /// پاسخ تایید توکن دستگاه /// public sealed class VerifyDeviceTokenResponse { public bool Success { get; set; } public string? Message { get; set; } public string? EncodedSettings { get; set; } }