拥有一个大的工作流程还是几个较小的特定工作流程更好? [英] Is it better to have one big workflow or several smaller specific ones?

查看:26
本文介绍了拥有一个大的工作流程还是几个较小的特定工作流程更好?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要构建一个从服务器获取文件并移动到另一台服务器的应用程序.有人建议我考虑使用 Windows Workflow Foundation (WF).

I need to build an app that gets files from a server and moves to another server. It was suggested that I look into using Windows Workflow Foundation (WF).

我开始构建工作流程,但它变得凌乱不堪,我不确定我是否以最好的方式在做.

I started to build the workflow but it is getting messy and I'm not sure I'm doing it the best way possible.

以下是基本的工作流活动:

Here is the basic worklow activities:

获取来源列表确定源是 ftp 还是磁盘驱动器从服务器获取文件列表如果源是 ftp,则使用 ftp get 获取文件,如果源是驱动器,则从驱动器读取文件如果目标是 ftp,则将 ftp 文件发送到服务器,否则,如果目标是驱动器,则写入驱动器,否则,如果目标是 Web 服务,则将其发布到 Web 服务如果源是 ftp 则用 ftp 命令删除文件如果源是驱动器则删除文件

Get a list of sources Determine if source is ftp or disk drive Get a list of files from the server If source is ftp then get the file with ftp get else if source is drive then read file from drive If target is ftp then ftp file to server else if target is drive then write to a drive else if target is web service then post to web service If source is ftp then delete file with ftp commands else if source is drive then delete file

有了一个工作流程,它就会变得有点忙.我需要 2 个 while 循环,一个围绕集成,一个在获得文件列表之后.

With one workflow it gets a little busy. I need 2 while loops, one around the integrations and one after I get a file list.

我想到的另一件事是构建多个工作流.一个用于 FTPtoFTP、FTPtoDrive、FTPtoWebServie、DriveToFTP、DrivetoDrive、DriveToWebService.

The other thing I thought of was to build multiple workflows. One for FTPtoFTP, FTPtoDrive, FTPtoWebServie, DriveToFTP, DrivetoDrive, DriveToWebService.

有什么建议吗?

推荐答案

首先,在我看来,这就像使用 WF 给本应相当简单的过程增加了额外的复杂性.尽管 WF 可用于对执行流进行建模,但其目的是对业务流进行建模,并包含业务规则和逻辑,而无需将它们放入您的实现中.

First of all, this sounds to me like using WF is adding extra complications to what should be a fairly straightforward process. Although WF can be used to model execution flow, its purpose is to model business flow, and include business rules and logic without putting those into your implementations.

在您的示例中,业务规则似乎在很大程度上应该由 app.config 文件处理.

In your example, the business rules seem largely like things which should be dealt with by an app.config file.

但是,关于使用一个或多个工作流程的更广泛问题.您希望每个工作流程任务大致相同的广泛范围"

However, on the broader question of using one workflow or many. You want each of your workflow tasks to be approximately the same 'broad scope'

例如用于建表的 WF

  • 购买木材
  • 伐木
  • 为腿砍木
  • 斜边
  • 圆形飞檐
  • 用不同的粗度打磨两次
  • 组装表

中间的步骤都比周围的步骤详细得多.因此,您可以考虑将其拆分为两个单独的工作流:包含基本步骤的高级工作流和包含细节的低级工作流.

The steps in the middle are all much more detailed than the steps around them. So you would consider splitting it up into two separate workflows: a high level workflow that contains the broads steps, and lower level workflows that contain the particulars.

因此,GetDatasource"工作流步骤不会关心(外部)它从什么类型的数据源收集,它只是返回到工作流中的下一步一组数据.

So the 'GetDatasource' workflow step would not care (externally) what type of datasource it is gathering from, it just returns to the next step in the workflow a set of data.

目标也是如此,它不关心它拥有什么类型的数据源,它只关心它与数据有什么关系.所以也应该封装.

Same goes for target, it doesn't care what type of datasource it had, it only cares what it has to do with the data. So that should be encapsulated as well.

所以你的工作流程可以是三个工作流程

So your Workflow could be three workflows

最高 WF

  1. 获取数据源WF
  2. DoThingsWithDataWF

然后您的 DoThingsWithDataWF 和 GetDataSourceWF 工作流可以分别只关注它们需要的执行上下文.

Then your DoThingsWithDataWF and GetDataSourceWF Workflows can each be concerned with only the execution context that they need.

编辑

正如评论者 James Schek 所指出的.您可以使用更高级别的工作流来实际启动较低级别的工作流并管理它们的执行.

As pointed out by the commenter James Schek. You can use the higher level workflow to actually kick off your lower level workflows and manage their execution into each other.

这篇关于拥有一个大的工作流程还是几个较小的特定工作流程更好?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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