简体   繁体   English

每15秒运行一次ASPX页面

[英]Run ASPX page for every 15 secs

I need to call an ASPX page every 15 seconds. 我需要每15秒调用一次ASPX页面。 That page will receive data through the request and update a table in the database. 该页面将通过请求接收数据并更新数据库中的表。

I have below a sample table for auction data. 我在下面的样本表中有拍卖数据。

--------------------------------------------------------------
AID           STARTDATE               ENDDATE
-------------------------------------------------------------
1             18-7-2013 12:00 PM     20-7-2013 12:00 PM
2             19-7-2013 12:00 PM     21-7-2013 12:00 PM
3             19-7-2013 01:00 PM     21-7-2013 12:00 PM
4             19-7-2013 01:00 PM     22-7-2013 12:00 PM

We need to check in our database and send a web request for all records which are presently in auction mode (the current date and time between the STARTDATE and ENDDATE ). 我们需要检入数据库并发送Web请求以获取当前处于拍卖模式的所有记录( STARTDATEENDDATE之间的当前日期和时间)。 Sometimes 3 or 4 items will start their auction at same time. 有时3或4件物品将同时开始拍卖。 How do we handle this scenario? 我们如何处理这种情况?

What is the best way to get an update every 15 seconds for all items which are currently in running auction mode and store in our database? 对于当前处于拍卖模式并存储在我们数据库中的所有商品,每15秒更新一次的最佳方法是什么?

Thank you in advance... 先感谢您...

If you simple need to automatically reload your ASPX page every 15 seconds, just add a meta tag to page header: 如果您只需要每15秒自动重新加载ASPX页面,只需在页面标题中添加一个meta标记即可:

<head>
<meta http-equiv="refresh" content="15">
</head>

You can use Quartz.NET Scheduling Framework for .NET Platform which is like Windows Task Scheduler but a lot better. 您可以使用Quartz.NET Scheduling Framework for .NET Platform,它类似于Windows Task Scheduler,但效果要好得多。

Project site: http://www.quartz-scheduler.net/ 项目站点: http : //www.quartz-scheduler.net/

Nuget package: http://nuget.org/packages/Quartz/ Nuget软件包: http ://nuget.org/packages/Quartz/

As a client-side solution, you can use the JavaScript setInterval() function, like this: 作为客户端解决方案,您可以使用JavaScript setInterval()函数,如下所示:

var ResInterval = window.setInterval('myAjaxCall()', 15000); // 15 seconds
var myAjaxCall = function() {
    $.ajax({
        type: "GET",
        url: 'YourPage.aspx/MyMethod',
        dataType: "json",
        success: function(xml) {
            // Put logic here when data comes back from server
        }
};

Note: The url can be whatever is script callable (web service, WCF service, ASP.NET AJAX Page Method , etc.). 注意: url可以是脚本可调用的任何内容(Web服务, WCF服务, ASP.NET AJAX Page Method等)。

To stop the interval, do this: 要停止间隔,请执行以下操作:

window.clearInterval(resInterval);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM