Ejemplo n.º 1
0
        /// <summary>
        /// Executes the external process for processing the task
        /// </summary>
        /// <param name="task">The task to be processed.</param>
        /// <param name="settings">Contains information about the processing request.</param>
        /// <returns>The result of task processing.</returns>
        protected override TaskProcessResult RunExternalTaskProcess(ITask task, TaskExecutionSettings settings)
        {
            var taskParameters = BlenderParameters.FromTask(task);
            var initialFiles   = CollectFiles(LocalStoragePath);

            if (!taskParameters.Valid)
            {
                Log.Error(taskParameters.ErrorText);
                return(new TaskProcessResult
                {
                    Success = TaskProcessSuccess.PermanentFailure,
                    ProcessorOutput = "Parameter error: " + taskParameters.ErrorText,
                });
            }

            var inputFile  = LocalPath(taskParameters.JobFile);
            var outputFile = LocalPath(taskParameters.Prefix);

            string externalProcessPath = ExecutablePath(RenderPath);
            string externalProcessArgs = string.Format(CultureInfo.InvariantCulture, RenderArgs, inputFile, outputFile, taskParameters.Format, task.TaskIndex);

            Log.Info("Calling '{0}' with Args '{1}' for Task '{2}' / Job '{3}' .", RenderPath, externalProcessArgs, task.TaskId, task.JobId);
            var processResult = ExecuteProcess(externalProcessPath, externalProcessArgs);

            if (processResult == null)
            {
                return(new TaskProcessResult {
                    Success = TaskProcessSuccess.RetryableFailure
                });
            }

            var newFiles = GetNewFiles(initialFiles, LocalStoragePath);
            var result   = TaskProcessResult.FromExternalProcessResult(processResult, newFiles);

            var thumbnail = CreateThumbnail(task, newFiles);

            if (!string.IsNullOrEmpty(thumbnail))
            {
                var taskPreview = new TaskOutputFile
                {
                    FileName = thumbnail,
                    Kind     = TaskOutputFileKind.Preview
                };
                result.OutputFiles.Add(taskPreview);
            }
            return(result);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Method to execute the external processing for merging the tasks output into job output
        /// </summary>
        /// <param name="mergeTask">The merge task.</param>
        /// <param name="settings">Contains information about the processing request.</param>
        /// <returns>The job outputs resulting from the merge process.</returns>
        protected override JobResult RunExternalMergeProcess(ITask mergeTask, TaskExecutionSettings settings)
        {
            var taskParameters = BlenderParameters.FromTask(mergeTask);

            if (!taskParameters.Valid)
            {
                Log.Error(taskParameters.ErrorText);
                throw new InvalidParameterException(taskParameters.ErrorText);
            }

            var inputFilter = string.Format(CultureInfo.InvariantCulture, "{0}*", taskParameters.Prefix);
            var inputFiles  = CollectFiles(LocalStoragePath, inputFilter);



            var outputFile = LocalPath("output.zip");
            var result     = ZipOutputs(inputFiles, outputFile);

            result.PreviewFile = CreateThumbnail(mergeTask, inputFiles.ToArray());

            return(result);
        }