chore: 自定义基建配置时间仍在有效期内时不检查其他时间段

This commit is contained in:
uye
2025-09-15 00:26:30 +08:00
parent 7e3ab62aae
commit 00e5c1eb9f

View File

@@ -605,6 +605,22 @@ public class InfrastSettingsUserControlModel : TaskViewModel
}
var now = DateTime.Now;
if (CustomInfrastPlanIndex >= CustomInfrastPlanInfoList.Count || CustomInfrastPlanIndex < 0)
{
CustomInfrastPlanIndex = 0;
}
var currentPlan = CustomInfrastPlanInfoList.First(p => p.Index == CustomInfrastPlanIndex);
foreach (var period in currentPlan.PeriodList)
{
if (TimeLess(period.BeginHour, period.BeginMinute, now.Hour, now.Minute) &&
TimeLess(now.Hour, now.Minute, period.EndHour, period.EndMinute))
{
return; // 当前 index 仍在有效时间内,不需要切换
}
}
foreach (var plan in CustomInfrastPlanInfoList.Where(
plan => plan.PeriodList.Any(
period => TimeLess(period.BeginHour, period.BeginMinute, now.Hour, now.Minute) &&
@@ -614,11 +630,6 @@ public class InfrastSettingsUserControlModel : TaskViewModel
return;
}
if (CustomInfrastPlanIndex >= CustomInfrastPlanList.Count || CustomInfrastPlanList.Count < 0)
{
CustomInfrastPlanIndex = 0;
}
return;
static bool TimeLess(int lHour, int lMin, int rHour, int rMin) => (lHour != rHour) ? (lHour < rHour) : (lMin <= rMin);