简体   繁体   English

代码运行时的ASP.NET应用程序日志/进度条

[英]ASP.NET Application log while code is running / progress bar

I'm building a OCR scanning module in my ASP forms webapplication. 我正在ASP表单webapplication中构建一个OCR扫描模块。 As you may know a operation like that can take some time. 您可能知道这样的操作可能需要一些时间。 Therefor I'm using a background service application that responds to a message queue that runs the code so the user does not even have to stay on the same webpage. 因此,我正在使用后台服务应用程序来响应运行代码的消息队列,因此用户甚至不必停留在同一网页上。

What I would like to do is inform the user what is going on while the service is running. 我想要做的是告知用户在服务运行时发生了什么。 If lets say the user uploaded 5 documents I would like to see something like this appear in a literal, label or repeater control. 如果让我们说用户上传了5个文档,我希望看到这样的内容出现在文字,标签或转发器控件中。 These items do not have to be saved in a database and I don't want then to. 这些项目不必保存在数据库中,我不希望这样。

Processing document 1 of 5 处理文件1 of 5
Document 1 processed with code 6732842 文件1使用代码6732842处理
Processing document 2 of 5 处理文件2的5
Document 2 processed with code 8732457 文件2使用代码8732457处理
Processing document 3 of 5 处理文件3 of 5
Document 3 processed with code 8725347 文件3使用代码8725347处理
Processing document 4 of 5 处理文件4 of 5
Document 4 could not be processed “no OCR string recognized” 无法处理文档4“未识别OCR字符串”
Processing document 5 of 5 处理文件5 of 5
Document 5 processed with code 4372537 文件5使用代码4372537处理
Completed: Processed 4 of 5 documents received 完成:处理收到的5份文件中的4份

If an error occurred I would like to see something like this 如果发生错误,我希望看到类似的内容

An error occurred. 发生错误。 The scanning process has been stopped. 扫描过程已停止。

I have some idears but I don't know what's the best practice. 我有一些想法,但我不知道什么是最好的做法。

Option 1: 选项1:
I could save above items in a static class and let javascript post every 5 sec. 我可以在静态类中保存上面的项目,让javascript每5秒发布一次。 to get that value via a web method. 通过Web方法获取该值。

Option 2: 选项2:
I could save above items in the session returning a updated session object when I let JavaScript post every 5 sec. 当我让JavaScript每5秒发布一次时,我可以在会话中保存上面的项目,返回更新的会话对象。 I don't know if this is available when using a service Application. 使用服务应用程序时,我不知道这是否可用。

If you have any other options (preferably better ones) that would be greatly appriciated. 如果您有任何其他选项(最好是更好的选项),那将会非常受欢迎。

Thanx in advance. Thanx提前。

Save the progress items in a database , give each user's upload with a different id, publish this data with a web service. 将进度项保存在数据库中,为每个用户上传不同的ID,使用Web服务发布此数据。 In the browser, use JavaScipt to retrieve the progress from the web service. 在浏览器中,使用JavaScipt从Web服务检索进度。
Of course, the database need to delete periodically, eg, every minitue. 当然,数据库需要定期删除,例如每个minitue。

I wish I could give you a working example, but what you're wanting to do is not easy, and is made even more difficult by the fact that you're not using ASP.NET MVC which makes async work easier. 我希望我能给你一个有用的例子,但是你想要做的事情并不容易,而且由于你没有使用ASP.NET MVC这使得异步工作变得更容易,因此更加困难。 You're going to need to write a series of asynchronous tasks to do some work for you. 您将需要编写一系列异步任务来为您完成一些工作。 This article will give you a good start: http://blogs.msdn.com/b/tmarq/archive/2010/04/14/performing-asynchronous-work-or-tasks-in-asp-net-applications.aspx 本文将为您提供一个良好的开端: http//blogs.msdn.com/b/tmarq/archive/2010/04/14/performing-asynchronous-work-or-tasks-in-asp-net-applications.aspx

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

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