Exemplo n.º 1
0
        internal void GetCancellationTrace(TraceGroup traceGroup)
        {
            // This handler should only be invoked once (unless the CA is in a loop).
            _currentIterationCount++;
            if (_currentIterationCount > _hintIterationCount)
            {
                return;
            }

            // Attempt to process through the provided compensation activity to pick up the traces
            if (_cancellation != null)
            {
                _cancellation.GetTrace(traceGroup);
            }

            // Additionally, if there are any hints, trace these as well...
            // Scenario1: There are just hints but no compensation activity -- hints control all the work
            // Scenario2: There is a compensation activity which does work but there is work remaining afterwards -- hints control the remaining work
            foreach (Directive directive in this.CompensationHint)
            {
                TestActivity target = FindChildActivity(directive.Name);

                TestCompensableActivity.ProcessDirective(target, directive, Directive.Compensate, traceGroup);
            }
        }
Exemplo n.º 2
0
        private void HandleError(TraceGroup traceGroup)
        {
            // Use the expected hints to get the compensation traces for each
            foreach (Directive directive in this.CompensationHint)
            {
                TestActivity target = FindChildActivity(directive.Name);

                TestCompensableActivity.ProcessDirective(target, directive, Directive.Compensate, traceGroup);
            }
        }
Exemplo n.º 3
0
        //
        // Example hint list describing 3 branches and the order of processing for CA's on each Branch
        // { Branch, CA2, CA1, Branch, CA3, Branch, CA6, CA5, CA4 }
        //

        private void ProcessCompensationHints(IList <Directive> hints, string defaultAction, TraceGroup traceGroup)
        {
            // A splited flowchart Confirmation/Compensation are collections of unordered branch traces
            // (similar to Parallel)
            UnorderedTraces unordered = new UnorderedTraces();

            OrderedTraces ordered = null;

            foreach (Directive directive in hints)
            {
                // If we encounter a Branch directive that means we need to start a new OrderedTraces group
                if (directive.Name == "Branch")
                {
                    if (ordered != null)             // Already had one, so add it to our collection before we create a new one
                    {
                        if (ordered.Steps.Count > 0) // There's a chance we didn't produce any output
                        {
                            unordered.Steps.Add(ordered);
                        }
                    }

                    ordered = new OrderedTraces();
                }
                else
                {
                    TestActivity target = FindChildActivity(directive.Name);

                    TestCompensableActivity.ProcessDirective(target, directive, defaultAction, traceGroup);
                }
            }

            // Was there one left over? (From the last branch directive)
            if (ordered != null)
            {
                if (ordered.Steps.Count > 0) // There's a chance we didn't produce any output
                {
                    unordered.Steps.Add(ordered);
                }
            }

            if (unordered.Steps.Count > 0)
            {
                traceGroup.Steps.Add(unordered);
            }
        }