如何创建重复日历事件? [英] How to create recurring calendar events?

查看:579
本文介绍了如何创建重复日历事件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用ASP的MVC 3,jQuery的完整的日历,MS SQL SEVER 2008和C#。

I am using asp mvc 3, jquery full calendar, ms sql sever 2008 and c#.

我想知道是否有人知道如何使经常性的事件?

I am wondering if anyone knows how to make recurring events?

我不能确定如何使它们。

I am unsure how to make them.

例如,在谷歌日历,你可以预约每年重复永远。我怀疑,他们生成预约X倍于数据库中。

For instance in google calendar you can make an appointment repeat yearly forever. I doubt that they generate that appointment X times in the database.

我想知道我怎么能有一个排在我的分贝,不知怎么知道调用了需要的时候。

I am wondering how I could have one row in my db and somehow know to call that up when needed.

也是谷歌日历和Outlook有许多重复的选项,如重复的第一个月,上个月等。

Also google calendar and outlook have lots of repeating options like repeat on the 1st month, last month and etc.

有没有库的构建有此?还是我得从头开始呢?

Is there any libraries build that have this? Or do I got to make it from scratch?

P.S

我是一个共享的主机上,从而解决了有限的工作权。

I am on a shared host so a solution has to work with limited rights.

推荐答案

生成事件的所有可能的重复会(理论上)填写您的存储与最有可能永远不会被用户看到(恭喜上的事件您999,999,999,999,999,999,999th生日!)。

Generating all possible repetitions of an event would (in theory) fill up your storage with events that would most likely never ever be seen by the user (congrats on your 999,999,999,999,999,999,999th birthday!).

这需要更多的工作,但解决的办法是从根本上存储你链接您的日历条目为您打造一个日历重复规则的表(或表):

It takes a bit more work, but the solution is to basically store a table (or tables) of repetition rules which you link your calendar entries to as you build a calendar:

对正在显示一周的每一天,检查其重复那些日子事件
   对于正在显示该月的每周,检查其重复的周事件
   在一年每月,等等...

"for every day of the week being shown, check for events which repeat on those days" "for every week of the month being shown, check for events which repeat in those weeks" "for every month in a year", etc...

有多少这些检查你所要做的取决于你有多少种类(和持续时间)重复想要的。

How many of these checks you have to do depends on how many types (and duration) of repetitions you'd want.

至于苏pressing事件,这是又一个在表上市日期点/它必须苏pressed倍。 如果显示星期一,显示在几个月重复的所有事件,除了在苏pression表列出的

As for supressing events, that's yet another table listing points at dates/times which have to be supressed. "if showing mondays, show all events that repeat on months, except the ones listed in the supression table"

评论随访:

好了,你有你的标准日历项表,存储的核心信息。日期/时间,等等...则至少两个其它表来存储重复的信息。一个存储您重复的规则。 每周一,每月第一天,年年,等等,并且该日历项和规则之间联系的第三个表

Well, you'd have your standard calendar entry table, to store the core information. date/time, etc... Then at least two other tables to store the repeat information. One that stores your repetition rules. "every monday", "first day of month", "every year", etc..., and a third table that links between the calendar entries and the the rules

这样:

 calendar entries table  <--->  link table  <--->  repeat rules table

查询将建设东西不管这么说的你考虑的日期,相应的规则出来,让你的日历项的标识显示。如果你这样做动态的链接到根据您在已经通过的日期相应的规则看中查询可以变得丑陋。

Querying would be a matter of building things so that for the date you're considering, the appropriate rules come out and give you the IDs of calendar entries to display. Could get ugly if you do a fancy query that dynamically links to the appropriate rules based on a date you've passed in.

这篇关于如何创建重复日历事件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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