Exemplo n.º 1
0
        public TaskLoader(ILogger <TaskLoader> logger, IOptions <TaskManagerOptions> taskManagerOptions, IOptions <SnapshootOptions> snapshootOptions) // DI : constructor must be public
        {
            _logger = logger ?? throw new ArgumentNullException(nameof(logger));
            _logger.LogTrace("new TaskLoader()");
            _taskManagerOptions = taskManagerOptions?.Value ?? throw new ArgumentNullException(nameof(taskManagerOptions));
            _snapshootOptions   = snapshootOptions?.Value ?? throw new ArgumentNullException(nameof(snapshootOptions));

            // config check
            if (string.IsNullOrWhiteSpace(_taskManagerOptions.TaskList))
            {
                throw new ArgumentNullException(nameof(taskManagerOptions), "TaskList is empty !");
            }
            else if (_taskManagerOptions.LoopTaskLimit <= 0 && _taskManagerOptions.TaskList.Contains(",LOOP", StringComparison.OrdinalIgnoreCase))
            {
                throw new ArgumentOutOfRangeException(nameof(taskManagerOptions), "LoopTaskLimit must be greater than 0 when LOOP task is used !");
            }
        }
Exemplo n.º 2
0
        public SnapshootAction(ILogger <SnapshootAction> logger, IOptions <SnapshootOptions> snapshootOptions, PersistenceManager persistenceManager, SeleniumWrapper seleniumWrapper) // DI : constructor must be public
        {
            _logger = logger ?? throw new ArgumentNullException(nameof(logger));
            _logger.LogTrace("new SnapshootAction()");
            _snapshootOptions   = snapshootOptions.Value ?? throw new ArgumentNullException(nameof(snapshootOptions));
            _seleniumWrapper    = seleniumWrapper ?? throw new ArgumentNullException(nameof(seleniumWrapper));
            _persistenceManager = persistenceManager ?? throw new ArgumentNullException(nameof(persistenceManager));

            // config check
            if (_snapshootOptions.MakeSnapShootEachSeconds <= 0)
            {
                throw new ArgumentOutOfRangeException(nameof(snapshootOptions), "MakeSnapShootEachSeconds must be greater than 0 when SNAPSHOOT tasks are used !");
            }

            // default
            EnableTask = true;
        }