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 set the EffectiveDate for WateFor event in JSON? #644

Closed
smadurange opened this issue Sep 9, 2020 · 6 comments
Closed

How to set the EffectiveDate for WateFor event in JSON? #644

smadurange opened this issue Sep 9, 2020 · 6 comments

Comments

@smadurange
Copy link

smadurange commented Sep 9, 2020

Hi, I opened the issue danielgerlag/conductor#28 too. But considering the documentation on the JSON defnition for WaitFor event is under Workflow Core, I will ask it here.

I have the following workflow definition:

{
    "Id": "AutomaticReply",
    "Steps": [
        {
            "Id": "OnMoReceived",
            "StepType": "While",
            "Inputs": {
                "Condition": "1"
            },
            "Do": [[
                {
                    "Id": "WaitForMo",
                    "StepType": "WaitFor",
                    "Inputs": {
                        "EventName": "\"MoReceived\"",
                        "EventKey": "\"MOIN\"",
                        "EffectiveDate": "DateTime.Now"
                    },
                    "Outputs": {
                        "Mo": "step.EventData"
                    },
                    "NextStepId": "SendMt"
                },
                {
                    "Id": "SendMt",
                    "StepType": "HttpRequest",
                    "Inputs": {
                        "BaseUrl": "http://localhost:5006/api/v1/test/",
                        "Resource": "message",
                        "Method": "POST",
                        "Headers":{
                            "@Authorization": "Bearer xxx",
                            "@Content-Type": "application/json"
                        },
                        "Body": {
                            "destination": "data.Mo.Source",
                            "text": "data.Mo.Text"
                        }
                    }
                }
            ]]
        }
    ]
}

When I start this workflow (I'm using Conductor) using the http request:

curl --location --request POST 'http://localhost:5000/api/workflow/AutomaticReply' \
--header 'Content-Type: application/json' \
--data-raw '{
    
}'

I get the following exception

fail: WorkflowCore.Services.WorkflowExecutor[0]
      Workflow 5f5889a91cf3171bf042a51b raised error on step 1 Message: name 'DateTime' is not defined
IronPython.Runtime.UnboundNameException: name 'DateTime' is not defined
   at IronPython.Runtime.Operations.PythonOps.GetVariable(CodeContext context, String name, Boolean isGlobal, Boolean lightThrow)
   at IronPython.Compiler.LookupGlobalInstruction.Run(InterpretedFrame frame)
   at Microsoft.Scripting.Interpreter.Interpreter.Run(InterpretedFrame frame)
   at Microsoft.Scripting.Interpreter.LightLambda.Run2[T0,T1,TRet](T0 arg0, T1 arg1)
   at IronPython.Compiler.PythonScriptCode.RunWorker(CodeContext ctx)
   at IronPython.Compiler.PythonScriptCode.EvalWrapper(CodeContext ctx)
   at IronPython.Compiler.PythonScriptCode.Run(Scope scope)
   at IronPython.Compiler.RuntimeScriptCode.InvokeTarget(Scope scope)
   at IronPython.Compiler.RuntimeScriptCode.Run(Scope scope)
   at Microsoft.Scripting.SourceUnit.Execute(Scope scope, ErrorSink errorSink)
   at Microsoft.Scripting.SourceUnit.Execute(Scope scope)
   at Microsoft.Scripting.Hosting.ScriptSource.Execute(ScriptScope scope)
   at Conductor.Domain.Scripting.ScriptEngineHost.EvaluateExpression(String expression, IDictionary`2 inputs) in C:\Users\conductor\src\Conductor.Domain.Scripting\ScriptEngineHost.cs:line 33
   at Conductor.Domain.Services.ExpressionEvaluator.EvaluateExpression(String sourceExpr, Object pData, IStepExecutionContext pContext) in C:\Users\conductor\src\Conductor.Domain\Services\ExpressionEvaluator.cs:line 22
   at Conductor.Domain.Services.WorkflowLoader.<>c__DisplayClass12_0.<BuildScalarInputAction>g__acn|0(IStepBody pStep, Object pData, IStepExecutionContext pContext) in C:\Users\conductor\src\Conductor.Domain\Services\WorkflowLoader.cs:line 258
   at WorkflowCore.Models.ActionParameter`2.Assign(Object data, IStepBody step, IStepExecutionContext context)
   at WorkflowCore.Models.ActionParameter`2.AssignInput(Object data, IStepBody body, IStepExecutionContext context)
   at WorkflowCore.Services.WorkflowExecutor.ExecuteStep(WorkflowInstance workflow, WorkflowStep step, ExecutionPointer pointer, WorkflowExecutorResult wfResult, WorkflowDefinition def)
   at WorkflowCore.Services.WorkflowExecutor.Execute(WorkflowInstance workflow)

How do I set DateTime.Now in json? I'm following the syntax given here.

@danielgerlag
Copy link
Owner

Have you tried DateTime.Parse(String value)?

@smadurange
Copy link
Author

@danielgerlag I'm trying to follow the advice #353. I want to set the effective date each time the step is run. So, DateTime.Parse(String value) would not work for me here.

@danielgerlag
Copy link
Owner

It's not clear if you are using conductor or workflow core?

@smadurange
Copy link
Author

I'm using Conductor. I created the workflow using the workflow definition I mentioned.

@danielgerlag
Copy link
Owner

Let's move the discussion to that project. The api is different.

@smadurange
Copy link
Author

Moving discussion to danielgerlag/conductor#28 (comment).

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

2 participants