Exemple #1
0
        /// <summary>
        ///     Trigger every event before the new step
        ///     Do not send messages, use NextStep for that
        /// </summary>
        public override async void PreStep()
        {
            MessageProcessor?.ClearMessagesPerPeriod();
            ForgettingModel?.InitializeForgettingProcess();

            // Databases
            if (HasEmail)
            {
                Email.ForgettingProcess(Schedule.Step);
            }

            _newInteractionCounter = 0;

            var isolated = Cognitive.InteractionPatterns.IsIsolated(Schedule.Step);

            HandleStatus(isolated);
            // intentionally after Status
            HandleCapacity(isolated, true);
            // Task manager
            if (!Cognitive.TasksAndPerformance.CanPerformTask)
            {
                return;
            }

            async Task <bool> ProcessWorkInProgress()
            {
                while (Capacity.HasCapacity && Status != AgentStatus.Offline)
                {
                    try
                    {
                        var task = await TaskProcessor.Receive(Schedule.Step).ConfigureAwait(false);

                        switch (task.Parent)
                        {
                        case Message message:
                            // When Schedule.Type is Intraday, messages are treated as tasks and stored in task.Parent attribute
                            // Once a message (as a task) is receive it is treated as a message
                            if (!task.IsStarted)
                            {
                                ActMessage(message);
                            }

                            WorkOnTask(task);
                            break;

                        default:
                            WorkInProgress(task);
                            break;
                        }
                    }
                    catch (Exception exception)
                    {
                        var exceptionDispatchInfo = ExceptionDispatchInfo.Capture(exception);
                        exceptionDispatchInfo.Throw();
                    }
                }

                // If we didn't deschedule then run the continuation immediately
                return(true);
            }

            await ProcessWorkInProgress().ConfigureAwait(false);

            if (Schedule.Type <= TimeStepType.Daily)
            {
                ActEndOfDay();
            }
        }
Exemple #2
0
 /// <summary>
 ///     Trigger every event before the new step
 ///     Do not send messages, use NextStep for that
 /// </summary>
 public virtual async void PreStep()
 {
     MessageProcessor?.ClearMessagesPerPeriod();
     HandleStatus(false);
 }