public Task Handle(EvaluatingJavaScriptExpression notification, CancellationToken cancellationToken)
        {
            var engine = notification.Engine;
            var activityExecutionContext = notification.ActivityExecutionContext;

            engine.SetValue(
                "queryString",
                (Func <string, string>)(key => _httpContextAccessor.HttpContext !.Request.Query[key].ToString())
                );
            engine.SetValue(
                "absoluteUrl",
                (Func <string, string>)(url => _absoluteUrlProvider.ToAbsoluteUrl(url).ToString())
                );
            engine.SetValue(
                "signalUrl",
                (Func <string, string>)(signal => activityExecutionContext.GenerateSignalUrl(signal))
                );
            engine.SetValue(
                "getRemoteIPAddress",
                (Func <string>)(() => _httpContextAccessor.HttpContext !.Connection.RemoteIpAddress.ToString())
                );
            engine.SetValue(
                "getRouteValue",
                (Func <string, object>)(key => _httpContextAccessor.HttpContext !.GetRouteValue(key))
                );

            return(Task.CompletedTask);
        }
Esempio n. 2
0
        private string GenerateUrl(string signal, WorkflowExecutionContext workflowExecutionContext)
        {
            var workflowInstanceId = workflowExecutionContext.Workflow.Id;
            var payload            = new Signal(signal, workflowInstanceId);
            var token = tokenService.CreateToken(payload);
            var url   = $"/workflows/signal?token={token}";

            return(absoluteUrlProvider.ToAbsoluteUrl(url).ToString());
        }
Esempio n. 3
0
        public Task Handle(EvaluatingJavaScriptExpression notification, CancellationToken cancellationToken)
        {
            var engine = notification.Engine;
            var workflowExecutionContext = notification.WorkflowExecutionContext;

            engine.SetValue(
                "queryString",
                (Func <string, string>)(key => httpContextAccessor.HttpContext.Request.Query[key].ToString())
                );
            engine.SetValue(
                "absoluteUrl",
                (Func <string, string>)(url => absoluteUrlProvider.ToAbsoluteUrl(url).ToString())
                );
            engine.SetValue(
                "signalUrl",
                (Func <string, string>)(signal => GenerateUrl(signal, workflowExecutionContext))
                );

            return(Task.CompletedTask);
        }