コード例 #1
0
ファイル: AMActionRunner3.cpp プロジェクト: acquaman/acquaman
void AMActionRunner3::onCurrentActionStateChanged(int state, int previousState)
{
	updateActionRunnerPausable();

	emit currentActionStateChanged(state, previousState);

	switch (state) {
	case AMAction3::Starting:
		onCurrentActionStarting();
		break;

	case AMAction3::Running:
		if ( previousState != AMAction3::Resuming )
			onCurrentActionRunning();

		break;

	case AMAction3::Failed:
		onCurrentActionFailed();
		break;

	case 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);
		break;
	}

	// 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) {
		onCurrentActionFinished();
	}
}
コード例 #2
0
ファイル: AMActionRunner3.cpp プロジェクト: Cpppro/acquaman
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();
	}
}