2024-10-07 02:13:35 +03:00
|
|
|
|
using Mirea.Api.Endpoint.Configuration.ConfigurationChecks.Attributes;
|
|
|
|
|
using Mirea.Api.Endpoint.Configuration.ConfigurationChecks.Interfaces;
|
2024-05-28 06:38:24 +03:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
|
2024-10-07 02:13:35 +03:00
|
|
|
|
namespace Mirea.Api.Endpoint.Configuration.ConfigurationChecks.Settings;
|
2024-05-28 06:38:24 +03:00
|
|
|
|
|
|
|
|
|
[RequiredSettings]
|
|
|
|
|
public class ScheduleSettings : IIsConfigured
|
|
|
|
|
{
|
|
|
|
|
public struct PairPeriodTime
|
|
|
|
|
{
|
|
|
|
|
public TimeOnly Start { get; set; }
|
|
|
|
|
public TimeOnly End { get; set; }
|
|
|
|
|
|
|
|
|
|
public PairPeriodTime(TimeOnly t1, TimeOnly t2)
|
|
|
|
|
{
|
|
|
|
|
if (t1 > t2)
|
|
|
|
|
{
|
|
|
|
|
Start = t2;
|
|
|
|
|
End = t1;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
Start = t1;
|
|
|
|
|
End = t2;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public PairPeriodTime(Dto.Common.PairPeriodTime time) : this(time.Start, time.End) { }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public required string CronUpdateSchedule { get; set; }
|
|
|
|
|
public DateOnly StartTerm { get; set; }
|
|
|
|
|
public required IDictionary<int, PairPeriodTime> PairPeriod { get; set; }
|
|
|
|
|
|
|
|
|
|
public bool IsConfigured()
|
|
|
|
|
{
|
|
|
|
|
return !string.IsNullOrEmpty(CronUpdateSchedule) &&
|
|
|
|
|
StartTerm != default &&
|
|
|
|
|
PairPeriod.Count != 0 &&
|
|
|
|
|
PairPeriod.Any();
|
|
|
|
|
}
|
|
|
|
|
}
|