我是评估此类表达式的库的作者。它是特定领域的语言,看起来有点像SQL,所以很多用户应该熟悉它的语法。对于问题表达式:
我希望每隔25秒发生一次。
repeat every 25 seconds start at '29.10.2017 01:55:00'
我想只有先发生,本月的最后一天。但是,每个月的第一天应该在上午9点到上午11:00之间给我5分钟的分辨率。每月的最后一天应评估至凌晨5:00。
repeat every minutes where 1 =
(case
when GetDay() = 1 and GetHour() between 9 and 11
then GetMinute() % 5 = 0
when IsLastDayOfMonth()
then GetHour() = 5 and GetMinute() = 0 and GetSecond() = 0
else 0
esac) start at '01.01.2017'
在每月第一周和第三周的周一下午12:00
repeat every minutes where 1 =
(case
when GetWeekOfMonth() in (1,3) and GetDayOfWeek() = monday
then GetTime() between Time(8, 30, 0) and Time(11, 30, 0)
when GetWeekOfMonth() in (2,4) and GetDayOfWeek() in (tuesday, sunday)
then GetTime() = Time(12, 0, 0)
else 0
esac) start at '01.04.2017'
得到8:30 AM和11:30 AM在周二和第二周和第四周周日的时间之间的时间
这里值得指出的是,通常几个月的周数可以不同地进行计算,没有这样做的标准方式,因此结果可能取决于所选择的策略。 GetWeekOfMonth(string type)
有改变策略的可选类型参数。
可以注意到,包含where
零件的查询允许在当前时间线上应用复杂的过滤器。您只需像在SQL中那样编写过滤器,但您将过滤时间轴,而不是数据。
有几个内置函数可以帮助更快地设计新的查询。也可以开发其他的过滤功能。见wiki默认可用。所有这些函数都是用纯C#编写的,添加自定义函数应该很容易。它在nuget上可用。我希望这个图书馆对社区有用。
我也做了cron评估器,它共享抽象,所以可以互换使用它,因为有时使用cron会更好。
https://github.com/Puchaczov/TQL.RDL