using Quadarax.Application.QLiberace.Processor.Entities; using Quadarax.Application.QLiberace.Common.Executor; using Quadarax.Foundation.Core.Data.Interface.Entity.Dto; using Quadarax.Foundation.Core.Logging; using Quadarax.Foundation.Core.Reflection.Extensions; namespace Quadarax.Application.QLiberace.Processor.Executor { internal class ExecutorInternal { private ProcessingQueue _item; private IList _data; public ExecutorInternal(ProcessingQueue item, IEnumerable data) { _item = item ?? throw new ArgumentNullException(nameof(item)); _data = new List(); } public ResultBoolDto Execute(TimeSpan timeout, IQLogger? logger = null) { try { var provider = (IParametricExecutorProvider) ActivatorExt.CreateInstance(_item.Provider,true, timeout, logger); if (provider == null) throw new InvalidOperationException($"Cannot create executor provider from '{_item.Provider}'."); var result = provider.Execute(_data); return new ResultBoolDto(result); } catch (Exception e) { return new ResultBoolDto(e); } } } }