4

我想知道是否有适用于 AWS .NET SDK 的 SWF 工作流 C# 示例代码?

AWS 论坛帖子:https ://forums.aws.amazon.com/thread.jspa?threadID=122216&tstart=0

4

2 回答 2

5

作为熟悉 SWF 的一部分,我最终编写了一个通用案例库,希望其他人也可以使用它。它称为 SimpleWorkflowFramework.NET,可在https://github.com/sdebnath/SimpleWorkflowFramework.NET作为开源获得。它绝对可以提供很多帮助,所以如果您有兴趣,请立即加入!:)

于 2013-05-04T16:27:07.303 回答
0

我开发了一个开源 .NET 库- Guflow来对 Amazon SWF 进行编程。以下是如何编写工作流程来对视频进行转码:

[WorkflowDescription("1.0")]
public class TranscodeWorkflow : Workflow
{
  public TranscodeWorkflow()
  {
    //DownloadActivity is the startup activity and will be scheduled when workflow is started.
    ScheduleActivity<DownloadActivity>().OnFailure(Reschedule);

    //After DownloadActivity is completed TranscodeActivity activity will be scheduled.
    ScheduleActivity<TranscodeActivity>().AfterActivity<DownloadActivity>()
        .WithInput(a => new {InputFile = ParentResult(a).DownloadedFile, Format = "MP4"})

    ScheduleActivity<UploadToS3Activity>().AfterActivity<TranscodeActivity>()
        .WithInput(a => new {InputFile = ParentResult(a).TranscodedFile});

    ScheduleActivity<SendConfirmationActivity>().AfterActivity<UploadToS3Activity>();
  }
  private static dynamic ParentResult(IActivityItem a) => a.ParentActivity().Result();
}

在上面的示例中,为了清楚起见,我省略了任务路由。以下是创建活动的方法:

[ActivityDescription("1.0")]
public class DownloadActivity : Activity
{
  //It supports both sync/async method.
  [ActivityMethod]
  public async Task<Response> Execute(string input)
  {
      //simulate downloading of file
      await Task.Delay(10);
      return new Response() { DownloadedFile = "downloaded path", PollingQueue = PollingQueue.Download};
  }

  public class Response
  {
      public string DownloadedFile;
  }
}

为清楚起见,我省略了其他活动的示例。Guflow 由文档教程示例支持。

于 2018-01-18T18:42:13.943 回答