问题描述
能有人给我实现与.NET技术每天工作一个最好的办法。
我有一个在共享主机托管,GoDaddy的在我的实例中的SQLSERVER数据库的asp.net应用程序。
我的应用程序被用于在此时执行相当相当数据库中添加/更改数据。
我有一个新的要求,每天发送一些电子邮件警报基于存储在数据库中的一些数据标准。
Can some one give me a best way to implement a daily job with .NET technology.I have an asp.net application with the sqlserver database hosted in shared hosting, GODaddy in my instance.My application is used to add / change the data in the database which is performing quite fairly at this time.I got a new requirement to send some email alerts daily based on some data criteria that were stored in the database.
起初我还以为写了一个窗口服务,但GoDaddy的是不允许访问其它数据库比其托管的应用。
是否有人有任何想法,以每天1:00 AM发送警报?
Initially I thought to write a windows service, but godaddy is not allowing to access the database other than its hosted applications.Does someone has any idea to send alerts daily at 1:00AM?
在此先感谢
推荐答案
请参阅的任务由杰夫·阿特伍德。
See Easy Background Tasks in ASP.NET by Jeff Atwood.
复制/从链接贴:
private static CacheItemRemovedCallback OnCacheRemove = null;
protected void Application_Start(object sender, EventArgs e)
{
AddTask("DoStuff", 60);
}
private void AddTask(string name, int seconds)
{
OnCacheRemove = new CacheItemRemovedCallback(CacheItemRemoved);
HttpRuntime.Cache.Insert(name, seconds, null,
DateTime.Now.AddSeconds(seconds), Cache.NoSlidingExpiration,
CacheItemPriority.NotRemovable, OnCacheRemove);
}
public void CacheItemRemoved(string k, object v, CacheItemRemovedReason r)
{
// do stuff here if it matches our taskname, like WebRequest
// re-add our task so it recurs
AddTask(k, Convert.ToInt32(v));
}
这篇关于附表托管Web服务器的作业的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!