修复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) if (info.ExecType == TodoTaskExecType.CRON)
{ {
CronExpression exp = new CronExpression(info.Cron); CronExpression exp = new CronExpression(info.Cron);
DateTime dtNow = DateTime.Now; DateTime nowTime = DateTime.Now;
DateTimeOffset ddo = DateTime.SpecifyKind(dtNow, DateTimeKind.Local);
string nextExecTime = ddo.LocalDateTime.ToString("yyyy-MM-dd HH:mm:ss");
info.ExeTime = nextExecTime;
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); int minutes = (int)Math.Ceiling(ts.TotalMinutes);
if (minutes < 0) if (minutes < 0)
{ {

View File

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

View File

@@ -84,20 +84,5 @@ namespace GeekDesk.Control.UserControls.Backlog
Menu.IsOpen = true; 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;
}
} }
} }

View File

@@ -3,6 +3,7 @@
xmlns:hc="https://handyorg.github.io/handycontrol"> xmlns:hc="https://handyorg.github.io/handycontrol">
<!--整体样式-->
<Style x:Key="BorderBG" TargetType="Border"> <Style x:Key="BorderBG" TargetType="Border">
<Style.Setters> <Style.Setters>
<Setter Property="Background"> <Setter Property="Background">
@@ -18,18 +19,18 @@
</Style.Setters> </Style.Setters>
</Style> </Style>
<LinearGradientBrush x:Key="BtnBG" Opacity="0.97">
<GradientStop Color="#84fab0" Offset="0"/>
<GradientStop Color="#8fd3f4" Offset="1"/>
</LinearGradientBrush>
<!--按钮样式-->
<Style x:Key="Btn1" TargetType="Button" BasedOn="{StaticResource ButtonInfo}"> <Style x:Key="Btn1" TargetType="Button" BasedOn="{StaticResource ButtonInfo}">
<Setter Property="Background"> <Setter Property="Background" Value="{StaticResource BtnBG}"/>
<Setter.Value> <Setter Property="Foreground" Value="Gray"/>
<LinearGradientBrush Opacity="0.97">
<GradientStop Color="#5BC0DE" Offset="0"/>
<GradientStop Color="#5BC0DE" Offset="1"/>
</LinearGradientBrush>
</Setter.Value>
</Setter>
<Setter Property="Foreground" Value="White"/>
</Style> </Style>
<!--菜单样式-->
<Style x:Key="MyMenuStyle" TargetType="hc:SideMenuItem" BasedOn="{StaticResource SideMenuItemBaseStyle}"> <Style x:Key="MyMenuStyle" TargetType="hc:SideMenuItem" BasedOn="{StaticResource SideMenuItemBaseStyle}">
<Style.Setters> <Style.Setters>
<Setter Property="Background" Value="Transparent"/> <Setter Property="Background" Value="Transparent"/>