Beispiel #1
0
        public virtual async Task Execute(IJobExecutionContext context)
        {
            try
            {
                if (context.JobDetail.JobDataMap.ContainsKey(nameof(IWidget)) &&
                    context.JobDetail.JobDataMap[nameof(IWidget)] is IWidget widget &&
                    widget.IsEnabled)
                {
                    var request = widget switch
                    {
                        IMetricWidget _ => MetricRequestFactory.Create((dynamic)widget),

                        IStatusWidget _ => StatusRequestFactory.Create((dynamic)widget),

                        _ => throw new NotSupportedException($"{widget?.GetType().FullName} is not supported by the job scheduler."),
                    };

                    await _mediator.Send(request).ConfigureAwait(false);
                }
                else
                {
                    _logger.LogError("An error occurred while executing job. Widget not found in job context.");
                }
            }
Beispiel #2
0
 private void updateInfoMessage(IStatusWidget helpItem)
 {
     updateInfoMessage(helpItem.HelpText);
 }