internal override bool NotifyTraces(ActualTrace instanceTraces) { // Dont want to modify the original numOccurances int countCopy = _numOccurences; foreach (IActualTraceStep step in instanceTraces.Steps) { if (step is WorkflowAbortedTrace) { countCopy--; // if this aborted is the last trace, we wont have a deleted if (_waitingForDeleted && countCopy == 1) { countCopy--; } if (_expectedFinalState != WorkflowInstanceState.Aborted) { _error = string.Format("While waiting for a {0} trace, received an aborted trace - {1}", _expectedFinalState, ActualTracesAsString()); } } else if (step is WorkflowInstanceTrace) { WorkflowInstanceTrace wit = (WorkflowInstanceTrace)step; if (wit.InstanceStatus == WorkflowInstanceState.Deleted) { countCopy--; // Deleted trace will always be last, if its not then this will hang, so instead complete it and throw exception if (countCopy > 0) { _error = string.Format("Received deleted trace, before the expected number of {0} - {1}.", _expectedFinalState, ActualTracesAsString()); countCopy = 0; } } else if (wit.InstanceStatus == WorkflowInstanceState.Completed || wit.InstanceStatus == WorkflowInstanceState.Canceled || wit.InstanceStatus == WorkflowInstanceState.Terminated) { // reset error countCopy--; _error = (wit.InstanceStatus == _expectedFinalState) ? null : string.Format("While waiting for a {0} trace, received another terminal trace, {1} - {2}.", _expectedFinalState.ToString(), wit.InstanceStatus.ToString(), ActualTracesAsString()); } } } bool success = countCopy <= 0; if (success) { this.manualResetEvent.Set(); } return(success); }
public void Transfer(WorkflowInstanceState state, string instanceID) { base.Connection.Execute(ResourceManage.SQL_WORKFLOW_INSTANCE_UPDATE_TRANSFER, new { State = state.ToString(), InstanceID = instanceID }); }
public void Transfer(WorkflowInstanceState state, string instanceID) { string update = " UPDATE T_INSTANCE SET State=@State WHERE InstanceID=@InstanceID "; base.Connection.Execute(update, new { State = state.ToString(), InstanceID = instanceID }); }
string IActualTraceStep.GetStringId() { string stepId = null; if (this.WorkflowDefinitionIdentity == null) { stepId = String.Format("WorkflowInstanceTrace: {0}", _instanceStatus.ToString()); } else { stepId = String.Format("WorkflowInstanceTrace: {0}, {1}", this.WorkflowDefinitionIdentity.ToString(), _instanceStatus.ToString()); } return(stepId); }
// Returns true if no aborted or unhandled exception internal void WaitForFinalTrace(WorkflowInstanceState state, int numOccurences) { // If not using the DefaultTracking configuration, then we need to wait for a user trace. The reason is that // InMemoryTrackingParticipant, unlike SQL, pushed traces to the subscription. SQL however is pull only, // so the subscription will hang forever. The workaround is in the Tracking tests wait for the synchronize trace // since it is a user trace and we will always get it. if (!TestTraceManager.IsDefaultTrackingConfiguration) { WaitForSynchronizeTrace(numOccurences); } else { ManualResetEvent mre = new ManualResetEvent(false); FinalTraceSubscription subscription = new FinalTraceSubscription(_workflowInstanceId, mre, numOccurences, _hasPersistenceProvider, state); TestTraceManager.Instance.AddSubscription(_workflowInstanceId, subscription); if (!mre.WaitOne(TimeSpan.FromSeconds(TestTraceManager.MaximumNumberOfSecondsToWaitForATrace))) { throw new TimeoutException(string.Format("Waited for {0} seconds in WaitForFinalTrace without getting the expeced trace of {1}", TestTraceManager.MaximumNumberOfSecondsToWaitForATrace, state.ToString())); } subscription.CheckIfSuccessful(); } }