附表托管Web服务器的作业 [英] Schedule a job in hosted web server

查看:86
本文介绍了附表托管Web服务器的作业的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

能有人给我实现与.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?

在此先感谢

推荐答案

请参阅的易于背景在ASP.NET 任务由杰夫·阿特伍德。

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服务器的作业的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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