Пример #1
0
        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();
        }
Пример #2
0
        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
            }));
        }
Пример #3
0
        private ProblemPluginInfo AnalyzeAssembly(Guid taskDefinitionGuid, string mainDllName)
        {
            var problemPluginFacade = _problemPluginFacadeProvider.Provide(taskDefinitionGuid, mainDllName);

            return(problemPluginFacade.GetProblemPluginInfo());
        }