Exemplo n.º 1
0
        private void TrackWorkflowInstanceRecord(WorkflowInstanceRecord workflowInstanceRecord, ActualTrace _trace)
        {
            WorkflowInstanceState workflowInstanceState = (WorkflowInstanceState)Enum.Parse(typeof(WorkflowInstanceState), workflowInstanceRecord.State);
            WorkflowInstanceTrace workflowInstanceTrace = new WorkflowInstanceTrace(workflowInstanceRecord.InstanceId, workflowInstanceRecord.WorkflowDefinitionIdentity, workflowInstanceState);

            _trace.Add(workflowInstanceTrace);
        }
Exemplo n.º 2
0
 public void TraceData(object data)
 {
     //tracking data is now directly pushed by the tracking participant to the test trace manager.
     if (data is WorkflowInstanceTrace)
     {
         WorkflowInstanceTrace instanceTrace = (WorkflowInstanceTrace)data;
         this.testTraceManager.AddTrace(instanceTrace.InstanceName, instanceTrace);
         //Log.TraceInternal("[TestTraceListener] {0}", instanceTrace.ToString());
     }
     else if (data is WorkflowExceptionTrace)
     {
         WorkflowExceptionTrace exceptionTrace = (WorkflowExceptionTrace)data;
         this.testTraceManager.AddTrace(exceptionTrace.InstanceName, exceptionTrace);
         //Log.TraceInternal("[TestTraceListener] {0}", exceptionTrace.ToString());
     }
     else if (data is UserTrace)
     {
         UserTrace userTrace = (UserTrace)data;
         this.testTraceManager.AddTrace(userTrace.InstanceId, userTrace);
         //Log.TraceInternal("[TestTraceListener] {0}", userTrace.ToString());
     }
     else if (data is SynchronizeTrace)
     {
         SynchronizeTrace synchronizeTrace = (SynchronizeTrace)data;
         this.testTraceManager.AddTrace(synchronizeTrace.userTrace.InstanceId, synchronizeTrace);
         //Log.TraceInternal("[TestTraceListener] {0}", synchronizeTrace.ToString());
     }
     else if (data is WorkflowAbortedTrace)
     {
         WorkflowAbortedTrace synchronizeTrace = (WorkflowAbortedTrace)data;
         this.testTraceManager.AddTrace(synchronizeTrace.InstanceId, synchronizeTrace);
         //Log.TraceInternal("[TestTraceListener] {0}", synchronizeTrace.ToString());
     }
 }
        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);
        }
Exemplo n.º 4
0
        private static bool ShouldTrackStep(this TrackingProfile profile, WorkflowTraceStep workflowTraceStep)
        {
            if (workflowTraceStep is TraceGroup)
            {
                // Don't filter out a nested TraceGroup.
                return(true);
            }

            ActivityTrace activityTrace = workflowTraceStep as ActivityTrace;

            if (activityTrace != null)
            {
                //check the activity track queries
                foreach (ActivityStateQuery activityQuery in profile.Queries.OfType <ActivityStateQuery>())
                {
                    //either all activities are tracked or only this specific one.
                    if (TrackingFilter.IsActivityLocationTracked(activityQuery, activityTrace.ActivityName, activityTrace.ActivityStatus))
                    {
                        return(true);
                    }
                }

                //check the ActivityScheduledQuery
                foreach (ActivityScheduledQuery activityScheduledQuery in profile.Queries.OfType <ActivityScheduledQuery>())
                {
                    //either all activities are tracked or only this specific one.
                    if (TrackingFilter.IsActivityScheduledTracked(activityScheduledQuery, activityTrace.ActivityName))
                    {
                        return(true);
                    }
                }
            }

            WorkflowInstanceTrace workflowInstanceTrace = workflowTraceStep as WorkflowInstanceTrace;

            if (workflowInstanceTrace != null)
            {
                foreach (WorkflowInstanceQuery workflowInstanceTrackingQuery in profile.Queries.OfType <WorkflowInstanceQuery>())
                {
                    if (workflowInstanceTrackingQuery.States.Contains(workflowInstanceTrace.InstanceStatus.ToString()))
                    {
                        return(true);
                    }
                }
            }

            UserTrace userTrace = workflowTraceStep as UserTrace;

            if (userTrace != null)
            {
                //presently we (trackign team) do not track any userTrace values through profile om.
                return(true);
            }
            return(false);
        }
        private void AddWorkflowInstanceTrace(TraceEventType eventType, Guid instanceId, WorkflowIdentity workflowDefintionIdentity, WorkflowInstanceState instanceStatus)
        {
            WorkflowInstanceTrace trace = new WorkflowInstanceTrace(instanceId, workflowDefintionIdentity, instanceStatus);

            this.TestTraceManager.AddTrace(instanceId, trace);
            if (workflowDefintionIdentity != null)
            {
                TestTraceManager.OptionalLogTrace(string.Format("[TestTrackingParticipantBase]{0} : {1} : {2,-11} : {3}", instanceId, workflowDefintionIdentity, eventType, instanceStatus));
            }
            else
            {
                TestTraceManager.OptionalLogTrace(string.Format("[TestTrackingParticipantBase]{0} : {1,-11} : {2}", instanceId, eventType, instanceStatus));
            }
        }