示例#1
0
        private Activity DequeueActivity(bool firstRun)
        {
            // Load the available activities into the queue if the queue is empty
            // or on first run (repeat session situation)
            if (!ExecutionQueue.Any() || firstRun)
            {
                // Add activities based on the execution count which describes
                // the overall distribution or weight of different activities
                // being executed.
                List <Activity> activities = new List <Activity>();
                foreach (var item in MasterList.OrderBy(n => n.ExecutionOrder))
                {
                    activities.Add(item);
                }

                if (Randomize)
                {
                    // If randomize was set for this collection of activities, then shuffle them
                    activities.Shuffle();
                    TraceFactory.Logger.Debug("Activities were shuffled");
                }

                foreach (Activity activity in activities)
                {
                    // Then enqueue each activity onto the execution queue.
                    ExecutionQueue.Enqueue(activity);
                }
            }

            _currentActivityExecutionCount = 1;

            return(ExecutionQueue.Dequeue());
        }
        private Activity DequeueActivity(bool firstRun)
        {
            //during a repeat session the previous session would have queued the execution queue, which makes it run out of order by 1 activity
            //by clearning the queue for the repeat session, we maintain the same order.
            if (firstRun)
            {
                ExecutionQueue.Clear();
            }

            //if there is any queued item return the topmost
            if (ExecutionQueue.Any())
            {
                return(ExecutionQueue.Dequeue());
            }

            // Load the available activities into the queue if the queue is empty
            // or on first run (repeat session situation)
            // Add activities based on the execution count which describes
            // the overall distribution or weight of different activities
            // being executed.
            List <Activity> activities = new List <Activity>();

            foreach (var activity in MasterList.OrderBy(n => n.ExecutionOrder))
            {
                for (int i = 0; i < activity.ExecutionValue; i++)
                {
                    activities.Add(activity);
                }
            }

            if (Randomize)
            {
                activities.Shuffle();
                TraceFactory.Logger.Debug("Activities were shuffled");
            }

            foreach (Activity activity in activities)
            {
                ExecutionQueue.Enqueue(activity);
            }

            return(ExecutionQueue.Dequeue());
        }