Beispiel #1
0
        public int Fire(int maxRulesNumber, CancellationToken cancellationToken)
        {
            int ruleFiredCount = 0;

            while (!_agenda.IsEmpty && ruleFiredCount < maxRulesNumber)
            {
                Activation     activation    = _agenda.Pop();
                IActionContext actionContext = new ActionContext(this, activation, cancellationToken);

                try
                {
                    _actionExecutor.Execute(_executionContext, actionContext);
                }
                finally
                {
                    ruleFiredCount++;
                    if (AutoPropagateLinkedFacts)
                    {
                        PropagateLinked();
                    }
                }

                if (actionContext.IsHalted || cancellationToken.IsCancellationRequested)
                {
                    break;
                }
            }
            return(ruleFiredCount);
        }
Beispiel #2
0
 public void ProcessQueue()
 {
     Logger.Debug("Processing tasks for scheduler");
     lock (_processLocker) // since queues are being manipulated here, don't let this happen multiple times
     {
         if (IsPaused)
         {
             Logger.Debug("Since this runner is paused, jobs will not be processed");
             return;
         }
         if (_queuedRuns.Count == 0)
         {
             Logger.Debug("There is nothing to do right now");
             return;
         }
         var readyJobRun = _queuedRuns.Peek();
         if (readyJobRun.IsFinishedRunning)
         {
             Logger.Info($"Task {readyJobRun} has finished running, so removing it from the queue");
             _queuedRuns.Dequeue();
             _finishedTasks.Add(readyJobRun.ToStatus());
         }
         else if (!readyJobRun.IsRunning)
         {
             Logger.Info(
                 $"Task {readyJobRun} is not yet run and it is the next thing to run, so running it");
             _actionExecutor.Execute(readyJobRun.Run);
         }
         else
         {
             Logger.Debug($"Since {readyJobRun} is still running, waiting for it to complete");
         }
     }
     Logger.Debug("Finished processing tasks for scheduler");
 }
Beispiel #3
0
        public async void Run(IBackgroundTaskInstance taskInstance)
        {
            var deferral = taskInstance.GetDeferral();

            Debug.WriteLine($"{DateTime.Now} - run background task");

            try
            {
                await _dataContextManager.RefreshSettingsDataContext();

                await _dataContextManager.BeginTransaction();

                _actionExecutor.Execute();
            }
            catch (Exception ex)
            {
                _logger.Log(ex);
            }
            finally
            {
                await _dataContextManager.SaveChanges();

                deferral.Complete();
            }
        }
Beispiel #4
0
        public Task <TResult> Execute <TResult>(AbstractAction <TResult> action, CancellationToken cancellationToken = default)
        {
            var result = _decoratee.Execute(action, cancellationToken);

            AppendToAuditTrail(action);
            return(result);
        }
        public async Task <IActionResult> Get()
        {
            var action = new ListRoleAction(_actionCallContext);
            var result = await _actionExecutor.Execute(action);

            return(Ok(result.Roles));
        }
        public IEnumerable <string> Get()
        {
            _logger.LogInformation("Getting items");

            var action = new SampleAction(new ActionCallerContext());
            var result = _actionExecutor.Execute(action);

            return(new string[] { "value1", "value2", result.Test });
        }
        private static FlowToken Execute(IActionExecutor actionExecutor, EntityToken entityToken, ActionToken actionToken, FlowControllerServicesContainer flowControllerServicesContainer)
        {
            FlowToken result = actionExecutor.Execute(entityToken, actionToken, flowControllerServicesContainer);

            if (result == null)
            {
                result = new NullFlowToken();
            }

            return(result);
        }
        public async Task <object> TryExecuteAction()
        {
            await _action.TryApproveAction();

            if (_action.Status.Equals(Status.FullAccepted))
            {
                return(await _actionExecutor.Execute());
            }
            else
            {
                return(await _actionExecutor.Decline());
            }
        }
Beispiel #9
0
        public int Fire(int maxRulesNumber)
        {
            int ruleFiredCount = 0;

            while (!_agenda.IsEmpty() && ruleFiredCount < maxRulesNumber)
            {
                Activation     activation    = _agenda.Pop();
                IActionContext actionContext = new ActionContext(this, activation);

                _actionExecutor.Execute(_executionContext, actionContext);

                ruleFiredCount++;
                if (actionContext.IsHalted)
                {
                    break;
                }
            }
            return(ruleFiredCount);
        }
        private static FlowToken Execute(IActionExecutor actionExecutor, EntityToken entityToken, ActionToken actionToken, FlowControllerServicesContainer flowControllerServicesContainer)
        {
            FlowToken result = actionExecutor.Execute(entityToken, actionToken, flowControllerServicesContainer);

            if (result == null)
            {
                result = new NullFlowToken();
            }

            return result;
        }