//methods
        public virtual bool Execute()
        {
            EntityContext entityContext = _entityContext;

            bool flushRequired = _flushCandidatesRegistry.CheckIsFlushRequired(entityContext);

            if (flushRequired)
            {
                List <ICommand> flushCommands = _flushCandidatesRegistry
                                                .GetNextFlushCommands(entityContext);
                flushCommands.ForEach(command =>
                                      _setup.Supervisor.EnqueueCommand(command));
            }

            return(true);
        }
Beispiel #2
0
        //Update current counters
        public virtual void HandleGenerateCompleted(EntityContext entityContext, IList generatedEntities)
        {
            //increment total number of generated entities
            entityContext.EntityProgress.CurrentCount += generatedEntities.Count;

            //check if flush to persistent storage required
            //and enqueue flush actions
            bool isFlushRequired = _flushCandidatesRegistry.CheckIsFlushRequired(entityContext);

            if (isFlushRequired)
            {
                List <ICommand> flushCommands = _flushCandidatesRegistry.GetNextFlushCommands(entityContext);
                flushCommands.ForEach(command => _commandsQueue.Enqueue(command));
            }

            //update progress state variables
            ProgressState.UpdateCounters(entityContext, generatedEntities);
            _requiredQueueBuilder.UpdateCounters(entityContext, generatedEntities, isFlushRequired);
        }