Ejemplo n.º 1
0
void AMListAction3::startImplementation()
{
	// if this was called by the base class, we know that we are in the Starting state.

	// no actions? That's easy...
	if(subActionCount() == 0) {
		setStarted();
		setSucceeded();	// done and done.
		return;
	}

	if(subActionMode() == Sequential) {

		setStarted();
		internalDoNextAction();
	}
	// parallel mode
	else {
		setStarted();
		foreach(AMAction3* action, subActions_) {
			internalConnectAction(action);
		}
		foreach(AMAction3* action, subActions_) {
			action->start();
		}
	}
Ejemplo n.º 2
0
void AMActionRunner3::insertActionInQueue(AMAction3 *action, int index)
{
	if(!action)
		return;

	if(index < 0 || index > queuedActions_.count())
		index = queuedActions_.count();

	if(!action->isValid()){
		QMessageBox box;
		box.setWindowTitle("The Action You've Added May Not Be Valid");
		box.setText("The '" % action->info()->typeDescription() % "' action you've just added reports:\n" % action->notValidWarning());
		box.setInformativeText("\n\nYou can ignore this warning (maybe something will happen between now and the time the action is run to make it valid) or you can cancel adding the action.");

		QPushButton* ignoreAndAddButton = new QPushButton("Ignore this warning and add");
		QPushButton* cancelAddingButton = new QPushButton("Cancel adding this action");

		box.addButton(ignoreAndAddButton, QMessageBox::RejectRole);
		box.addButton(cancelAddingButton, QMessageBox::AcceptRole);
		box.setDefaultButton(cancelAddingButton);

		box.exec();
		if(box.clickedButton() == cancelAddingButton)
			return;
	}

	emit queuedActionAboutToBeAdded(index);
	queuedActions_.insert(index, action);
	emit queuedActionAdded(index);

	// was this the first action inserted into a running but empty queue? Start it up!
	if(!isPaused_ && !actionRunning())
		internalDoNextAction();
}
Ejemplo n.º 3
0
void AMLoopAction3::startImplementation()
{
	// done already with nothing to do.
	if(subActionCount() == 0 || loopCount() == 0) {
		setStarted();
		setSucceeded();
		return;
	}

	setStarted();
	setStatusText(QString("Loop %1 of %2").arg(currentIteration_+1).arg(loopCount()));
	internalDoNextAction();
}
Ejemplo n.º 4
0
void AMActionRunner3::insertActionInQueue(AMAction3 *action, int index)
{
	if(!action)
		return;

	if(index < 0 || index > queuedActions_.count())
		index = queuedActions_.count();

	if ( ! validateAction(action, QString("Ignore this warning and add"), QString("Cancel adding this action")) )
		return;

	insertActionToQueue(action, index);

	// was this the first action inserted into a running but empty queue? Start it up!
	if(!isPaused_ && !actionRunning())
		internalDoNextAction();
}
Ejemplo n.º 5
0
void AMActionRunner3::onCurrentActionStateChanged(int state, int previousState)
{
	emit currentActionStateChanged(state, previousState);

	if(state == AMAction3::Starting){

		AMListAction3* listAction = qobject_cast<AMListAction3*>(currentAction_);

		if(listAction){

			int parentLogId = -1;
			AMListAction3* parentAction = qobject_cast<AMListAction3*>(listAction->parentAction());

			if(parentAction)
				parentLogId = parentAction->logActionId();

			if(!AMActionLog3::logUncompletedAction(currentAction_, loggingDatabase_, parentLogId)) {
				AMErrorMon::report(AMErrorReport(this, AMErrorReport::Alert, -200, "There was a problem logging the uncompleted action to your database.  Please report this problem to the Acquaman developers."));
			}
		}

		if (isScanAction())
			emit scanActionCreated((AMScanAction *)currentAction());
	}

	if ( (state == AMAction3::Running) && (previousState != AMAction3::Resuming) ){

		if (isScanAction())
			emit scanActionStarted((AMScanAction *)currentAction());
	}

	if(state == AMAction3::Failed) {
		// What should we do?
		int failureResponse = currentAction_->failureResponseInActionRunner();
		if(failureResponse == AMAction3::PromptUserResponse)
			failureResponse = internalAskUserWhatToDoAboutFailedAction(currentAction_);

		if(failureResponse == AMAction3::AttemptAnotherCopyResponse) {
			// make a fresh copy of this action and put it at the front of the queue to run again.
			insertActionInQueue(currentAction_->createCopy(), 0);
		}
		// other failure response is to MoveOn, which we'll do anyway.
	}

	if(state == AMAction3::Cancelled) {
		// Usability guess for now: If the user intervened to cancel, they probably want to make some changes to something. Let's pause the workflow for now to let them do that, rather than automatically go on to the next.
		setQueuePaused(true);
	}

	// for all three final states, this is how we wrap things up for the current action:
	if(state == AMAction3::Failed ||
			state == AMAction3::Cancelled ||
			state == AMAction3::Succeeded) {

		// log it, unless it's a list action that wants to take care of logging its sub-actions itself.
		AMListAction3* listAction = qobject_cast<AMListAction3*>(currentAction_);
		int parentLogId = -1;
		AMListAction3* parentAction = qobject_cast<AMListAction3*>(currentAction_->parentAction());
		if(parentAction)
			parentLogId = parentAction->logActionId();
		if(!(listAction && listAction->shouldLogSubActionsSeparately())) {
			if(!AMActionLog3::logCompletedAction(currentAction_, loggingDatabase_, parentLogId)) {
				AMErrorMon::report(AMErrorReport(this, AMErrorReport::Alert, -200, "There was a problem logging the completed action to your database.  Please report this problem to the Acquaman developers."));
			}
		}
		else if(listAction){
			if(!AMActionLog3::updateCompletedAction(currentAction_, loggingDatabase_)) {
				AMErrorMon::report(AMErrorReport(this, AMErrorReport::Alert, -200, "There was a problem updating the log of the completed action to your database.  Please report this problem to the Acquaman developers."));
			}
		}

		if (isScanAction())
			emit scanActionFinished((AMScanAction *)currentAction());

		// move onto the next, if there is one, and disconnect and delete the old one.
		internalDoNextAction();
	}
}