表示“重复发生的事件"的最佳方式是什么?在数据库中? [英] What is the best way to represent "Recurring Events" in database?

查看:24
本文介绍了表示“重复发生的事件"的最佳方式是什么?在数据库中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试用 C# 开发一个依赖于调度程序和日历的事件应用程序,其中一个关键要求是在数据库中表示重复发生的事件.在数据库中表示重复事件的最佳方式是什么?

I am trying to develop a scheduler- and calendar-dependent event application in C#, for which a crucial requirement is to represent recurring events in the database. What is the best way to represent recurring events in a database?

更多详情:

在创建活动时,我还向某些用户发送邀请,应允许受邀者仅在指定的窗口(会议持续时间)内登录会议,或者在受邀者尝试登录时拒绝登录,例如,会议预定开始前 5 分钟.

While creating the event I am also sending invites to the certain users and the invitees should be allowed to login to the meeting only during the specified window(meeting duration) or may be decline the login when the invitee attempts to login say, 5 minutes before the scheduled start of the meeting.

推荐答案

sysjobssysjobsschedulesysschedules 表在这方面做得很好.我不会重新发明轮子,我只会复制他们的设计.

The sysjobs, sysjobsschedule and sysschedules tables in SQL Server does a pretty good job of this. I wouldn't reinvent the wheel, I'd just copy their design.

以下是 sysschedules

freq_type

针对此计划的作业运行频率.

How frequently a job runs for this schedule.

1 = 仅一次

4 = 每日

8 = 每周

16 = 每月

32 = 每月,相对于 freq_interval

32 = Monthly, relative to freq_interval

64 = 在 SQL Server 代理服务启动时运行

64 = Runs when the SQL Server Agent service starts

128 = 在计算机空闲时运行

128 = Runs when the computer is idle

freq_interval

作业执行的天数.取决于 freq_type 的值.默认值为 0,表示未使用 freq_interval.freq_type 的值对 freq_interval 的影响

Days that the job is executed. Depends on the value of freq_type. The default value is 0, which indicates that freq_interval is unused. Value of freq_type Effect on freq_interval

1(一次)freq_interval 未使用 (0)

1 (once) freq_interval is unused (0)

4(每天)每隔 freq_interval 天

4 (daily) Every freq_interval days

8(每周)freq_interval 是以下一项或多项:1 = 周日 2 = 周一 4 = 周二 8 = 周三 16 = 周四 32 = 周五 64 = 周六

8 (weekly) freq_interval is one or more of the following: 1 = Sunday 2 = Monday 4 = Tuesday 8 = Wednesday 16 = Thursday 32 = Friday 64 = Saturday

16(每月)在每月的 freq_interval 日

16 (monthly) On the freq_interval day of the month

32(每月,相对)freq_interval 是以下之一:1 = 周日 2 = 周一 3 = 周二 4 = 周三 5 = 周四 6 = 周五 7 = 周六 8 = 第 9 天 = 工作日 10 = 周末

32 (monthly, relative) freq_interval is one of the following: 1 = Sunday 2 = Monday 3 = Tuesday 4 = Wednesday 5 = Thursday 6 = Friday 7 = Saturday 8 = Day 9 = Weekday 10 = Weekend day

64(在 SQL Server 代理服务启动时启动)freq_interval 未使用 (0)

64 (starts when SQL Server Agent service starts) freq_interval is unused (0)

128(计算机空闲时运行)freq_interval 未使用 (0)

128 (runs when computer is idle) freq_interval is unused (0)

freq_subday_type

freq_subday_interval 的单位.可以是以下值之一:值说明(单位)

Units for the freq_subday_interval. Can be one of the following values: Value Description (unit)

1 在指定时间

2 秒

4 分钟

8 小时

freq_subday_interval

在每次作业执行之间发生的 freq_subday_type 周期数.

Number of freq_subday_type periods to occur between each execution of the job.

freq_relative_interval

当 freq_interval 在每个月发生时,如果 freq_interval 为 32(每月相对).可以是以下值之一:

When freq_interval occurs in each month, if freq_interval is 32 (monthly relative). Can be one of the following values:

0 = freq_relative_interval 未使用

0 = freq_relative_interval is unused

1 = 第一个

2 = 第二

4 = 第三

8 = 第四

16 = 最后

freq_recurrence_factor

计划执行作业之间的周数或月数.freq_recurrence_factor 仅在 freq_type 为 8、16 或 32 时使用.如果此列包含 0,则不使用 freq_recurrence_factor.

Number of weeks or months between the scheduled execution of a job. freq_recurrence_factor is used only if freq_type is 8, 16, or 32. If this column contains 0, freq_recurrence_factor is unused.

这篇关于表示“重复发生的事件"的最佳方式是什么?在数据库中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆