Пример #1
0
        public async Task <int> RunSequenceAsync(Options obj)
        {
            var log = LogManager.GetLogger(nameof(Program));

            var state = new RunState
            {
                ProgressLog        = MakeProgressLogger(),
                Log                = log,
                RunId              = MakeRunId(),
                CommandLineOptions = null,
                YamlOptions        = null
            };

            try
            {
                YamlScript yaml = !string.IsNullOrWhiteSpace(obj.YamlFile)
                    ? YamlLoad.Load <YamlScript>(obj?.YamlFile)
                    : obj?.YamlDirect;

                state.CommandLineOptions = obj;
                state.YamlOptions        = yaml ?? throw new InvalidOperationException(nameof(RunSequenceAsync));

                var errors = CompileSequence(state.YamlOptions);
                //if (errors != null) { log.Error(errors); return 2; }

                var options = new ProcessSequenceItem.Options
                {
                    state             = state,
                    parent            = null,
                    model             = null,
                    sequenceItem      = yaml.sequence_items.First(),
                    nextSequenceItems = yaml.sequence_items.Skip(1),
                    breadcrumbs       = new Stack <KeyValuePair <string, ISequenceItemAction> >()
                };

                var retryAfter    = new Stack <ISequenceItemAction>();
                var itemProcessor = new ProcessSequenceItem(options);
                // Pass in the chain of command to do after
                var processResult = await itemProcessor.ProcessSequenceItemAsync(retryAfter);

                //waitFor.Wait();
                var result = processResult && !retryAfter.Any();

                return(result ? 0 : 1);
            }
            catch (Exception e)
            {
                log.Error(e);
                return(2);
            }
        }
Пример #2
0
 private string CompileSequence(YamlScript yamlOptions)
 {
     //var templateList = Scriban.Template.Parse(JsonConvert.SerializeObject(yamlOptions));
     //if (templateList.HasErrors) return string.Join(Environment.NewLine, templateList.Messages);
     return(null);
 }