Fix to Test run mode.

This commit is contained in:
axeleron007 2021-09-16 12:51:27 +03:00
parent 191928a943
commit dd16c1921f
10 changed files with 19 additions and 26 deletions

View file

@ -81,8 +81,12 @@ namespace Elsa.Activities.Http
[ActivityOutput(Hint = "The received HTTP request.")]
public HttpRequestModel? Output { get; set; }
protected override IActivityExecutionResult OnExecute(ActivityExecutionContext context) =>
context.WorkflowExecutionContext.IsFirstPass && !context.WorkflowExecutionContext.WorkflowBlueprint.IsTestRun ? ExecuteInternal(context) : Suspend();
protected override IActivityExecutionResult OnExecute(ActivityExecutionContext context)
{
var result = context.WorkflowExecutionContext.IsFirstPass && !context.WorkflowExecutionContext.WorkflowBlueprint.IsTestRun ? ExecuteInternal(context) : Suspend();
context.WorkflowExecutionContext.WorkflowBlueprint.IsTestRun = false;
return result;
}
protected override IActivityExecutionResult OnResume(ActivityExecutionContext context) => ExecuteInternal(context);
private IActivityExecutionResult ExecuteInternal(ActivityExecutionContext context)

View file

@ -76,8 +76,8 @@ namespace Elsa.Activities.Http.Middleware
}
var isTestRun = pendingWorkflowInstance.MetaData.FirstOrDefault(x => x.Key == "isTestRun").Value;
var workflowBlueprint = (isTestRun != null && Convert.ToBoolean(isTestRun)) ?
await workflowRegistry.FindAsync(x => x.Id == pendingWorkflowInstance.DefinitionId, cancellationToken) :
var workflowBlueprint = (isTestRun != null && Convert.ToBoolean(isTestRun)) ?
await workflowRegistry.FindAsync(x => x.Id == pendingWorkflowInstance.DefinitionId, cancellationToken) :
await workflowRegistry.FindAsync(x => x.IsPublished && x.Id == pendingWorkflowInstance.DefinitionId && !x.IsDisabled, cancellationToken);
if (workflowBlueprint is null)

View file

@ -1,9 +1,9 @@
using System;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Elsa.Events;
using Elsa.Services;
using Elsa.Services.Bookmarks;
using MediatR;
namespace Elsa.Handlers
@ -20,7 +20,10 @@ namespace Elsa.Handlers
public async Task Handle(WorkflowInstanceSaved notification, CancellationToken cancellationToken)
{
var workflowInstance = notification.WorkflowInstance;
await _bookmarkIndexer.IndexBookmarksAsync(workflowInstance, cancellationToken);
//var isTestRun = workflowInstance.MetaData.FirstOrDefault(x => x.Key == "isTestRun");
//if (!Convert.ToBoolean(isTestRun.Value))
await _bookmarkIndexer.IndexBookmarksAsync(workflowInstance, cancellationToken);
}
public async Task Handle(ManyWorkflowInstancesDeleted notification, CancellationToken cancellationToken)

View file

@ -333,10 +333,6 @@ export class ElsaWorkflowPropertiesPanel {
return (
<dl
class="elsa-mt-2 elsa-border-t elsa-border-b elsa-border-gray-200 elsa-divide-y elsa-divide-gray-200">
<div class="elsa-py-3 elsa-flex elsa-justify-between elsa-text-sm elsa-font-medium">
<dt class="elsa-text-gray-500">{t('Instance Id')}</dt>
<dd class="elsa-text-gray-900">{testActivity.workflowInstanceId}</dd>
</div>
<div class="elsa-py-3 elsa-flex elsa-justify-between elsa-text-sm elsa-font-medium">
<dt class="elsa-text-gray-500">{t('Correlation Id')}</dt>
<dd class="elsa-text-gray-900">{testActivity.correlationId}</dd>

View file

@ -324,7 +324,6 @@ export class SyntaxNames {
}
export interface WorkflowTestActivityMessage {
workflowInstanceId: string;
correlationId: string;
activityId: string;
status: string;

View file

@ -1,14 +1,10 @@
using System;
using System.Collections.Generic;
using System.Dynamic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using AutoMapper.Internal;
using Elsa.Models;
using Elsa.Scripting.JavaScript.Events;
using Elsa.Scripting.JavaScript.Providers;
using MediatR;
using Newtonsoft.Json;
@ -46,7 +42,8 @@ namespace Elsa.Scripting.JavaScript.Services
#pragma warning disable CS8600 // Converting null literal or possible null value to non-nullable type.
dynamic data = JsonConvert.DeserializeObject<ExpandoObject>(json, new ExpandoObjectConverter());
#pragma warning restore CS8600 // Converting null literal or possible null value to non-nullable type.
string title = data != null ? data.title : "Schema";
string? title = data != null ? data.title : null;
title = title != null ? title : "schema";
var schema = await JsonSchema.FromJsonAsync(json);
var generator = new TypeScriptGenerator(schema, new TypeScriptGeneratorSettings {

View file

@ -36,8 +36,6 @@ namespace Elsa.Server.Api.Handlers
var message = new WorkflowTestMessage
{
SignalRConnectionId = signalRConnectionId,
WorkflowInstanceId = context.WorkflowInstance.Id,
CorrelationId = context.CorrelationId,
ActivityId = context.ActivityId,
Status = context.WorkflowExecutionContext.Status == WorkflowStatus.Running
@ -46,7 +44,7 @@ namespace Elsa.Server.Api.Handlers
Data = JsonConvert.SerializeObject(data, Formatting.Indented)
};
await _workflowTestService.DispatchMessage(message);
await _workflowTestService.DispatchMessage(signalRConnectionId, message);
}
}
}

View file

@ -1,11 +1,7 @@
using Newtonsoft.Json.Linq;
namespace Elsa.Server.Api.Models
{
public class WorkflowTestMessage
{
public string SignalRConnectionId { get; set; } = default!;
public string WorkflowInstanceId { get; set; } = default!;
public string CorrelationId { get; set; } = default!;
public string ActivityId { get; set; } = default!;
public string Status { get; set; } = default!;

View file

@ -5,6 +5,6 @@ namespace Elsa.Server.Api.Services
{
public interface IWorkflowTestService
{
Task DispatchMessage(WorkflowTestMessage message);
Task DispatchMessage(string signalRConnectionId, WorkflowTestMessage message);
}
}

View file

@ -14,9 +14,9 @@ namespace Elsa.Server.Api.Services
_hubContext = hubContext;
}
public async Task DispatchMessage(WorkflowTestMessage message)
public async Task DispatchMessage(string signalRConnectionId, WorkflowTestMessage message)
{
await _hubContext.Clients.Client(message.SignalRConnectionId).SendAsync("DispatchMessage", message);
await _hubContext.Clients.Client(signalRConnectionId).SendAsync("DispatchMessage", message);
}
}
}