Ejemplo n.º 1
0
        protected WorkflowInfo GetWorkflowInfo(RunningOptions options, IList<IWorkflowLookup> lookups, LogHelper log)
        {
            log.Info("Searching for workflows...");

            var lookupOptions = new LookupOptions(options);
            foreach (var lookup in lookups)
            {
                if (lookup.CanHandle(lookupOptions))
                {
                    log.Info("using lookup {0} for workflow searching", lookup.GetType());
                    var foundWorkflows = lookup.Find(lookupOptions);

                    return SelectDefaultWorkflow(foundWorkflows.ToList(), options, log);
                }
            }

            throw new Exception(string.Format("No lookup to handle input file: {0}", options.InputFile));
        }
Ejemplo n.º 2
0
 private TaskContext(
     IResultsStorage results, 
     IExecutionStrategy executionStrategy, 
     Identity identity, 
     ILogRenderer logRenderer, 
     IDirectory workDirectory, 
     IEnvironment environment, 
     ITaskInterceptor interceptor, 
     Identities identitiesTail)
 {
     _identity = identity;
     _results = results;
     _executionStrategy = executionStrategy;
     _logRenderer = logRenderer;
     _workDirectory = workDirectory;
     _environment = environment;
     _interceptor = interceptor;
     _identitiesTail = identitiesTail;
     _log = new LogHelper(message => logRenderer.Render(message, GetFullIdentitiesPath()));
 }
Ejemplo n.º 3
0
        private WorkflowInfo SelectDefaultWorkflow(IList<WorkflowInfo> foundWorkflows, RunningOptions options, LogHelper log)
        {
            log.Info("workflows found: {0}", foundWorkflows.Count);

            if (foundWorkflows.Count == 0)
            {
                throw new Exception("No workflows found");
            }

            WorkflowInfo workflowToExecute = null;
            if (foundWorkflows.Count > 1)
            {
                if (string.IsNullOrEmpty(options.Workflow))
                {
                    throw new Exception("Multiple workflows found but default workflow was not set!");
                }

                workflowToExecute = foundWorkflows.FirstOrDefault(info =>
                    info.WorkflowType.FullName.Contains(options.Workflow));
            }
            else
            {
                workflowToExecute = foundWorkflows[0];
            }

            if (workflowToExecute == null)
            {
                throw new Exception("Could not select default workflow to execute.");
            }

            log.Info("Workflow to execute: {0}", workflowToExecute.WorkflowType.Name);

            return workflowToExecute;
        }