Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to write Waitfor in JSON ? #1234

Closed
godzff opened this issue Feb 20, 2024 · 1 comment
Closed

How to write Waitfor in JSON ? #1234

godzff opened this issue Feb 20, 2024 · 1 comment

Comments

@godzff
Copy link

godzff commented Feb 20, 2024

Hi,I created a new console demo to use json.
The JSON likes this

{
  "Id": "Test02",
  "Version": 1,
  "Description": "",
  "DataType": "WFC.Sample.WfData, WFC.Sample",
  "Steps": [
    {
      "Id": "Hello",
      "StepType": "WFC.Sample.Steps.HelloWorld, WFC.Sample",
      "NextStepId": "WaitFor"
    },
    {
      "Id": "WaitFor",
      "StepType": "WorkflowCore.Primitives.WaitFor, WorkflowCore",
      "NextStepId": "Decide",
      "CancelCondition": "data.Value1 != \"two\"",
      "Inputs": {
        "EventName": "\"MyEvent\"",
        "EventKey": "context.Workflow.Id"
      },
      "Outputs": {
        "Value1": "step.EventData"
      }
    },
    {
      "Id": "Decide",
      "StepType": "WorkflowCore.Primitives.Decide, WorkflowCore",
      "SelectNextStep": {
        "Print1": "data.Value1 == \"one\"",
        "Print2": "data.Value1 == \"two\""
      }
    },
    {
      "Id": "Print1",
      "StepType": "WFC.Sample.Steps.CustomMsg, WFC.Sample",
      "Inputs": {
        "Message": "\"Hello from print1 , dataValue1:\"+ data.Value1 + \", dataValue2:\" + data.Value2"
      },
      "NextStepId": "Bye"
    },
    {
      "Id": "Print2",
      "StepType": "WFC.Sample.Steps.CustomMsg, WFC.Sample",
      "Inputs": {
        "Message": "\"Hello from print2 , dataValue1:\"+ data.Value1 + \", dataValue2:\" + data.Value2"
      },
      "NextStepId": "Bye"
    },
    {
      "Id": "Bye",
      "StepType": "WFC.Sample.Steps.GoodByeWorld, WFC.Sample"
    }
  ]
}

WfData class like this

public class WfData
{
    public string Value1 { get; set; }
    public string Value2 { get; set; }
}

The host codes like this

host.Start();
var wid = host.StartWorkflow("Test02", 1, new WfData{ Value1 = "two", Value2 = "data2" }).Result;
Console.WriteLine("started...");
host.PublishEvent("MyEvent", wid, new WfData { Value1 = "two", Value2 = "data2" });
host.Stop();

when I set "Hello" to "Decide",everything is ok, and the console

started...
Hello world
Hello from print2 , dataValue1:two, dataValue2:data2
GoodBye world

when I set "Hello" to "WaitFor", console only

started...
Hello world

what's wrong with the json ?

@godzff
Copy link
Author

godzff commented Feb 27, 2024

I find the problem。
Error Json

    {
      "Id": "WaitFor",
      "StepType": "WorkflowCore.Primitives.WaitFor, WorkflowCore",
      "NextStepId": "Decide",
      "CancelCondition": "data.Value1 != \"two\"",
      "Inputs": {
        "EventName": "\"MyEvent\"",
        "EventKey": "context.Workflow.Id"
      },
      "Outputs": {
        "Value1": "step.EventData"
      }
    }

True Json

    {
      "Id": "WaitFor",
      "StepType": "WorkflowCore.Primitives.WaitFor, WorkflowCore",
      "NextStepId": "Decide",
      "CancelCondition": "data.Value1 != \"two\"",
      "Inputs": {
        "EventName": "\"MyEvent\"",
        "EventKey": "context.Workflow.Id"
      },
      "Outputs": {
        "Value1": "step.EventData.Value1"
      }
    }

Outputs.Value1 is string and step.EventData is object

@godzff godzff closed this as completed Feb 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant