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? #28

Open
smadurange opened this issue Sep 9, 2020 · 4 comments
Open

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

smadurange opened this issue Sep 9, 2020 · 4 comments

Comments

@smadurange
Copy link

Hi,

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.Data"
                    },
                    "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 a JSON datetime like 2012-04-23T18:25:43.511Z ?

@smadurange
Copy link
Author

I need to set the datetime dynamically to the current time, hence the attempt to use DateTime.Now. It might even be a good idea to set the default EffectiveDate to DateTime.Now instead of DateTime.Min as it is easier to specify a hardcoded old date to process all received events actually.

@smadurange smadurange changed the title DateTime is not defined error How to set the EffectiveDate for WateFor event in JSON? Sep 10, 2020
@marcselis
Copy link

marcselis commented Sep 18, 2020

Maybe try System.DateTime.Now?

@danielgerlag
Copy link
Owner

This is not the same as workflow core... the scripting engine here is Python
see https://conductor-core.readthedocs.io/en/latest/primitives/
Maybe try datetime.now()

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

3 participants