如何从 ASP.NET 定期调用 wcf 服务?
首先,我很抱歉我确实发布了一个与此相关的问题,但无法澄清我的观点,感谢所有回答这个问题的人(Timdog、M.Babcock、David),但我认为真正阐明了这个问题,最好重新发布并明确含义。
所以,我有这个网站 hearteptics.com(假设不是现在),在该网站中我可以选择让任何访问该网站的用户配置一个时间,比如 6 小时、12 小时、1 天或其他时间,以便在当他们配置好后,就会发送一封邮件,提醒他们服用心脏药。我在 WCF 服务中有一个名为 SendMail 的方法,所以现在应该清楚了,我需要在用户配置的特定时间为特定用户调用该方法,那么我该怎么做呢?另外请考虑一下,如果用户数量增加,我应该如何管理这一切?我的意思是说用户 A 设置时间 6 小时,而用户 B 设置 1 天,所以我需要的是,每 6 小时后用户 A 设置时间,并且每 1 天用户 B 设置时间后,调用此方法并应将邮件发送给相应的用户。
我还没有设计该方法,所以如果您希望我在方法中自定义某些内容,我也可以这样做。
ps:我试图删除我之前的问题,但我做不到。
First I am quite sorry that I did post a question in regard to this, but was unable to clear my view point, thanks everyone who answered that (Timdog, M.Babcock, David), but I think to really shed lights on the matter, it would be best to repost this with clear meaning.
So, I have this site heartpatients.com (not right now, say hypothetically), in the site I have option to let any user who visits the site, configure a time, say 6hrs, 12hrs, 1day or whatever, so that after the time they configured, a mail be dispatched reminding them to take their heart pills. I have a method in WCF service named SendMail, so as should be clear by now, I need to call that method for particular user at a particular time as configured by user, so how can I do it? Also please take into consideration that if user number increases, how should I manage all this? I mean say User A sets time 6hr while user B sets 1Day, so what I need is that after every 6hr user A sets the time, and after every 1day user B sets the time, this method be called and should dispatch mail to respective user.
I haven't designed the method yet, so if you want me to customize something in method I could do that too.
ps: I tried to delete my previous question but I couldn't.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不建议将 ASP.NET 用于除基于 Web 的代码之外的任何内容。您的定期函数不是基于浏览器上的用户发出请求并获得响应。
相反,您应该为此功能创建一个 Windows 服务,或者创建一个控制台应用程序并使用 Windows 的计划任务功能来计划它。
It is not recommended to use ASP.NET for anything other than web-based code. Your periodic function isn't based on a user at a browser making a request and getting a response.
Instead, you should either create a Windows Service for this function, or else create a Console application and schedule it using the Scheduled Tasks feature of Windows.