不断重复直到无穷大
假设我想在 ASP.NET MVC 视图中显示提醒(由用户动态创建) 每个星期/每月/......直到“无限”。
对于每个重复发生的情况,此提醒必须是单独的数据库记录(或者在我的例子中为 EF 实体实例对象),因为我在数据库中为每次发生的情况存储特定数据。
你们如何将这些提醒克隆“插入”到数据库中? 我无法插入无限的提醒,..并且选择从现在开始的任意日期说“2000年”似乎是错误的,并且还会将大量记录插入数据库中。
这里有点无能为力......
提前感谢任何(替代)解决方案/建议。 *关键是我可以存储每次发生的数据!*
Let's say I wanted to display a Reminder (dynamically created by user) in my ASP.NET MVC View
Every WEEK/MONTH/.... until "infinity".
This reminder has to be seperate database record (or in my case EF Entity Instance object) for each reocurrence, because i'm storing specific data in my database for each occurrence.
How would you guys go about "inserting" these reminder clones into the database?
I Can't insert infinite reminders, .. And choosing an arbitrary date say "2000 years" from now seems wrong, and also inserts a lot of records into the database.
Kind of clueless here...
Thanks in advance for any (alternative) solution/ advice.
*It is key tough that i can store data for each occurence!*
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
恕我直言,将提醒插入数据库是一种糟糕的实现方式。这只是懒惰。
我的方法是存储条件,然后定期测试条件。也许只是保留上次提醒检查的时间戳,如果超过 8 小时,则重新计算 - 围绕这些线。
更新
为了知道用户是否看到了哪个提醒,对于每种类型,您只需保留读取时间的时间戳。
如果差异大于项目间隔,则必须显示。如果时间戳小于必须显示的时间提醒,则必须显示。Inserting reminders into the database, IMHO, is a bad way of implementing it. It is just lazy.
My approach would be to store the conditions and then test the conditions on a regular basis. Perhaps just keeping a timestamp of last reminder check and if it is more than 8 hours, re-calculate - something around these lines.
UPDATE
In order to know which reminder has been seen by the user or not, for every type you just keep a timestamp of when it was read.
If the difference is more than the item interval, then it must be shown.If timestamp is less than the the time reminder must be shown, then it must be shown.您的代码在 10 年后被使用的可能性有多大吗?
如果没有尝试10年。
Is there the remotest possibility that your code will be used in 10 years time?
If not try 10 years.