views:

47

answers:

2

I have a windows service (Win32 Service API) mostly designed that will generate images from data in a frequently updated text file. The idea being that these images can then be referenced by an html file to satisy a client requirement.

There will also be varying text data from the file in that html.

what I'm wondering is.....

--- whether it makes sense for this same windows service to also generate that html (htmlwriter). On the one hand, it seems sensible. On the other hand, it WAS my idea so it is inherently subject to scrutiny.

Another option is having the html (javascript) query the service for any updates to the html?

--- finally, timer vs. file watcher as the event to trigger the image generation?

Almost all opinions would be appreciated ;) thanks.

A: 

Can't the act of refreshing the page trigger getting new data from the file?

If not, I use something called XRefresh that auto-refreshes when specified local files change. It crashes on me every hundred refreshes or so and I have to restart it.

Another option, but one I also wouldn't recommend, is to use a SQL Server database and SQL triggers. These are highly unreliable.

Sorry for not giving a definite answer, but that may give you some ideas.

crizCraig
A: 

Assuming it's worth doing (why not just draw the image on demand?)....

The C Win32 API is good at file watching. I don't know about FileSystemWatcher but it's likely to be a thin wrapper and I have no reason to think it's broken.

The ASP.NET code needs to delete the output files it doesn't want and use the latest version of the output files that are complete, and the output file sets of the service should (...atomically somehow or other...) include the text file copy used for image generation, or you'll get wrong image / text versions displayed together.

So I would go with the HTML generation not managed by the service, but the TXT file version issue managed by the service.

martinr