public async Task <string> StartWorkflow <TData>(string workflowId, int version, TData data) { if (_shutdown) { throw new Exception("Host is not running"); } var def = _registry.GetDefinition(workflowId, version); if (def == null) { throw new Exception(String.Format("Workflow {0} version {1} is not registered", workflowId, version)); } var wf = new WorkflowInstance(); wf.WorkflowDefinitionId = workflowId; wf.Version = version; wf.Data = data; wf.Description = def.Description; wf.NextExecution = 0; wf.Status = WorkflowStatus.Runnable; wf.ExecutionPointers.Add(new ExecutionPointer() { StepId = def.InitialStep, Active = true }); string id = await _persistenceStore.CreateNewWorkflow(wf); await _queueProvider.QueueForProcessing(id); return(id); }