I am designing a piece of software that needs to operate different pieces of hardware based mainly on a schedule but it also needs to have a web interface for configuring settings, configuring the schedule, and possibly even manually controlling the hardware. I'm not sure how to design the architecture of software like this.
One thought that I have had was to create a Windows service that does the communication with the hardware as well as "publishing" web services through WCF and then having an ASP.NET application that then controls the Windows service 开发者_如何学Gothrough WCF. This approach seems to be a lot of work for what I'm trying to accomplish.
Could someone please give me some direction whether or not this is a good approach, and even give me a better way to do it if one exists?
Thanks! Joel
You can instantiate a WCF endpoint as a TCP service from within the Windows service, as explained on MSDN: How to: Host WCF in a Windows Service Using TCP .
From there, it is relatively straightforward to consume that endpoint in an ASP.NET application (same as consuming any other WCF endpoint).
In the absence of any compelling reasons to do otherwise, this is probably the approach I would take. Your only other option is to use some other form of IPC, such as memory-mapped files or named pipes. WCF is a lot easier to get up and running.
You could just use a common XML file (or something) that the service monitors for changes. The web interface could just read/write that XML file. This only works well if the service and web site are running on the same machine (you can do it through a share as well, but that's extra configuration and you may was well just go with WCF in that case).
You can embed an ASP.Net web server in the service using the ASP.Net hosting API, then use it to run an ASP.Net website directly.
Note that the ASP.Net site would run in a separate AppDomain.
精彩评论