修复cron表达式待办 无限提醒的bug

This commit is contained in:
liufei
2021-12-23 13:09:46 +08:00
parent 7f585dd095
commit 09d3a520b4
4 changed files with 19 additions and 32 deletions

View File

@@ -40,13 +40,15 @@ namespace GeekDesk.Control.Other
if (info.ExecType == TodoTaskExecType.CRON)
{
CronExpression exp = new CronExpression(info.Cron);
DateTime dtNow = DateTime.Now;
DateTimeOffset ddo = DateTime.SpecifyKind(dtNow, DateTimeKind.Local);
string nextExecTime = ddo.LocalDateTime.ToString("yyyy-MM-dd HH:mm:ss");
info.ExeTime = nextExecTime;
DateTime nowTime = DateTime.Now;
DateTime nextTime = ddo.LocalDateTime;
TimeSpan ts = nextTime.Subtract(dtNow);
//计算下次执行时间
DateTime nextTime = DateTime.SpecifyKind(exp.GetNextValidTimeAfter(nowTime).Value.LocalDateTime, DateTimeKind.Local);
string nextTimeStr = nextTime.ToString("yyyy-MM-dd HH:mm:ss");
info.ExeTime = nextTimeStr;
TimeSpan ts = nextTime.Subtract(nowTime);
int minutes = (int)Math.Ceiling(ts.TotalMinutes);
if (minutes < 0)
{

View File

@@ -27,11 +27,10 @@
<DataGrid.RowStyle>
<Style TargetType="DataGridRow" BasedOn="{StaticResource DataGridRowStyle}">
<EventSetter Event="MouseRightButtonDown" Handler="DataGridRow_MouseRightButtonDown" />
<EventSetter Event="Selected" Handler="DataGridRow_Selected"/>
<Setter Property="Background" Value="White"/>
<Style.Triggers>
<Trigger Property="IsSelected" Value="True">
<Setter Property="Background" Value="#5BC0DE"/>
<Setter Property="Background" Value="{StaticResource BtnBG}"/>
</Trigger>
<Trigger Property="IsSelected" Value="False">
<Setter Property="Background" Value="White"/>

View File

@@ -84,20 +84,5 @@ namespace GeekDesk.Control.UserControls.Backlog
Menu.IsOpen = true;
}
/// <summary>
/// 选中时颜色变化
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void DataGridRow_Selected(object sender, RoutedEventArgs e)
{
Color c = Color.FromRgb(91, 192, 222);
SolidColorBrush b = new SolidColorBrush
{
Color = c,
Opacity = 0.9
};
((DataGridRow)sender).Background = b;
}
}
}