[英]ASP.NET Best way to queue a report in sql and then update the user when it's available
I want to allow users on the website to queue a report (enter the request in a sql table). 我想允许网站上的用户将报告排队(在sql表中输入请求)。 The queue will be processed by a windows app that will read the queue from the sql server, run the reports, and update the reportcomplete field in the record. Windows应用程序将处理该队列,该应用程序将从sql服务器读取队列,运行报告,并更新记录中的reportcomplete字段。 I need to be able to post a message saying something similar to "Generating report" and then alert the user when the report is available. 我需要能够发布一条类似于“生成报告”的消息,然后在报告可用时提醒用户。 I have toyed with SQLDependency and I can get the onchange event to fire, but of course I can't get back to the page that has already loaded in the browser. 我玩弄了SQLDependency,可以触发onchange事件,但是当然我无法回到已经在浏览器中加载的页面。 Pretty much out of ideas on how to accomplish this, and I'm thinking SQLDependency might be the wrong avenue. 关于如何完成此操作的想法几乎不存在,我认为SQLDependency可能是错误的途径。 Any ideas? 有任何想法吗?
HTTP cannot connect back to the client. HTTP无法连接回客户端。 The only solution is to for the client to poll, usually via a long tail (eg. Comet Ajax ) request. 唯一的解决方案是通常通过一条长尾巴(例如Comet Ajax )请求让客户端进行轮询。 So the original page request returns, a script starts on the result page and posts a background request that enters the ASP.Net code and blocks on an event. 因此,原始页面请求返回,脚本在结果页面上启动,并发布一个后台请求,该后台请求输入ASP.Net代码并阻止事件。 The SQLDependency notifies the event, so the long tail requests re-activates and returns the response to the agent, which now completes the Ajax call and can update the page. SQLDependency通知事件,因此长尾请求重新激活并将响应返回给代理,该代理现在完成Ajax调用并可以更新页面。 At least this is the 10000 ft. view. 至少这是10000英尺的视图。 This will work, but won't scale (primarily because of the resources tied up by the Ajax request, the blocked ASP.Net processing thread). 这将起作用,但不会扩展(主要是由于Ajax请求(阻塞的ASP.Net处理线程)占用了资源)。 More scalable approaches exists, but are significantly more complex. 存在更多可扩展的方法,但是要复杂得多。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.