Пример #1
0
        public override async Task RunAsync(bool dryRun, bool parallel, Logger log, Func <Exception, bool> messageOnly)
        {
            var inputsList = this.inputs.ToList();

            if (inputsList.Count == 0)
            {
                await log.NoInputs(this.Name).Tax();

                return;
            }

            await log.Starting(this.Name).Tax();

            var stopWatch = Stopwatch.StartNew();

            try
            {
                if (parallel)
                {
                    var tasks = inputsList.Select(input => this.InvokeAsync(input, dryRun, log, messageOnly)).ToList();
                    await Task.WhenAll(tasks).Tax();
                }
                else
                {
                    foreach (var input in inputsList)
                    {
                        await this.InvokeAsync(input, dryRun, log, messageOnly).Tax();
                    }
                }
            }
            catch (Exception)
            {
                await log.Failed(this.Name, stopWatch.Elapsed.TotalMilliseconds).Tax();

                throw;
            }

            await log.Succeeded(this.Name, stopWatch.Elapsed.TotalMilliseconds).Tax();
        }