当前位置: 动力学知识库 > 问答 > 编程问答 >

asp.net - Application Design - Daemon w/ WebPage FrontEnd

问题描述:

I have an application that scans an input directory every five seconds and when a job (i.e. file) is placed in the directory the application reads it, processes it and outputs another file(s) in an output directory.

My question is, If I wanted to put a web based front end on this application, how would I wait for the processing to be complete?

  • User submits job
  • job is placed in input directory
  • ......What am I doing on the web page here?
  • processing occurs
  • output file is generated
  • ......How do I know that the job is finished?

The two solutions I came up with were:

  • poll output directory every x seconds from the webpage
  • use ajax to poll a webservice or webpage that reports back whether the output file is present

Is there a better design for the server? In other words, how would TCP or Named Pipes help in this situation? (Cannot use remoting due to a DCOM object.)

网友答案:

A solution we have done commercially in the past is basically the daemon writes to a log (typically DB), with a date/time stamp, about what its doing, and the web frontend just shows the latest X amount of entries from the log, with a little toggle to hide all of the "Looked in directory, no file found" messages, worked fairly well, we upgraded it later on with AJAX (Timer that reloaded every 20 seconds).

网友答案:

I don't think that Named Pipes are going to make it any easier to get the web client to poll automatically, but it might make the server better able to notify another process that the conversion has completed--and ultimately queue a message to the web browser.

You can try having the web client poll every few seconds to see if the file process has completed, alternatively you could have something like Juggernaut "push" commands out to the page. Juggernaut works using Flash to open a socket on the web browser that continually feeds JavaScript from the server. It could be responsible for sending a command to alert the browser that the file has completed and then issue a redirect.

分享给朋友:
您可能感兴趣的文章:
随机阅读: