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

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

问题描述

我试图在C#中开发一个调度程序和日历相关的事件应用程序,其中关键的要求是在数据库中表示重复的事件。
代表数据库中的重复事件的最佳方式是什么?



更多详细信息:



在创建活动的同时我也向某些用户发送邀请,被邀请者只能在指定的窗口(会议期限)内登录会议,或者被邀请者在5分钟前尝试登录时可能会拒绝登录计划的会议开始。

解决方案

sysjobs sysjobsschedule 和SQL Server中的 sysschedules 表做一个漂亮的这个很好。我不会重塑轮子,我只是复制他们的设计。



以下是 sysschedules中的一些重要字段



freq_type


此计划的作业运行频率。



1 =仅一次



4 =每日



8 =每周



16 =每月



32 =每月,相对于freq_interval



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



128 =计算机空闲时运行


freq_interval


作业执行。取决于freq_type的值。默认值为0,表示freq_interval未使用。
freq_type的值freq_interval



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



4(每天)每个freq_interval天



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



16(月)在每月的freq_interval天



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



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



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


freq_subday_type


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



1在指定的时间



2秒



4分钟



8小时


freq_subday_interval


每次执行之间发生的freq_subday_type周期数的工作。


freq_relative_interval


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



0 = freq_relative_interval未使用



1 =首先



2 = Second



4 =第三个



8 =第四



16 =最后


freq_recurrence_factor / p>


计划执行作业之间的周数或月数。如果freq_type为8,16或32,则使用freq_recurrence_factor。如果此列包含0,则freq_recurrence_factor未使用。



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?

More Details:

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.

解决方案

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.

Here are some of the important fields from sysschedules

freq_type

How frequently a job runs for this schedule.

1 = One time only

4 = Daily

8 = Weekly

16 = Monthly

32 = Monthly, relative to freq_interval

64 = Runs when the SQL Server Agent service starts

128 = Runs when the computer is idle

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 (once) freq_interval is unused (0)

4 (daily) Every freq_interval days

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 (monthly) On the freq_interval day of the month

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 (starts when SQL Server Agent service starts) freq_interval is unused (0)

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

freq_subday_type

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

1 At the specified time

2 Seconds

4 Minutes

8 Hours

freq_subday_interval

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

freq_relative_interval

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 is unused

1 = First

2 = Second

4 = Third

8 = Fourth

16 = Last

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天全站免登陆