Beispiel #1
0
// Copy constructor. Takes care of making copies of the sub-actions
AMListAction3::AMListAction3(const AMListAction3& other)
	: AMAction3(other)
{
	currentSubActionIndex_ = -1; // prior to running an subactions
	subActionMode_ = other.subActionMode_;
	if(subActionMode_ == AMListAction3::Parallel)
		AMAction3::info()->setIconFileName(":/32x32/format-line-spacing-triple.png");
	logSubActionsSeparately_ = other.shouldLogSubActionsSeparately();
	logActionId_ = other.logActionId();
	skipAfterCurrentAction_ = false;
	loggingDatabase_ = other.loggingDatabase();

	if (subActionMode_ == Sequential)
		skipOptions_.append("After current action");

	foreach(AMAction3* action, other.subActions_)
		subActions_ << action->createCopy();
	foreach(AMAction3* action, subActions_)
		action->setParentAction(this);
}
Beispiel #2
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();
	}
}