public async Task <StartProcessInstanceResponse> CreateProcessInstanceByModelId <T>(string modelId, string startEvent, T token, string correlationId) { try { // terminate process with same correlationId before start new // temporary solution (await _instanceClient.QueryAsync( options => options.FilterByCorrelationId(correlationId) )).ToList().ForEach( p => _instanceClient.TerminateProcessInstanceAsync(p.Id) ); return(await _defClient.StartProcessInstanceAsync(modelId, startEvent, token, correlationId)); } catch (Exception e) { Console.WriteLine(e); throw; } }
public async Task <bool> TerminateProcessInstanceById(string processId) { try { await _instanceClient.TerminateProcessInstanceAsync(processId); return(true); } catch (Exception e) { Console.WriteLine(e); return(false); } }