-
Notifications
You must be signed in to change notification settings - Fork 30
/
Copy pathCompleteResult.cs
46 lines (40 loc) · 1.43 KB
/
CompleteResult.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
using System.Collections.Generic;
using System.Net;
using System.Threading.Tasks;
using Camunda.Worker.Client;
using Camunda.Worker.Variables;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging.Abstractions;
namespace Camunda.Worker;
public sealed class CompleteResult : IExecutionResult
{
public CompleteResult()
{
}
public Dictionary<string, VariableBase>? Variables { get; set; }
public Dictionary<string, VariableBase>? LocalVariables { get; set; }
public async Task ExecuteResultAsync(IExternalTaskContext context)
{
var externalTask = context.Task;
var client = context.Client;
try
{
await client.CompleteAsync(externalTask.Id, new CompleteRequest(externalTask.WorkerId)
{
Variables = Variables,
LocalVariables = LocalVariables,
});
}
catch (ClientException e) when (e.StatusCode == HttpStatusCode.InternalServerError)
{
var logger = context.ServiceProvider.GetService<ILogger<CompleteResult>>();
logger?.LogResult_FailedCompletion(externalTask.Id, e.Message, e);
await client.ReportFailureAsync(externalTask.Id, new ReportFailureRequest(externalTask.WorkerId)
{
ErrorMessage = e.ErrorType,
ErrorDetails = e.ErrorMessage,
});
}
}
}