private async Task FinishDistributedTaskAsync(int distributedTaskId) { var finishedDistributedTask = await _dbContext.DistributedTasks.Include(distributedTask => distributedTask.DistributedTaskDefinition) .FirstAsync(distributedTask => distributedTask.Id == distributedTaskId); var problemPluginFacade = _problemPluginFacadeProvider.Provide(finishedDistributedTask.DistributedTaskDefinition); var subtaskResults = _dbContext.Subtasks .Where(subtask => subtask.DistributedTaskId == distributedTaskId) .OrderBy(subtask => subtask.SequenceNumber) .Select(subtask => subtask.Result); try { finishedDistributedTask.Result = problemPluginFacade.JoinSubtaskResults(subtaskResults); finishedDistributedTask.Status = DistributedTaskStatus.Done; } catch (SubtaskResultsJoiningException exception) { finishedDistributedTask.Status = DistributedTaskStatus.Error; finishedDistributedTask.Errors = finishedDistributedTask.Errors.Append(exception.ToString()).ToArray(); } await _dbContext.SaveChangesAsync(); }
private IEnumerable <Subtask> CreateSubtasks(DistributedTaskDefinition taskDefinition, DistributedTask distributedTask) { var problemPluginFacade = _problemPluginFacadeProvider.Provide(taskDefinition); var subtasksData = problemPluginFacade.GetSubtasksFromData(distributedTask.InputData); return(subtasksData.Select((subtaskData, index) => new Subtask { DistributedTaskId = distributedTask.Id, InputData = subtaskData, SequenceNumber = index, Status = SubtaskStatus.WaitingForExecution })); }
private ProblemPluginInfo AnalyzeAssembly(Guid taskDefinitionGuid, string mainDllName) { var problemPluginFacade = _problemPluginFacadeProvider.Provide(taskDefinitionGuid, mainDllName); return(problemPluginFacade.GetProblemPluginInfo()); }