Windows服务应用程序体系结构的疑虑 [英] Windows Service application architecture doubts

查看:114
本文介绍了Windows服务应用程序体系结构的疑虑的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要创建一些的 Windows服务应用程序(C#)应执行多个定期执行,并绑定到对方的任务,如:


  

      
  1. 观看的文件夹被更改。

  2.   
  3. 发送文件的Web服务(Web API)。

  4.   
  5. 写日志,并保存在本地数据库。

  6.   

所以,我游荡,如果我可以只用的快速和肮脏的的方针,实现这一切使用的BackgroundWorker 类,或者有使用更多复杂的东西,如任务ÿ等( .NET Windows服务 - 建筑的决定)。或事件有一些框架,做到这一点。

有关应用程序的可能的现代和干净结构任何意见将是很好听的。非常感谢你!


解决方案

听起来你会需要这样的专用服务器上。所以我的第一个建议是使用 TopShelf 。它使得现代的Windows服务放在一起那么容易了可笑的。

然后执行你的问题我会使用某种形式的工作流模式的步骤。 的Windows Workflow Foundation 似乎是不够的现代化,以应付这一点。 (就个人而言,我只是用链方面的责任,该模式与DI容器作为我的快速和脏的)。

最后结合与该揭开序幕的工作流程,如<一个事件驱动的方法href=\"https://msdn.microsoft.com/en-us/library/system.io.filesystemwatcher%28v=vs.110%29.aspx?f=255&MSPPError=-2147217396\"相对=nofollow> FileSystemWatcher的 ,你甚至不会需要担心backgroundworkers等。

因此​​,这些架构做出的决定,你的服务将是易于安装,运行,测试和安装(TopShelf),您可以构建和单元模块化测试服务(工作流模式)。

I need to create some Windows Service App (C#) that should perform several periodically executed and binded to each other tasks like:

  1. Watch for folder changes.
  2. Send files to Web Services (Web API).
  3. Write Log and keep it in local DB.

So I am wandering if I can just use "quickly and dirty" approach and implement all this using BackgroundWorker class or I have use more sophisticated stuff like Tasks y etc (.NET Windows Service - Architectural Decisions). Or event there are some frameworks to do it.

Any advice about possible modern and clean structure of that application would be nice to hear. Thank you very much!

解决方案

Sounds like you'll be needing this on a dedicated server. So my first suggestion is to use TopShelf. It makes putting together modern Windows services so easy its laughable.

Then to perform the steps in your question I'd use some sort of workflow pattern. Windows Workflow Foundation seems to be modern enough to cater for this. (Personally, I just use the chain-of-responsibility pattern with a DI container as my quick and "dirty").

Lastly combining that with an event-driven approach that kicks off the workflow, like FileSystemWatcher, you won't even need to worry about backgroundworkers etc.

So with those architecture decisions made, your service will be easy to setup, run, test and install (TopShelf), and you can build and unit test your service modularly (workflow pattern).

这篇关于Windows服务应用程序体系结构的疑虑的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆